Three.js: Get the Direction in which the Camera is Looking

后端 未结 4 1874
离开以前
离开以前 2020-12-08 01:40

I\'m creating game in using html5 and THREE.js, and I have a camera that rotates with the euler order of \'YXZ\'.

This is so the camera rotation up, down, left and r

4条回答
  •  旧时难觅i
    2020-12-08 02:14

    I spent a long time trying to figure out captain obvious's question.

    This is how it finally worked for me:

        vector = camera.getWorldDirection();
        theta = Math.atan2(vector.x,vector.z);
    

    theta is in radians. This is how I orient my game's character to face the same way the camera is facing. The getWorldDirection() is a fairly new option on camera.

提交回复
热议问题