我对Quickhull扩展名感到困惑。如何找到两个物体的凸包?翻译后我需要将它们脱壳,所以也许我需要翻译实际的顶点而不是简单地改变位置?找不到有关此扩展程序的任何文档,因此感谢那些知道的人提供的帮助。
答案 0 :(得分:1)
您必须将网格合并在一起,然后获取该meshes.geometry的ConvexHull。
var box = new THREE.BoxGeometry(1, 1, 1);
var sphere = new THREE.SphereGeometry(.65, 32, 32);
sphere.position.x = 4;
var singleGeometry = new THREE.Geometry();
var boxMesh = new THREE.Mesh(box);
var sphereMesh = new THREE.Mesh(sphere);
boxMesh.updateMatrix(); // as needed
singleGeometry.merge(boxMesh.geometry, boxMesh.matrix);
sphereMesh.updateMatrix(); // as needed
singleGeometry.merge(sphereMesh.geometry, sphereMesh.matrix);
var material = new THREE.MeshPhongMaterial({color: 0xFF0000});
var mesh = new THREE.Mesh(singleGeometry, material);
if(mesh.geometry.type==='BufferGeometry')mesh.geometry = new THREE.Geometry().fromBufferGeometry(mesh.geometry);
mesh.geometry = new THREE.ConvexGeometry(mesh.geometry.vertices);
scene.add(mesh);