0

I'm trying to rotate object on two axis y and x. But it does not work properly. Here is example

https://imge.to/i/vqyt20 local axis (no rotations)

https://imge.to/i/vqypnA what I have after moving with rotations

wheel1.rotation.x += movement;
wheel1.rotation.y = angle;

PS it works when movement == 0 or angle == 0 but fails when they both are not 0.

I've tried to use quaternions and multiply rotation vectors but nothing helps. Thanks in advance!

SOLUTION:

I've found answer on my question with vector rotation around y-axis

 angleX += movement; 

    [wheel1, wheel2].forEach(function (wheel) {
        let vector = new THREE.Vector3(1, 0, 0);
        vector.applyAxisAngle(new THREE.Vector3(0, 1, 0), angleY);

        wheel.rotation.y = angleY;
        wheel.rotation.x = 0;
        wheel.rotation.z = 0;

        wheel.rotateOnWorldAxis(vector, angleX);
    });

ONE MORE SOLUTION given in comments is to change wheel.rotation to 'YXZ' How to Rotate an Object and Reset it's Rotation to Zero?

0 Answers0