且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有轨迹球控件或其他相机控制库的threeJS中的缩放相机

更新时间:2023-11-01 23:14:04

如果你想要真正的变焦,不移动相机,那么你可以玩转相机的视野(fov)参数:

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();

参见: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.