I am trying to rotate an object around the axis of the world. I found this question: How to rotate an object in the world of the three.js axis?
But this did not help to solve this problem:
var rotWorldMatrix;
multiplySelf and getRotationFromMatrix not defined (I get a console error). How to fix the problem?
Refresh
I tried using Quaternion , but it doesn't seem to work correctly. I am trying to rotate an object on user click, this is the function I wrote:
function mouseUp(event) { var x= event.clientX; var y= event.clientY; var dx= (x - xBegin); var dy= (y - yBegin); var quaternion= new THREE.Quaternion(); quaternion.setFromAxisAngle(new THREE.Quaternion(dy,dx,0).normalize(),Math.sqrt(dx*dx+dy*dy)/250.0); object.quaternion.multiplyQuaternions(quaternion,object.quaternion); }
It rotates correctly while the object is in vertical or horizontal position, but if, for example, it is 45 degrees from the x axis, it rotates very slowly and in the opposite direction of the click.
Ramy Al Zuhouri
source share