简体   繁体   中英

Three.js Rotating camera pitch not working?

I'm very new to three.js and so sorry if this is a stupid question.

The issue is that I have a camera and I want to rotate it with the arrow keys. The left and right (yaw) rotation seems to work as excepted, however when the angle is not at 0 the camera seems to rotate incorrectly up and down (pitch). I have seen this issue been addressed and the way they fixed was in how three.js handles their euler angles as they have a specific order. (YXZ) However I've tried:

camera.rotation.y = AngleY;
camera.rotation.x = AngleX;
camera.rotation.z = AngleZ;

I have also tried using vectors and camera.target.lookAt, but since camera.target has been removed I am not sure how to fix this.

Thanks in advance.

The camera's rotation will have meaning in terms of "heading", "pitch", and "roll" if you set:

camera.rotation.order = 'YXZ'; // the default is 'XYZ'

For more information, see this stackoverflow answer .

three.js r.83

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM