(Three.js) 在使用加载程序加载 stl 文件后,如何从 STL 文件中获取索引?

(Three.js) how can i get indices from STL file after load stl file with loader?

我有一个问题, 我想从 Three.js 的 STLLoader 的 stl 文件中获取顶点和索引。 我可以获取顶点,但无法获取索引...

我试过了

console.log(STLgeometry)

但是索引属性为空....

有没有机会获得指数..?

我尝试了循环

//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 return 是一个 non-indexed 几何体。

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