First person simulation with three.js using keyboard arrows

前端 未结 3 2122
予麋鹿
予麋鹿 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:33

    While this does not directly fix your code, I thought I'd mention that Three.js provides two ready-made controllers to navigate in FPS mode. They both use mouse for looking and can move, but should be rather simple to adapt to keyboard look and remove movement if needed. They are:

    • FirstPersonControls
    • PointerLockControls

    I'd recommend the latter as a starting point because it's rather simple and the former confusingly has the looking code twice, probably as an artifact from old features.

提交回复
热议问题