Skip to content Skip to sidebar Skip to footer

Zooming Camera In ThreeJS Without Trackball Controls Or Other Camera Control Library

I'm trying to use threeJS to control a camera in my scene. I currently have the camera set up to orbit in a circle around my object using the left and right keys on my keyboard. Bu

Solution 1:

If you want a real zoom, without moving the camera, then you can play with the field of view (fov) parameter of the camera:

  camera.fov *= zoomFactor;
  camera.updateProjectionMatrix();

See: http://jsfiddle.net/bvcCB/87/

If you want to move the camera near (or far) of the target, then calculate the vector from the camera position to the target, and move the camera position along that vector.


Solution 2:

From r69 you can now use camera.zoom:

camera.zoom = zoomFactor;
camera.updateProjectionMatrix();

Post a Comment for "Zooming Camera In ThreeJS Without Trackball Controls Or Other Camera Control Library"