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/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]
]);
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) : INTERSECTION
Determines which side of a plane the axis-aligned bounding box is located.
planeThe plane to test against.
Returns
INTERSECTION.INSIDEif the entire box is on the side of the plane the normal is pointingINTERSECTION.OUTSIDEif the entire box is on the opposite side, andINTERSECTION.INTERSECTINGif 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.