@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
120 lines (119 loc) • 5.3 kB
TypeScript
import type { DeepImmutable } from "../types.js";
import { Vector3, Matrix } from "./math.vector.js";
import type { IPlaneLike } from "./math.like.js";
/**
* Represents a plane by the equation ax + by + cz + d = 0
*/
export declare class Plane implements IPlaneLike {
private static _TmpMatrix;
/**
* Normal of the plane (a,b,c)
*/
normal: Vector3;
/**
* d component of the plane
*/
d: number;
/**
* Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
* @param a a component of the plane
* @param b b component of the plane
* @param c c component of the plane
* @param d d component of the plane
*/
constructor(a: number, b: number, c: number, d: number);
/**
* @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
*/
asArray(): number[];
/**
* @returns a new plane copied from the current Plane.
*/
clone(): Plane;
/**
* @returns the string "Plane".
*/
getClassName(): string;
/**
* @returns the Plane hash code.
*/
getHashCode(): number;
/**
* Normalize the current Plane in place.
* @returns the updated Plane.
*/
normalize(): Plane;
/**
* Applies a transformation the plane and returns the result
* @param transformation the transformation matrix to be applied to the plane
* @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
*/
transform(transformation: DeepImmutable<Matrix>): Plane;
/**
* Compute the dot product between the point and the plane normal
* @param point point to calculate the dot product with
* @returns the dot product (float) of the point coordinates and the plane normal.
*/
dotCoordinate(point: DeepImmutable<Vector3>): number;
/**
* Updates the current Plane from the plane defined by the three given points.
* @param point1 one of the points used to construct the plane
* @param point2 one of the points used to construct the plane
* @param point3 one of the points used to construct the plane
* @returns the updated Plane.
*/
copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
/**
* Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
* Note that for this function to work as expected you should make sure that:
* - direction and the plane normal are normalized
* - epsilon is a number just bigger than -1, something like -0.99 for eg
* @param direction the direction to check if the plane is facing
* @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
* @returns True if the plane is facing the given direction
*/
isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
/**
* Calculates the distance to a point
* @param point point to calculate distance to
* @returns the signed distance (float) from the given point to the Plane.
*/
signedDistanceTo(point: DeepImmutable<Vector3>): number;
/**
* Creates a plane from an array
* @param array the array to create a plane from
* @returns a new Plane from the given array.
*/
static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
/**
* Creates a plane from three points
* @param point1 point used to create the plane
* @param point2 point used to create the plane
* @param point3 point used to create the plane
* @returns a new Plane defined by the three given points.
*/
static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
/**
* Creates a plane from an origin point and a normal
* @param origin origin of the plane to be constructed
* @param normal normal of the plane to be constructed
* @returns a new Plane the normal vector to this plane at the given origin point.
*/
static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
/**
* Updates the given Plane "result" from an origin point and a normal.
* @param origin origin of the plane to be constructed
* @param normal the normalized normals of the plane to be constructed
* @param result defines the Plane where to store the result
* @returns result input
*/
static FromPositionAndNormalToRef<T extends Plane>(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, result: T): T;
/**
* Calculates the distance from a plane and a point
* @param origin origin of the plane to be constructed
* @param normal normal of the plane to be constructed
* @param point point to calculate distance to
* @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
*/
static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
}