THREE.BufferGeometry - 访问面部索引和面法线

时间:2017-01-09 02:48:21

标签: three.js

在BufferGeometry中,有没有办法在不转换为Geometry的情况下访问面部索引和法线?

手头的几何体是由threejs编辑器创建的SphereBufferGeometry。

我只需要阅读面部索引和法线,而不是修改它们。

1 个答案:

答案 0 :(得分:3)

BufferGeometry或者是#34;索引"或"非索引"。 SphereBufferGeometry属于索引类型。

您可以在几何数据结构中访问面法线,如下所示:

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 );

three.js r.83

相关问题