Constructor
new Sphere(centeropt, radiusopt)
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
center | Vector3 | <optional> | Vector3(0, 0, 0) | center of the sphere. |
radius | number | <optional> | -1 | radius of the sphere. |
Methods
applyMatrix4(matrix) → {Matrix4}
Transforms this sphere with the provided Matrix4.
Name | Type | Description |
---|---|---|
matrix | Matrix4 | the Matrix4 to apply |
- Type:
- Matrix4
clone() → {Sphere}
Returns a new sphere with the same center and radius as this one.
- Type:
- Sphere
containsPoint(point) → {boolean}
Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.
Name | Type | Description |
---|---|---|
point | Vector3 | The point to check for containment. |
- Type:
- boolean
copy(sphere) → {Sphere}
Copies the values of the passed sphere's center and radius properties to this sphere.
Name | Type | Description |
---|---|---|
sphere | Sphere |
- Type:
- Sphere
distanceToPoint(point) → {number}
Returns the closest distance from the boundary of the sphere to the point. If the sphere contains the point, the distance will be negative.
Name | Type | Description |
---|---|---|
point | Vector3 | The point to calculate the distance to. |
- Type:
- number
expandByPoint(point) → {Sphere}
Expands the boundaries of this sphere to include point.
Name | Type | Description |
---|---|---|
point | Vector3 | The vector3 that should be included in the sphere. |
- Type:
- Sphere
getBoundingBox(target) → {Box3}
Returns aMinimum Bounding Box for the sphere.
Name | Type | Description |
---|---|---|
target | Box3 | — the result will be copied into this Box3. |
- Type:
- Box3
isEmpty() → {boolean}
Checks to see if the sphere is empty (the radius set to a negative number). Spheres with a radius of 0 contain only their center point and are not considered to be empty.
- Type:
- boolean
makeEmpty() → {Sphere}
Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.
- Type:
- Sphere
set(center, radius) → {Sphere}
Sets the center and radius properties of this sphere.
Name | Type | Description |
---|---|---|
center | Vector3 | center of the sphere. |
radius | number | radius of the sphere. |
- Type:
- Sphere
setFromArray(array, gapopt, offsetopt) → {Sphere}
Computes the minimum bounding sphere for an array of points.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<number> | an Array of Vector3 positions. | ||
gap | number | <optional> | 3 | array gap. |
offset | number | <optional> | 0 | array offset. |
- Type:
- Sphere
setFromPoints(points, optionalCenteropt) → {Sphere}
Computes the minimum bounding sphere for an array of points. If optionalCenteris given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing points is calculated.
Name | Type | Attributes | Description |
---|---|---|---|
points | Array.<Vector3> | an Array of Vector3 positions. | |
optionalCenter | Vector3 | <optional> | the center of the sphere. |
- Type:
- Sphere
union(sphere) → {Sphere}
Expands this sphere to enclose both the original sphere and the given sphere.
Name | Type | Description |
---|---|---|
sphere | Sphere | The sphere to include. |
A reference to this sphere.
- Type:
- Sphere