Constructor
new AABB(x, y, width, height)
Create an AABB using centre position, width, and height.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x value of the centre. |
y |
number | The y value of the centre. |
width |
number | The width measured from the centre. |
height |
number | The height measured from the centre. |
Classes
Methods
contains(point) → {boolean}
Check if this AABB contains a Vector.
Parameters:
Name | Type | Description |
---|---|---|
point |
Vector | The vector to check. |
Returns:
- Type
- boolean
intersects(range) → {boolean}
Check if this AABB intersects another AABB.
Parameters:
Name | Type | Description |
---|---|---|
range |
AABB | The target AABB to check. |
Returns:
- Type
- boolean
lines() → {Array.<Line>}
Create an array of Lines containing one line for each side of the AABB.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options.stroke |
string |
<optional> |
|
options.strokeWidth |
number |
<optional> |
Returns:
- Type
- Array.<Line>
(static) fromCorners(topLeft, topRight, bottomRight, bottomLeft) → {AABB}
Create an AABB from four corner Vectors.
Parameters:
Name | Type | Description |
---|---|---|
topLeft |
Vector | |
topRight |
Vector | |
bottomRight |
Vector | |
bottomLeft |
Vector |
Returns:
- A new AABB object.
- Type
- AABB