Reputation: 1978
I loaded a .obj
earth and I'm trying to perfectly center it to the world origin. By "center it to the world origin" I mean I want the object exact center to be at the world exact center (0, 0, 0).
I know I can use a bounding box to get the center of the object and then maybe translate the whole object by minus that amount but is there a simpler way to do this ?
Upvotes: 1
Views: 701
Reputation: 8866
When you add a mesh to a scene, it is automatically added at the origin.
The bounding box way is non-destructive to your geometry, so if your shape has an offset built into it, you won't lose that. It's also "easy" because a majority of the processing is in finding the bounding box initially, and then that box doesn't change unless you scale or deform the shape.
There is an alternate way, if you don't mind your geometry changing: mesh.geometry.center();
will shift all the vertices such that the shape's geometric origin is at the mesh's origin (and if your mesh's origin is already at the scene origin, then you're good to go).
Upvotes: 1