(Three.js)用加载器加载STL文件后,如何从STL文件中获取索引



我有个问题,我想从Three.js的STLLoader的stl文件中获取顶点和索引。我可以得到顶点,但是,我不能得到索引。。。

我试过

console.log(STLgeometry)

但是index属性为null。。。。

有机会得到指数吗。。?

我尝试了循环

//arr = devided vertices array in 3 elements
// ex) arr =[[x1,y1,z1],[x2,y2,z2]...,] 
//but there are same elements ex) [[x1,y1,z1],..,[x1,y1,z1]]
// so i remove same elements and that called "node" array
//if node's element and arr's elment is same, take that index and push it to "indices" array.
//but it takes so much time..... if vertices array is too big.

for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < node.length; j++) {
if (String(arr[i]) === String(node[j])) {
indices.push(j);
}
}
}

我真的需要你的帮助。

STL没有顶点索引的概念。这意味着STL文件中的三角形不共享顶点。因此,THREE.STLLoader返回一个未索引的几何体。

尝试使用实用函数BufferGeometryUtils.mergeVertices((。它将通过合并相等的顶点数据来返回一个新的索引几何体。

最新更新