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