[name]

Represents an axis-aligned bounding box (AABB) in 3D space.

Code Example

const box = new THREE.Box3(); const mesh = new THREE.Mesh( new THREE.SphereGeometry(), new THREE.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 );

Constructor

[name]( [param:Vector3 min], [param:Vector3 max] )

[page:Vector3 min] - (optional) [page:Vector3] representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).
[page:Vector3 max] - (optional) [page:Vector3] representing the upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).

Creates a [name] bounded by min and max.

Properties

[property:Vector3 min]

[page:Vector3] representing the lower (x, y, z) boundary of the box.
Default is ( + Infinity, + Infinity, + Infinity ).

[property:Vector3 max]

[page:Vector3] representing the upper (x, y, z) boundary of the box.
Default is ( - Infinity, - Infinity, - Infinity ).

Methods

[method:this applyMatrix4]( [param:Matrix4 matrix] )

[page:Matrix4 matrix] - The [page:Matrix4] to apply

Transforms this Box3 with the supplied matrix.

[method:Vector3 clampPoint]( [param:Vector3 point], [param:Vector3 target] )

[page:Vector3 point] - [page:Vector3] to clamp.
[page:Vector3 target] — the result will be copied into this Vector3.

[link:https://en.wikipedia.org/wiki/Clamping_(graphics) Clamps] the [page:Vector3 point] within the bounds of this box.

[method:Box3 clone]()

Returns a new [page:Box3] with the same [page:.min min] and [page:.max max] as this one.

[method:Boolean containsBox]( [param:Box3 box] )

[page:Box3 box] - [page:Box3 Box3] to test for inclusion.

Returns true if this box includes the entirety of [page:Box3 box]. If this and [page:Box3 box] are identical,
this function also returns true.

[method:Boolean containsPoint]( [param:Vector3 point] )

[page:Vector3 point] - [page:Vector3] to check for inclusion.

Returns true if the specified [page:Vector3 point] lies within or on the boundaries of this box.

[method:this copy]( [param:Box3 box] )

[page:Box3 box] - [page:Box3] to copy.

Copies the [page:.min min] and [page:.max max] from [page:Box3 box] to this box.

[method:Float distanceToPoint]( [param:Vector3 point] )

[page:Vector3 point] - [page:Vector3] to measure distance to.

Returns the distance from any edge of this box to the specified point. If the [page:Vector3 point] lies inside of this box, the distance will be 0.

[method:Boolean equals]( [param:Box3 box] )

[page:Box3 box] - Box to compare with this one.

Returns true if this box and [page:Box3 box] share the same lower and upper bounds.

[method:this expandByObject]( [param:Object3D object] )

[page:Object3D object] - [page:Object3D] to expand the box by.

Expands the boundaries of this box to include [page:Object3D 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.

[method:this expandByPoint]( [param:Vector3 point] )

[page:Vector3 point] - [page:Vector3] that should be included in the box.

Expands the boundaries of this box to include [page:Vector3 point].

[method:this expandByScalar]( [param:Float scalar] )

[page:Float scalar] - Distance to expand the box by.

Expands each dimension of the box by [page:Float scalar]. If negative, the dimensions of the box will be contracted.

[method:this expandByVector]( [param:Vector3 vector] )

[page:Vector3 vector] - [page:Vector3] to expand the box by.

Expands this box equilaterally by [page:Vector3 vector]. The width of this box will be expanded by the x component of [page:Vector3 vector] in both directions. The height of this box will be expanded by the y component of [page:Vector3 vector] in both directions. The depth of this box will be expanded by the z component of *vector* in both directions.

[method:Sphere getBoundingSphere]( [param:Sphere target] )

[page:Sphere target] — the result will be copied into this Sphere.

Gets a [page:Sphere] that bounds the box.

[method:Vector3 getCenter]( [param:Vector3 target] )

[page:Vector3 target] — the result will be copied into this Vector3.

Returns the center point of the box as a [page:Vector3].

[method:Vector3 getParameter]( [param:Vector3 point], [param:Vector3 target] )

[page:Vector3 point] - [page:Vector3].
[page:Vector3 target] — the result will be copied into this Vector3.

Returns a point as a proportion of this box's width and height.

[method:Vector3 getSize]( [param:Vector3 target] )

[page:Vector3 target] — the result will be copied into this Vector3.

Returns the width, height and depth of this box.

[method:this intersect]( [param:Box3 box] )

[page:Box3 box] - Box to intersect with.

Computes the intersection of this and [page:Box3 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.

[method:Boolean intersectsBox]( [param:Box3 box] )

[page:Box3 box] - Box to check for intersection against.

Determines whether or not this box intersects [page:Box3 box].

[method:Boolean intersectsPlane]( [param:Plane plane] )

[page:Plane plane] - [page:Plane] to check for intersection against.

Determines whether or not this box intersects [page:Plane plane].

[method:Boolean intersectsSphere]( [param:Sphere sphere] )

[page:Sphere sphere] - [page:Sphere] to check for intersection against.

Determines whether or not this box intersects [page:Sphere sphere].

[method:Boolean intersectsTriangle]( [param:Triangle triangle] )

[page:Triangle triangle] - [page:Triangle] to check for intersection against.

Determines whether or not this box intersects [page:Triangle triangle].

[method:Boolean isEmpty]()

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.

[method:this makeEmpty]()

Makes this box empty.

[method:this set]( [param:Vector3 min], [param:Vector3 max] )

[page:Vector3 min] - [page:Vector3] representing the lower (x, y, z) boundary of the box.
[page:Vector3 max] - [page:Vector3] representing the lower 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.

[method:this setFromArray]( [param:Array array] )

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*.

[method:this setFromBufferAttribute]( [param:BufferAttribute attribute] )

[page:BufferAttribute 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 [page:BufferAttribute attribute].

[method:this setFromCenterAndSize]( [param:Vector3 center], [param:Vector3 size] )

[page:Vector3 center], - Desired center position of the box.
[page:Vector3 size] - Desired x, y and z dimensions of the box.

Centers this box on [page:Vector3 center] and sets this box's width, height and depth to the values specified
in [page:Vector3 size]

[method:this setFromObject]( [param:Object3D object] )

[page:Object3D object] - [page:Object3D] to compute the bounding box of.

Computes the world-axis-aligned bounding box of an [page: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.

[method:this setFromPoints]( [param:Array points] )

[page:Array points] - Array of [page:Vector3 Vector3s] that the resulting box will contain.

Sets the upper and lower bounds of this box to include all of the points in [page:Array points].

[method:this translate]( [param:Vector3 offset] )

[page:Vector3 offset] - Direction and distance of offset.

Adds [page:Vector3 offset] to both the upper and lower bounds of this box, effectively moving this box [page:Vector3 offset] units in 3D space.

[method:this union]( [param:Box3 box] )

[page:Box3 box] - Box that will be unioned with this box.

Computes the union of this box and [page:Box3 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.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]