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.

WestLangley
  • 102,557
  • 10
  • 276
  • 276
eguneys
  • 6,028
  • 7
  • 31
  • 63
  • `but it doesn't rotate as I wanted` what was expected, what was the actual? Looks like you can use [this](https://stackoverflow.com/a/30154137/1790644) to maybe rotate two axies at once? – Matt Clark Apr 30 '19 at 02: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. – eguneys Apr 30 '19 at 02: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. – WestLangley Apr 30 '19 at 03:05
  • Possible duplicate of [How to rotate a 3D object on axis three.js?](https://stackoverflow.com/questions/11060734/how-to-rotate-a-3d-object-on-axis-three-js) – Bardi Harborow Apr 30 '19 at 10:45

1 Answers1

2

We can achieve like this,

mesh.rotateX(Math.PI * 0.5);
mesh.rotateY(Math.PI * 0.5);
srj
  • 41
  • 4