AxisAlignedBoundingBox
An AxisAlignedBoundingBox is a closed and convex cuboid that is aligned with the orthogonal axes.
Usage
AxisAlignedBoundingBox can be created using two corners of the box:
import {AxisAlignedBoundingBox} from '@math.gl/geometry/culling';
const box = new AxisAlignedBoundingBox([-1, -1, -1], [1, 1, 1]);
Or from a collection of points:
import {makeAxisAlignedBoundingBoxFromPoints} from '@math.gl/geometry/culling';
const box = makeAxisAlignedBoundingBoxFromPoints([
[2, 0, 0],
[-2, 0, 0]
]);
Inheritanceโ
class AxisAlignedBoundingBox implements BoundingVolume.
Global Functionsโ
makeAxisAlignedBoundingBoxFromPoints(positions : Array[3][], result? : AxisAlignedBoundingBox) : AxisAlignedBoundingBoxโ
Computes an instance of an AxisAlignedBoundingBox of the given positions.
positionsList ofVector3points that the bounding box will enclose.resultOptional object onto which to store the result.
Fieldsโ
center: Vector3 = [0, 0, 0]โ
The center position of the box.
halfDiagonal: Vector3โ
The positive diagonal vector.
minimum: Vector3โ
The minimum corner of the bounding box.
maximum: Vector3โ
The maximum corner of the bounding box.
Methodsโ
constructor(minimum = [0, 0, 0], maximum = [0, 0, 0])โ
constructorโ
minimum=Vector3.ZERO:Vector3The minimum corner of the box, i.e.[xMin, yMin, zMin].maximum=Vector3.ZERO:Vector3The maximum corner of the box, i.e.[xMax, yMax, zMax].
clone() : AxisAlignedBoundingBoxโ
Duplicates a AxisAlignedBoundingBox instance.
Returns
- A new
AxisAlignedBoundingBoxinstance.
equals(right : AxisAlignedBoundingBox) : Booleanโ
Compares the provided AxisAlignedBoundingBox componentwise and returns true if they are equal, false otherwise.
rightThe secondAxisAlignedBoundingBox
Returns
trueif left and right are equal,falseotherwise.
intersectPlane(plane : Plane) : CullingResultโ
Determines which side of a plane the axis-aligned bounding box is located.
planeThe plane to test against.
Returns
'inside'if the entire box is on the side of the plane the normal is pointing'outside'if the entire box is on the opposite side, and'intersecting'if the box intersects the plane.
distanceTo(point : Number[3]) : Numberโ
Computes the estimated distance from the closest point on a bounding box to a point.
pointThe point
Returns
- The estimated distance from the bounding sphere to the point.
distanceSquaredTo(point : Number[3]) : Numberโ
Computes the estimated distance squared from the closest point on a bounding box to a point.
pointThe point
Returns
- The estimated distance squared from the bounding sphere to the point.
Affine transform domainโ
transform(matrix)โ
Accepts finite affine matrices, including rotation, reflection, nonuniform scale and shear. It recomputes the axis-aligned bounds enclosing all transformed corners and updates center and half extents consistently. Translation does not affect half extents. Projective matrices and inverted input bounds are rejected before mutation.