/**
* 锚点重置到中心
* @param {Object3D} mesh
*/
function reAnchorCenter(mesh) {
const geometry = mesh.geometry
const position = mesh.position
geometry.computeBoundingBox()
const center = new THREE.Vector3();
geometry.boundingBox.getCenter(center);
const m = new THREE.Matrix4();
m.set(1, 0, 0, center.x-position.x,
0, 1, 0, center.y - position.y,
0, 0, 1, center.z - position.z,
0, 0, 0, 1)
geometry.center();
mesh.position.applyMatrix4(m)
}
该方法可以用于因为通过曲线,点阵生成物体,如管线,车削物体后锚点被设置在原点处,需要将锚点设置到物体中间时使用