Jump to content

Rotating in local space when rotationQuaternion is in use


neoRiley
 Share

Recommended Posts

In reading the tutorial here it says that mesh.rotate is based on eulers and is local BUT, if rotationQuaternion is set/in use, then rotation is not used at all in favor of rotationQuaternion.  So, an example of how to rotate in world space was given, but nothing was said about how to rotate in local space if rotationQuaternion is in use.

 

I can confirm that mesh.rotate does nothing if rotationQuaternion is in use.

 

I'm not a quaternion expert, but my guess was that rotationQuaternion was local by default, and that if I did something like this:

this.rotationQuaternion = this.rotationQuaternion.add(BABYLON.Quaternion.RotationYawPitchRoll(tempV3.y, tempV3.x, tempV3.z));

it should work, but I get the craziest results.  So that's bad apparently.  

 

Can someone shed some light on how to add to the rotation in local space when having to use rotationQuaternion?

 

PS> I would like to suggest keeping both euler and quaternions updated for ease of use in the future.  And even updating the API to be more like:

 

rotation = world rotation in radians

localRotation = local rotation in radians

eulers = world rotation in degrees

localEulers = local rotation in degrees

 

This way, developers can do whatever they want however they want.

 

Thanks for the help,

 

John

Link to comment
Share on other sites

About the rotation using euler or using quaternion, I choose to prefer quaternion is rotationQuaternion is defined instead of rotation for performance reasons. I do not want to update my euler angles when quaternion are in use because it implies a test and a complex operation for every object in the scene on every frame

 

I try to keep Babylon.js as simple as possible and frankly the rotation part is not my favourite J

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...