Shaku

Shaku JS

Back To Table of Content

Sphere

Sphere

A 3D sphere.

Kind: global class

new Sphere(center, radius)

Create the Sphere.

Param Type Description
center Vector3 Sphere center position.
radius Number Sphere radius.

sphere.clone() ⇒ Sphere

Return a clone of this sphere.

Kind: instance method of Sphere
Returns: Sphere - Cloned sphere.

sphere.containsVector(p) ⇒ Boolean

Check if this sphere contains a Vector3.

Kind: instance method of Sphere
Returns: Boolean - if point is contained within the sphere.

Param Type Description
p Vector3 Point to check.

sphere.equals(other) ⇒ Boolean

Check if equal to another sphere.

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

Param Type Description
other Sphere Other sphere to compare to.

sphere.toDict(minimized) ⇒ \*

Convert to dictionary.

Kind: instance method of Sphere
Returns: \* - Dictionary with {center, radius}.

Param Type Description
minimized Boolean If true, will not include keys that their values are 0. You can use fromDict on minimized dicts.

sphere.collideBox(box) ⇒ Boolean

Check if collide with a box.

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

Param Type Description
box Box Box to check.

sphere.collidePlane(plane) ⇒ Boolean

Check if collide with a plane.

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

Param Type Description
plane Plane Plane to test.

Sphere.fromDict(data) ⇒ Sphere

Create sphere from a dictionary.

Kind: static method of Sphere
Returns: Sphere - Newly created sphere.

Param Type Description
data \* Dictionary with {center, radius}.

Sphere.lerp(p1, p2, a) ⇒ Sphere

Lerp between two sphere.

Kind: static method of Sphere
Returns: Sphere - result sphere.

Param Type Description
p1 Sphere First sphere.
p2 Sphere Second sphere.
a Number Lerp factor (0.0 - 1.0).