【问题标题】:Is there a way to get the vertices array from a three.js QuickHull instance?有没有办法从 three.js QuickHull 实例中获取顶点数组?
【发布时间】:2019-04-13 00:21:21
【问题描述】:
我正在尝试从三个网格的 quickhull 创建一个几何体,但 QuickHull 实例似乎只包含与 Faces 相关的信息。
有没有办法从这个实例中获取每个顶点信息?
提前谢谢你。
const hull = new QuickHull().setFromObject(mesh) //Mesh is an already rendered object
//hull.vertices //this returns the entire geometry instead of the hull's vertices
【问题讨论】:
标签:
javascript
three.js
3d
【解决方案1】:
是的,这应该是可能的。像这样尝试:
const hull = new THREE.QuickHull().setFromObject( mesh );
const vertices = [];
const faces = quickHull.faces;
for ( let i = 0; i < faces.length; i ++ ) {
const face = faces[ i ];
let edge = face.edge;
do {
const point = edge.head().point;
vertices.push( point.x, point.y, point.z );
edge = edge.next;
} while ( edge !== face.edge );
}
如您所见,这个想法是使用面的半边来按正确的顺序收集所有顶点。