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

标签 three.js

在 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/

相关文章:

javascript - 三个 js 补间 js 性能滞后于许多同时补间

javascript - 无法看到 OrthographicCamera 查看的场景

javascript - 在 Three.js 中渲染具有重叠三 Angular 形的透明网格

javascript - 变形后的点坐标?

javascript - Three.js 导入 Blender 模型。未捕获的类型错误 : Cannot read property 'x' of undefined

c# - 使用 three.js 加载 .obj 时出现问题

three.js - 三个js : why is wireframe thickness not adjusting for me?

javascript - ThreeJS - 如何测量 x/y/z 中给定点的光强度/像素值?

javascript - 如何在 Three.js 中设置可见性动画?

javascript - 如何避免浏览器的 Zoom 改变 Canvas 的大小?