API Reference

Class List

BoundingBox

Axis-Aligned Bounding Box.

Summary

Static Methods

computeMinMax

Compute the min and max bounding values to encapsulate all specified vertices.

Properties

center

Center of box.

halfExtents

Half the distance across the box in each axis.

Methods

add

Combines two bounding boxes into one, enclosing both.

clone

Returns a clone of the AABB.

compute

Compute the size of the AABB to encapsulate all specified vertices.

containsPoint

Test if a point is inside a AABB.

copy

Copies the contents of a source AABB.

getMax

Return the maximum corner of the AABB.

getMin

Return the minimum corner of the AABB.

intersects

Test whether two axis-aligned bounding boxes intersect.

intersectsBoundingSphere

Test if a Bounding Sphere is overlapping, enveloping, or inside this AABB.

intersectsRay

Test if a ray intersects with the AABB.

setFromTransformedAabb

Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.

setMinMax

Sets the minimum and maximum corner of the AABB.

Details

Static Methods

computeMinMax(vertices, min, max, [numVerts])

Compute the min and max bounding values to encapsulate all specified vertices.

Parameters

verticesnumber[], Float32Array

The vertices used to compute the new size for the AABB.

minVec3

Stored computed min value.

maxVec3

Stored computed max value.

numVertsnumber

Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.

Constructor

BoundingBox([center], [halfExtents])

Create a new BoundingBox instance. The bounding box is axis-aligned.

Parameters

centerVec3

Center of box. The constructor takes a reference of this parameter.

halfExtentsVec3

Half the distance across the box in each axis. The constructor takes a reference of this parameter. Defaults to 0.5 on each axis.

Properties

Vec3center

Center of box.

Vec3halfExtents

Half the distance across the box in each axis.

Methods

add(other)

Combines two bounding boxes into one, enclosing both.

Parameters

otherBoundingBox

Bounding box to add.

clone()

Returns a clone of the AABB.

Returns

BoundingBox

A duplicate AABB.

compute(vertices, [numVerts])

Compute the size of the AABB to encapsulate all specified vertices.

Parameters

verticesnumber[], Float32Array

The vertices used to compute the new size for the AABB.

numVertsnumber

Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.

containsPoint(point)

Test if a point is inside a AABB.

Parameters

pointVec3

Point to test.

Returns

boolean

True if the point is inside the AABB and false otherwise.

copy(src)

Copies the contents of a source AABB.

Parameters

srcBoundingBox

The AABB to copy from.

getMax()

Return the maximum corner of the AABB.

Returns

Vec3

Maximum corner.

getMin()

Return the minimum corner of the AABB.

Returns

Vec3

Minimum corner.

intersects(other)

Test whether two axis-aligned bounding boxes intersect.

Parameters

otherBoundingBox

Bounding box to test against.

Returns

boolean

True if there is an intersection.

intersectsBoundingSphere(sphere)

Test if a Bounding Sphere is overlapping, enveloping, or inside this AABB.

Parameters

sphereBoundingSphere

Bounding Sphere to test.

Returns

boolean

True if the Bounding Sphere is overlapping, enveloping, or inside the AABB and false otherwise.

intersectsRay(ray, [point])

Test if a ray intersects with the AABB.

Parameters

rayRay

Ray to test against (direction must be normalized).

pointVec3

If there is an intersection, the intersection point will be copied into here.

Returns

boolean

True if there is an intersection.

setFromTransformedAabb(aabb, m, ignoreScale)

Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.

Parameters

aabbBoundingBox

Box to transform and enclose.

mMat4

Transformation matrix to apply to source AABB.

ignoreScaleboolean

If true is specified, a scale from the matrix is ignored. Defaults to false.

setMinMax(min, max)

Sets the minimum and maximum corner of the AABB. Using this function is faster than assigning min and max separately.

Parameters

minVec3

The minimum corner of the AABB.

maxVec3

The maximum corner of the AABB.