Moving the camera, lookAt and rotations in three.js

前端 未结 1 619
忘了有多久
忘了有多久 2020-12-29 01:12

I\'m having trouble understanding lookAt and the rotations of the camera.

I have a circle of small spheres around [0,0,0] on the x-y plane.

The camera is pla

相关标签:
1条回答
  • 2020-12-29 01:58

    To fix the problem you can specify the up vector for the camera before executing the lookAt() command.

    // Place camera on x axis
    camera.position.set(30,0,0);
    camera.up = new THREE.Vector3(0,0,1);
    camera.lookAt(new THREE.Vector3(0,0,0));
    

    Change the vector to your needs. You can even turn it upside down by specifying a negative value: (0,0,-1). It is important to set the up vector BEFORE using lookAt().

    I have created a full example at http://jsfiddle.net/VsWb9/991/ with 2 cubes. The smaller one is suppose to be on top of the big one (on the positive z-axis).

    0 讨论(0)
提交回复
热议问题