Box3

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

Constructor

new Box3(min, max)

Parameters:
NameTypeDescription
minVector3

(optional) Vector3 representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).

maxVector3

(optional) Vector3 representing the upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).

Methods

applyMatrix4(matrix) → {Box3}

Transforms this Box3 with the supplied matrix.

Parameters:
NameTypeDescription
matrixMatrix4

The Matrix4 to apply

Returns:
Type: 
Box3

clampPoint(point, target) → {Vector3}

Clamps the point within the bounds of this box.

Parameters:
NameTypeDescription
pointVector3

Vector3 to clamp.

targetVector3

Vector3 to store the result in.

Returns:
Type: 
Vector3

clone() → {Box3}

Returns a new Box3 with the same min and max as this one.

Returns:
Type: 
Box3

containsPoint(point) → {boolean}

Returns true if the specified point lies within or on the boundaries of this box.

Parameters:
NameTypeDescription
pointVector3

Vector3 to check for inclusion.

Returns:
Type: 
boolean

copy(box) → {Box3}

Copies the min and max from box to this box.

Parameters:
NameTypeDescription
boxBox3

Box3 to copy.

Returns:
Type: 
Box3

distanceToPoint(point) → {number}

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.

Parameters:
NameTypeDescription
pointVector3

Vector3 to measure the distance to.

Returns:
Type: 
number

equals(box) → {boolean}

Returns true if this box and box share the same lower and upper bounds.

Parameters:
NameTypeDescription
boxBox3

Box to compare with this one.

Returns:
Type: 
boolean

expandByBox3(box3) → {Box3}

Expands the boundaries of this box to include box3.

Parameters:
NameTypeDescription
box3Box3

Box that will be unioned with this box.

Returns:
Type: 
Box3

expandByPoint(point) → {Box3}

Expands the boundaries of this box to include point.

Parameters:
NameTypeDescription
pointVector3

Vector3 that should be included in the box.

Returns:
Type: 
Box3

expandByScalar(scalar) → {Box3}

Expands each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.

Parameters:
NameTypeDescription
scalarnumber

Distance to expand the box by.

Returns:
Type: 
Box3

getBoundingSphere(target) → {Sphere}

Returns aMinimum Bounding Sphere for the box.

Parameters:
NameTypeDescription
targetSphere

— the result will be copied into this Sphere.

Returns:
Type: 
Sphere

getCenter(target) → {Vector3}

Returns the center point of the box as a Vector3.

Parameters:
NameTypeDescription
targetVector3

the result will be copied into this Vector3.

Returns:
Type: 
Vector3

getPoints(points) → {Array.<Vector3>}

Get the 8 corner points of the bounding box, the order is as follows: 7-------3 /| /| 4-------0 | | | | | | 6-----|-2 |/ |/ 5-------1

Parameters:
NameTypeDescription
pointsArray.<Vector3>

The array to store the points.

Returns:

The array of points.

Type: 
Array.<Vector3>

getSize(target) → {Vector3}

Returns the width, height and depth of this box.

Parameters:
NameTypeDescription
targetVector3

the result will be copied into this Vector3.

Returns:
Type: 
Vector3

intersectsTriangle(triangle) → {boolean}

Determines whether or not this box intersects triangle.

Parameters:
NameTypeDescription
triangleTriangle

Triangle to check for intersection against.

Returns:
Type: 
boolean

isEmpty() → {boolean}

Returns true if this box includes zero points within its bounds.

Returns:
Type: 
boolean

makeEmpty() → {Box3}

Makes this box empty.

Returns:
Type: 
Box3

set(min, max)

Sets the lower and upper (x, y, z) boundaries of this box.

Parameters:
NameTypeDescription
minVector3

Vector3 representing the lower (x, y, z) boundary of the box.

maxVector3

Vector3 representing the lower upper (x, y, z) boundary of the box.

setFromArray(array, gapopt, offsetopt) → {Box3}

Sets the upper and lower bounds of this box to include all of the data in array.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number>

An array of position data that the resulting box will envelop.

gapnumber<optional>
3
offsetnumber<optional>
0
Returns:
Type: 
Box3

setFromPoints(points) → {Box3}

Sets the upper and lower bounds of this box to include all of the points in points.

Parameters:
NameTypeDescription
pointsArray.<Vector3>

Array of Vector3s that the resulting box will contain.

Returns:
Type: 
Box3

union(box) → {Box3}

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.

Parameters:
NameTypeDescription
boxBox3

Box that will be unioned with this box.

Returns:
Type: 
Box3