问题描述
我有一个THREE.PlaneGeometry
和ComputeFaceNormals()
.我使用此几何形状创建了两个网格,并对其应用了不同的旋转.我想计算相机和两个网格中心面法线之间的两个角度.应该是:
I have a THREE.PlaneGeometry
, with ComputeFaceNormals()
. I create two meshes using this geometry, with different rotations applied to them. I want to compute the two angles between the camera and the two meshes central face normal. It should be :
vLocalCamera = vCamera.position - mesh1.position;
mesh1.normal() . vLocalCamera = cos(angle);
问题是我不知道如何使用three.js API在世界坐标中(通过几何和网格旋转)获得网格法线
The problem is that I don't know how to get the mesh normal in world coordinate (from geometry and mesh rotation) with three.js API
推荐答案
如果要将面或顶点法线normal
从局部空间转换为世界空间,则可以这样做:
If you want to convert a face or vertex normal, normal
, from local space to world space, you do it like so:
var normalMatrix = new THREE.Matrix3(); // create once and reuse
var worldNormal = new THREE.Vector3(); // create once and reuse
...
normalMatrix.getNormalMatrix( object.matrixWorld );
worldNormal.copy( normal ).applyMatrix3( normalMatrix ).normalize();
three.js r.107
three.js r.107
这篇关于Three.js:将法线从本地空间转换为世界空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!