Represents an axis-aligned bounding box (AABB) in 3D space.
const box = new v3d.Box3();
const mesh = new v3d.Mesh(
new v3d.SphereGeometry(),
new v3d.MeshBasicMaterial()
);
// ensure the bounding box is computed for its geometry
// this should be done only once (assuming static geometries)
mesh.geometry.computeBoundingBox();
// ...
// in the animation loop, compute the current bounding box with the world matrix
box.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);
min — (optional) Vector3 representing the lower (x, y, z) boundary of the box.
Default is (+Infinity, +Infinity, +Infinity)
.
max — (optional) Vector3 representing the upper (x, y, z) boundary of the box.
Default is (-Infinity, -Infinity, -Infinity)
.
Creates a Box3 bounded by min and max.
Read-only flag to check if a given object is of type Box3.
Vector3 representing the lower (x, y, z) boundary of the box.
Default is (+Infinity, +Infinity, +Infinity)
.
Vector3 representing the upper (x, y, z) boundary of the box.
Default is (-Infinity, -Infinity, -Infinity)
.
matrix — The Matrix4 to apply.
Transforms this Box3 with the supplied matrix.
point — Vector3 to clamp.
target — the result will be copied into this Vector3.
Clamps the point within the bounds of this box.
Returns a new Box3 with the same min and max as this one.
box — Box3 to test for inclusion.
Returns true if this box includes the entirety of box. If this and box are identical,
this function also returns true.
point — Vector3 to check for inclusion.
Returns true if the specified point lies within or on the boundaries of this box.
Copies the min and max from box to this box.
point — Vector3 to measure distance to.
Returns the distance from any edge of this box to the specified point. If the point lies inside of this box, the distance will be 0.
box — Box to compare with this one.
Returns true if this box and box share the same lower and upper bounds.
object — Object3D to expand the box by.
precise — (optional) expand the bounding box as little as necessary at the expense of more computation. Default is false
.
Expands the boundaries of this box to include object and its children, accounting for the object's, and children's, world transforms. The function may result in a larger box than strictly necessary (unless the precise parameter is set to true).
point — Vector3 that should be included in the box.
Expands the boundaries of this box to include point.
scalar — Distance to expand the box by.
Expands each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.
vector — Vector3 to expand the box by.
Expands this box equilaterally by vector. The width of this box will be
expanded by the x component of vector in both directions. The height of
this box will be expanded by the y component of vector in both directions.
The depth of this box will be expanded by the z component of vector
in both directions.
target — the result will be copied into this Sphere.
Gets a Sphere that bounds the box.
target — the result will be copied into this Vector3.
Returns the center point of the box as a Vector3.
point — Vector3.
target — the result will be copied into this Vector3.
Returns a point as a proportion of this box's width, height and depth.
target — the result will be copied into this Vector3.
Returns the width, height and depth of this box.
box — Box to intersect with.
Computes the intersection of this and box, setting the upper bound of this box to the lesser of the two boxes' upper bounds and the lower bound of this box to the greater of the two boxes' lower bounds. If there's no overlap, makes this box empty.
box — Box to check for intersection against.
Determines whether or not this box intersects box.
plane — Plane to check for intersection against.
Determines whether or not this box intersects plane.
sphere — Sphere to check for intersection against.
Determines whether or not this box intersects sphere.
triangle — Triangle to check for intersection against.
Determines whether or not this box intersects triangle.
Returns true
if this box includes zero points within its bounds.
Note that a box with equal lower and upper bounds still includes one point,
the one both bounds share.
Makes this box empty.
s — Scale vector.
Scales the bounding box by a given vector value.
min — Vector3 representing the lower (x, y, z) boundary of the box.
max — Vector3 representing the upper (x, y, z) boundary of the box.
Sets the lower and upper (x, y, z) boundaries of this box.
Please note that this method only copies the values from the given objects.
array — An array of position data that the resulting box will envelop.
Sets the upper and lower bounds of this box to include all of the data in array
.
attribute — A buffer attribute of position data that the resulting box will envelop.
Sets the upper and lower bounds of this box to include all of the data in attribute.
center — Desired center position of the box.
size — Desired x, y and z dimensions of the box.
Centers this box on center and sets this box's width, height and depth to the values specified in size
object — Object3D to compute the bounding box of.
precise — (optional) compute the smallest world-axis-aligned bounding box at the expense of more computation. Default is false
.
Computes the world-axis-aligned bounding box of an Object3D (including its children), accounting for the object's, and children's, world transforms. The function may result in a larger box than strictly necessary.
points — Array of Vector3s that the resulting box will contain.
Sets the upper and lower bounds of this box to include all of the points in points.
offset — Direction and distance of offset.
Adds offset to both the upper and lower bounds of this box, effectively moving this box offset units in 3D space.
box — Box that will be unioned with this box.
Computes the union of this box and box, setting the upper bound of this box to the greater of the two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes' lower bounds.
For more info on how to obtain the source code of this module see this page.