Skip to content

@orillusion/core


Class: Box2 ​

Defined in: src/math/Box2.ts:8

Axis-aligned 2D box (min / max corners). Mirrors three.js Box2: screen rectangles, UV bounds, 2D culling, marquee selection.

Constructors ​

Constructor ​

new Box2(min?, max?): Box2

Defined in: src/math/Box2.ts:13

Defaults to an empty box (min = +∞, max = −∞) so the first expandByPoint defines it.

Parameters ​

min? ​

Vector2

max? ​

Vector2

Returns ​

Box2

Properties ​

min ​

min: Vector2

Defined in: src/math/Box2.ts:9


max ​

max: Vector2

Defined in: src/math/Box2.ts:10

Methods ​

set() ​

set(min, max): this

Defined in: src/math/Box2.ts:18

Parameters ​

min ​

Vector2

max ​

Vector2

Returns ​

this


setFromPoints() ​

setFromPoints(points): this

Defined in: src/math/Box2.ts:24

Parameters ​

points ​

Vector2[]

Returns ​

this


setFromCenterAndSize() ​

setFromCenterAndSize(center, size): this

Defined in: src/math/Box2.ts:30

Parameters ​

center ​

Vector2

size ​

Vector2

Returns ​

this


clone() ​

clone(): Box2

Defined in: src/math/Box2.ts:37

Returns ​

Box2


copy() ​

copy(box): this

Defined in: src/math/Box2.ts:41

Parameters ​

box ​

Box2

Returns ​

this


makeEmpty() ​

makeEmpty(): this

Defined in: src/math/Box2.ts:45

Returns ​

this


isEmpty() ​

isEmpty(): boolean

Defined in: src/math/Box2.ts:52

True when the box encloses no points (max < min on either axis).

Returns ​

boolean


getCenter() ​

getCenter(out?): Vector2

Defined in: src/math/Box2.ts:56

Parameters ​

out? ​

Vector2 = ...

Returns ​

Vector2


getSize() ​

getSize(out?): Vector2

Defined in: src/math/Box2.ts:60

Parameters ​

out? ​

Vector2 = ...

Returns ​

Vector2


expandByPoint() ​

expandByPoint(p): this

Defined in: src/math/Box2.ts:64

Parameters ​

p ​

Vector2

Returns ​

this


expandByVector() ​

expandByVector(v): this

Defined in: src/math/Box2.ts:72

Parameters ​

v ​

Vector2

Returns ​

this


expandByScalar() ​

expandByScalar(s): this

Defined in: src/math/Box2.ts:78

Parameters ​

s ​

number

Returns ​

this


containsPoint() ​

containsPoint(p): boolean

Defined in: src/math/Box2.ts:84

Parameters ​

p ​

Vector2

Returns ​

boolean


containsBox() ​

containsBox(box): boolean

Defined in: src/math/Box2.ts:88

Parameters ​

box ​

Box2

Returns ​

boolean


intersectsBox() ​

intersectsBox(box): boolean

Defined in: src/math/Box2.ts:93

Overlap test; touching edges count as intersecting.

Parameters ​

box ​

Box2

Returns ​

boolean


getParameter() ​

getParameter(p, out?): Vector2

Defined in: src/math/Box2.ts:98

Position of p inside the box as 0..1 on each axis.

Parameters ​

p ​

Vector2

out? ​

Vector2 = ...

Returns ​

Vector2


clampPoint() ​

clampPoint(p, out?): Vector2

Defined in: src/math/Box2.ts:102

Parameters ​

p ​

Vector2

out? ​

Vector2 = ...

Returns ​

Vector2


distanceToPoint() ​

distanceToPoint(p): number

Defined in: src/math/Box2.ts:107

0 when p is inside or on the box.

Parameters ​

p ​

Vector2

Returns ​

number


intersect() ​

intersect(box): this

Defined in: src/math/Box2.ts:114

Shrink to the overlap with box; becomes empty if they do not overlap.

Parameters ​

box ​

Box2

Returns ​

this


union() ​

union(box): this

Defined in: src/math/Box2.ts:121

Parameters ​

box ​

Box2

Returns ​

this


translate() ​

translate(offset): this

Defined in: src/math/Box2.ts:127

Parameters ​

offset ​

Vector2

Returns ​

this


equals() ​

equals(box): boolean

Defined in: src/math/Box2.ts:133

Parameters ​

box ​

Box2

Returns ​

boolean

Released under the MIT License