AABB(min, max)

Class representing an axis-aligned bounding box (AABB).

new AABB(min, max)

Constructs a new AABB with the given values.

Parameters:
Name Type Description
min Vector3

The minimum bounds of the AABB.

max Vector3

The maximum bounds of the AABB.

Author:

Members

max :Vector3

The maximum bounds of the AABB.

min :Vector3

The minimum bounds of the AABB.

Methods

applyMatrix4(matrix) → {AABB}

Transforms this AABB with the given 4x4 transformation matrix.

Parameters:
Name Type Description
matrix Matrix4

The 4x4 transformation matrix.

Returns:
AABB -

A reference to this AABB.

clampPoint(point, result) → {Vector3}

Ensures the given point is inside this AABB and stores the result in the given vector.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

clone() → {AABB}

Creates a new AABB and copies all values from this AABB.

Returns:
AABB -

A new AABB.

containsPoint(point) → {Boolean}

Returns true if the given point is inside this AABB.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

Returns:
Boolean -

The result of the containments test.

copy(aabb) → {AABB}

Copies all values from the given AABB to this AABB.

Parameters:
Name Type Description
aabb AABB

The AABB to copy.

Returns:
AABB -

A reference to this AABB.

equals(aabb) → {Boolean}

Returns true if the given AABB is deep equal with this AABB.

Parameters:
Name Type Description
aabb AABB

The AABB to test.

Returns:
Boolean -

The result of the equality test.

expand(point) → {AABB}

Expands this AABB by the given point. So after this method call, the given point lies inside the AABB.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

Returns:
AABB -

A reference to this AABB.

fromCenterAndSize(center, size) → {AABB}

Sets the values of the AABB from the given center and size vector.

Parameters:
Name Type Description
center Vector3

The center point of the AABB.

size Vector3

The size of the AABB per axis.

Returns:
AABB -

A reference to this AABB.

fromJSON(json) → {AABB}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
AABB -

A reference to this AABB.

fromPoints(points) → {AABB}

Computes an AABB that encloses the given set of points.

Parameters:
Name Type Description
points Array.<Vector3>

An array of 3D vectors representing points in 3D space.

Returns:
AABB -

A reference to this AABB.

getCenter(result) → {Vector3}

Computes the center point of this AABB and stores it into the given vector.

Parameters:
Name Type Description
result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

getNormalFromSurfacePoint(point, result) → {Vector3}

Returns the normal for a given point on this AABB's surface.

Parameters:
Name Type Description
point Vector3

The point on the surface

result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

getSize(result) → {Vector3}

Computes the size (width, height, depth) of this AABB and stores it into the given vector.

Parameters:
Name Type Description
result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

intersectsAABB(aabb) → {Boolean}

Returns true if the given AABB intersects this AABB.

Parameters:
Name Type Description
aabb AABB

The AABB to test.

Returns:
Boolean -

The result of the intersection test.

intersectsBoundingSphere(sphere) → {Boolean}

Returns true if the given bounding sphere intersects this AABB.

Parameters:
Name Type Description
sphere BoundingSphere

The bounding sphere to test.

Returns:
Boolean -

The result of the intersection test.

intersectsPlane(plane) → {Boolean}

Returns true if the given plane intersects this AABB.

Reference: Testing Box Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.3)

Parameters:
Name Type Description
plane Plane

The plane to test.

Returns:
Boolean -

The result of the intersection test.

set(min, max) → {AABB}

Sets the given values to this AABB.

Parameters:
Name Type Description
min Vector3

The minimum bounds of the AABB.

max Vector3

The maximum bounds of the AABB.

Returns:
AABB -

A reference to this AABB.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.