three.js
What @pmndrs/bvh/three gives a three.js app, on the GPU and on the CPU.
@pmndrs/bvh/three is the only part of the package that imports three. three is an optional peer dependency, pinned to
>=0.187.0 <0.188.0: BvhTraceNodes relies on three's WebGPU backend internals, so each three release is checked
before the range widens.
On the GPU (WebGPURenderer)
On the CPU (any renderer)
Coming from three-mesh-bvh? The mapping and what's missing.
Types
/three augments three's types as three-mesh-bvh does: BufferGeometry.boundsTree (a BvhBoundsTree),
computeBoundsTree, disposeBoundsTree and Raycaster.firstHitOnly, so the setup needs no casts. A program that
imports both libraries gets two declarations of the geometry members with different types (TS2717); skipLibCheck,
on in most templates, hides it.
Not supported
- WebGL2:
BvhTraceNodesneeds the WebGPU backend. The CPU raycast works with either backend. - Points, lines and sprites are not read by the scene sync, the GPU walk or the scene raycast, which take triangles. Points and lines have their own CPU trees (Points and lines); sprites have none.
- Layers 8-31 are not seen: the instance mask holds layers 0-7.