Gets the center point of the bounding box.
The center point is calculated as the midpoint between the minimum and maximum points. This value is cached and only recalculated when the bounds change.
The center point of the AABB
Gets the distance from the center point to any corner of the bounding box.
This represents the radius of a sphere that would completely contain the AABB when centered at the AABB's center point. Useful for sphere-based culling operations.
The distance from center to corner
Sets the maximum point of the bounding box.
Setting the maximum point will invalidate cached values and mark the AABB as non-vanilla.
The new maximum point vector
Sets the minimum point of the bounding box.
Setting the minimum point will invalidate cached values and mark the AABB as non-vanilla.
The new minimum point vector
Expands the AABB to include the given position.
If this is the first position added to a vanilla AABB, it will set both min and max points to this position. Otherwise, it will expand the bounds as necessary to encompass the new position.
The position to include in the bounding box
The input position vector for convenience
Expands the AABB to include a position from an array at the specified index.
This is a more efficient way to add positions when working with packed vertex data or other array-based position representations.
The array containing position data
The starting index in the array (x, y, z values at index, index+1, index+2)
The input array for convenience
Creates a deep copy of this AABB instance.
All internal state including bounds, cached values, and dirty flags are copied to the new instance.
A new AABB instance that is an exact copy of this one
Resets this AABB to its initial vanilla state.
Clears all bounds, cached values, and marks the AABB as vanilla. After initialization, the AABB will need new positions added to become valid.
Checks whether this AABB is in vanilla (uninitialized) state.
A vanilla AABB has not had any positions added and contains invalid bounds. Most operations on vanilla AABBs will return early or produce undefined results.
True if this AABB is vanilla, false otherwise
Merges this AABB with another AABB to create a combined bounding volume.
The resulting AABB will encompass both the original and the merged AABB. If either AABB is vanilla, special handling is applied.
The AABB to merge with this one
True if the merge was successful, false if the input AABB is vanilla
Returns a string representation of the AABB with full precision.
Includes minimum and maximum points, center point, and center-to-corner distance.
A detailed string representation of the AABB
Returns a string representation of the AABB with rounded numbers for readability.
Similar to toString() but with approximate values that are easier to read. Useful for debugging and logging where exact precision is not required.
A string representation with approximated numeric values
StaticmultiplyTransforms an AABB by a matrix and stores the result in an output AABB.
This method transforms all 8 corners of the input AABB using the given matrix, then calculates the axis-aligned bounding box that encompasses all transformed corners. This is necessary because matrix transformations can rotate the AABB, requiring recalculation of the axis-aligned bounds.
The output AABB for method chaining
A 3D axis-aligned bounding box (AABB) class for spatial calculations and collision detection.
The AABB represents a rectangular box aligned with the coordinate axes, defined by minimum and maximum points. It provides efficient methods for spatial queries, transformations, and merging operations commonly used in 3D graphics and physics simulations.
Example