How would you move a camera backwards and forwards from a fixed point along the trajectory that it is facing?
I know there are several control scripts that do this but I need to do something custom and I'm not able to break down their code to figure how to isolate the above behaviour.
I've seen this answer which I think addresses the question and have come up with this code:
cameraPosition = camera.position
cameraRotation = new THREE.Vector3(camera.rotation._x, camera.rotation._y, camera.rotation._z)
newCamera = new THREE.Vector3().addVectors(cameraPosition, cameraRotation)
camera.position.set(newCamera.x, newCamera.y, newCamera.z)
camera.updateProjectionMatrix()
But this seems to move the camera in a circle rather than backwards and forwards.
Any help would be much appreciated. Thank you!