BoundingBox

A three-dimensional axis-aligned bounding box.

Constructor

new L3D.BoundingBox()

Properties

static Empty BoundingBox

An empty BoundingBox.

depth number

The length of the box (z-axis extent)

dominantAxis number

The largest axis of the box.

height number

The height of the box (y-axis extent)

max Vector3

The maximum extent of the bounding box.

min Vector3

The minimum extent of the bounding box.

width number

The width of the box (x-axis extent)

Methods

static fromCenterHalfSize(center, halfSize)BoundingBox

Create a bounding box with a center and half-size.

Parameters
center Vector3
halfSize Vector3
Returns
BoundingBox

The new BoundingBox

static fromMinMax(min, max)BoundingBox

Create a bounding box with the given extents.

Parameters
min Vector3
max Vector3
Returns
BoundingBox

The new BoundingBox.

static fromPoint(point)BoundingBox

Create a bounding box around the given point.

Parameters
point Vector3
Returns
BoundingBox

The new BoundingBox.

clear()BoundingBox

Reset the box to (0,0,0)x(0,0,0).

Returns
BoundingBox

Returns self.

clone()BoundingBox

Create a copy of this BoundingBox.

Returns
BoundingBox

The cloned BoundingBox.

contains(point) → bool

Determines if the box contains a given point.

Parameters
point Vector3
Returns
bool

True if the point is within the bounding box.

copy(other)BoundingBox

Copy another BoundingBox.

Parameters
other BoundingBox

The BoundingBox to copy.

Returns
BoundingBox

Returns self.

expand(amount)BoundingBox

Expands (or shrinks) the box by a given amount.

Parameters
amount Vector3
Returns
BoundingBox

Returns this bounding box.

getCenter(_out)

Returns the centroid of the box

Parameters
_out Vector3

getCorner(index, _out)

Returns the coordinates of a particular corner of the box.

Parameters
index number
_out Vector3

getExtents(_out)Vector3

Get the dimensions of the box.

Parameters
_out Vector3
Returns
Vector3

getSize(_out)

Get the dimensions of the box.

Parameters
_out Vector3

include(b_x, y, z)BoundingBox

Expands this box to include the given point or BoundingBox.

Parameters
b_x *
y *
z *
Returns
BoundingBox

Returns this bounding box.

interpolate(uvw, _out)Vector3

Given a value [uvw] in the range [0, 1], return the interpolated point within the box.

Parameters
uvw Vecotr3
_out Vector3
Returns
Vector3

overlaps(other) → bool

Determines if this box overlaps the given box.

Parameters
other BoundingBox

The BoundingBox to test.

Returns
bool

True if other overlaps.

rayIntersect(ray) → Array

Determine if the ray intersects this box.

Parameters
ray Ray
Returns
Array

Returns [minDistance, maxDistance].

set(box)BoundingBox

Set the values of the bounding box from another bounding box, a point, or a list of points.

Parameters
box *
Returns
BoundingBox

Returns self.

setMinMax(arguments)BoundingBox

Set the min and max extents of the bounding box.

Parameters
arguments *

Either two vectors as min, max; or six floats as min, max.

Returns
BoundingBox

Returns self.

testSphere(center, radius) → bool

Test if a sphere intersects this bounding box.

Parameters
center Vector3

The center of the sphere

radius number

The radius of the sphere.

Returns
bool

transform(transform)BoundingBox

Transforms the box with a 4x4 transformation matrix

Parameters
transform Matrix4
Returns
BoundingBox

Returns this bounding box.

transformed(mat, out)BoundingBox

Return a new BoundingBox that is this box transformed by [mat].

Parameters
mat Matrix4
out BoundingBox
Returns
BoundingBox

translate(t_x, y)

Translate the bounding box.

Parameters
t_x *
y *

volume() → number

Returns the volume encompassed by this box.

Returns
number

The volume of the box.