ThreeJS X Rotation behaving unexpectedly

后端 未结 1 1718
庸人自扰
庸人自扰 2021-01-26 14:35

I\'m making a ThreeJS Demo, and I\'m currently using the arrow keys to rotate the camera. At first things seem to work out ok. I can successfully rotate up and down, and left an

1条回答
  •  被撕碎了的回忆
    2021-01-26 15:07

    See this answer for an explanation of how rotations work in three.js.

    That post suggests changing the Euler order to YXZ.

    camera.rotation.order = 'YXZ';
    

    In your case, however, you may find using the rotateX()/rotateY() methods preferable. Instead of changing the Euler order, use this pattern:

    if( window.isLeftDown ){
    
       camera.rotateY( 0.01 ); // or rotateX( +/- 0.01 )
    
    }
    

    The solution you choose depends on the behavior you prefer.

    three.js r.71

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