我已经创建了 Object3D 并在其中添加了四个立方体几何体,并计算了 Object3D 的边界框,它包含四个立方体对象,并使用 BoxHelper 来查看边界框是否正在工作。现在我想要边界框的所有角(即XYZ,角坐标)。
基本上,我试图实现爆炸和内爆效果,其中我的四个立方体从边界框中心的初始位置到达边界框的四个角。
var objectContainer = new THREE.Object3D();
scene.add(objectContainer);
var objectAGeom = new THREE.BoxGeometry(1,1,1);
objectAMesh = new THREE.Mesh(objectAGeom, objectAMaterial);
scene.add(objectAMesh);
objectContainer.add(objectAMesh);
var objectBGeom = new THREE.BoxGeometry(1,1,1);
var objectBMesh = new THREE.Mesh(objectBGeom, objectBMaterial);
scene.add(objectBMesh);
objectContainer.add(objectBMesh);
var objectCGeom = new THREE.BoxGeometry(1,1,1);
var objectCMesh = new THREE.Mesh(objectCGeom, objectCMaterial);
scene.add(objectCMesh);
objectContainer.add(objectCMesh);
var objectDGeom = new THREE.BoxGeometry(1,1,1);
var objectDMesh = new THREE.Mesh(objectDGeom, objectDMaterial);
scene.add(objectDMesh);
objectContainer.add(objectDMesh);`
helper = new THREE.BoxHelper(objectContainer);
helper.material.color.set(0xbbddff);
scene.add(helper);
boundingBox = new THREE.Box3();
boundingBox.setFromObject(objectContainer);`