Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

AABB

A 3D axis-aligned bounding box.

Description

The AABB built-in Variant type represents an axis-aligned bounding box in a 3D space. It is defined by its position and size, which are Vector3. It is frequently used for fast overlap tests (see intersects). Although AABB itself is axis-aligned, it can be combined with Transform3D to represent a rotated or skewed bounding box.

It uses floating-point coordinates. The 2D counterpart to AABB is Rect2. There is no version of AABB that uses integer coordinates.

Note: Negative values for size are not supported. With negative size, most AABB methods do not work correctly. Use abs to get an equivalent AABB with a non-negative size.

Note: In a boolean context, a AABB evaluates to false if both position and size are zero (equal to Vector3.ZERO). Otherwise, it always evaluates to true.

Note

There are notable differences when using this API with C#. See C# API differences to GDScript for more information.

Tutorials

Properties

Vector3

end

Vector3(0, 0, 0)

Vector3

position

Vector3(0, 0, 0)

Vector3

size

Vector3(0, 0, 0)

Constructors

AABB

AABB()

AABB

AABB(from: AABB)

AABB

AABB(position: Vector3, size: Vector3)

Methods

AABB

abs() const

bool

encloses(with: AABB) const

AABB

expand(to_point: Vector3) const

Vector3

get_center() const

Vector3

get_endpoint(idx: int) const

Vector3

get_longest_axis() const

int

get_longest_axis_index() const

float

get_longest_axis_size() const

Vector3

get_shortest_axis() const

int

get_shortest_axis_index() const

float

get_shortest_axis_size() const

Vector3

get_support(dir: Vector3) const

float

get_volume() const

AABB

grow(by: float) const

bool

has_point(point: Vector3) const

bool

has_surface() const

bool

has_volume() const

AABB

intersection(with: AABB) const

bool

intersects(with: AABB) const

bool

intersects_plane