t3d. Box3

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

Constructor

new Box3(min, max)

Parameters:
NameTypeDescription
mint3d.Vector3(optional) Vector3 representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).
maxt3d.Vector3(optional) Vector3 representing the upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).

Methods

applyMatrix4(matrix) → {t3d.Box3}

Transforms this Box3 with the supplied matrix.
Parameters:
NameTypeDescription
matrixt3d.Matrix4The Matrix4 to apply
Returns:
Type: 
t3d.Box3

clampPoint(point, target) → {t3d.Vector3}

Clamps the point within the bounds of this box.
Parameters:
NameTypeDescription
pointt3d.Vector3Vector3 to clamp.
targett3d.Vector3Vector3 to store the result in.
Returns:
Type: 
t3d.Vector3

clone() → {t3d.Box3}

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

containsPoint(point) → {Boolean}

Returns true if the specified point lies within or on the boundaries of this box.
Parameters:
NameTypeDescription
pointt3d.Vector3Vector3 to check for inclusion.
Returns:
Type: 
Boolean

copy(box) → {t3d.Box3}

Copies the min and max from box to this box.
Parameters:
NameTypeDescription
boxt3d.Box3Box3 to copy.
Returns:
Type: 
t3d.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
pointt3d.Vector3Vector3 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
boxt3d.Box3Box to compare with this one.
Returns:
Type: 
Boolean

expandByBox3(box3) → {t3d.Box3}

Expands the boundaries of this box to include box3.
Parameters:
NameTypeDescription
box3t3d.Box3Box that will be unioned with this box.
Returns:
Type: 
t3d.Box3

expandByPoint(point) → {t3d.Box3}

Expands the boundaries of this box to include point.
Parameters:
NameTypeDescription
pointt3d.Vector3Vector3 that should be included in the box.
Returns:
Type: 
t3d.Box3

expandByScalar(scalar) → {t3d.Box3}

Expands each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.
Parameters:
NameTypeDescription
scalarNumberDistance to expand the box by.
Returns:
Type: 
t3d.Box3

getBoundingSphere(target) → {t3d.Sphere}

Returns aMinimum Bounding Sphere for the box.
Parameters:
NameTypeDescription
targett3d.Sphere— the result will be copied into this Sphere.
Returns:
Type: 
t3d.Sphere

getCenter(target) → {t3d.Vector3}

Returns the center point of the box as a Vector3.
Parameters:
NameTypeDescription
targett3d.Vector3the result will be copied into this Vector3.
Returns:
Type: 
t3d.Vector3

getSize(target) → {t3d.Vector3}

Returns the width, height and depth of this box.
Parameters:
NameTypeDescription
targett3d.Vector3the result will be copied into this Vector3.
Returns:
Type: 
t3d.Vector3

intersectsTriangle(triangle) → {Boolean}

Determines whether or not this box intersects triangle.
Parameters:
NameTypeDescription
trianglet3d.TriangleTriangle 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() → {t3d.Box3}

Makes this box empty.
Returns:
Type: 
t3d.Box3

set(min, max)

Sets the lower and upper (x, y, z) boundaries of this box.
Parameters:
NameTypeDescription
mint3d.Vector3Vector3 representing the lower (x, y, z) boundary of the box.
maxt3d.Vector3Vector3 representing the lower upper (x, y, z) boundary of the box.

setFromArray(array, gapopt, offsetopt) → {t3d.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: 
t3d.Box3

setFromPoints(points) → {t3d.Box3}

Sets the upper and lower bounds of this box to include all of the points in points.
Parameters:
NameTypeDescription
pointsArray.<t3d.Vector3>Array of Vector3s that the resulting box will contain.
Returns:
Type: 
t3d.Box3

union(box) → {t3d.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
boxt3d.Box3Box that will be unioned with this box.
Returns:
Type: 
t3d.Box3