如何使用Three.js平面
How to use Three.js plane
我正在尝试使用 three.js 平面来获取点到平面的距离。
我有三个点 a、b、c,我这样计算法线:
const v = a.clone().sub(c);
const u = b.clone().sub(c);
const normal = u.cross(v);
然后
const plane = new THREE.Plane(normal, (?))
你应该在第二个参数中给出什么?
来自docs:
the negative distance from the origin to the plane along the normal vector. Default is 0.
这是什么意思?
如果我将点 a、b、c 之一到 (0,0,0)(正距离和负距离)的距离放在那里,如 const dist = a.distanceTo(new THREE.Vector3(0,0,0))
,那么如果我这样做:
plane.distanceToPoint(a);
我得到一个很大的数字而不是零,如果我将该参数留空,也会发生同样的情况。
那么我怎样才能将该平面放置在正确的位置,以便到该平面上的点的距离应该为零?
因为你有三个共面点,你可以使用THREE.Plane()
的.setFromCoplanarPoints(a, b, c)
方法。
.
中有一个使用示例
我正在尝试使用 three.js 平面来获取点到平面的距离。
我有三个点 a、b、c,我这样计算法线:
const v = a.clone().sub(c);
const u = b.clone().sub(c);
const normal = u.cross(v);
然后
const plane = new THREE.Plane(normal, (?))
你应该在第二个参数中给出什么?
来自docs:
the negative distance from the origin to the plane along the normal vector. Default is 0.
这是什么意思?
如果我将点 a、b、c 之一到 (0,0,0)(正距离和负距离)的距离放在那里,如 const dist = a.distanceTo(new THREE.Vector3(0,0,0))
,那么如果我这样做:
plane.distanceToPoint(a);
我得到一个很大的数字而不是零,如果我将该参数留空,也会发生同样的情况。
那么我怎样才能将该平面放置在正确的位置,以便到该平面上的点的距离应该为零?
因为你有三个共面点,你可以使用THREE.Plane()
的.setFromCoplanarPoints(a, b, c)
方法。