
Mirror Engine API / Plane
Class: Plane
An infinite plane. Internally it's represented in a parametric equation form: ax + by + cz + distance = 0.
Constructors
new Plane()
new Plane(normal?: Vec3, distance?: number): Plane
Create a new Plane instance.
Parameters
normal?
Vec3
= Vec3.UP
Normal of the plane. The constructor copies this parameter. Defaults to Vec3.UP.
distance?
number
= 0
The distance from the plane to the origin, along its normal. Defaults to 0.
Returns
Properties
distance
distance: number
The distance from the plane to the origin, along its normal.
normal
normal: Vec3
The normal of the plane.
Methods
clone()
clone(): Plane
Returns a clone of the specified plane.
Returns
A duplicate plane.
copy()
copy(src: Plane): Plane
Copies the contents of a source plane to a destination plane.
Parameters
src
A source plane to copy to the destination plane.
Returns
Self for chaining.
intersectsLine()
intersectsLine(
start: Vec3,
end: Vec3,
point?: Vec3): boolean
Test if the plane intersects between two points.
Parameters
start
Start position of line.
end
End position of line.
point?
If there is an intersection, the intersection point will be copied into here.
Returns
boolean
True if there is an intersection.
intersectsRay()
intersectsRay(ray: Ray, point?: Vec3): boolean
Test if a ray intersects with the infinite plane.
Parameters
ray
Ray to test against (direction must be normalized).
point?
If there is an intersection, the intersection point will be copied into here.
Returns
boolean
True if there is an intersection.
normalize()
normalize(): Plane
Normalize the plane.
Returns
Self for chaining.
set()
set(
nx: number,
ny: number,
nz: number,
d: number): Plane
Sets the plane based on a normal and a distance from the origin.
Parameters
nx
number
The x-component of the normal.
ny
number
The y-component of the normal.
nz
number
The z-component of the normal.
d
number
The distance from the origin.
Returns
Self for chaining.
setFromPointNormal()
setFromPointNormal(point: Vec3, normal: Vec3): Plane
Sets the plane based on a specified normal and a point on the plane.
Parameters
point
The point on the plane.
normal
The normal of the plane.
Returns
Self for chaining.