Box2
A 2D box.
Constructor Summary
Public Constructor | ||
public |
constructor(min: Vector2, max: Vector2) Constructs a new box. |
Member Summary
Public Members | ||
public |
The upper bounds. |
|
public |
The lower bounds. |
Method Summary
Public Methods | ||
public |
clampPoint(point: Vector2, target: Vector2): Vector2 Clamps the given point to the boundaries of this box. |
|
public |
Clones this box. |
|
public |
containsBox(b: Box2): Boolean Checks if the given box lies inside this box. |
|
public |
containsPoint(p: Vector2): Boolean Checks if the given point lies inside this box. |
|
public |
Copies the values of a given box. |
|
public |
distanceToPoint(p: Vector2): Number Calculates the distance from this box to the given point. |
|
public |
Checks if this box equals the given one. |
|
public |
expandByPoint(p: Vector2): Box2 Expands this box by the given point. |
|
public |
expandByScalar(s: Number): Box2 Expands this box by the given scalar. |
|
public |
expandByVector(v: Vector2): Box2 Expands this box by the given vector. |
|
public |
getBoundingSphere(target: Sphere): Sphere Computes the bounding sphere of this box. |
|
public |
Computes the center of this box. |
|
public |
Computes the size of this box. |
|
public |
Intersects this box with the given one. |
|
public |
intersectsBox(b: Box2): Boolean Checks if this box intersects the given one. |
|
public |
Indicates whether this box is truly empty. |
|
public |
Makes this box empty. |
|
public |
Sets the values of this box. |
|
public |
setFromCenterAndSize(center: Vector2, size: Number): Box2 Defines this box by the given center and size. |
|
public |
setFromPoints(points: Vector2[]): Box2 Defines this box by the given points. |
|
public |
Translates this box. |
|
public |
Expands this box by combining it with the given one. |
Public Constructors
Public Members
Public Methods
public clampPoint(point: Vector2, target: Vector2): Vector2 source
Clamps the given point to the boundaries of this box.
public containsBox(b: Box2): Boolean source
Checks if the given box lies inside this box.
Params:
Name | Type | Attribute | Description |
b | Box2 | A box. |
public containsPoint(p: Vector2): Boolean source
Checks if the given point lies inside this box.
Params:
Name | Type | Attribute | Description |
p | Vector2 | A point. |
public copy(b: Box2): Box2 source
Copies the values of a given box.
Params:
Name | Type | Attribute | Description |
b | Box2 | A box. |
public distanceToPoint(p: Vector2): Number source
Calculates the distance from this box to the given point.
Params:
Name | Type | Attribute | Description |
p | Vector2 | A point. |
public equals(b: Box2): Boolean source
Checks if this box equals the given one.
Params:
Name | Type | Attribute | Description |
b | Box2 | A box. |
public expandByPoint(p: Vector2): Box2 source
Expands this box by the given point.
Params:
Name | Type | Attribute | Description |
p | Vector2 | A point. |
public expandByScalar(s: Number): Box2 source
Expands this box by the given scalar.
Params:
Name | Type | Attribute | Description |
s | Number | A scalar. |
public expandByVector(v: Vector2): Box2 source
Expands this box by the given vector.
Params:
Name | Type | Attribute | Description |
v | Vector2 | A vector. |
public getBoundingSphere(target: Sphere): Sphere source
Computes the bounding sphere of this box.
Params:
Name | Type | Attribute | Description |
target | Sphere |
|
A target sphere. If none is provided, a new one will be created. |
public getCenter(target: Vector2): Vector2 source
Computes the center of this box.
Params:
Name | Type | Attribute | Description |
target | Vector2 |
|
A target vector. If none is provided, a new one will be created. |
public getSize(target: Vector2): Vector2 source
Computes the size of this box.
Params:
Name | Type | Attribute | Description |
target | Vector2 |
|
A target vector. If none is provided, a new one will be created. |
public intersect(b: Box2): Box2 source
Intersects this box with the given one.
Params:
Name | Type | Attribute | Description |
b | Box2 | A box. |
public intersectsBox(b: Box2): Boolean source
Checks if this box intersects the given one.
Params:
Name | Type | Attribute | Description |
b | Box2 | A box. |
public isEmpty(): Box2 source
Indicates whether this box is truly empty.
This is a more robust check for emptiness since the volume can get positive with two negative axes.
public makeEmpty(): Box2 source
Makes this box empty.
The lower bounds are set to infinity and the upper bounds to negative infinity to create an infinitely small box.
public setFromCenterAndSize(center: Vector2, size: Number): Box2 source
Defines this box by the given center and size.
public setFromPoints(points: Vector2[]): Box2 source
Defines this box by the given points.
Params:
Name | Type | Attribute | Description |
points | Vector2[] | The points. |