简体   繁体   English

THREE.js ORBITCONTROLLS更改mouseButtons不起作用

[英]THREE.js ORBITCONTROLLS changing mouseButtons are not working

Hello i`m trying to make something with THREE.js but for some reason my .mouseButtons are not working 您好我想尝试用THREE.js制作东西,但由于某种原因我的.mouseButtons不起作用

var controls = new THREE.OrbitControls( camera, renderer.domElement );
            controls.target.set( 0, 25, 0 );
            controls.mouseButtons = {ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
            controls.update();

i have THREE.js added in there and i checked if THREE.MOUSE is in there if i add that part of code the mousebuttons fully disable 我已经在那里添加了THREE.js并且我检查了如果我在那里添加了那部分代码鼠标按钮完全禁用THREE.MOUSE

hope someone can help me out 希望有人可以帮助我

Since this commit , the mouseButtons object has changed its keys. 自此提交以来, mouseButtons对象已更改其键。 You no longer specify ORBIT , ZOOM and PAN but instead you map mouse buttons to map buttons. 您不再指定ORBITZOOMPAN ,而是将鼠标按钮映射到地图按钮。 What version of THREE.js are you using? 您使用的是哪个版本的THREE.js? Could this be the cause of your issues? 这可能是你问题的原因吗?

In the current version, your code should (to my understanding) be written as follows: 在当前版本中,您的代码应该(根据我的理解)编写如下:

var controls = new THREE.OrbitControls( camera, renderer.domElement );
    controls.target.set( 0, 25, 0 );
    controls.mouseButtons = {LEFT: THREE.MOUSE.LEFT, MIDDLE: THREE.MOUSE.MIDDLE, RIGHT: THREE.MOUSE.RIGHT};
    controls.update();

Notice however that these are already the default mappings so if you don't intend to change them, the whole line could be omitted. 但请注意,这些已经是默认映射,因此如果您不打算更改它们,则可以省略整行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM