An AxisAlignedBoundingBox
is a closed and convex cuboid that is aligned with the orthogonal axes.
AxisAlignedBoundingBox
can be created using two corners of the box:
import {AxisAlignedBoundingBox} from '@math.gl/culling';
const box = new AxisAlignedBoundingBox([-1, -1, -1], [1, 1, 1]);
Or from a collection of points:
import {makeAxisAlignedBoundingBoxFromPoints} from '@math.gl/culling';
const box = makeAxisAlignedBoundingBoxFromPoints([
[2, 0, 0],
[-2, 0, 0]
]);
class AxisAlignedBoundingBox implements
BoundingVolume
.
Computes an instance of an AxisAlignedBoundingBox
of the given positions.
positions
List of Vector3
points that the bounding box will enclose.result
Optional object onto which to store the result.The center position of the box.
The positive diagonal vector.
The minimum corner of the bounding box.
The maximum corner of the bounding box.
[xMin, yMin, zMin]
.[xMax, yMax, zMax]
.Duplicates a AxisAlignedBoundingBox
instance.
Returns
AxisAlignedBoundingBox
instance.Compares the provided AxisAlignedBoundingBox
componentwise and returns true
if they are equal, false
otherwise.
right
The second AxisAlignedBoundingBox
Returns
true
if left and right are equal, false
otherwise.Determines which side of a plane the axis-aligned bounding box is located.
plane
The plane to test against.Returns
INTERSECTION.INSIDE
if the entire box is on the side of the plane the normal is pointingINTERSECTION.OUTSIDE
if the entire box is on the opposite side, andINTERSECTION.INTERSECTING
if the box intersects the plane.Computes the estimated distance from the closest point on a bounding box to a point.
point
The pointReturns
Computes the estimated distance squared from the closest point on a bounding box to a point.
point
The pointReturns