First person simulation with three.js using keyboard arrows

前端 未结 3 2089
予麋鹿
予麋鹿 2021-01-02 08:28

For my source, visit http://jsfiddle.net/fYtwf/

Background

I have a simple 3d simulation using three.js where the camera is surrounded in 3 dimens

3条回答
  •  迷失自我
    2021-01-02 08:57

    There are a number of solutions to this problem, but since you only want the camera to rotate up, down, left, and right, the answer in this case is easy.

    You just need to set the camera Euler order to "YXZ" like so:

    camera.rotation.order = "YXZ"; // three.js r.65
    

    If you do that, everything becomes very intuitive.

    Here is an updated fiddle: http://jsfiddle.net/fYtwf/3/ (this demo is using r.54, however)

    Once you change camera.rotation.z from it's default value of zero, things will become very confusing. So don't do that. :-)

    three.js r.65

提交回复
热议问题