Shaku

Shaku JS

Back To Table of Content

Box

Box

A 3D box shape.

Kind: global class

new Box(min, max)

Create the 3d box.

Param Type Description
min Vector3 Box min vector.
max Vector3 Box max vector.

box.set(min, max) ⇒ Box

Set the box min and max corners.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
min Vector3 Box min vector.
max Vector3 Box max vector.

box.setFromArray(array) ⇒ Box

Set box values from array.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
array Array.<Number> Array of values to load from.

box.setFromPoints(points) ⇒ Box

Set box from array of points.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
points Array.<Vector3> Points to set box from.

box.setFromCenterAndSize(center, size) ⇒ Box

Set box from center and size.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
center Vector3 Center position.
size Vector3 Box size.

box.clone() ⇒ Box

Clone this box.

Kind: instance method of Box
Returns: Box - Cloned box.

box.copy(box) ⇒ Box

Copy values from another box.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
box Box Box to copy.

box.makeEmpty() ⇒ Box

Turn this box into empty state.

Kind: instance method of Box
Returns: Box - Self.

box.isEmpty() ⇒ Boolean

Check if this box is empty.

Kind: instance method of Box
Returns: Boolean - True if empty.

box.getCenter() ⇒ Vector3

Get center position.

Kind: instance method of Box
Returns: Vector3 - Center position.

box.getSize() ⇒ Vector3

Get box size.

Kind: instance method of Box
Returns: Vector3 - Box size.

box.expandByPoint(point) ⇒ Box

Expand this box by a point. This will adjust the box boundaries to contain the point.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
point Vector3 Point to extend box by.

box.expandByVector(vector) ⇒ Box

Expand this box by pushing its boundaries by a vector. This will adjust the box boundaries by pushing them away from the center by the value of the given vector.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
vector Vector3 Vector to expand by.

box.expandByScalar(scalar) ⇒ Box

Expand this box by pushing its boundaries by a given scalar. This will adjust the box boundaries by pushing them away from the center by the value of the given scalar.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
scalar Number Value to expand by.

box.containsPoint(point) ⇒ Boolean

Check if this box contains a point.

Kind: instance method of Box
Returns: Boolean - True if box containing the point.

Param Type Description
point Vector3 Point to check.

box.containsBox(box) ⇒ Boolean

Check if this box contains another box.

Kind: instance method of Box
Returns: Boolean - True if box containing the box.

Param Type Description
box Box Box to check.

box.collideBox(box) ⇒ Boolean

Check if this box collides with another box.

Kind: instance method of Box
Returns: Boolean - True if collide, false otherwise.

Param Type Description
box Box Box to test collidion with.

box.collideSphere(sphere) ⇒ Boolean

Check if this box collides with a sphere.

Kind: instance method of Box
Returns: Boolean - True if collide, false otherwise.

Param Type Description
sphere Sphere Sphere to test collidion with.

box.collidePlane(plane) ⇒ Boolean

Check if this box collides with a plane.

Kind: instance method of Box
Returns: Boolean - True if collide, false otherwise.

Param Type Description
plane Plane Plane to test collidion with.

box.clampPoint(point) ⇒ Vector3

Clamp a given vector inside this box.

Kind: instance method of Box
Returns: Vector3 - Vector clammped.

Param Type Description
point Vector3 Vector to clamp.

box.distanceToPoint(point) ⇒ Number

Get distance between this box and a given point.

Kind: instance method of Box
Returns: Number - Distance to point.

Param Type Description
point Vector3 Point to get distance to.

box.intersectWith(box) ⇒ Box

Computes the intersection of this box with another box. This will set the upper bound of this box to the lesser of the two boxes’ upper bounds and the lower bound of this box to the greater of the two boxes’ lower bounds. If there’s no overlap, makes this box empty.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
box Box Box to intersect with.

box.unionWith(box) ⇒ Box

Computes the union of this box and box. This will set the upper bound of this box to the greater of the two boxes’ upper bounds and the lower bound of this box to the lesser of the two boxes’ lower bounds.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
box Box Box to union with.

box.translate(offset) ⇒ Box

Move this box.

Kind: instance method of Box
Returns: Box - Self.

Param Type Description
offset Vector3 Offset to move box by.

box.equals(other) ⇒ Boolean

Check if equal to another box.

Kind: instance method of Box
Returns: Boolean - True if boxes are equal, false otherwise.

Param Type Description
other Box Other box to compare to.