使用 Group 与 Box3 实现多个网格模型对象居中
const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cubeA = new THREE.Mesh( geometry, material );
cubeA.position.set( 100, 100, 0 );
const cubeB = new THREE.Mesh( geometry, material );
cubeB.position.set( -100, -100, 0 );
const group = new THREE.Group();
group.add( cubeA );
group.add( cubeB );
scene.add( group );
const box3 = new THREE.Box3();
box3.expandByObject(group);
const center = new THREE.Vector3();
box3.getCenter(center);
group.position.x = group.position.x - center.x
group.position.y = group.position.y - center.y
group.position.z = group.position.z - center.z
renderer.render(scene, camera);