# three-mesh-bvh/webgpu: Constants

## TSL Functions

### closestPointToTriangle: FunctionNode

WGSL function node that finds the closest point on a triangle to `p` and returns the barycoord.

### intersectRayTriangle: FunctionNode

WGSL function node that tests a ray against a single triangle and returns an
`rayIntersectionResultStruct` result. Useful when writing a custom `intersectRangeFn`
for `BVHComputeData#getShapecastFn`.

### ndcToCameraRay: FunctionNode

WGSL function node that builds a camera ray (origin + far-plane direction) from an NDC
coordinate and an inverse model-view-projection matrix. Works for both perspective and
orthographic projections. The origin sits on the near plane, the returned direction is
normalized, and "maxDist" is the world-space distance to the far plane so traversal
clips there.

## TSL Structs

### rayStruct: StructTypeNode

WGSL struct node representing a ray with an origin, direction, and maximum trace distance.
Used as the input to BVH traversal and intersection functions. Traversal ignores hits at or
beyond "maxDist", and a value of 0 (the zero-initialized default) means unbounded.

### rayIntersectionResultStruct: StructTypeNode

WGSL struct node describing a ray–triangle intersection result, including barycentric
coordinates, world-space normal, hit distance, face side, triangle indices, and the
object index within the TLAS.

### pointQueryResultStruct: StructTypeNode

WGSL struct node describing a closest-point query result, including the world-space
closest point, squared distance, barycentric coordinates, face normal, side, triangle
indices, and the object index within the TLAS.

Barycoord convention matches `rayIntersectionResultStruct`: `(bary_a, bary_b, bary_c)`
where each component is the weight for the corresponding vertex in `faceIndices.xyz`.
