Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js 三js:如何获取旋转平面的法线_Three.js_Plane - Fatal编程技术网

Three.js 三js:如何获取旋转平面的法线

Three.js 三js:如何获取旋转平面的法线,three.js,plane,Three.js,Plane,我试图得到旋转平面的法线。我的解决方案是复制更新的平面,然后获取法线。 当我只旋转1个角度时,它工作,但在旋转2或3个角度时不工作 绿色的是复制平面,紫色的是旋转平面。 如何解决这个问题?请帮帮我 我的复制功能: function copyPlane() { let copyPlaneGeom = new THREE.PlaneGeometry(3, 3, 3); copyPlaneGeom.rotateX(plane.rotation.x); copyPlaneGe

我试图得到旋转平面的法线。我的解决方案是复制更新的平面,然后获取法线。 当我只旋转1个角度时,它工作,但在旋转2或3个角度时不工作

绿色的是复制平面,紫色的是旋转平面。

如何解决这个问题?请帮帮我

我的复制功能:

 function copyPlane() {
    let copyPlaneGeom = new THREE.PlaneGeometry(3, 3, 3);
    copyPlaneGeom.rotateX(plane.rotation.x);
    copyPlaneGeom.rotateY(plane.rotation.y);
    copyPlaneGeom.rotateZ(plane.rotation.z);
    let copyPlane = new THREE.Mesh(copyPlaneGeom, new THREE.MeshBasicMaterial({color: 0x00ff00}));
        scene.add(copyPlane)
    
    let normals = copyPlane.geometry.faces[0].normal

我认为通过这种方法,你总是会得到一个向量
0,0,1
,因为平面的面法线总是
(0,0,1)*objectRotation

相反,请尝试从
0,0,1
的矢量3开始,然后对其应用对象的旋转:

var originalNormal=新向量3(0,0,1);
//获取网格旋转
var objRotation=平面旋转;
//将网格旋转应用于向量
原始正常。applyEuler(objRotation);

现在你有了一个更新了wold法线的向量3,而不是本地法线!阅读。

非常感谢!这正是我想要的。你救了我一天:)