在 BufferGeometry 中,有没有一种方法可以访问面索引和法线而不转换为 Geometry?
手头的几何体是由 Threejs 编辑器创建的 SphereBufferGeometry。
我只需要读取面索引和法线,而不需要修改它们。
最佳答案
BufferGeometry
要么是“索引”,要么是“非索引”。 SphereGeometry
,派生自BufferGeometry
,属于索引类型。
您可以像这样访问几何数据结构中的面法线:
var normal = new THREE.Vector3(); // create once and reuse
...
// specify the desired face index
var faceIndex = 15; // [ 0 ... num_faces-1 ]
// specify which face vertex you want
var vertexNumber = 2; // [ 0, 1, or 2 ]
// compute the index where the data is stored
var index = geometry.index.array[ 3 * faceIndex + vertexNumber ];
// get the vertex normal from the attribute data
normal.fromBufferAttribute( geometry.attributes.normal, index );
console.log( normal );
三.js r.143
关于three.js - THREE.BufferGeometry - 访问面索引和面法线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41540313/