# three-mesh-bvh/webgpu

```js
import { ... } from 'three-mesh-bvh/webgpu';
```

### Classes

- [BVHComputeData](/tools/docs/three-mesh-bvh/webgpu/BVHComputeData.md): Packs one or more scene objects into GPU-accessible BVH buffers (TLAS + BLAS) for use in WebGPU compute shaders via the Three.js TSL node system. After construction, call `BVHComputeData#update` to populate the storage buffers, then reference `this.storage` and `this.fns` in your compute shader nodes.

### Constants

- [closestPointToTriangle](/tools/docs/three-mesh-bvh/webgpu/constants.md): WGSL function node that finds the closest point on a triangle to `p` and returns the barycoord.
- [intersectRayTriangle](/tools/docs/three-mesh-bvh/webgpu/constants.md): 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](/tools/docs/three-mesh-bvh/webgpu/constants.md): 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.
- [pointQueryResultStruct](/tools/docs/three-mesh-bvh/webgpu/constants.md): 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.
- [rayIntersectionResultStruct](/tools/docs/three-mesh-bvh/webgpu/constants.md): 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.
- [rayStruct](/tools/docs/three-mesh-bvh/webgpu/constants.md): 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.
