ThreeJS camera.lookAt() has no effect, is there something I'm doing wrong?

前端 未结 6 489
半阙折子戏
半阙折子戏 2021-02-05 02:13

In Three.js, I want a camera to be pointed at a point in 3D space.

For this purpose, I tried using the camera.lookAt function like so:

camer         


        
6条回答
  •  轮回少年
    2021-02-05 02:31

    Here's an alternative solution: create an object (i.e. cube) with 0 dimensions.

    var cameraTarget = new THREE.Mesh( new THREE.CubeGeometry(0,0,0));
    

    In the render function set the camera.lookAt to the position of the cameraTarget.

    function render() {
        camera.lookAt( cameraTarget.position );
        renderer.render( scene, camera );
    }
    

    Then just move cameraTarget around as you wish.

提交回复
热议问题