Box3

class Box3(val min: Vector3 = Vector3(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY), val max: Vector3 = Vector3(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY))

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

The box is mutable and not thread-safe; confine an instance (and any object graph holding it) to a single thread, exactly as in three.js. Most methods mutate this and return it for chaining.

The constructor stores the given vectors by reference (it does not copy them). Passing the same vector as both bounds, or sharing a vector with another object, means later mutations are visible through every alias. Use set or clone when you need independent storage.

Constructors

Link copied to clipboard
constructor(min: Vector3 = Vector3(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY), max: Vector3 = Vector3(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY))

Properties

Link copied to clipboard

The upper (max) boundary of the box.

Link copied to clipboard

The lower (min) boundary of the box.

Functions

Link copied to clipboard
fun applyMatrix4(matrix: Matrix4): Box3

Transforms this box by the 4x4 matrix matrix. The transform of an empty box is an empty box.

Link copied to clipboard
fun clampPoint(point: Vector3, target: Vector3): Vector3

Writes point clamped into this box's bounds into target.

Link copied to clipboard
fun clone(): Box3

Returns a new box with copied bounds (independent storage).

Link copied to clipboard

Returns true if this box fully contains box (an identical box counts as contained).

Link copied to clipboard

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

Link copied to clipboard
fun copy(box: Box3): Box3

Copies the bounds of box into this instance.

Link copied to clipboard

Returns the Euclidean distance from point to the nearest edge of this box (0 if inside). An empty box yields +Infinity.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Structural equality: true when other is a Box3 with equal bounds.

Link copied to clipboard

Expands this box to include point.

Link copied to clipboard
fun expandByScalar(scalar: Double): Box3

Expands each dimension by scalar. A negative scalar contracts the box and can invert it (making it isEmpty).

Link copied to clipboard

Expands this box equilaterally by vector (x on both horizontal sides, y on both vertical sides, z on both depth sides).

Link copied to clipboard

Sets this box's bounds from json laid out as [minX, minY, minZ, maxX, maxY, maxZ].

Link copied to clipboard

Writes a bounding sphere that encloses this box into target (an empty sphere if this box is empty).

Link copied to clipboard
fun getCenter(target: Vector3): Vector3

Writes the center of this box into target (the zero vector if empty).

Link copied to clipboard
fun getParameter(point: Vector3, target: Vector3): Vector3

Writes point as a proportion of this box's width, height and depth into target.

Link copied to clipboard
fun getSize(target: Vector3): Vector3

Writes the dimensions (width/height/depth) of this box into target (the zero vector if empty).

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun intersect(box: Box3): Box3

Intersects this box with box (keeps the overlapping region), making this box empty if there is no overlap.

Link copied to clipboard

Returns true if box intersects this box (touching edges count).

Link copied to clipboard

Returns true if plane intersects this box.

Link copied to clipboard

Returns true if sphere intersects this box.

Link copied to clipboard

Returns true if triangle intersects this box.

Link copied to clipboard

Returns true if this box encloses no volume. A box with equal lower and upper bounds is not empty. It still contains the single shared point.

Link copied to clipboard

Makes this box empty (encloses zero space): min = +infinity, max = -infinity.

Link copied to clipboard
fun set(min: Vector3, max: Vector3): Box3

Copies the values of min and max into this box's bounds.

Link copied to clipboard

Expands this box to enclose the 3D position data packed in array (x, y, z triples). Fewer than three trailing entries are ignored.

Link copied to clipboard
fun setFromBufferAttribute(attribute: AttributeLike, count: Int): Box3

Expands this box to enclose the first count 3D positions in attribute.

Link copied to clipboard

Centers this box on center and sets its width, height and depth to size.

Link copied to clipboard

Expands this box to enclose all the given points. An empty sequence leaves the box empty.

Link copied to clipboard

Writes this box as [minX, minY, minZ, maxX, maxY, maxZ].

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun translate(offset: Vector3): Box3

Translates this box by offset, moving both bounds.

Link copied to clipboard
fun union(box: Box3): Box3

Unions this box with box (grows to enclose both).