Skip to content

Documentation / base / AABB

Class: AABB ​

Defined in: libs/base/src/math/aabb.ts:13

Axis aligned bounding box

Constructors ​

Constructor ​

new AABB(): AABB

Defined in: libs/base/src/math/aabb.ts:31

Construct an AABB with zero size at zero point.

Returns ​

AABB

Constructor ​

new AABB(box): AABB

Defined in: libs/base/src/math/aabb.ts:36

Construct an AABB by copying from another AABB.

Parameters ​

box ​

AABB

The AABB to be copied from.

Returns ​

AABB

Constructor ​

new AABB(minPoint, maxPoint): AABB

Defined in: libs/base/src/math/aabb.ts:42

Construct AABB from the min/max point.

Parameters ​

minPoint ​

Vector3

The min point of the AABB.

maxPoint ​

Vector3

The max point of the AABB.

Returns ​

AABB

Properties ​

ClipLeft ​

readonly static ClipLeft: number

Defined in: libs/base/src/math/aabb.ts:15

Clip to the left side


ClipRight ​

readonly static ClipRight: number

Defined in: libs/base/src/math/aabb.ts:17

Clip to the right side


ClipBottom ​

readonly static ClipBottom: number

Defined in: libs/base/src/math/aabb.ts:19

Clip to the bottom side


ClipTop ​

readonly static ClipTop: number

Defined in: libs/base/src/math/aabb.ts:21

Clip to the top side


ClipFront ​

readonly static ClipFront: number

Defined in: libs/base/src/math/aabb.ts:23

Clip to the front side


ClipBack ​

readonly static ClipBack: number

Defined in: libs/base/src/math/aabb.ts:25

Clip to the back side

Accessors ​

minPoint ​

Get Signature ​

get minPoint(): Vector3

Defined in: libs/base/src/math/aabb.ts:60

Get the min point of the AABB.

Returns ​

Vector3

Set Signature ​

set minPoint(p): void

Defined in: libs/base/src/math/aabb.ts:63

Parameters ​
p ​

Vector3

Returns ​

void


maxPoint ​

Get Signature ​

get maxPoint(): Vector3

Defined in: libs/base/src/math/aabb.ts:67

Get the max point of the AABB.

Returns ​

Vector3

Set Signature ​

set maxPoint(p): void

Defined in: libs/base/src/math/aabb.ts:70

Parameters ​
p ​

Vector3

Returns ​

void


extents ​

Get Signature ​

get extents(): Vector3

Defined in: libs/base/src/math/aabb.ts:74

Get half size of the AABB.

Returns ​

Vector3


center ​

Get Signature ​

get center(): Vector3

Defined in: libs/base/src/math/aabb.ts:78

Get center point of the AABB.

Returns ​

Vector3


size ​

Get Signature ​

get size(): Vector3

Defined in: libs/base/src/math/aabb.ts:82

Get size of the AABB.

Returns ​

Vector3


diagonalLength ​

Get Signature ​

get diagonalLength(): number

Defined in: libs/base/src/math/aabb.ts:86

Get the diagonal length of the AABB.

Returns ​

number

Methods ​

clone() ​

clone(): this

Defined in: libs/base/src/math/aabb.ts:56

Clone this aabb

Returns ​

this


computePoints() ​

computePoints(): Vector3[]

Defined in: libs/base/src/math/aabb.ts:93

Calculate the coordinates of the eight corners of the AABB.

Returns ​

Vector3[]

the coordinates of the eight corners of the AABB.


inplaceTransform() ​

inplaceTransform(matrix): AABB

Defined in: libs/base/src/math/aabb.ts:112

Inplace transform the AABB.

Parameters ​

matrix ​

Matrix4x4

The transform matrix.

Returns ​

AABB

self


beginExtend() ​

beginExtend(): AABB

Defined in: libs/base/src/math/aabb.ts:120

Invalidate the min/max point so that we can start extending the AABB.

Returns ​

AABB

self


extend() ​

