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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.