SetPivotMatrix with Gizmo

Hi,

When I move the pivot point, the gizmo is not correctly positioned.

Here is a PG for better understand: https://www.babylonjs-playground.com/#1UZM4G#1

Edite the value Translation(1, 1, 1) line 28 to see the problem.
Also edit the position of the box to put it back in the center of the world to see that it works as it should. I noticed that it works well when the box has the position 0,0,0, but not when the box is no longer in the center of the world.

Thanks @trevordev

@Dad72 If I understand your issue, I think

box.bakeCurrentTransformIntoVertices();

is causing the translation you added to be baked as well. Could you not cache the position, do your changes and then set the position back?

See https://www.babylonjs-playground.com/#1UZM4G#2

1 Like

Works well. Thank you Trevor

1 Like

I made a few improvements to make it work perfectly.

I removed :box.setPivotMatrix(BABYLON.Matrix.Identity());
And I added :
box.position.set(-box.getPivotMatrix().getTranslation().x, -box.getPivotMatrix().getTranslation().y, -box.getPivotMatrix().getTranslation().z);
instead of
set(0,0,0)
so that I can recover the new pivot transformation with box.getPivotMatrix().getTranslation() and reset it to zero or some other value.

https://www.babylonjs-playground.com/#1UZM4G#4

1 Like