Pivot point not at center of imported mesh

Reference playground: https://playground.babylonjs.com/#8LFTCH#1451

(Please excuse terrible code, it was quickly made to reproduce the issue I’m having in a large repo.)

In the above playground, you can see that I import a somewhat complicated mesh and set the primary parent nodes’ positions to (0,0,0). I then create an ArcRotateCamera that targets (0,0,0).

However, as you can see by the position gizmo for the mesh and the fact that the camera does not appear to target the mesh, the mesh is not actually at 0,0,0. I suspect that this has to do with its pivot point, but I don’t know the correct way to adjust it so that the pivot point is at the center of the car.

This is an issue because I am trying to apply an animation that rotates the wheels, however, since the pivot point is not at the middle of the car, they instead spin around their pivot point.

So I am wondering how I ought to go about centering the pivot position in the mesh so that the mesh actually appears at (0,0,0) and I am able to rotate the wheels as one would expect.

Hi!

I’ve yet to experiment with the pivot point code.

But… if you created or someone you know created the model…
You can open the wheel model in Blender and…
in object mode place your object at (0, 0, 0);
and , in edit mode, you center your mesh at (0,0,0);

If it is already at the origin then just do Ctrl+A and select “all transformations”…
That will reset the pivot point to 0,0,0 and reset any rotations and scaling.

1 Like

@ThomasMeetKai you could check the bounding information of your mesh, then translate it to be centered on 0 and finally bake the current transform in the mesh.

But fully agree with @SamuelSousa it would be better to do in your edition tools.

1 Like