Can't get gizmo pivot placed correctly on imported mesh

Hey there everyone!

This is my first time posting but have found these posts very helpful. Hopefully this is a clear question. (May just be a bug?)

So I am importing geometry into Babylon and then want to be able to select a mesh by clicking it, and use the GizmoManager to position, scale and rotate that individual mesh.

The issue I am running into is that the pivot is at the origin no matter which mesh I select. I would like to be able to move the gizmo/pivot point some place else, potentially the center of the selected mesh. I’m hoping to make this work for a variety of imported models, hence the normalizingToUnitCube and mesh selection.

Here is a playground of me trying some of the many ways I have tried to make this work: https://www.babylonjs-playground.com/#Z38R7R#9

I have three commented out approaches in here 1) TransformNode, 2) PivotPoint, and 3) PivotMatrix. If you have any thoughts to make any of those work or something entirely different, would be greatly appreciated! Please and thank you for your time!

I worry that what I am trying to do might simply not be supported in conjunction with importing a GLTF/GLB and “normalizingToUnitCube”?

Welcome aboard!

Adding @Cedric who knows everything (and more) about gizmos!

1 Like

IMHO, the best to do is to center pivot on the mesh in your DCC tool and export it again.
I did a quick look and fixed the code with the transform node :
Testing gizmo pivot issue | Babylon.js Playground (babylonjs-playground.com)
there is a call to bake vertices because changing its parent will break its orientation and scale.
Then, place the transform in the mesh center world.

4 Likes

Thanks so much for the response! Yeah, that edit to the playground looks good. Do you happen to know why the mesh appears to disappear? It’s almost like a clipping plane issue because when I back out the camera pretty far, the camera seems to reappear.

CLARIFICATION: This fix works perfectly for the tripod but it specifically makes the camera disappear unless you zoom out pretty far away

And yeah, I was hoping to be able to set up the scene to be able to work for an arbitrary mesh, so getting it to work within the scene would be ideal! But yeah, it’s been seeming like I may need to do some adjusting outside of Babylon if this doesn’t work

1 Like