jmb462 Posted September 5, 2018 Share Posted September 5, 2018 Hi here, I've got trouble with mesh rotation around an axis. Thanks to this forum, i've found a function that manage the rotation around an axis but it doesn't give me the result i'm expecting. I want to rotate a box around the world Y axes then the world Z axis. If I do only rotation around Y or around Z, every thing is working. But when I do a rotation around Y then around Z, the box rotates correctly around the axis BUT spins around its own center with the same angle. (as the earth that spin while doing its revolution around the sun...) Here is a playground (the small cube is the reference). I'd like the big cube keep the same orientation as the small one (without parenting). http://www.babylonjs-playground.com/indexStable.html#DVUAAQ#2 As far I understand, it's seem to be a local / global axis probleme when using the rotation around axis. Because, if I choose LOCAL for the small one, it gives me the same result that the big one. But I want global axes (thoses who are shown in the playground). Thanks for any help or idea. Hope my english is understandable JMB Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 5, 2018 Share Posted September 5, 2018 Hi, You have this quaternion multiplication order reversed: this.rotationQuaternion = this._rq.multiply(_q); Should be: this.rotationQuaternion = _q.multiply(this._rq); http://www.babylonjs-playground.com/indexStable.html#DVUAAQ#3 jmb462 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted September 5, 2018 Share Posted September 5, 2018 Hi @jmb462 if you have not done so already I suggest you read the following documentation pages http://doc.babylonjs.com/babylon101/position http://doc.babylonjs.com/features/position,_rotation,_scaling http://doc.babylonjs.com/how_to/pivots http://doc.babylonjs.com/how_to/pivot http://doc.babylonjs.com/resources/rotation_conventions From your earlier post I see that you are "planning to make a rubik's cube with babylon. I'm new to babylon and javascript ." A challenging task - good luck. jmb462 1 Quote Link to comment Share on other sites More sharing options...
jmb462 Posted September 5, 2018 Author Share Posted September 5, 2018 @Gijs Thanks a lot ! That's now working fine. ? @JohnK Thanks too for the links. I've read several times these pages but I didn't manage to find the problem. I'm surely lacking some knownledge too fully understand some 3D parts. My cube is now functional. http://jmbernard.com/cube5/ (Controls are keyboard with standard cube notation (R L U D B F and so) with shift for anticlockwise moves. I can now implement other function but this 3D rotation programming part was the trickiest part for me I think. JohnK and Gijs 2 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 5, 2018 Share Posted September 5, 2018 Flagging this topic as solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.