threejs - Reset camera position/rotation when using PointerLockControls

眉间皱痕 提交于 2021-02-11 12:32:31

问题


well i wants to reset the position and the rotation, when i am using the PointerLockControls. Currently i use

controls.getObject().position.set( -30, 10, 80 );
controls.getObject().position.y = 10; 

for the position. But how can i reset the rotation?

I tried different things like:

camera.lookAt(new THREE.Vector3(1,0,0));
camera.rotation.x = - Math.PI / 2;
controls.getObject().rotation.x = 0;
controls.getObject().rotation.y = 0;
controls.updateProjectionMatrix();
...

Have you an idea?

Greeting, Johannes


回答1:


I figured it out

controls.getObject().rotation.y = 0; // Rotates Yaw Object
controls.getObject().children[0].rotation.x = 0; // Rotates the Pitch Object

Now, the Camera is looking in the original direction!

three.js r.62



来源:https://stackoverflow.com/questions/19098775/threejs-reset-camera-position-rotation-when-using-pointerlockcontrols

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!