Data Structures

Aabb

Branded axis-aligned bounding boxes built from validated vectors and sizes.

The public shape is centered: each AABB is described by a center position and a non-negative size. Geometry helpers derive edges and overlap relationships without mutating the original value.

In game code this is the natural helper for collision volumes, trigger regions, camera bounds, and spatial authored data that should stay validated and immutable after construction.

Examples

// Build a collision volume from raw authored data.
const player = Aabb.result({
  position: { x: 0, y: 0 },
  size: { width: 16, height: 16 }
})

Construction

Non-throwing constructor boundaries for converting raw position and size input into branded AABBs.

result

Source

Validates one raw AABB and returns an explicit result.

const playerBox = Aabb.result({
  position: { x: 24, y: 24 },
  size: { width: 16, height: 16 }
})

option

Source

Validates one raw AABB and returns null on failure.

is

Source

Checks whether one raw value already satisfies the AABB invariants.

Accessors

Pure readers that expose center, size, and derived edge positions.

position

Source

Reads the center position of one AABB.

size

Source

Reads the size of one AABB.

left

Source

Returns the left edge of one centered AABB.

top

Source

Returns the top edge of one centered AABB.

bottom

Source

Returns the bottom edge of one centered AABB.

Operations

Immutable geometry helpers for translation and overlap checks.

intersects

Source

Checks whether two AABBs overlap on both axes.

const overlaps = Aabb.intersects(playerBox, wallBox)

overlapsHorizontally

Source

Checks whether two AABBs overlap on the horizontal axis.

overlapsVertically

Source

Checks whether two AABBs overlap on the vertical axis.

translate

Source

Returns a translated copy of one AABB.