playcanvas
Version:
PlayCanvas WebGL game engine
51 lines (50 loc) • 1.73 kB
TypeScript
/**
* A bounding sphere is a volume for facilitating fast intersection testing.
*
* @category Math
*/
export class BoundingSphere {
/**
* Creates a new BoundingSphere instance.
*
* @param {Vec3} [center] - The world space coordinate marking the center of the sphere. The
* constructor takes a reference of this parameter.
* @param {number} [radius] - The radius of the bounding sphere. Defaults to 0.5.
* @example
* // Create a new bounding sphere centered on the origin with a radius of 0.5
* const sphere = new pc.BoundingSphere();
*/
constructor(center?: Vec3, radius?: number);
/**
* Center of sphere.
*
* @type {Vec3}
* @readonly
*/
readonly center: Vec3;
/**
* The radius of the bounding sphere.
*
* @type {number}
*/
radius: number;
containsPoint(point: any): boolean;
/**
* Test if a ray intersects with the sphere.
*
* @param {Ray} ray - Ray to test against (direction must be normalized).
* @param {Vec3} [point] - If there is an intersection, the intersection point will be copied
* into here.
* @returns {boolean} True if there is an intersection.
*/
intersectsRay(ray: Ray, point?: Vec3): boolean;
/**
* Test if a Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere.
*
* @param {BoundingSphere} sphere - Bounding Sphere to test.
* @returns {boolean} True if the Bounding Sphere is overlapping, enveloping, or inside this Bounding Sphere and false otherwise.
*/
intersectsBoundingSphere(sphere: BoundingSphere): boolean;
}
import { Vec3 } from '../math/vec3.js';
import type { Ray } from './ray.js';