Jump to content

Get world RotationQuaternion of a descendant


ChrisR
 Share

Recommended Posts

Hey,

 

Sorry for becoming the guy that always asks questions. I promise i look into everything quite hard before i ask here. I am after all trying to learn the wonderful world of 3D Space.

 

So, this time, i am trying to get the world rotation of a Mesh. This mesh is the child of several other meshes. I am trying to multiply all the quaterions of its parent together to calculate its quaterion.

 

Take a look: http://www.babylonjs-playground.com/#1JUUIH

 

I want the final blue cube to have the same rotation as the original green cube.

 

Now, if i take away the initial rotation of the cube by commenting out the line:

cube.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(5, 0, 0);

It works. But i am dealing with meshes that have their initial rotationQuaterion set. So after i rotate them then try to get its "world rotation" its not coming back properly. Is there some undertanding to this that i am missing?

 

Thanks as always :)

Link to comment
Share on other sites

Hey,

 

First - don't be afraid to ask questions. I think I wrote it a fe times already, but I guess it's worth repeating - there are no stupid questions. Especially a question like yours, which you invested quite some time trying to understand :-)

 

So, first - http://www.babylonjs-playground.com/#1JUUIH#2

 

You were missing the last cube - you never multiplied the newRotation with the rotation of the last cube, which still has a rotationQuaternion. Is this what you were trying to achieve?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...