Get absolute rotation of child mesh...

Recommended Posts

Deltakosh has the answer, but just wanted to add that in case you are trying to unparent a child mesh and keep rotation, in BJS 3.0 there is a setParent(mesh) in AbstractMesh - pass in null to unparent.

If not then here is a code sample of using decompose - don't forget to check if rotationQuaternion has been set, because otherwise rotation will have no effect:

// here is how you could unparent a child mesh, while keep rotation and position.
var rotation = Quaternion.Identity()
var position = Vector3.Zero()

child.getWorldMatrix().decompose(Vector3.Zero(), rotation, position)

if (child.rotationQuaternion) {
} else {

child.parent = undefined

child.position.x = position.x
child.position.y = position.y
child.position.z = position.z


Share this post

Link to post
Share on other sites


Just found this thread. @DeltakoshWhat if wanted to SET the absolute rotation of a matrix?

What I thought of doing was decomposing the worldMatrix, updating the rotation quaternion and then "recomposing" the world matrix with the updated rotation quaternion. I'm not sure how to do that though, or even if that really makes sense... Is there a simpler way?


Share this post

Link to post
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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.