Recently, I've delved into the world of THREE.js and decided to create a game featuring a spaceship as the main element. Utilizing a chase camera for my model, I encountered a challenge where I needed to adjust the camera's position in relation to what it is looking at. Here is the code I am currently using:
var relativeCameraOffset = new THREE.Vector3(0,200,-500);
var cameraOffset = relativeCameraOffset.applyMatrix4( spaceship1.matrixWorld );
camera.position.x = cameraOffset.x;
camera.position.y = cameraOffset.y;
camera.position.z = cameraOffset.z;
camera.lookAt(spaceship1.position);
My goal is to position the camera in front of the spaceship to always look forward as I navigate, without having it constantly pointed at the spaceship itself.