How can i block block X and Z axis rotation ?
Opened this issue · 0 comments
tiagoernst commented
Is there a simple way to block the rotations on X and Z axis ? I'm using the trackball and managed somewhat to block thoose axis by converting the rotation (in quaternion ) to euler angles and putting x=0 and y=0, the problem is at some point the y doesn't go further (it looks like it's glitching and can't continue the rotation),I believe it's when the value of the y axis gets close to -1 or 1 (180° -180°).
code snippet from modified LeapTrackballControls.js:
THREE.LeapTrackballControls = function ( object , controller , params, domElement ) {
//initializing euler angle
rot3D_blocked = new THREE.Euler(0,0,0,'XYZ');
....
//later on the update function
rot3D_blocked.setFromQuaternion(rotation);
rot3D_blocked.z=0;
rot3D_blocked.x=0;
rotation.setFromEuler(rot3D_blocked);
this.rotation = rotation;
this.rotatingObject.rotation.setFromQuaternion(rotation);