MeshExploder causes submeshes to rotate

I have a parent/child mesh structure. The parent rotates around the Y axis and the submeshes rotates fine with it. If I add an MeshExploder to the mix, the submeshes “inherits” the rotation and starts rotate around their own Y-axes. Sample here:
Is this by design or a bug?
All the best,

Pinging @danjpar who created the MeshExploder !

The children rotate because their parent rotates. I’ll dig around to see if there is a way to ignore the inherited animations.

A quick workaround is to create an empty mesh and set that as the parent for the smaller cubes.

1 Like

Thanks but that does not solve the problem. The small cubes should still circle around the center cube while “exploding in/out”.

After messing around in the code, I realize the smaller cubes should be following the large cube like the sphere is.

Here is the code that is setting the positions of the exploding meshes. I imagine an easy fix would be to have a boolean flag on the explode function to update the origin vectors with the centermesh/parent transformations.

public explode(direction: number = 1.0): void {
    for (var index = 0; index < this._meshes.length; index++) {
        if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
            this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
            this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);

Any recommendations for easiest way to update those vectors?

BTW, any plans to make the MeshExploder an Animatable ?

My guts tell me that if we want to support parent hierarchy we should simply call .position instead of setAbsolutePosition


I’ll keep messing around with the code. Right off the bat, changing to this._meshes[index].position = this._newPosition; allows for the parent transformations, however, only one of the smaller cubes are present (or all of the smaller cubes in one position).

I think the latter. Can you somehow recreates your tests in the PG?

I’ll rewrite the code as a function in the playground

1 Like

Any progress on this?
Would love to see a fix, here is a sample using the exploder (would be awesome to be able to rotate the cube)…