Pivot and local positionning

Hi everybody,

I have a problem when i wan’t to change the local axes of a mesh.

Here’s the playground : https://playground.babylonjs.com/#BRY0P8

it seem to work because the position of box seems to be calculated from the left corner of the box but when i wan’t to show the local axes, they still are in the middle of the cube.

I don’t understand why

This is by design in how the Gizmo are working, @Cedric might have a trick ?

hi @bvaisman

Gizmo is positioned on (0,0,0) local position. Which is the center of the cube. The gizmo position is not the pivot position.
Use intermediate transform between object and the gizmo isf you want to place the gizmo somewhere else.

Hi @Cedric

I agree but I think i’ve changed the local position of the cube with the setPivotMatrix function.

If I display the position of the cube, it’s [0,0,0] which is exactly the position of the sphere.

I don’t understand why the gizmo still remains in the centre of the cube.

I’m sure i don’t work correctly but i don’t know where is my mistake.

Please note that

box.setPivotPoint(vect);
box.setPivotMatrix(BABYLON.Matrix.Translation(1,1,1), false);

Are alternative methods of applying a pivot that behave differently. The first does not change the mesh position. Alternating between lines 25 and 26 in the following playground will show you the difference.

https://playground.babylonjs.com/#BRY0P8#1

More information in the docs

The

box.setPivotMatrix(BABYLON.Matrix.Translation(1,1,1), false);

method makes the pivot behave as in these very old docs prior to the changes.

http://babylonjsguide.github.io/advanced/Pivots

You could attach the gizmo to the sphere https://playground.babylonjs.com/#BRY0P8#2

or a TransformNode https://playground.babylonjs.com/#BRY0P8#3

in which case you may as well use the TransformNode as a parent and as the center of rotation https://playground.babylonjs.com/#BRY0P8#4

Plenty of choices for you to decide which is best for you.

3 Likes