Axis-Aligned Bounding Box.
new BoundingBox(center?: Vec3, halfExtents?: Vec3): BoundingBox
Create a new BoundingBox instance. The bounding box is axis-aligned.
Center of box. The constructor takes a reference of this parameter. Defaults to (0, 0, 0).
Half the distance across the box in each axis. The constructor takes a reference of this parameter. Defaults to (0.5, 0.5, 0.5).
readonly center: Vec3;
Center of box.
readonly halfExtents: Vec3;
Half the distance across the box in each axis.
add(other: BoundingBox): void
Combines two bounding boxes into one, enclosing both.
Bounding box to add.
void
clone(): BoundingBox
Returns a clone of the AABB.
A duplicate AABB.
compute(vertices:
| number[]
| Float32Array<ArrayBufferLike>, numVerts?: number): void
Compute the size of the AABB to encapsulate all specified vertices.
The vertices used to compute the new size for the AABB.
number | Float32Array<ArrayBufferLike>
number
Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.
void
containsPoint(point: Vec3): boolean
Test if a point is inside a AABB.
Point to test.
boolean
True if the point is inside the AABB and false otherwise.
copy(src: BoundingBox): void
Copies the contents of a source AABB.
The AABB to copy from.
void
getMax(): Vec3
Return the maximum corner of the AABB.
Maximum corner.
getMin(): Vec3
Return the minimum corner of the AABB.
Minimum corner.
intersects(other: BoundingBox): boolean
Test whether two axis-aligned bounding boxes intersect.
Bounding box to test against.
boolean
True if there is an intersection.
intersectsBoundingSphere(sphere: BoundingSphere): boolean
Test if a Bounding Sphere is overlapping, enveloping, or inside this AABB.
Bounding Sphere to test.
boolean
True if the Bounding Sphere is overlapping, enveloping, or inside the AABB and false otherwise.
intersectsRay(ray: Ray, point?: Vec3): boolean
Test if a ray intersects with the AABB.
Ray to test against (direction must be normalized).
If there is an intersection, the intersection point will be copied into here.
boolean
True if there is an intersection.
setFromTransformedAabb(
aabb: BoundingBox,
m: Mat4,
ignoreScale: boolean): void
Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.
Box to transform and enclose.
Transformation matrix to apply to source AABB.
boolean = false
If true is specified, a scale from the matrix is ignored. Defaults to false.
void
setMinMax(min: Vec3, max: Vec3): void
Sets the minimum and maximum corner of the AABB. Using this function is faster than assigning min and max separately.
The minimum corner of the AABB.
The maximum corner of the AABB.
void
static computeMinMax(
vertices:
| number[]
| Float32Array<ArrayBufferLike>,
min: Vec3,
max: Vec3,
numVerts?: number): void
Compute the min and max bounding values to encapsulate all specified vertices.
The vertices used to compute the new size for the AABB.
number | Float32Array<ArrayBufferLike>
Stored computed min value.
Stored computed max value.
number = ...
Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.
void