A Bounding Volume Hierarchy (BVH) implementation to accelerate raycasting and spatial queries for three.js meshes.
three-mesh-bvh is a JavaScript library that implements a Bounding Volume Hierarchy (BVH) data structure for three.js geometries. It solves the performance problem of raycasting against complex 3D meshes by organizing geometry into a hierarchical tree, enabling fast spatial queries and intersection tests. This is crucial for applications requiring real-time interaction, physics, or advanced rendering like path tracing.
three.js developers building interactive 3D applications, games, simulations, or rendering engines that require efficient raycasting, collision detection, or spatial querying against complex geometry.
Developers choose three-mesh-bvh because it provides a production-ready, highly optimized BVH implementation specifically designed for three.js, with a simple API that integrates seamlessly into existing workflows while offering advanced features like asynchronous generation, serialization, and support for various geometry types.
A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Dramatically speeds up ray-mesh intersection tests, enabling real-time interactions with complex models, as shown in examples handling 500 rays against 80,000 polygons at 60fps.
Supports sphere casting, shape casting, and distance queries beyond basic raycasting, enabling collision detection and spatial analysis for games and tools.
Provides specialized BVHs for Points, Lines, SkinnedMesh, BatchedMesh, and more, catering to diverse three.js use cases with tailored implementations.
Allows BVH construction in Web Workers to avoid blocking the main thread and enables saving/loading precomputed BVHs for efficient asset management.
The BVH is not dynamic, making it unsuitable for geometry with morph targets or skinning without manual refitting, which can be cumbersome for animated scenes.
Async generation has inconsistent support across bundlers, often requiring manual code adjustments or copying from source, as admitted in the README.
BVH types like SkinnedMeshBVH and ObjectBVH are recently added with APIs that may change, leading to potential maintenance issues.