先简单解释一下摄像头的配置
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
PerspectiveCamera( fov, aspect, near, far );
-
fov - 相机平截头体垂直视野。
-
aspect - 相机截锥体纵横比。(宽度/高度)
-
near - 平面附近的相机平截头体。
-
far — 相机截头远平面。
这会配置相机,但不会控制其移动或看到的位置。
要控制相机的视线,请使用以下代码:
this.camera.lookAt(new THREE.Vector3(0,0,0)); // x, y, z
但是如果你使用一些库来控制相机(OrbitControls.js),你可能不得不使用:
this.controls.target.set( 0, 0, 0 ); //x, y, z
如果您不使用任何库来控制相机,那么“lookAt()”应该没有问题。
为了让摄像头保持在固定位置,请使用以下代码:
this.camera.position.x = 0;
this.camera.position.z = 0;
this.camera.position.y = 0;
Ahora lo que realmente desea es administrar la profundidad de la cámara que tendra que utilizar el siguiente código:
this.fov = 0;
this.camera.projectionMatrix.makePerspective(this.fov, window.innerWidth / window.innerHeight, this.near, this.far));
注意这一点,以免离开由远近所控制的视野。
欲了解更多信息,请参阅threejs.org