extend(v): AABB

Defined in: libs/base/src/math/aabb.ts:130

Extend the AABB so that it can contain specified point.

Parameters ​

v ​

Vector3

The point used to extend the AABB.

Returns ​

AABB

self


extend3() ​

extend3(x, y, z): AABB

Defined in: libs/base/src/math/aabb.ts:142

Extend the AABB so that it can contain specified point.

Parameters ​

x ​

number

The x coordinate of the point.

y ​

number

The y coordinate of the point.

z ​

number

The z coordinate of the point.

Returns ​

AABB

self


union() ​

union(other): AABB

Defined in: libs/base/src/math/aabb.ts:168

Merge the AABB with another AABB.

Parameters ​

other ​

AABB

The AABB to be merged with.

Returns ​

AABB

self


isValid() ​

isValid(): boolean

Defined in: libs/base/src/math/aabb.ts:179

Check if the AABB is valid.

Returns ​

boolean

true if the AABB is valid, otherwise false.


equalsTo() ​

equalsTo(other, epsl?): boolean

Defined in: libs/base/src/math/aabb.ts:192

Check if the AABB is close enough to another AABB.

Parameters ​

other ​

AABB

The AABB to be compared with.

epsl? ​

number

The epsilon for comparison.

Returns ​

boolean

true if the comparison error is less than epsl, otherwise false.


intersectedWithBox() ​

intersectedWithBox(other): boolean

Defined in: libs/base/src/math/aabb.ts:200

Check if the AABB intersects with another AABB.

Parameters ​

other ​

AABB

The destination AABB.

Returns ​

boolean

true if the AABB intersects with other, otherwise false.


containsPoint() ​

containsPoint(pt): boolean

Defined in: libs/base/src/math/aabb.ts:215

Check if the box contains specified point.

Parameters ​

pt ​

Vector3

The point to be checked.

Returns ​

boolean

true if the box contains the point, otherwise false.s


containsBox() ​

containsBox(other): boolean

Defined in: libs/base/src/math/aabb.ts:230

Check if the AABB contains all of the eight corner point of another AABB

Parameters ​

other ​

AABB

The AABB to be checked.

Returns ​

boolean

true if all contains, otherwise false.


getClipStateMask() ​

getClipStateMask(viewProjMatrix, mask): NOT_CLIPPED | A_INSIDE_B | CLIPPED

Defined in: libs/base/src/math/aabb.ts:246

Do a clip test at the AABB and a frustum.

Parameters ​

viewProjMatrix ​

Matrix4x4

The view projection matrix of the frustum.

mask ​

number

The frustum planes that needs to be tested.

Returns ​

NOT_CLIPPED | A_INSIDE_B | CLIPPED

The clip test result.


getClipState() ​

getClipState(viewProjMatrix): NOT_CLIPPED | A_INSIDE_B | CLIPPED

Defined in: libs/base/src/math/aabb.ts:308

Do a clip test at the AABB and a frustum.

Parameters ​

viewProjMatrix ​

Matrix4x4

The view projection matrix of the frustum.

Returns ​

NOT_CLIPPED | A_INSIDE_B | CLIPPED

The clip test result.


behindPlane() ​

behindPlane(p): boolean

Defined in: libs/base/src/math/aabb.ts:364

Check if the box is behind a plane.

Parameters ​

p ​

Plane

The plane to be tested.

Returns ​

boolean

true if the box is behind the plane, otherwise false.


getClipStateWithFrustum() ​

getClipStateWithFrustum(frustum): NOT_CLIPPED | A_INSIDE_B | CLIPPED

Defined in: libs/base/src/math/aabb.ts:378

Do a clip test at the AABB and a frustum.

Parameters ​

frustum ​

