aabb
aabb
The aabb class represents a 3D Axis-Aligned Bounding Box defined by a minimum corner position and dimensions size. Used for spatial bounds, collision detection, and rendering extents.
Overview
Properties (9)
| Property | Type | Summary |
|---|---|---|
center
|
vector3
|
The center point of the bounding box. |
end
|
vector3
|
The maximum corner position (position + size). |
hasVolume
|
boolean
|
Checks whether the box has positive volume. |
isValid
|
boolean
|
Checks if the bounding box has valid non-negative dimensions. |
longestAxisSize
|
number
|
The length of the longest axis. |
position
|
vector3
|
The origin / minimum position corner of the bounding box. |
shortestAxisSize
|
number
|
The length of the shortest axis. |
size
|
vector3
|
The dimensions (width, height, depth) of the bounding box. |
volume
|
number
|
Total 3D volume of the bounding box. |
Methods (11)
| Method Signature | Returns | Summary |
|---|---|---|
aabb:encloses(other)
|
boolean
|
Checks if this bounding box completely contains another. |
aabb:expand(point)
|
aabb
|
Expands the bounding box to include the specified point. |
aabb.fromMinMax(min, max)
|
aabb
|
Constructs an AABB enclosing the specified minimum and maximum bounds. |
aabb:grow(amount)
|
aabb
|
Grows the bounding box by the specified amount on all sides. |
aabb:hasPoint(point)
|
boolean
|
Checks if a 3D point is inside the bounding box. |
aabb:intersects(other)
|
boolean
|
Checks if this bounding box overlaps another. |
aabb:merge(other)
|
aabb
|
Returns a new AABB that encloses both bounding boxes. |
aabb.new([position], [size])
|
aabb
|
Constructs a new bounding box. |
aabb.newFromFloats(x, y, z, sx, sy, sz)
|
aabb
|
Constructs an AABB from individual coordinates. |
aabb:scale(scaleFactor)
|
aabb
|
Scales the bounding box by a 3D factor. |
aabb:transformed([translation], [rotationEulerDeg], [scale])
|
aabb
|
Transforms the bounding box by translation, rotation, and scale. |
Detailed Reference
aabb.centervector3Center 3D position.
Calculates the center coordinates of the box.
aabb.endvector3Maximum corner position.
Returns the maximum corner coordinates.
aabb.hasVolumebooleanTrue if volume is greater than 0.
Returns true if width, height, and depth are all strictly greater than 0.
aabb.isValidbooleanTrue if dimensions are non-negative.
Returns true if all size axes are >= 0.
aabb.longestAxisSizenumberMaximum dimension.
Returns the maximum dimension among X, Y, and Z sizes.
aabb.positionvector3Min corner position.
Gets or sets the minimum coordinate corner of the box.
aabb.shortestAxisSizenumberMinimum dimension.
Returns the minimum dimension among X, Y, and Z sizes.
aabb.sizevector3Size dimensions.
Gets or sets the size vector of the bounding box.
aabb.volumenumberTotal volume.
Calculates the volume (size.x size.y size.z).
aabb:encloses(other)| Parameter | Type | Default | Description |
|---|---|---|---|
other | aabb | Other bounding box. |
booleanTrue if other is fully inside.
Returns true if other is entirely inside this box.
aabb:expand(point)| Parameter | Type | Default | Description |
|---|---|---|---|
point | vector3 | Point to include. |
aabbExpanded bounding box.
Returns a new AABB expanded to enclose point.
aabb.fromMinMax(min, max)| Parameter | Type | Default | Description |
|---|---|---|---|
min | vector3 | Minimum bounds. | |
max | vector3 | Maximum bounds. |
aabbBounding box enclosing min and max.
Calculates origin as min and size as max - min.
aabb:grow(amount)| Parameter | Type | Default | Description |
|---|---|---|---|
amount | number | Amount to grow or shrink on all sides. |
aabbGrown bounding box.
Expands (or contracts if negative) the box in all directions.
aabb:hasPoint(point)| Parameter | Type | Default | Description |
|---|---|---|---|
point | vector3 | Point to test. |
booleanTrue if point is inside box.
Tests whether point lies within the box volume.
aabb:intersects(other)| Parameter | Type | Default | Description |
|---|---|---|---|
other | aabb | Other bounding box. |
booleanTrue if boxes overlap.
Returns true if there is any volumetric intersection with other.
aabb:merge(other)| Parameter | Type | Default | Description |
|---|---|---|---|
other | aabb | Other bounding box. |
aabbCombined bounding box.
Merges this bounding box with other to create an enclosing box.
aabb.new([position], [size])| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | `(0, 0, 0)` | Origin position. |
size | vector3 | `(0, 0, 0)` | Dimensions. |
aabbNewly created bounding box.
Creates an AABB with the specified position and size.
aabb.newFromFloats(x, y, z, sx, sy, sz)| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | Origin X. | |
y | number | Origin Y. | |
z | number | Origin Z. | |
sx | number | Size X. | |
sy | number | Size Y. | |
sz | number | Size Z. |
aabbNewly created bounding box.
Creates an AABB from 6 explicit float values.
aabb:scale(scaleFactor)| Parameter | Type | Default | Description |
|---|---|---|---|
scaleFactor | vector3 | 3D scaling vector. |
aabbScaled bounding box.
Multiplies both position and size by scaleFactor.
aabb:transformed([translation], [rotationEulerDeg], [scale])| Parameter | Type | Default | Description |
|---|---|---|---|
translation | vector3 | `(0, 0, 0)` | Translation offset. |
rotationEulerDeg | vector3 | `(0, 0, 0)` | Euler rotation in degrees. |
scale | vector3 | `(1, 1, 1)` | Scale vector. |
aabbTransformed axis-aligned bounding box.
Calculates the new axis-aligned bounding box enclosing the rotated and transformed vertices.