Geometry.center() will change the location of mesh

geometry

#1

i use geometry.center() for rotate mesh around mesh’s own center,the result is that mesh can rotate around its own center,but it also cause the changing of mesh’s location in scene.how can i do to avoid it?


#2

Hi!
If I got you correctly, try something like this:

var mesh = ..some_mesh..
var center = new THREE.Vector3();
mesh.geometry.computeBoundingBox();
mesh.geometry.boundingBox.getCenter(center);
mesh.geometry.center();
mesh.position.copy(center);

#3

thanks for your replay,it’s work.But is there any other way besides this that can keep the mesh’s position doesn’t change?


#4

Well, as I can see, if you create your object in a modelling software, then set its geometry in the center there, then export it, then import in your scene and move a mesh itself.