How gkjohnson/three-mesh-bvh works
three-mesh-bvh is a three.js spatial-query library. Its principal workflow is to build a BVH over geometry, attach or construct it for an object, then accelerate raycasting or perform direct spatial queries. It also supports specialized primitive and scene hierarchies, asynchronous worker generation, WebGL/WebGPU integrations, and utilities for inspection and geometry preparation. The graph follows documented relationships and sampled imports/calls; several unsampled subsystems are included as capabilities documented by the README, without guessing their internal wiring.
Main entry points: MeshBVH.js Mesh BVH · index.js Public API · GeometryBVH.js Geometry BVH · BVHComputeData.js WebGPU Compute Data
Components 22
BVH Core
- Public API
src/index.js - Packed BVH
src/core/BVH.js - Geometry BVH
src/core/GeometryBVH.js - Mesh BVH
src/core/MeshBVH.js - Node Layout
src/core/utils/nodeBufferUtils.js
Geometry Queries
- Triangle Math
src/math/ExtendedTriangle.js - Lines and Points
src/core/LineBVH.js - Skinned Mesh BVH
src/core/SkinnedMeshBVH.js - Object BVH
src/core/ObjectBVH.js
Integrations
- Worker API
src/workers/ParallelMeshBVHWorker.js - Worker Lifecycle
src/workers/utils/WorkerBase.js - Worker Builder
src/workers/parallelMeshBVH.worker.js - Three.js Extensions
src/utils/ExtensionUtilities.js
GPU Acceleration
- WebGL BVH Textures
src/webgl/VertexAttributeTexture.js - WebGL Uniforms
src/webgl/MeshBVHUniformStruct.js - WebGPU Compute Data
src/webgpu/BVHComputeData.js - WebGPU Query Functions
src/webgpu/shapecastFns/getShapecastFn.js
Tools
- BVH Inspection
src/debug/Debug.js - BVH Helper
src/objects/BVHHelper.js - Static Geometry
src/utils/StaticGeometryGenerator.js - Triangle Utilities
src/utils/TriangleUtilities.js
Other components
- three.js App
Connections 32
- three.js App → Public API: imports
README.md - Public API → Mesh BVH: exports
src/index.js - Public API → Geometry BVH: exports
src/index.js - Public API → Lines and Points: exports
src/index.js - Public API → Object BVH: exports
src/index.js - Public API → Skinned Mesh BVH: exports
src/index.js - Public API → Three.js Extensions: exports
src/index.js - Geometry BVH → Packed BVH: extends
src/core/GeometryBVH.js - Mesh BVH → Geometry BVH: extends
src/core/MeshBVH.js - Packed BVH → Node Layout: decodes nodes
src/core/BVH.js - Mesh BVH → Triangle Math: uses triangle math
src/core/MeshBVH.js - Mesh BVH → Triangle Utilities: sets triangles
src/core/MeshBVH.js - Skinned Mesh BVH → Geometry BVH: extends
src/core/SkinnedMeshBVH.js - Object BVH → Packed BVH: uses hierarchy
src/core/ObjectBVH.js - three.js App → Mesh BVH: builds BVH
README.md - three.js App → Mesh BVH: raycasts
README.md - Worker API → Worker Lifecycle: inherits lifecycle
src/workers/ParallelMeshBVHWorker.js - Worker API → Worker Builder: dispatches build
src/workers/ParallelMeshBVHWorker.js - Worker Builder → Mesh BVH: creates proxy BVH
src/workers/parallelMeshBVH.worker.js - Worker Builder → Geometry BVH: generates indirect buffer
src/workers/parallelMeshBVH.worker.js - WebGL Uniforms → Mesh BVH: packs BVH
src/webgl/MeshBVHUniformStruct.js - WebGL Uniforms → WebGL BVH Textures: creates textures
src/webgl/MeshBVHUniformStruct.js - WebGPU Compute Data → Mesh BVH: consumes BVH
src/webgpu/BVHComputeData.js - WebGPU Compute Data → Skinned Mesh BVH: consumes BVH
src/webgpu/BVHComputeData.js - WebGPU Query Functions → WebGPU Compute Data: uses compute data
src/webgpu/shapecastFns/getShapecastFn.js - BVH Inspection → Packed BVH: inspects hierarchy
src/debug/Debug.js - BVH Helper → Mesh BVH: visualizes bounds
src/objects/BVHHelper.js - BVH Helper → Geometry BVH: reads bounds
src/objects/BVHHelper.js - three.js App → Object BVH: queries scene
README.md - three.js App → Worker API: generates asynchronously
README.md - three.js App → WebGL Uniforms: uses GPU data
- three.js App → WebGPU Compute Data: uses compute API