Three.js TrackballControls.js rotating in z & x axis only

I,m trying to set TracballControls in threejs to move only in two axles, only pan and tilt, without roll. Is there any possibilities to make it? My code: Mouse move should behave like this:

i think this will help you: (solved my problem)

look in your TrackballControl.js-file and change the line 148


_this.object.up.applyQuaternion( quaternion );


_this.object.up.applyQuaternion( new THREE.Vector4(0,0,0,1) );

//Update Only work with older versions

I realize this is very old, but as it's still the main result in google I'll describe how I made this work.

To prevent roll (lock the z axis), you can prevent rotateCamera() from making changes to the camera's Up vector.

Comment out the line (~line 200)


If you like you can lock the camera's rotation vector as well, add either

_this.object.rotation.z = 0; 


_this.object.rotation.set(0, 0, 0);

to the end of the function. However in practice I found this doesn't make much difference as most of the rotation is caused by movement of the camera relative to it's lookAt target ( in the trackballControls.js file).

i just changed the variable


on line 26 to false. Uncommented

_this.object.up.applyQuaternion( quaternion );

And increased the

this.dynamicDampingFactor = 0.2;

to 0.8.