Constructor
new Sphere(radius, center)
Creates a new sphere.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
radius |
Number | 0 | The radius of the sphere. |
center |
Vector3 | The center of the sphere. The default is (0, 0, 0). |
Members
diameter
Gets the diameter of the sphere.
diameter
Sets the diameter of the sphere.
Methods
clone() → {Sphere}
Creates a clone of the sphere.
Returns:
The cloned sphere.
- Type
- Sphere
copy(sphere) → {Sphere}
Copies the radius and the center of another sphere.
Parameters:
Name | Type | Description |
---|---|---|
sphere |
Sphere | The sphere to copy. |
Returns:
The sphere.
- Type
- Sphere
equals(sphere) → {Boolean}
Compares the radius and the center to another sphere.
Parameters:
Name | Type | Description |
---|---|---|
sphere |
Sphere | sphere to compare to. |
Returns:
A value indicating whether the radius and the center are equal.
- Type
- Boolean
setCenter(center)
Sets the center of the sphere to the same values of a vector.
Parameters:
Name | Type | Description |
---|---|---|
center |
Vector3 | The vector containing the values to set. |
setRadius(radius) → {Sphere}
Sets the radius of the sphere.
Parameters:
Name | Type | Description |
---|---|---|
radius |
Number | The radius of the sphere. |
Returns:
The sphere.
- Type
- Sphere
surfaceArea() → {Number}
Calculates the surface area of the sphere.
Returns:
The surface area of the sphere.
- Type
- Number
volume() → {Number}
Calculates the volume of the sphere.
Returns:
The volume of the sphere.
- Type
- Number