Box2
Axis-aligned bounding box defined by minimum and maximum corners.
Box2 represents a 2D region bounded by two corners: min and max. It is used for view rectangles, viewport regions, and intersection checks. A default-constructed box is empty and intersection treats boxes as half-open intervals.
Constructor
Creates a box from optional corner points. The corners are cloned. When a corner is omitted the box starts empty.
new Box2(min?, max?): Box2;| Parameter | Description |
|---|---|
min?: vec2 | The minimum corner. |
max?: vec2 | The maximum corner. |
Properties
min
Minimum corner of the box.
min: vec2;max
Maximum corner of the box.
max: vec2;Methods
clone() Box2
Returns a deep copy of the box.
clone(): Box2;isEmpty() boolean
Returns true when the box encloses no area.
isEmpty(): boolean;intersects() boolean
Tests whether two boxes overlap. Boxes are treated as half-open intervals so touching edges do not count as overlap.
static intersects(a, b): boolean;| Parameter | Description |
|---|---|
a: Box2 | The first box. |
b: Box2 | The second box. |
equals() boolean
Tests whether two boxes have exactly equal corners.
static equals(a, b): boolean;| Parameter | Description |
|---|---|
a: Box2 | The first box. |
b: Box2 | The second box. |
floor() Box2
Returns a copy with both corners floored componentwise.
floor(): Box2;toRect()
Converts the box to an x, y, width, height rectangle.
toRect(): {
x: number;
y: number;
width: number;
height: number;
};