如何同时使用键盘和鼠标控制相机-three.js [英] How to control camera both with keyboard and mouse - three.js

查看:873
本文介绍了如何同时使用键盘和鼠标控制相机-three.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WEB GL中具有3.js的3D环境,曾经使用过orbitcontrols.js( http像该项目一样:://codepen.io/nireno/pen/cAoGI ).现在,我看到了一种使用WASD密钥在环境中移动的好方法( http://stemkoski.github.io/Three.js/Chase-Camera.html )也可以使用orbitcontrols.js,例如FPS(但不能使用指针锁定等).问题是,当我强制使用最后一个功能时,我失去了第一个功能(用鼠标删除了(删除了controls.update(),并在链接上使用了customa update()).

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.

谢谢

推荐答案

我认为您想要这样的东西: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js

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

从这个SO问题中找到: Three.js第一人称控件

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

这篇关于如何同时使用键盘和鼠标控制相机-three.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