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
Gets the maximum point of the bounding box.
The maximum point as a read-only Vector3
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
Gets the minimum point of the bounding box.
The minimum point as a read-only Vector3
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
Gets the width of the bounding box along the X-axis.
The difference between maximum and minimum X coordinates
Gets the height of the bounding box along the Y-axis.
The difference between maximum and minimum Y coordinates
Gets the depth of the bounding box along the Z-axis.
The difference between maximum and minimum Z coordinates
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
Copies all components and state from another AABB into this instance.
This is a more efficient alternative to creating a new instance when you want to overwrite the current AABB's state.
The source AABB to copy from
This AABB instance for method chaining
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 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
Static
multiplyTransforms 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