rotateAroundPivot() not working properly with rotated meshes


I am currently using the rotateAroundPivot function from this doc
to basically rotate a mesh around a pivot just like you would do in 3ds max or in blender.

Everything works fine, except if the mesh already is rotated in an Axis, which is not the same Axis you pass to the function.

This is the result on using rotateAroundPivot on a non rotated mesh:
Everything works fine here.

And this is the result on using rotateAroundPivot on an already rotated mesh:
Screenshot 2023-09-17 172843

In this example, I am trying to rotate the mesh around a pivot in the Z axis. The mesh was rotated in y Axis beforehand.
And as you can see, the mesh suddenly has an offset in its local z position.

Here’s the PG:

Hoping for this to get fixed quickly, as I can not figure out how to use the pivot/parenting system in BabylonJS, as it is not the same as in 3d modelling programs such as blender/3ds max.

I’ve stated what I am trying to achieve in this post:,
so if anyone could help me figure out how to achieve that without using the function, that would be just as fine!


that’s because you’re rotating the mesh in the WORLD axis and not LOCAL,
it worked at first because the object local axis and the world axis aligned perfectly, the moment you rotated the box on the Y axis, everything changed.

the rotateAroundPivot only handles rotation in WORLD space,

I modified on your playground, and used the pivot mesh as a parent to the box2 and used the pivot.rotate() instead.

hope this helps


You are a lifesaver, thank you!

1 Like


I did some research and I updated the rotateAroundPivot function so it can handle LOCAL and WORLD rotations, (found the fix in another playground, so credits goes to whoever fixed it)
you just need to pass the local z axis (box2.forward) to the axis param instead of the world Z axis.

hope this helps as you will avoid parenting the box2 to the new pivot mesh

1 Like

should probably be updated here as well then

1 Like

Yep, I submitted a PR, it should update the docs:

1 Like