Javascript 如何在three.js中为二十面体BufferGeometry创建索引

Javascript 如何在three.js中为二十面体BufferGeometry创建索引,javascript,three.js,Javascript,Three.js,我遇到了麻烦,不知道如何解决或处理这种情况。 我只是想要一个替代的纹理球体,而不是在three.js中使用spherebuffergeometry。我想要使用二十面体缓冲几何体和一些附加代码来生成索引,因为我的渲染使用了drawarray而不是drawelement。但是,结果与预期不符,请参见下面的链接 对多面体BufferGeometry函数的修改如下: 1. var idx = []; // line 24097 2. this.setIndex( new ( Uint16Attrib

我遇到了麻烦,不知道如何解决或处理这种情况。 我只是想要一个替代的纹理球体,而不是在three.js中使用spherebuffergeometry。我想要使用二十面体缓冲几何体和一些附加代码来生成索引,因为我的渲染使用了drawarray而不是drawelement。但是,结果与预期不符,请参见下面的链接

对多面体BufferGeometry函数的修改如下:

 1. var idx = []; // line 24097
 2. this.setIndex( new ( Uint16Attribute )( idx, 1 ) ); // line 24119
 3. var iv = []; // line 24157 to store temp indices
 4. var iCount = idx.length; // line 24157
 5. iv[ i ][ j ] = ij ; ij++; // in the loop in line 24174
 6. idx.push( iCount+ iv[ i ][ k + 1 ]); // in the loop in line 24194
下面是使用修改的二十面体几何体得到的结果

使用spherebuffergeometry时,如下所示
在几天内进行了分析之后,我知道一些附加代码是错误的。我现在了解到,顶点缓冲区位置被多次复制以设置三角形,因此不需要创建索引或索引。只需将上面的代码6替换为

 6. idx.push( idx.length + counter); // in the loop in line 24194
代码3到5不再需要了。结果可以在上面的链接上看到,不再缺少三角形面

我认为可以重新创建多面体缓冲几何体上的代码以提高效率