需求:鼠标选中模型,然后点击定位按钮,将相机平移到模型跟前,相机视线不变
var box = new THREE.Box3();//包围盒
box.expandByObject(model);//model是模型
var center = new THREE.Vector3();
box.getCenter(center);//获取中心点
var distance = Math.max(box.max.x - box.min.x, Math.max(box.max.y - box.min.y, box.max.z - box.min.z));//计算模型尺寸
var direction = new THREE.Vector3();
camera.getWorldDirection(direction);//相机视线
direction.negate();
center.add(direction.multiplyScalar(distance));//中心点加上尺寸
//相机定位,这一步可以换成tweenjs动画
camera.position.set(center.x,center.y,center.z)