Is there a tool for centering GLTF models?

Non-centered models can cause problems.

You can find some questions and answers to this problem.


Simple full code example - #5 by hofk

How to rotate a gltf model in a specific direction

Centering a glTF geometry

Centering and Resizing GLTF models automatically in Three.js - Stack Overflow

rotation - Three.js glTF model centered but rotating on circular curve rather than center point - Stack Overflow

How to rotate a gltf model using mouse events?

Get wrong position center of mesh in gltf


It would sometimes be better if you could load a non-centered model with a tool and then export it centered.

Already asked there: How to center vertices of a gltf model - Stack Overflow

Is there a tool in order to center a gltf model?

I couldn’t find anything. :face_with_monocle:

There is not always a well-defined definition of “centering.” Sometimes you want the center of the model to be at 0,0,0. Sometimes you want the model to be sitting exactly on top of the point 0,0,0, like a chair when the ground is at y=0.

Code for computing the bounding box of an object and then moving it around is not too complicated, see https://github.com/donmccurdy/three-gltf-viewer/blob/9ef59abc24fbff84a5f0ce4413ca54a31ef11957/src/viewer.js#L266-L274 for an example.

For a general-purpose tool, I would open the file in Blender, move it, and export the result.

3 Likes

Thanks for the information. :slightly_smiling_face:

I have already tried the calculation of the movement and rotation myself.

See How to rotate a gltf model in a specific direction - #18 by Heyam

Check it out LoadGLTFmove

Since I’m not interested in modelling myself, I take finished models. When there is time, I have to take a closer look at Blender.

1 Like