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

后端 未结 2 370
天命终不由人
天命终不由人 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.

    0 讨论(0)
  • 2021-02-04 11:24

    From r69 you can now use camera.zoom:

    camera.zoom = zoomFactor;
    camera.updateProjectionMatrix();
    
    0 讨论(0)
提交回复
热议问题