API Reference

Class List

pc.BoundingBox

Axis-Aligned Bounding Box.

Summary

Methods

addCombines two bounding boxes into one, enclosing both.
containsPointTest if a point is inside a AABB.
getMaxReturn the maximum corner of the AABB.
getMinReturn the minimum corner of the AABB.
intersectsTest whether two axis-aligned bounding boxes intersect.
intersectsBoundingSphereTest if a Bounding Sphere is overlapping, enveloping, or inside this AABB.
intersectsRayTest if a ray intersects with the AABB.
setFromTransformedAabbSet 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.Vec3Center of box. The constructor takes a reference of this parameter.
halfExtentspc.Vec3Half the distance across the box in each axis. The constructor takes a reference of this parameter.

Methods

add(other)

Combines two bounding boxes into one, enclosing both.

Parameters

otherpc.BoundingBoxBounding box to add.

containsPoint(point)

Test if a point is inside a AABB.

Parameters

pointpc.Vec3Point 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.BoundingBoxBounding 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.BoundingSphereBounding 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.RayRay to test against (direction must be normalized).
pointpc.Vec3If 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.BoundingBoxBox to transform and enclose
mpc.Mat4Transformation matrix to apply to source AABB.