// Copyright (c) 2026 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT var CAMERA_OFFSET_ANGLE = 0.0; var CAMERA_OFFSET_RADIUS = 18.0; var CAMERA_OFFSET_HEIGHT = 10.0; class PlayerCamera { constructor(target) { this.target = target; this.entity = new Entity(); this.position = this.entity.add(POSITION); this.entity.add(CAMERA); this.update(); } update() { var targetPosition = this.target.position.getLocalPosition(); var eyeX = targetPosition.x + Math.cos(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS; var eyeY = targetPosition.y + CAMERA_OFFSET_HEIGHT; var eyeZ = targetPosition.z + Math.sin(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS; this.position.lookAt( eyeX, eyeY, eyeZ, targetPosition.x, targetPosition.y, targetPosition.z, 0.0, 1.0, 0.0 ); } } module.exports = PlayerCamera;