Defines a 3D axis-aligned bounding box.
The box is defined by two corners: minCorner containing the minimum coordinates and maxCorner containing the maximum coordinates.
new Box(
corner1?,corner2?):Box
Creates a box from two points.
The minimum corner is determined from the minimum values of each coordinate in the given points. The maximum corner is determined from the maximum values.
If no points are provided, the box is initialized with non-finite bounds: minCorner is set to (-Infinity, -Infinity, -Infinity) and maxCorner is set to (Infinity, Infinity, Infinity). This state is useful as an accumulator and becomes finite as soon as finite points are added.
First corner.
Second corner.
Box
readonlymaxCorner:Point
Maximum corner of the box.
readonlyminCorner:Point
Minimum corner of the box.
get center():
Point
Center point of the box.
The center is the middle point of the diagonal between minCorner and maxCorner.
get xRange():
number
Length of the range along the X axis.
number
get yRange():
number
Length of the range along the Y axis.
number
get zRange():
number
Length of the range along the Z axis.
number
add(
point):this
Adjusts the box corners so that it contains point.
Only finite coordinates of point are taken into account.
Added point.
this
add(
box):this
Adjusts the box corners so that it contains box.
Box
Added box.
this
clear():
this
Resets the box to its initial non-finite accumulator state, so that isInfinity() returns true.
this
clone():
Box
Creates a new box with the same minCorner and maxCorner as this box.
Box
copy(
other):this
Copies the minCorner and maxCorner of other to this box.
The values of the points are copied without replacing the existing corner objects of this box.
Box
Box to copy.
this
corner(
index):Point
Returns one of the box corners:
index equals 0index equals 1Throws a RangeError if index is not in the range [0, 1].
number
Corner index.
enlarge(
x,y,z):this
Enlarges the box dimensions by the specified values.
Each box extent is shifted by 0.5 of the specified value to the negative and positive side along the corresponding axis.
number
Value along X axis.
number
Value along Y axis.
number
Value along Z axis.
this
enlarge(
size):this
Enlarges the box dimensions by the specified value.
Each box extent is shifted by 0.5 * size to the negative and positive side along each axis.
number
Shift value.
this
enlarged(
x,y,z):Box
Returns a new box obtained by applying enlarge() to this box.
number
Value along X axis.
number
Value along Y axis.
number
Value along Z axis.
Box
enlarged(
size):Box
Returns a new box obtained by applying enlarge() to this box.
number
Shift value.
Box
isIn(
point):boolean
Returns true if the point lies inside the box.
Checked point.
boolean
isInfinity():
boolean
Returns true if at least one coordinate is not finite.
boolean
isIntersecting(
other):boolean
Returns true if the other box has at least one common point with this box.
Box
Checked box.
boolean
multiplied(
scalar):Box
Returns a new box obtained by applying multiply() to this box.
number
Scalar value.
Box
multiply(
scalar):this
Scales the box by a scalar value.
number
Scalar value.
this
range(
index):number
Returns the length of the range along the specified axis:
index equals 0index equals 1index equals 2Throws a RangeError if index is not in the range [0, 2].
number
Range index.
number
setRange(
index,min,max):this
Sets one range of the box to the specified values:
index equals 0index equals 1index equals 2Throws a RangeError if index is not in the range [0, 2].
number
Range index.
number
Minimum corner coordinate.
number
Maximum corner coordinate.
this
setXRange(
min,max):this
Sets the range of box along X axis to the specified values.
number
Minimum corner coordinate.
number
Maximum corner coordinate.
this
setYRange(
min,max):this
Sets the range of box along Y axis to the specified values.
number
Minimum corner coordinate.
number
Maximum corner coordinate.
this
setZRange(
min,max):this
Sets the range of box along Z axis to the specified values.
number
Minimum corner coordinate.
number
Maximum corner coordinate.
this
transform(
transformation):this
Transforms the box.
If the transformation does not contain anything besides perhaps a translation, the box dimensions are kept as is and its position is recalculated accordingly.
If rotation or scale are present, all box corners are transformed and a new axis-aligned box containing them is built. If the box was infinite in one of the directions, the new box will also be infinite in the directions that result from applying the transformation to the original directions. The new box most likely has larger dimensions than the original.
For more accurate results, it is recommended to transform the objects the box was built from and only then calculate the box.
Transformation.
this
transformed(
transformation):Box
Returns a new box obtained by applying transform() to this box.
Transformation.
Box