Documentation / @ripl/3d / rayIntersectTriangleBuffer
Function: rayIntersectTriangleBuffer() ​
rayIntersectTriangleBuffer(
ray,vertices,offsetA,offsetB,offsetC):number
Defined in: 3d/src/math/ray.ts:117
Intersects a ray with a triangle read straight out of a packed vertex buffer.
The same Möller–Trumbore solve as rayIntersectTriangle, written against three flat offsets and scalars. That version allocates five vectors per triangle, which a pointer move over a mesh of a few thousand triangles turns into tens of thousands of short-lived objects; this one allocates nothing, at the cost of reporting only the distance.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
ray | Ray | The ray to cast. |
vertices | Float64Array | World-space vertex components, three floats per vertex. |
offsetA | number | Index into vertices of the triangle's first vertex. |
offsetB | number | Index into vertices of the triangle's second vertex. |
offsetC | number | Index into vertices of the triangle's third vertex. |
Returns ​
number
The distance along the ray, or -1 when the ray misses, is parallel, or would hit behind its origin.