gkjohnson/three-mesh-bvh
A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
30 Releases
Latest: 1mo ago
v0.9.10Latest
🐛 Fixed
- MeshBVH: closestPointToGeometry will no longer log warnings for coplanar triangles.
- Updated types.
- Fix internal imports causing types to break in some cases.
v0.9.9
✨ Added
- Add tests for ObjectBVH, SkinnedMeshBVH
- ObjectBVH: Add "getObjectFromId", "getInstanceFromId" functions
- Moved "ObjectBVH" and "SkinnedMeshBVH" to core. These classes are still in development and APIs may change.
📋 Changed
- BVHHelper: Handled case where the a root object does not have geometry.
🐛 Fixed
- ParallelMeshBVHWorker: Fix failure when reporting progress.
- ObjectBVH, SkinnedMeshBVH: Fix raycasting bugs for both classes
- ObjectBVH: Fix case where the first BatchedMesh instance would be skipped
v0.9.8
📋 Changed
- Added deprecation warning when using "intersectsTriangle" without casting boundsTree.
🐛 Fixed
- "onProgress" function not broadcasting percentages correctly.
✨ Added
- "ObjectBVH" to examples.
v0.9.7
✨ Added
- BVH: Added support for "bvhcast" callback
🐛 Fixed
- BVHHelper: Rename "objectIndex" to "instanceId"
- BVHHelper: Enable "instanceId" to be set to - 1 to ignore the instance transform.
📋 Changed
- MeshBVH: deprecated "maxLeafTris" option in favor of "maxLeafSize".
- MeshBVHHelper: deprecated class in favor of "BVHHelper".
- BVH: Changed internal shapecast callbacks
v0.9.6
🐛 Fixed
- BVHHelper: Fix "clone" function not cloning all fields.
- acceleratedRaycast: Fix case where raycasting will fail if "type" is modified.
- Update types.
- WGSL: Fix use of keyword as a variable.
✨ Added
- PointsBVH, LineBVH, LineLoopBVH, LineSegmentsBVH: Added support for "refit" function.
- SkinnedMeshBVH for skinned meshes or morph target meshes to the examples directory.
v0.9.5
✨ Added
- Support for PointsBVH, LineBVH, LineSegmentsBVH, LineLoopBVH.
🐛 Fixed
- Removed unnecessary PURE annotation.
- Fixed typing
v0.9.4
✨ Added
- Docs for bvhcast function.
- More usage of "PURE" annotations.
- Added "version" field to serialized data.
- Add support for "shiftTriangleOffsets" function.
📋 Changed
- Changed the internal storage of child indices from uint32 offsets to node indices. Old serialized data will continue to work via a "fixup" step while logging a warning.
v0.9.3
🐛 Fixed
- Fixed dependencies on WebGPURenderer compute nodes.
- Fixed MeshBVH.bvhcast passing "NaN" `nodeIndex` values to callbacks when more than one group was present.
- Fixed triangles being included in the BVH when they were not included in a groups range (eg exclude triangles in group gaps).
- Ensure "triangle bounds" buffer is limited to the size it needs to be to avoid unnecessary memory overhead.
- Remove limitation preventing "indirect" BVHs from being generated for BatchedMesh instances.
- Raycasting will now return the correct material index aligned with three.js' results including when geometry with overlapping groups are used.
v0.9.2
✨ Added
- Types for web workers.
- Add tsl functions for running bvh raycasting and distance queries via compute shaders.
- Add "three-mesh-bvh/worker" export.
- Add "three-mesh-bvh/webgpu" export.
🐛 Fixed
- Type definitions.
- Case where raycasting results would not match three.js' behavior.
- Case where "intersectsGeometry" would throw an error if a geometry without an index was provided.
- MeshBVHHelper: fix types to align with docs.
- MeshBVHHelper: fix case where "update" causes an error if "mesh" is not provided.
- MeshBVH: Fixed case where generating a bvh for a sub geometry was significantly slower, impacting BatchedMesh generation.
v0.9.1
🐛 Fixed
- Type definitions
v0.9.0
📋 Changed
- Changed "bvhClosestPointToPoint" function signature to include "maxDistance" argument.
v0.8.3
🐛 Fixed
- Library not working with BatchedMesh in three.js r170.
v0.8.2
🐛 Fixed
- Unnecessarily large triangle bounds buffer used during BVH construction.
v0.8.1
🐛 Fixed
- Made example SDF generation logic more robust.
- Adjust the valid the three.js peer dependency.
- Add "barycoord" to the intersection values to align with latest three.js.
v0.8.0
🐛 Fixed
- Updated three.js version to r158 where BatchedMesh is supported and available so certain bundlers do not fail on build.
v0.7.8 (Deprecated)v0.7.8
🐛 Fixed
- Failure with older versions of three.js in some bundlers.
v0.7.7 (Deprecated)v0.7.7
✨ Added
- Support for a custom "range" option to build a BVH from a sub range of the geometry.
- BatchedMesh support for bounds tree generation functions and raycasting. See "computeBatchedBoundsTree" and "disposeBatchedBoundsTree".
- MeshBVHHelper support for InstancedMesh, BatchedMesh.
🐛 Fixed
- Bug in `MeshBVH.bvhcast` causing the incorrect bounds to be checked on the other bvh.
- Box3.setFromObject failing when MeshBVHHelper is included.
v0.7.6
🐛 Fixed
- Regression when intersecting InstancedMesh instances.
v0.7.5
📋 Changed
- Respect `Raycaster.near` and `Raycaster.far` during raycast traversal, improving performance.
🐛 Fixed
- The `resolveTriangleIndex` throwing an error when deserializing an `indirect` BVH.
v0.7.4
📋 Changed
- Improved raycasting performancy by ~20% by avoiding use of the "arrayToBox" function internally.
🐛 Fixed
- ParallelMeshBVHWorker now generates a geometry index if it's required.
- Add support for the "indirect" option to both workers.
- Worker generators not guaranteeing that 100% progress would be fired to the `onProgress` callback.
v0.7.3
🐛 Fixed
- StaticGeometryGenerator, VertexAttributeTexture now support empty geometry.
v0.7.2
🐛 Fixed
- MeshBVHHelper not updating correctly
✨ Added
- StaticGeometryGenerator now inverts geometry winding order when a mesh uses negative scales.
v0.7.1
🐛 Fixed
- Minor case where outside bounds did not have floating point epsilon accounted for which could have resulted in missed intersections at the very edge of the bounds.
- The `MeshBVHHelper( mesh, depth )` constructor not working as expected.
- The `validateBounds` function not accounting for the use of the "indirect" option.
✨ Added
- Added new "ParallelMeshBVHWorker" that parallelizes MeshBVH generation across multiple WebWorkers. Falls back to a single threaded approach if SharedArrayBuffer is not supported.
v0.7.0
📋 Changed
- `MeshBVHVisualizer` has been deprecated and renamed `MeshBVHHelper` to align with three.js' conventions.
- `MeshBVHHelper` constructor now optionally takes a bvh.
- Organization of shader GLSL snippets. They are now grouped into the `BVHSShaderGLSL` object. Backwards compatible glsl snippets are provided for now but it's recommended to use the new location.
🐛 Fixed
- `MeshBVHHelper` will now display correctly regardless of parent in hierarchy.
- `MeshBVHHelper.copy` now correctly copies opacity, color.
v0.6.8
📋 Changed
- Small performance improvements to bvhcast function (up to ~10%).
v0.6.7
🐛 Fixed
- GPU function parameters to fix undefined behavior on some platforms.
v0.6.6
🐛 Fixed
- Case where indirect buffer with no index failed to raycast.
v0.6.5
✨ Added
- Added support for draw range so the BVH now implicitly respects the start and end range specified in the geometry.
v0.6.4
✨ Added
- An experimental "indirect" option to support an indirect triangle sorting for the BVH structure so the geometry index is not adjusted or implicitly generated.
🐛 Fixed
- Fixed estimateMemoryInBytes not testing for SharedArrayBuffers resulting in a smaller memory footprint.
- Fixed bug in "intersectsGeometry" function.
🗑️ Removed
- Removed long deprecated shapecast code path using old function signature.
- Removed long deprecated serialization code path using old function signature.
- Removed long deprecated "terminate" function from web worker class.
v0.6.3
🐛 Fixed
- Fixed another triangle / triangle intersection failure case.
- Type declaration and documentation for shapecast function.
