result
SourceValidates one raw AABB and returns an explicit result.
const playerBox = Aabb.result({
position: { x: 24, y: 24 },
size: { width: 16, height: 16 }
})
Data Structures
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.
// Build a collision volume from raw authored data.
const player = Aabb.result({
position: { x: 0, y: 0 },
size: { width: 16, height: 16 }
})
Non-throwing constructor boundaries for converting raw position and size input into branded AABBs.
Validates one raw AABB and returns an explicit result.
const playerBox = Aabb.result({
position: { x: 24, y: 24 },
size: { width: 16, height: 16 }
})
Validates one raw AABB and returns null on failure.
Checks whether one raw value already satisfies the AABB invariants.
Pure readers that expose center, size, and derived edge positions.
Reads the center position of one AABB.
Reads the size of one AABB.
Returns the left edge of one centered AABB.
Returns the right edge of one centered AABB.
Returns the top edge of one centered AABB.
Returns the bottom edge of one centered AABB.
Immutable geometry helpers for translation and overlap checks.
Checks whether two AABBs overlap on both axes.
const overlaps = Aabb.intersects(playerBox, wallBox)
Checks whether two AABBs overlap on the horizontal axis.
Checks whether two AABBs overlap on the vertical axis.
Returns a translated copy of one AABB.