Creates a new BoundingSphere instance.
Optionalcenter: Vec3
The world space coordinate marking the center of the sphere. The constructor copies this parameter. Defaults to (0, 0, 0).
Optionalradius: number = 0.5
The radius of the bounding sphere. Defaults to 0.5.
ReadonlycenterCenter of sphere.
The radius of the bounding sphere.
Test if a point is inside the sphere.
Point to test.
True if the point is inside the sphere and false otherwise.
Test if a Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere.
Bounding Sphere to test.
True if the Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere and false otherwise.
Test if a ray intersects with the sphere. A ray that starts inside the sphere intersects it.
True if there is an intersection.
A bounding sphere is a volume for facilitating fast intersection testing.
A sphere is a center and a radius. It is the cheapest bounding volume to test, so it suits broad-phase checks made before a finer test. containsPoint, intersectsBoundingSphere and intersectsRay return a boolean and allocate nothing. Like BoundingBox, the constructor copies the center vector it is given, so later changes to that vector do not affect the sphere.
Example