Dev » Lua API » aabb
← Back to all classes

aabb

Math 9 Properties 11 Methods

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

# center PROPERTY
aabb.center
The center point of the bounding box.
Parameters
None
Returns
vector3

Center 3D position.

Description

Calculates the center coordinates of the box.

# end PROPERTY
aabb.end
The maximum corner position (position + size).
Parameters
None
Returns
vector3

Maximum corner position.

Description

Returns the maximum corner coordinates.

# hasVolume PROPERTY
aabb.hasVolume
Checks whether the box has positive volume.
Parameters
None
Returns
boolean

True if volume is greater than 0.

Description

Returns true if width, height, and depth are all strictly greater than 0.

# isValid PROPERTY
aabb.isValid
Checks if the bounding box has valid non-negative dimensions.
Parameters
None
Returns
boolean

True if dimensions are non-negative.

Description

Returns true if all size axes are >= 0.

# longestAxisSize PROPERTY
aabb.longestAxisSize
The length of the longest axis.
Parameters
None
Returns
number

Maximum dimension.

Description

Returns the maximum dimension among X, Y, and Z sizes.

# position PROPERTY
aabb.position
The origin / minimum position corner of the bounding box.
Parameters
None
Returns
vector3

Min corner position.

Description

Gets or sets the minimum coordinate corner of the box.

# shortestAxisSize PROPERTY
aabb.shortestAxisSize
The length of the shortest axis.
Parameters
None
Returns
number

Minimum dimension.

Description

Returns the minimum dimension among X, Y, and Z sizes.

# size PROPERTY
aabb.size
The dimensions (width, height, depth) of the bounding box.
Parameters
None
Returns
vector3

Size dimensions.

Description

Gets or sets the size vector of the bounding box.

# volume PROPERTY
aabb.volume
Total 3D volume of the bounding box.
Parameters
None
Returns
number

Total volume.

Description

Calculates the volume (size.x size.y size.z).

# encloses METHOD
aabb:encloses(other)
Checks if this bounding box completely contains another.
Parameters
ParameterTypeDefaultDescription
otheraabb

Other bounding box.

Returns
boolean

True if other is fully inside.

Description

Returns true if other is entirely inside this box.

# expand METHOD
aabb:expand(point)
Expands the bounding box to include the specified point.
Parameters
ParameterTypeDefaultDescription
pointvector3

Point to include.

Returns
aabb

Expanded bounding box.

Description

Returns a new AABB expanded to enclose point.

# fromMinMax METHOD
aabb.fromMinMax(min, max)
Constructs an AABB enclosing the specified minimum and maximum bounds.
Parameters
ParameterTypeDefaultDescription
minvector3

Minimum bounds.

maxvector3

Maximum bounds.

Returns
aabb

Bounding box enclosing min and max.

Description

Calculates origin as min and size as max - min.

# grow METHOD
aabb:grow(amount)
Grows the bounding box by the specified amount on all sides.
Parameters
ParameterTypeDefaultDescription
amountnumber

Amount to grow or shrink on all sides.

Returns
aabb

Grown bounding box.

Description

Expands (or contracts if negative) the box in all directions.

# hasPoint METHOD
aabb:hasPoint(point)
Checks if a 3D point is inside the bounding box.
Parameters
ParameterTypeDefaultDescription
pointvector3

Point to test.

Returns
boolean

True if point is inside box.

Description

Tests whether point lies within the box volume.

# intersects METHOD
aabb:intersects(other)
Checks if this bounding box overlaps another.
Parameters
ParameterTypeDefaultDescription
otheraabb

Other bounding box.

Returns
boolean

True if boxes overlap.

Description

Returns true if there is any volumetric intersection with other.

# merge METHOD
aabb:merge(other)
Returns a new AABB that encloses both bounding boxes.
Parameters
ParameterTypeDefaultDescription
otheraabb

Other bounding box.

Returns
aabb

Combined bounding box.

Description

Merges this bounding box with other to create an enclosing box.

# new METHOD
aabb.new([position], [size])
Constructs a new bounding box.
Parameters
ParameterTypeDefaultDescription
positionvector3`(0, 0, 0)`

Origin position.

sizevector3`(0, 0, 0)`

Dimensions.

Returns
aabb

Newly created bounding box.

Description

Creates an AABB with the specified position and size.

# newFromFloats METHOD
aabb.newFromFloats(x, y, z, sx, sy, sz)
Constructs an AABB from individual coordinates.
Parameters
ParameterTypeDefaultDescription
xnumber

Origin X.

ynumber

Origin Y.

znumber

Origin Z.

sxnumber

Size X.

synumber

Size Y.

sznumber

Size Z.

Returns
aabb

Newly created bounding box.

Description

Creates an AABB from 6 explicit float values.

# scale METHOD
aabb:scale(scaleFactor)
Scales the bounding box by a 3D factor.
Parameters
ParameterTypeDefaultDescription
scaleFactorvector3

3D scaling vector.

Returns
aabb

Scaled bounding box.

Description

Multiplies both position and size by scaleFactor.

# transformed METHOD
aabb:transformed([translation], [rotationEulerDeg], [scale])
Transforms the bounding box by translation, rotation, and scale.
Parameters
ParameterTypeDefaultDescription
translationvector3`(0, 0, 0)`

Translation offset.

rotationEulerDegvector3`(0, 0, 0)`

Euler rotation in degrees.

scalevector3`(1, 1, 1)`

Scale vector.

Returns
aabb

Transformed axis-aligned bounding box.

Description

Calculates the new axis-aligned bounding box enclosing the rotated and transformed vertices.