Sphere

A sphere defined by a center and radius.

Constructor

Sphere(center : Vector3, radius : Float)

center — center of the sphere. Default is a Vector3 at (0, 0, 0).
radius — radius of the sphere. Default is -1.

Creates a new Sphere.

Properties

.center : Vector3

A Vector3 defining the center of the sphere. Default is (0, 0, 0).

.radius : Float

The radius of the sphere. Default is -1.

Methods

.applyMatrix4(matrix : Matrix4) → this

matrix — the Matrix4 to apply.

Transforms this sphere with the provided Matrix4.

.clampPoint(point : Vector3, target : Vector3) → Vector3

pointVector3 the point to clamp.
target — the result will be copied into this Vector3.

Clamps a point within the sphere. If the point is outside the sphere, it will clamp it to the closest point on the edge of the sphere. Points already inside the sphere will not be affected.

.clone() → Sphere

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

.containsPoint(point : Vector3) → Boolean

point — the Vector3 to be checked.

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

.copy(sphere : Sphere) → this

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

.distanceToPoint(point : Vector3) → Float

Returns the closest distance from the boundary of the sphere to the point. If the sphere contains the point, the distance will be negative.

.expandByPoint(point : Vector3) → this

pointVector3 that should be included in the sphere.

Expands the boundaries of this sphere to include point.

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

.makeEmpty() → this

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

.equals(sphere : Sphere) → Boolean

Checks to see if the two spheres' centers and radii are equal.

.getBoundingBox(target : Box3) → Box3

target — the result will be copied into this Box3.

Returns aMinimum Bounding Box for the sphere.

.intersectsBox(box : Box3) → Boolean

boxBox3 to check for intersection against.

Determines whether or not this sphere intersects a given box.

.intersectsPlane(plane : Plane) → Boolean

plane — Plane to check for intersection against.

Determines whether or not this sphere intersects a given plane.

.intersectsSphere(sphere : Sphere) → Boolean

sphere — Sphere to check for intersection against.

Checks to see if two spheres intersect.

.set(center : Vector3, radius : Float) → this

center — center of the sphere.
radius — radius of the sphere.

Sets the center and radius properties of this sphere.
Please note that this method only copies the values from the given center.

.setFromPoints(points : Array, optionalCenter : Vector3) → this

points — an Array of Vector3 positions.
optionalCenter — Optional Vector3 position for the sphere's center.

Computes the minimum bounding sphere for an array of points. If optionalCenter is given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing points is calculated.

.translate(offset : Vector3) → this

Translate the sphere's center by the provided offset Vector3.

.union(sphere : Sphere) → this

sphere — Bounding sphere that will be unioned with this sphere.

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

Source

For more info on how to obtain the source code of this module see this page.