在我的 Three.js 项目中,我有一个使用缓冲区几何形状的网格。
使用光线投射器,我找到光线与该网格在特定面上的交集,它告诉我索引。
我怎样才能找到这个面的顶点位置?
与使用 相比faceIndex,使用face交集对象的属性更容易。你可以像这样使用它:
var vA = new THREE.Vector3();
var vB = new THREE.Vector3();
var vC = new THREE.Vector3();
var face = intersection.face;
var geometry = intersection.object.geometry;
var position = geometry.attributes.position;
vA.fromBufferAttribute( position, face.a );
vB.fromBufferAttribute( position, face.b );
vC.fromBufferAttribute( position, face.c );
Run Code Online (Sandbox Code Playgroud)
如果您需要世界空间中的顶点,请将这三个向量与对象的世界矩阵相乘。
three.js R102
| 归档时间: |
|
| 查看次数: |
2569 次 |
| 最近记录: |