C4rdZ
C4rdZ

Reputation: 47

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

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

hope someone can help me out

Upvotes: 3

Views: 1380

Answers (1)

Berthur
Berthur

Reputation: 4495

Since this commit, the mouseButtons object has changed its keys. You no longer specify ORBIT, ZOOM and PAN but instead you map mouse buttons to map buttons. What version of THREE.js are you using? 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.

Upvotes: 2

Related Questions