Class: BoundingSphere

pc.BoundingSphere

A bounding sphere is a volume for facilitating fast intersection testing.

Constructor

new BoundingSphere(centeropt, radiusopt)

Creates a new bounding sphere.
Parameters:
Name Type Attributes Description
center pc.Vec3 <optional>
The world space coordinate marking the center of the sphere. The constructor takes a reference of this parameter.
radius Number <optional>
The radius of the bounding sphere. Defaults to 0.5.
Source:
Example
// Create a new bounding sphere centered on the origin with a radius of 0.5
var sphere = new pc.BoundingSphere();

Methods

intersectsBoundingSphere(sphere) → {Boolean}

Test if a Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere.
Parameters:
Name Type Description
sphere pc.BoundingSphere Bounding Sphere to test.
Source:
Returns:
true if the Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere and false otherwise.
Type
Boolean

intersectsRay(ray, pointopt) → {Boolean}

Test if a ray intersects with the sphere.
Parameters:
Name Type Attributes Description
ray pc.Ray Ray to test against (direction must be normalized).
point pc.Vec3 <optional>
If there is an intersection, the intersection point will be copied into here.
Source:
Returns:
True if there is an intersection.
Type
Boolean