Sphere

A sphere defined by a center and radius.

Constructor

new Sphere(centeropt, radiusopt)

Parameters:
NameTypeAttributesDefaultDescription
centerVector3<optional>
Vector3(0, 0, 0)

center of the sphere.

radiusnumber<optional>
-1

radius of the sphere.

Methods

applyMatrix4(matrix) → {Matrix4}

Transforms this sphere with the provided Matrix4.

Parameters:
NameTypeDescription
matrixMatrix4

the Matrix4 to apply

Returns:
Type: 
Matrix4

clone() → {Sphere}

Returns a new sphere with the same center and radius as this one.

Returns:
Type: 
Sphere

containsPoint(point) → {boolean}

Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.

Parameters:
NameTypeDescription
pointVector3

The point to check for containment.

Returns:
Type: 
boolean

copy(sphere) → {Sphere}

Copies the values of the passed sphere's center and radius properties to this sphere.

Parameters:
NameTypeDescription
sphereSphere
Returns:
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.

Parameters:
NameTypeDescription
pointVector3

The point to calculate the distance to.

Returns:
Type: 
number

expandByPoint(point) → {Sphere}

Expands the boundaries of this sphere to include point.

Parameters:
NameTypeDescription
pointVector3

The vector3 that should be included in the sphere.

Returns:
Type: 
Sphere

getBoundingBox(target) → {Box3}

Returns aMinimum Bounding Box for the sphere.

Parameters:
NameTypeDescription
targetBox3

— the result will be copied into this Box3.

Returns:
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.

Returns:
Type: 
boolean

makeEmpty() → {Sphere}

Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.

Returns:
Type: 
Sphere

set(center, radius) → {Sphere}

Sets the center and radius properties of this sphere.

Parameters:
NameTypeDescription
centerVector3

center of the sphere.

radiusnumber

radius of the sphere.

Returns:
Type: 
Sphere

setFromArray(array, gapopt, offsetopt) → {Sphere}

Computes the minimum bounding sphere for an array of points.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number>

an Array of Vector3 positions.

gapnumber<optional>
3

array gap.

offsetnumber<optional>
0

array offset.

Returns:
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.

Parameters:
NameTypeAttributesDescription
pointsArray.<Vector3>

an Array of Vector3 positions.

optionalCenterVector3<optional>

the center of the sphere.

Returns:
Type: 
Sphere

union(sphere) → {Sphere}

Expands this sphere to enclose both the original sphere and the given sphere.

Parameters:
NameTypeDescription
sphereSphere

The sphere to include.

Returns:

A reference to this sphere.

Type: 
Sphere