Mirror Engine
V5
How To
Mirror Engine Logo

Mirror Engine API


Mirror Engine API / BoundingSphere

Class: BoundingSphere

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

Constructors

new BoundingSphere()

new BoundingSphere(center?: Vec3, radius?: number): BoundingSphere

Creates a new BoundingSphere instance.

Parameters

center?

Vec3 = ...

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

radius?

number = 0.5

The radius of the bounding sphere. Defaults to 0.5.

Returns

BoundingSphere

Example

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

Properties

center

readonly center: Vec3;

Center of sphere.


radius

radius: number

The radius of the bounding sphere.

Methods

intersectsBoundingSphere()

intersectsBoundingSphere(sphere: BoundingSphere): boolean

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

Parameters

sphere

BoundingSphere

Bounding Sphere to test.

Returns

boolean

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


intersectsRay()

intersectsRay(ray: Ray, point?: Vec3): boolean

Test if a ray intersects with the sphere.

Parameters

ray

Ray

Ray to test against (direction must be normalized).

point?

Vec3

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

Returns

boolean

True if there is an intersection.

Mirror Engine Logo