【发布时间】:2017-03-14 23:05:37
【问题描述】:
我正在尝试通过 Three.js 中的一组点绘制一个最小二乘平面。我有一个plane 定义如下:
var plane = new THREE.Plane();
plane.setFromNormalAndCoplanarPoint(normal, point).normalize();
我的理解是,我需要使用该平面并使用它来提出几何图形,以便创建网格以添加到场景中进行显示:
var dispPlane = new THREE.Mesh(planeGeometry, planeMaterial);
scene.add(dispPlane);
我一直在尝试应用 this answer 来获取几何图形。这是我想出的:
plane.setFromNormalAndCoplanarPoint(dir, centroid).normalize();
planeGeometry.vertices.push(plane.normal);
planeGeometry.vertices.push(plane.orthoPoint(plane.normal));
planeGeometry.vertices.push(plane.orthoPoint(planeGeometry.vertices[1]));
planeGeometry.faces.push(new THREE.Face3(0, 1, 2));
planeGeometry.computeFaceNormals();
planeGeometry.computeVertexNormals();
但是飞机根本没有显示,也没有错误提示我可能哪里出错了。
所以我的问题是,如何获取我的 Math.Plane 对象并将其用作网格的几何图形?
【问题讨论】:
-
planeMaterial 是什么样子的?你试过改变planeMaterial.side吗?例如,planeMaterial.side = THREE.DoubleSide
-
var planeMaterial = new THREE.MeshLambertMaterial({color: 0xffff00, side: THREE.DoubleSide});
-
我注意到您使用 plane.normal 作为顶点:例如,planeGeometry.vertices.push(plane.normal);这似乎不成立。改用 plane.coplanarPoint() 运气好吗?
-
谢谢,但还是没有运气。
-
顺便说一句,第三个顶点与第二个顶点共线——所以创建的三角形面本质上是一条直线。因此,为什么您什么也看不到。
标签: javascript 3d three.js linear-algebra plane