API Reference

Class List

BoundingSphere

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

// Create a new bounding sphere centered on the origin with a radius of 0.5
const sphere = new pc.BoundingSphere();

Summary

Properties

center

Center of sphere.

radius

The radius of the bounding sphere.

Methods

intersectsBoundingSphere

Test if a Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere.

intersectsRay

Test if a ray intersects with the sphere.

Details

Constructor

BoundingSphere([center], [radius])

Creates a new BoundingSphere instance.

// Create a new bounding sphere centered on the origin with a radius of 0.5
const sphere = new pc.BoundingSphere();

Parameters

centerVec3

The world space coordinate marking the center of the sphere. The constructor takes a reference of this parameter.

radiusnumber

The radius of the bounding sphere. Defaults to 0.5.

Properties

Vec3center

Center of sphere.

numberradius

The radius of the bounding sphere.

Methods

intersectsBoundingSphere(sphere)

Test if a Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere.

Parameters

sphereBoundingSphere

Bounding Sphere to test.

Returns

boolean

True if the Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere and false otherwise.

intersectsRay(ray, [point])

Test if a ray intersects with the sphere.

Parameters

rayRay

Ray to test against (direction must be normalized).

pointVec3

If there is an intersection, the intersection point will be copied into here.

Returns

boolean

True if there is an intersection.