AABB

lumin.math. AABB

Axis-aligned bounding box.

Constructor

new AABB(min, max)

Parameters:
Name Type Description
min vec3
max vec3

Members

(static, constant) EMPTY :lumin.math.AABB

Default constructed AABB with no enclosed volume.

Type:

Methods

contains(point) → {boolean}

Is the point contained within the bounds.

Parameters:
Name Type Description
point vec3
Returns:
Type
boolean

extend(other)

Extend this AABB to also enclose the given AABB.

Parameters:
Name Type Description
other lumin.math.AABB

extend(point)

Extend this AABB to enclose the given point.

Parameters:
Name Type Description
point vec3

getCenter() → {vec3}

Get the center of the bounding box.

Returns:
Type
vec3

getDepth() → {number}

Get the depth (z dimension) of the bounding box.

Returns:
Type
number

getExtents() → {vec3}

Get the extents (w/2,h/2,d/2) of the bounding box.

Returns:
Type
vec3

getHeight() → {number}

Get the height (y dimension) of the bounding box.

Returns:
Type
number

getMax() → {vec3}

Get the maximum coordinate of the bounding box.

Returns:
Type
vec3

getMin() → {vec3}

Get the minimum coordinate of the bounding box.

Returns:
Type
vec3

getWidth() → {number}

Get the width (x dimension) of the bounding box.

Returns:
Type
number

intersect(rayOri, rayDir) → {number}

Intersect AABB with a ray. The AABB is assumed to be a solid block; if the ray origin is inside
the AABB it will be considered a hit with a distance of 0.

Parameters:
Name Type Description
rayOri vec3

Start point of the ray.

rayDir vec3

Direction of the ray. The ray is assumed to be infinite in length.

Returns:

Distance to the intersection. To get the intersection point, use rayOri + rayDir * dist.

Type
number

isEmpty() → {boolean}

Get whether the AABB is EMPTY.

An EMPTY AABB is un-initialized and contains
no valid data, but is ready for extending.

Returns:
Type
boolean

isValid() → {boolean}

Get whether the AABB is valid.

An invalid AABB is where any component in max is
less than the same component in min.

EMPTY is an invalid AABB.

Returns:
Type
boolean

isZeroSize() → {boolean}

Get whether the AABB is of zero size.

An AABB with zero size is where min and max
are at the same point.

Returns:
Type
boolean

isZeroVolume() → {boolean}

Get whether the AABB is of zero volume.

An AABB with zero volume is where any component
in min equals the same component in max.

Returns:
Type
boolean

setMax(max)

Set the maximum coordinate of the bounding box

Parameters:
Name Type Description
max vec3

setMin(min)

Set the minimum coordinate of the bounding box

Parameters:
Name Type Description
min vec3

toString() → {string}

Return a readable string representation of the given AABB object.

Returns:
Type
string

transform(transform)

Transform the AABB. The resulting AABB will be the
minimal AABB enclosing the original AABB with the provided
transform applied.

Parameters:
Name Type Description
transform mat4

translate(offset)

Translate this AABB by the given offset.

Parameters:
Name Type Description
offset vec3