BoundingSphere(center, radius)

Class representing a bounding sphere.

new BoundingSphere(center, radius)

Constructs a new bounding sphere with the given values.

Parameters:
Name Type Default Description
center Vector3

The center position of the bounding sphere.

radius Number 0

The radius of the bounding sphere.

Author:

Members

center :Vector3

The center position of the bounding sphere.

radius :Number

The radius of the bounding sphere.

Methods

applyMatrix4(matrix) → {BoundingSphere}

Transforms this bounding sphere with the given 4x4 transformation matrix.

Parameters:
Name Type Description
matrix Matrix4

The 4x4 transformation matrix.

Returns:
BoundingSphere -

A reference to this bounding sphere.

clampPoint(point, result) → {Vector3}

Ensures the given point is inside this bounding sphere and stores the result in the given vector.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

clone() → {BoundingSphere}

Creates a new bounding sphere and copies all values from this bounding sphere.

Returns:
BoundingSphere -

A new bounding sphere.

containsPoint(point) → {Boolean}

Returns true if the given point is inside this bounding sphere.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

Returns:
Boolean -

The result of the containments test.

copy(sphere) → {BoundingSphere}

Copies all values from the given bounding sphere to this bounding sphere.

Parameters:
Name Type Description
sphere BoundingSphere

The bounding sphere to copy.

Returns:
BoundingSphere -

A reference to this bounding sphere.

equals(sphere) → {Boolean}

Returns true if the given bounding sphere is deep equal with this bounding sphere.

Parameters:
Name Type Description
sphere BoundingSphere

The bounding sphere to test.

Returns:
Boolean -

The result of the equality test.

fromJSON(json) → {BoundingSphere}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
BoundingSphere -

A reference to this bounding sphere.

fromPoints(points) → {BoundingSphere}

Computes a bounding sphere that encloses the given set of points.

Parameters:
Name Type Description
points Array.<Vector3>

An array of 3D vectors representing points in 3D space.

Returns:
BoundingSphere -

A reference to this bounding sphere.

getNormalFromSurfacePoint(point, result) → {Vector3}

Returns the normal for a given point on this bounding sphere's surface.

Parameters:
Name Type Description
point Vector3

The point on the surface

result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

intersectsBoundingSphere(sphere) → {Boolean}

Returns true if the given bounding sphere intersects this bounding sphere.

Parameters:
Name Type Description
sphere BoundingSphere

The bounding sphere to test.

Returns:
Boolean -

The result of the intersection test.

intersectsPlane(plane) → {Boolean}

Returns true if the given plane intersects this bounding sphere.

Reference: Testing Sphere Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.2)

Parameters:
Name Type Description
plane Plane

The plane to test.

Returns:
Boolean -

The result of the intersection test.

set(center, radius) → {BoundingSphere}

Sets the given values to this bounding sphere.

Parameters:
Name Type Description
center Vector3

The center position of the bounding sphere.

radius Number

The radius of the bounding sphere.

Returns:
BoundingSphere -

A reference to this bounding sphere.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.