Pick<Frustum, "planes"> | Readonly<{ planes: readonly Readonly<{[key: number]: number; a: number; b: number; c: number; d: number; px: number; py: number; pz: number; nx: number; ny: number; nz: number; assign: Plane; setEquation: Plane; initWithOriginNormal: Plane; initWithPoints: Plane; distanceToPoint: number; nearestPointToPoint: Vector3; getNormal: Vector3; inplaceFlip: Plane; inplaceNormalize: Plane; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; }>[]; corners: readonly Readonly<{[key: number]: number; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; clone: Vector3; x: number; y: number; z: number; magnitude: number; magnitudeSq: number; xy: Vector2; setXYZ: Vector3; setAndNormalize: Vector3; subBy: Vector3; addBy: Vector3; combineBy: Vector3; mulBy: Vector3; divBy: Vector3; scaleBy: Vector3; inplaceNormalize: Vector3; inplaceInverse: Vector3; inplaceMin: Vector3; inplaceMax: Vector3; }>[]; getCorner: Readonly<{[key: number]: number; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; clone: Vector3; x: number; y: number; z: number; magnitude: number; magnitudeSq: number; xy: Vector2; setXYZ: Vector3; setAndNormalize: Vector3; subBy: Vector3; addBy: Vector3; combineBy: Vector3; mulBy: Vector3; divBy: Vector3; scaleBy: Vector3; inplaceNormalize: Vector3; inplaceInverse: Vector3; inplaceMin: Vector3; inplaceMax: Vector3; }>; containsPoint: boolean; initWithMatrix: Frustum; }>

The frustum object.

Returns ​

NOT_CLIPPED | A_INSIDE_B | CLIPPED

The clip test result.


getClipStateWithFrustumMask() ​

getClipStateWithFrustumMask(frustum, mask): NOT_CLIPPED | A_INSIDE_B | CLIPPED

Defined in: libs/base/src/math/aabb.ts:403

Do a clip test at the AABB and a frustum.

Parameters ​

frustum ​

Pick<Frustum, "planes"> | Readonly<{ planes: readonly Readonly<{[key: number]: number; a: number; b: number; c: number; d: number; px: number; py: number; pz: number; nx: number; ny: number; nz: number; assign: Plane; setEquation: Plane; initWithOriginNormal: Plane; initWithPoints: Plane; distanceToPoint: number; nearestPointToPoint: Vector3; getNormal: Vector3; inplaceFlip: Plane; inplaceNormalize: Plane; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; }>[]; corners: readonly Readonly<{[key: number]: number; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; clone: Vector3; x: number; y: number; z: number; magnitude: number; magnitudeSq: number; xy: Vector2; setXYZ: Vector3; setAndNormalize: Vector3; subBy: Vector3; addBy: Vector3; combineBy: Vector3; mulBy: Vector3; divBy: Vector3; scaleBy: Vector3; inplaceNormalize: Vector3; inplaceInverse: Vector3; inplaceMin: Vector3; inplaceMax: Vector3; }>[]; getCorner: Readonly<{[key: number]: number; equalsTo: boolean; toString: string; isNaN: boolean; setRandom: void; clone: Vector3; x: number; y: number; z: number; magnitude: number; magnitudeSq: number; xy: Vector2; setXYZ: Vector3; setAndNormalize: Vector3; subBy: Vector3; addBy: Vector3; combineBy: Vector3; mulBy: Vector3; divBy: Vector3; scaleBy: Vector3; inplaceNormalize: Vector3; inplaceInverse: Vector3; inplaceMin: Vector3; inplaceMax: Vector3; }>; containsPoint: boolean; initWithMatrix: Frustum; }>

The frustum object.

mask ​

number

The frustum planes that needs to be tested.

Returns ​

NOT_CLIPPED | A_INSIDE_B | CLIPPED

The clip test result.


transform() ​

static transform(bbox, matrix, result?): AABB

Defined in: libs/base/src/math/aabb.ts:431

Get an AABB by transforming another AABB

Parameters ​

bbox ​

AABB

The AABB to be transformed.

matrix ​

Matrix4x4

The transform matrix.

result? ​

AABB

The out AABB to be write to.

Returns ​

AABB

The out AABB.

Released under the MIT License.