Skip to content

Documentation / @ripl/3d / rayIntersectTriangle

Function: rayIntersectTriangle() ​

rayIntersectTriangle(ray, a, b, c): RayTriangleHit | null

Defined in: 3d/src/math/ray.ts:63

Intersects a ray with a triangle using the Möller–Trumbore algorithm.

Both facings are reported rather than culled, because a Shape3D's faces carry whatever winding their author emitted and rejecting on it would silently miss geometry. Callers that want front-facing hits only can filter on RayTriangleHit.backFacing.

Parameters ​

ParameterTypeDescription
rayRayThe ray to cast.
aVector3The triangle's first vertex.
bVector3The triangle's second vertex.
cVector3The triangle's third vertex.

Returns ​

RayTriangleHit | null

The hit, or null when the ray misses, is parallel, or would hit behind its origin.