How to control camera both with keyboard and mouse - three.js

岁酱吖の 提交于 2019-12-11 01:26:58

问题


I have a 3D enviroment in WEB GL with three.js and I used to use orbitcontrols.js (http://codepen.io/nireno/pen/cAoGI like this project) to move the point of view. Now I saw a nice way to move inside the enviroment with W A S D keys (http://stemkoski.github.io/Three.js/Chase-Camera.html) like in an FPS (but not with pointerlocking etc) also using orbitcontrols.js . The problem is that when I impelmentes the last functionality, I lost the first functionality with the mouse (I removed the controls.update() and I used the customa update() on the link).

My question is if and how can I have both functionalities at the same time. Both Keys and mouse moving the camera.

thanks


回答1:


I think you want something like this: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js

Found from this SO question: Three.js First Person Controls



来源:https://stackoverflow.com/questions/23553235/how-to-control-camera-both-with-keyboard-and-mouse-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!