0

I want to apply rotation to an object around it's x axis 90 degrees first, and then around it's y axis 90 degrees. How can I do that in three.js?

I tried

mesh.rotation.x = Math.PI * 0.5;
mesh.rotation.y = Math.PI * 0.5;

but it doesn't rotate as I wanted.

4
  • but it doesn't rotate as I wanted what was expected, what was the actual? Looks like you can use this to maybe rotate two axies at once? Commented Apr 30, 2019 at 2:20
  • think of axises like global don't change, i want to rotate the object around x axis, and then around y axis. It's pretty easy to visualize. But I guess rotating first on x axis changes it's local axises so i can't rotate around global y axis again. Commented Apr 30, 2019 at 2:40
  • 2
    Is using quaternions a requirement? Is the mesh rotated to begin with? Make sure your question is clear as to global or local axes. Study the Object3D methods. Commented Apr 30, 2019 at 3:05
  • Possible duplicate of How to rotate a 3D object on axis three.js? Commented Apr 30, 2019 at 10:45

1 Answer 1

2

We can achieve like this,

mesh.rotateX(Math.PI * 0.5);
mesh.rotateY(Math.PI * 0.5);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.