t3d. Sphere

A sphere defined by a center and radius.

Constructor

new Sphere(centeropt, radiusopt)

Parameters:
NameTypeAttributesDefaultDescription
centert3d.Vector3<optional>
Vector3(0, 0, 0)center of the sphere.
radiusNumber<optional>
-1radius of the sphere.

Methods

applyMatrix4(matrix) → {t3d.Matrix4}

Transforms this sphere with the provided Matrix4.
Parameters:
NameTypeDescription
matrixt3d.Matrix4the Matrix4 to apply
Returns:
Type: 
t3d.Matrix4

clone() → {t3d.Sphere}

Returns a new sphere with the same center and radius as this one.
Returns:
Type: 
t3d.Sphere

containsPoint(point) → {Boolean}

Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.
Parameters:
NameTypeDescription
pointt3d.Vector3The point to check for containment.
Returns:
Type: 
Boolean

copy(sphere) → {t3d.Sphere}

Copies the values of the passed sphere's center and radius properties to this sphere.
Parameters:
NameTypeDescription
spheret3d.Sphere
Returns:
Type: 
t3d.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
pointt3d.Vector3The point to calculate the distance to.
Returns:
Type: 
Number

expandByPoint(point) → {t3d.Sphere}

Expands the boundaries of this sphere to include point.
Parameters:
NameTypeDescription
pointt3d.Vector3The vector3 that should be included in the sphere.
Returns:
Type: 
t3d.Sphere

getBoundingBox(target) → {t3d.Box3}

Returns aMinimum Bounding Box for the sphere.
Parameters:
NameTypeDescription
targett3d.Box3— the result will be copied into this Box3.
Returns:
Type: 
t3d.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() → {t3d.Sphere}

Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.
Returns:
Type: 
t3d.Sphere

set(center, radius) → {t3d.Sphere}

Sets the center and radius properties of this sphere.
Parameters:
NameTypeDescription
centert3d.Vector3center of the sphere.
radiusNumberradius of the sphere.
Returns:
Type: 
t3d.Sphere

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

Computes the minimum bounding sphere for an array of points.
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number>an Array of Vector3 positions.
gapNumber<optional>
3array gap.
offsetNumber<optional>
0array offset.
Returns:
Type: 
t3d.Sphere

setFromPoints(points, optionalCenteropt) → {t3d.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.<t3d.Vector3>an Array of Vector3 positions.
optionalCentert3d.Vector3<optional>
the center of the sphere.
Returns:
Type: 
t3d.Sphere