首页 / three.js / API 文档
Plane
先看结论
无限平面。由法线与到原点的距离定义,用于裁剪、剖面分析、 判断点位于面的哪一侧。
new THREE.Plane(normal, constant)
构造参数
| 参数 | 默认 | 说明 |
|---|---|---|
normal | (0, 0, 1) | 法线,必须是单位向量 |
constant | 0 | 平面到原点的有符号距离 |
平面方程写作 normal · p + constant = 0。
constant 为负时平面沿法线反方向平移。
属性
| 属性 | 说明 |
|---|---|
normal | 法线,Vector3 |
constant | 到原点的有符号距离 |
isPlane | 恒为 true |
方法
| 方法 | 说明 |
|---|---|
set(normal, constant) | 设置法线与距离 |
setComponents(x, y, z, w) | 由四个分量设置 |
setFromNormalAndCoplanarPoint(normal, point) | 用法线与面上一点定义 |
setFromCoplanarPoints(a, b, c) | 由三个不共线的点定义,法线朝上 |
normalize() | 把法线归一化并同步调整 constant |
negate() | 翻转法线方向 |
distanceToPoint(point) | 有符号距离,正值在法线一侧 |
distanceToSphere(sphere) | 到球面的有符号距离 |
projectPoint(point, target) | 把点投影到平面上 |
coplanarPoint(target) | 返回平面上离原点最近的点 |
intersectLine(line, target) | 与直线的交点,平行时返回 undefined |
intersectsLine(line) | 是否与直线相交 |
applyMatrix4(matrix, optionalNormalMatrix) | 用变换矩阵改写平面 |
translate(offset) | 沿法线方向平移 |
clone() / copy(plane) | 复制 |
示例:水平剖面
// 高度 120 米的水平面,法线朝上
const plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -120);
// 点在面之上还是之下
const d = plane.distanceToPoint(new THREE.Vector3(0, 150, 0));
console.log(d > 0 ? '在上方' : '在下方');
// 与射线的交点,用于拾取剖面位置
const ray = new THREE.Ray(
new THREE.Vector3(0, 300, 0),
new THREE.Vector3(0, -1, 0)
);
const hit = plane.intersectLine(ray);
console.log(hit);
constant 的符号
new Plane(new Vector3(0, 1, 0), -120) 表示平面位于 y = 120。
直觉上容易把 constant 当成高度直接写入,
得到 y = -120 的平面。distanceToPoint 的结果符号
可以用来验证朝向:正表示点在法线方向上。
裁剪平面
WebGLRenderer.localClippingEnabled = true 之后,
把平面放进材质的 clippingPlanes 数组即可剖切模型。
平面上方的部分被裁掉,剖切面本身不会自动补面,
需要另做一块盖面才能看到内部结构。
法线必须是单位向量。构造时不校验长度,非单位法线会让
distanceToPoint 的距离按比例失真。
手工构造后调用一次 normalize() 最稳妥。
经纬志(2026)。《Plane》。https://www.jingweizhi.com/three/api/plane.html(访问日期 2026-11-03)。