playcanvas
Version:
PlayCanvas WebGL game engine
91 lines (90 loc) • 2.91 kB
TypeScript
/**
* @import { Ray } from './ray.js'
*/
/**
* An infinite plane. Internally it's represented in a parametric equation form:
* ax + by + cz + distance = 0.
*
* @category Math
*/
export class Plane {
/**
* Create a new Plane instance.
*
* @param {Vec3} [normal] - Normal of the plane. The constructor copies this parameter. Defaults
* to {@link Vec3.UP}.
* @param {number} [distance] - The distance from the plane to the origin, along its normal.
* Defaults to 0.
*/
constructor(normal?: Vec3, distance?: number);
/**
* The normal of the plane.
*
* @type {Vec3}
*/
normal: Vec3;
/**
* The distance from the plane to the origin, along its normal.
*
* @type {number}
*/
distance: number;
/**
* Returns a clone of the specified plane.
*
* @returns {this} A duplicate plane.
*/
clone(): this;
/**
* Copies the contents of a source plane to a destination plane.
*
* @param {Plane} src - A source plane to copy to the destination plane.
* @returns {Plane} Self for chaining.
*/
copy(src: Plane): Plane;
/**
* Test if the plane intersects between two points.
*
* @param {Vec3} start - Start position of line.
* @param {Vec3} end - End position of line.
* @param {Vec3} [point] - If there is an intersection, the intersection point will be copied
* into here.
* @returns {boolean} True if there is an intersection.
*/
intersectsLine(start: Vec3, end: Vec3, point?: Vec3): boolean;
/**
* Test if a ray intersects with the infinite plane.
*
* @param {Ray} ray - Ray to test against (direction must be normalized).
* @param {Vec3} [point] - If there is an intersection, the intersection point will be copied
* into here.
* @returns {boolean} True if there is an intersection.
*/
intersectsRay(ray: Ray, point?: Vec3): boolean;
/**
* Normalize the plane.
*
* @returns {Plane} Self for chaining.
*/
normalize(): Plane;
/**
* Sets the plane based on a normal and a distance from the origin.
*
* @param {number} nx - The x-component of the normal.
* @param {number} ny - The y-component of the normal.
* @param {number} nz - The z-component of the normal.
* @param {number} d - The distance from the origin.
* @returns {Plane} Self for chaining.
*/
set(nx: number, ny: number, nz: number, d: number): Plane;
/**
* Sets the plane based on a specified normal and a point on the plane.
*
* @param {Vec3} point - The point on the plane.
* @param {Vec3} normal - The normal of the plane.
* @returns {Plane} Self for chaining.
*/
setFromPointNormal(point: Vec3, normal: Vec3): Plane;
}
import { Vec3 } from '../math/vec3.js';
import type { Ray } from './ray.js';