GitPedia
gkjohnson

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
gkjohnsongkjohnson·1mo ago·May 13, 2026
GitHub

🐛 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
gkjohnsongkjohnson·3mo ago·March 3, 2026
GitHub

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
gkjohnsongkjohnson·4mo ago·January 28, 2026
GitHub

📋 Changed

  • Added deprecation warning when using "intersectsTriangle" without casting boundsTree.

🐛 Fixed

  • "onProgress" function not broadcasting percentages correctly.

Added

  • "ObjectBVH" to examples.
v0.9.7
gkjohnsongkjohnson·4mo ago·January 17, 2026
GitHub

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
gkjohnsongkjohnson·5mo ago·January 15, 2026
GitHub

🐛 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
gkjohnsongkjohnson·5mo ago·January 8, 2026
GitHub

Added

  • Support for PointsBVH, LineBVH, LineSegmentsBVH, LineLoopBVH.

🐛 Fixed

  • Removed unnecessary PURE annotation.
  • Fixed typing
v0.9.4
gkjohnsongkjohnson·5mo ago·December 18, 2025
GitHub

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
gkjohnsongkjohnson·6mo ago·December 1, 2025
GitHub

🐛 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
gkjohnsongkjohnson·7mo ago·October 24, 2025
GitHub

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
gkjohnsongkjohnson·11mo ago·June 20, 2025
GitHub

🐛 Fixed

  • Type definitions
v0.9.0
gkjohnsongkjohnson·1y ago·January 21, 2025
GitHub

📋 Changed

  • Changed "bvhClosestPointToPoint" function signature to include "maxDistance" argument.
v0.8.3
gkjohnsongkjohnson·1y ago·November 11, 2024
GitHub

🐛 Fixed

  • Library not working with BatchedMesh in three.js r170.
v0.8.2
gkjohnsongkjohnson·1y ago·October 1, 2024
GitHub

🐛 Fixed

  • Unnecessarily large triangle bounds buffer used during BVH construction.
v0.8.1
gkjohnsongkjohnson·1y ago·September 29, 2024
GitHub

🐛 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
gkjohnsongkjohnson·1y ago·September 18, 2024
GitHub

🐛 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
gkjohnsongkjohnson·1y ago·September 11, 2024
GitHub

🐛 Fixed

  • Failure with older versions of three.js in some bundlers.
v0.7.7 (Deprecated)v0.7.7
gkjohnsongkjohnson·1y ago·September 9, 2024
GitHub

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
gkjohnsongkjohnson·1y ago·July 20, 2024
GitHub

🐛 Fixed

  • Regression when intersecting InstancedMesh instances.
v0.7.5
gkjohnsongkjohnson·2y ago·June 2, 2024
GitHub

📋 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
gkjohnsongkjohnson·2y ago·April 10, 2024
GitHub

📋 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
gkjohnsongkjohnson·2y ago·February 20, 2024
GitHub

🐛 Fixed

  • StaticGeometryGenerator, VertexAttributeTexture now support empty geometry.
v0.7.2
gkjohnsongkjohnson·2y ago·February 13, 2024
GitHub

🐛 Fixed

  • MeshBVHHelper not updating correctly

Added

  • StaticGeometryGenerator now inverts geometry winding order when a mesh uses negative scales.
v0.7.1
gkjohnsongkjohnson·2y ago·January 30, 2024
GitHub

🐛 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
gkjohnsongkjohnson·2y ago·January 15, 2024
GitHub

📋 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
gkjohnsongkjohnson·2y ago·October 8, 2023
GitHub

📋 Changed

  • Small performance improvements to bvhcast function (up to ~10%).
v0.6.7
gkjohnsongkjohnson·2y ago·September 7, 2023
GitHub

🐛 Fixed

  • GPU function parameters to fix undefined behavior on some platforms.
v0.6.6
gkjohnsongkjohnson·2y ago·September 3, 2023
GitHub

🐛 Fixed

  • Case where indirect buffer with no index failed to raycast.
v0.6.5
gkjohnsongkjohnson·2y ago·August 30, 2023
GitHub

Added

  • Added support for draw range so the BVH now implicitly respects the start and end range specified in the geometry.
v0.6.4
gkjohnsongkjohnson·2y ago·August 28, 2023
GitHub

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
gkjohnsongkjohnson·2y ago·July 22, 2023
GitHub

🐛 Fixed

  • Fixed another triangle / triangle intersection failure case.
  • Type declaration and documentation for shapecast function.