在three.js中,我使用camera.lookAt(0,0,0)将摄像机指向某处。之后,camera.up向量基本上在随机方向上。我有一个已知的向上矢量,我希望相机达到这个位置,但是当我设置它时,它什么也不做:

camera.position.set(0, 0, 5);  // works
camera.lookAt(0, 0, 0);        // works
camera.up.set(1, 0, 0);        // nothing
camera.up.set(-1, 0, 0);       // nothing
camera.up.set(0, 1, 0);        // nothing
camera.up.set(0, -1, 0);       // nothing
camera.up.set(0, 0, 1);        // nothing
camera.up.set(0, 0, -1);       // nothing


如何更改相机的向上矢量? camera.rotateZ(0.1)可以工作,但是我不知道要旋转多少,我只想用尽向量。

最佳答案

up仅在调用lookAt时使用。 lookAt不是状态,它是为您设置rotation的功能。因此,如果更改up,则需要再次调用lookAt

camera.position.set(0, 0, 5);  //
camera.up.set(1, 0, 0);        // set up
camera.lookAt(0, 0, 0);        // now call lookAt

09-30 16:32
查看更多