Move camera backwards and forwards in Three js
<p>How would you move a camera backwards and forwards from a fixed point along the trajectory that it is facing?</p>

<p>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.</p>

<p>I've seen <a href="https://stackoverflow.com/questions/17661571/how-to-properly-change-the-camera-view-to-move-forward-and-backward-into-a-scene">this answer</a> which I think addresses the question and have come up with this code:</p>

<pre><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()
</code></pre>

<p>But this seems to move the camera in a circle rather than backwards and forwards.</p>

<p>Any help would be much appreciated. Thank you!</p>