API Reference

Class List

pc.BoundingBox

Axis-Aligned Bounding Box.

Summary

Properties

center

Center of box.

halfExtents

Half the distance across the box in each axis.

Methods

add

Combines two bounding boxes into one, enclosing both.

containsPoint

Test if a point is inside a AABB.

getMax

Return the maximum corner of the AABB.

getMin

Return the minimum corner of the AABB.

intersects

Test whether two axis-aligned bounding boxes intersect.

intersectsBoundingSphere

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

intersectsRay

Test if a ray intersects with the AABB.

setFromTransformedAabb

Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.

Details

Constructor

BoundingBox([center], [halfExtents])

Create a new axis-aligned bounding box.

Parameters

centerpc.Vec3

Center of box. The constructor takes a reference of this parameter.

halfExtentspc.Vec3

Half the distance across the box in each axis. The constructor takes a reference of this parameter.

Properties

pc.Vec3center

Center of box.

pc.Vec3halfExtents

Half the distance across the box in each axis.

Methods

add(other)

Combines two bounding boxes into one, enclosing both.

Parameters

otherpc.BoundingBox

Bounding box to add.

containsPoint(point)

Test if a point is inside a AABB.

Parameters

pointpc.Vec3

Point to test.

Returns

boolean

True if the point is inside the AABB and false otherwise.

getMax()

Return the maximum corner of the AABB.

Returns

pc.Vec3

Maximum corner.

getMin()

Return the minimum corner of the AABB.

Returns

pc.Vec3

Minimum corner.

intersects(other)

Test whether two axis-aligned bounding boxes intersect.

Parameters

otherpc.BoundingBox

Bounding box to test against.

Returns

boolean

True if there is an intersection.

intersectsBoundingSphere(sphere)

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

Parameters

spherepc.BoundingSphere

Bounding Sphere to test.

Returns

boolean

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

intersectsRay(ray, [point])

Test if a ray intersects with the AABB.

Parameters

raypc.Ray

Ray to test against (direction must be normalized).

pointpc.Vec3

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

Returns

boolean

True if there is an intersection.

setFromTransformedAabb(aabb, m)

Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.

Parameters

aabbpc.BoundingBox

Box to transform and enclose.

mpc.Mat4

Transformation matrix to apply to source AABB.