zooming camera in threeJS without trackball controls or other camera control library

后端 未结 2 369
天命终不由人
天命终不由人 2021-02-04 11:10

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

2条回答
  •  庸人自扰
    2021-02-04 11:23

    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.

提交回复
热议问题