The Goal
Im trying to make a simple camera zoom in animation that will zoom the camera in X amount every time the button is clicked.
The Current Progress
I current have the animation coded within Three.js and the buttons running running the script.
function cameraZoomIn() {
console.log("Camera Zoom In Function Clicked");
camera.position.z -= 50;
requestAnimationFrame( cameraZoomIn );
render();
};
<input type="button" onclick="cameraZoomIn();" value="Zoom Camera In!" />
The Problem
The animation runs however it runs forever as you can see here when clicking on the Zoom Camera In button - http://www.midlandgates.co.uk/three.js-master/examples/webgl_loader_obj.html
Update 1
If I remove requestAnimationFrame
it will only run once however will jump to position not tween there. So why does this make the animation repeat itself?