All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- 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.
- BVHHelper: Handled case where the a root object does not have geometry.
- 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
- Added deprecation warning when using "intersectsTriangle" without casting boundsTree.
- "onProgress" function not broadcasting percentages correctly.
- "ObjectBVH" to examples.
- BVH: Added support for "bvhcast" callback
- BVHHelper: Rename "objectIndex" to "instanceId"
- BVHHelper: Enable "instanceId" to be set to - 1 to ignore the instance transform.
- MeshBVH: deprecated "maxLeafTris" option in favor of "maxLeafSize".
- MeshBVHHelper: deprecated class in favor of "BVHHelper".
- BVH: Changed internal shapecast callbacks
- 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.
- PointsBVH, LineBVH, LineLoopBVH, LineSegmentsBVH: Added support for "refit" function.
- SkinnedMeshBVH for skinned meshes or morph target meshes to the examples directory.
- Support for PointsBVH, LineBVH, LineSegmentsBVH, LineLoopBVH.
- Removed unnecessary PURE annotation.
- Fixed typing
- Docs for bvhcast function.
- More usage of "PURE" annotations.
- Added "version" field to serialized data.
- Add support for "shiftTriangleOffsets" function.
- 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.
- Fixed dependencies on WebGPURenderer compute nodes.
- Fixed MeshBVH.bvhcast passing "NaN"
nodeIndexvalues 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.
- 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.
- 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.
- Type definitions.
- Changed "bvhClosestPointToPoint" function signature to include "maxDistance" argument.
- Library not working with BatchedMesh in three.js r170.
- Unnecessarily large triangle bounds buffer used during BVH construction.
- 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.
- Updated three.js version to r158 where BatchedMesh is supported and available so certain bundlers do not fail on build.
deprecated due to three.js version incompatibility. Use v0.8.0.
- Failure with older versions of three.js.
deprecated due to three.js version incompatibility. Use v0.8.0.
- 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.
- Bug in
MeshBVH.bvhcastcausing the incorrect bounds to be checked on the other bvh. - Box3.setFromObject failing when MeshBVHHelper is included.
- Regression when intersecting InstancedMesh instances.
- Respect
Raycaster.nearandRaycaster.farduring raycast traversal, improving performance.
- The
resolveTriangleIndexthrowing an error when deserializing anindirectBVH.
- Improved raycasting performancy by ~20% by avoiding use of the "arrayToBox" function internally.
- 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
onProgresscallback.
- StaticGeometryGenerator, VertexAttributeTexture now support empty geometry.
- MeshBVHHelper not updating correctly
- StaticGeometryGenerator now inverts geometry winding order when a mesh uses negative scales.
- 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
validateBoundsfunction not accounting for the use of the "indirect" option.
- Added new "ParallelMeshBVHWorker" that parallelizes MeshBVH generation across multiple WebWorkers. Falls back to a single threaded approach if SharedArrayBuffer is not supported.
MeshBVHVisualizerhas been deprecated and renamedMeshBVHHelperto align with three.js' conventions.MeshBVHHelperconstructor now optionally takes a bvh.- Organization of shader GLSL snippets. They are now grouped into the
BVHSShaderGLSLobject. Backwards compatible glsl snippets are provided for now but it's recommended to use the new location.
MeshBVHHelperwill now display correctly regardless of parent in hierarchy.MeshBVHHelper.copynow correctly copies opacity, color.
- Small performance improvements to bvhcast function (up to ~10%).
- GPU function parameters to fix undefined behavior on some platforms.
- Case where indirect buffer with no index failed to raycast.
- Added support for draw range so the BVH now implicitly respects the start and end range specified in the geometry.
- 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 estimateMemoryInBytes not testing for SharedArrayBuffers resulting in a smaller memory footprint.
- Fixed bug in "intersectsGeometry" function.
- 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.
- Fixed another triangle / triangle intersection failure case.
- Type declaration and documentation for shapecast function.
- Fixed triangle / triangle intersection failure case.
- The root bounding box incorrectly including the origin causing an extra large bounds for shift geometry.
- Bumped minimum required three.js version to v0.151.0
- MeshBVH Worker error when incorrectly transferring shader array buffers.
- Case where raycasting would not work if uvs are not present.
- Support to suppress logs in
ExtendedTriangle.intersectsTriangle.
- Removed use of optional chaining.
- Diff support to
StaticGeometryGeneratorso only changed meshes and skinned meshes are updated in order to improve performance on subsequent updates.
- StaticGeometryGenerator: now correctly only traverses and includes visible meshes.
- Support for distance queries on the GPU.
- Case in triangle intersect function that would incorrectly report an intersection.
- Case in new three.js that caused the vertex texture to work incrrectly.
- Removed incomplete and incorrect Box3 inheritance from OrientedBox.
- Adde
minandmaxto typescript definition for OrientedBox.
- Support for normalized vertex attributes.
- Removed deprecated
MeshBVHfunction signatures forraycast,raycastFirst,closestPointToPoint,closestPointToGeometry,refit,intersectsGeometry,shapecast,intersectsBox,intersectsSphere.
- single point intersection in
intersectsTrianglefunction. - issue in the
closestPointLineToLinefunction.
- ExtendedTriangle: Fix Another case where IntersectsTriangle failed
- ExtendedTriangle: Fix Another case where IntersectsTriangle failed
- MeshBVHVisualizer: not removing child roots on update.
- ExtendedTriangle: Fix intersection not being reported when triangles intersect at vertex.
- MeshBVH.bvhcast: Fix bvhcast using incorrect bounds to traverse.
- "global" unnecessarily being used in the web worker.
- GenerateMeshBVHWorker.generate: reject when class has been disposed of or error is thrown in worker.
- GenerateMeshBVHWorker: ensure the root array buffers ate transfered when finishing construction.
StaticGeometryGeneratorto enable skinned and morph target mesh support.
- Incorrect return type for
computeBoundsTree.
- Improved type definitions.
- GenerateMeshBVHWorker: Added "dispose" function. Deprecated "terminate" function.
- WebWorker BVH generation not accounting for geometry groups.
- Export and document "OrientedBox" and "ExtendedTriangle" classes for more clarity and enable use of internal mathematical functions.
- Case where
MeshBVH.closestPointToGeometrywould return an incorrect value. - Automatically dispose of textures on update instead of just "needsUpdate".
- Case where
SeparatingAxisTriangle.intersectsTrianglewould return incorrect intersection lines. Performance of the function improved as a side effect.
onProgresscallback now always reports1.0when the BVH creation is complete instead of just passing intermmediate progress.
- Removed use of
RGBFormatandRGBIntegerFormatfor compatibility with three.js r137.
- Improved SAH build time by ~20% by checking every triangle split once fewer than 8 triangles are present which also improves the split cost.
- GenerateMeshBVHWorker / MeshBVH: Add
onProgresscallback option to enable the ability to display BVH build percentage.
- MeshBVH.bvhcast incorrectly using the same geometry for both bvh.
shapecastandbvhcasttypes to be more correct.
- src/utils incorrectly being published as src/Utils in the previous release.
- Typescript definition files.
VertexAttributeTexture,BVHStructUniform, and associated helper shader functions for performing raytracing in a fragment shader.- Warning when passing in an unknown split strategy option value.
src/workers/GenerateMeshBVHWorkerto use a proper webworker syntax compatible with esm-capable bundlers.
useSharedArrayBufferoption toMeshBVHsoSharedArrayBuffersare created rather thanArrayBuffersmaking it easier to share and reuse BVH memory across workers.- SeparatingAxisTriangle.intersectsTriangle: added
targetfield to retrieve the edge describing the intersection. - "box" argument to shapecast "intersectsRange" function.
/* @__PURE__ */indicator to reusable variables.
raycastandraycastFirstnot properly accounting for material sidedness with geometry groups.- Case where the BVH root bounds would be incorrect if the geometry bounding box was incorrect / out of date.
- MeshBVH.closestPointTGeometry not returning a proper intersection point if triangles intersect.
- Shapecast function will now ensure a unique triangle / box is provided for each recursive call.
- Fix
GenerateMeshBVHWorkernot setting the geometry index correctly on return.
- Changed function signature for
intersectsGeometry,shapecast,intersectsBox,intersectsSphere,closestPointToGeometry,closestPointToPoint,raycast, andraycastFirst. Specifically at least the first "mesh" argument has been removed. Calling functions with the old signature will log a warning. See documentation for current signatures. raycastandraycastFirstnow return hits in the local space of the geometry rather than world space when querying the BVH directly to conform with other cast functions. Results still match three.js' original results when usingRaycaster.intersectObject(s)functions. See documentation for more details.MeshBVHDebugclass has been removed and the functiongetJSONStructureandvalidateBoundsare now exported individually.- Small observed performance improvements possibly a result of simplified function arguments.
- The function signatures and options for
MeshBVH.serializeandMeshBVH.deserializehave changed. See documentation for more new signature. - Changed
refitfunction to take just a single argument with traversed node indices. Calling the function with the old signature will log a warning. See documentation for current signature.
distanceToGeometryanddistanceToPointfunctions.
- Fixed Surface Area Heuristic (SAH) split strategy to function correctly, improve build performance, and produce more optimal bounds and improved a memory footprint.
- Return "surfaceAreaCost" in returned
getBVHExtremesobject to compare BVH structure quality. - Support for
displayEdges,meshMaterial, andedgeMaterialto MeshBVHVisualizer to enable displaying bounds as solid meshes.
- Deprecated the
getBVHExtremes"total" return value in favor ofnodeCount.
- Case where
intersectsRangeFunccould be passed the incorrect node id in shapecast. - Bug in
distanceToGeometryandclosestPointToGeometrywhich would likely result in some closest points being missed. This fix greatly degrades performance in the case where the passed geometry does not have a BVH. It is recommended that the passed in geometry include a computed bounds tree. - Cases where passed in geometry that did not include an index buffer could throw an error when calling functions like
closestPointToGeometry. - Case where raycastFirst would return the incorrect result.
- Greatly improved
MeshBVHVisualizerrender and update performance. - Case where MeshBVHVisualizer would not correctly display a BVH for geometry with multiple groups.
distanceToGeometryandclosestPointToGeometryfast path when the passed in geometry has a bounds tree.- Support for position BufferAttribute to be interleaved.
- package.json "main" field to use a .cjs file extension
MeshBVH.refitfunction to refit the bounds to modified vertices.setBoundingBoxMeshBVH construction option.MeshBVH.getBoundingBoxfunction.intersectsRangecallback option toMeshBVH.shapecast.
- Removed
src/worker/generateAsync.jsfunction. UseGenerateMeshBVHWorkerinstead. - Use
type: modulein package.json to enable use of es6 modules in node. - Add
sideEffects: falseto package.json. - Remove ability to generate an unpacked BVH.
- Improved "closestPointToPoint" performance slightly.
MeshBVH.shapecastto take an object of callback functions instead of a list of function arguments and the triangle intersection callback has been changed to take a single triangle index. See README for new API. Calls using the old function will log a warning.
MeshBVHVisualizernot using the new geometry BVH if one was generated.MeshBVHVisualizernot using the new mesh if it was set.- Case where passing in null
intersectsTriangleFunctoMeshBVH.shapecastcould throw an error. - Case where the buffer being raycast against was not cleared correctly if a BVH had multiple roots.
- Include built umd file including v0.3.6 changes.
- Incorrect face index would be returned from intersection (related to three.js bug fixed in v0.126.1).
- Case where
raycastFirstfailed to return a valid result.
- Raycast result to return a custom intersection object aligned with three.js v0.126.0.
depthargument tointersectsBoundsFuncandintersectsTriangleFuncofshapecast.- "webvr" and "webxr" tags.
closestPointToSegmentfunction to the triangle object used during shapecast which can be used for capsule intersection detection.
- Case where float 32 rounding error could result in leaf bounds not completely containing the triangles by expanding the bounds by an estimation of the error.
ShapecastintersectsBoundsFuncto return one of theNOT_INTERSECTED,INTERSECTED, orCONTAINEDconstants. Returningtrueandfalsecurrently retains the old functionality.
- Performance improvements when computing distance to geometry.
shapecastto the docs.MeshBVHVisualizerto exports.
- Cloning the bvh visualizer causing an error.
- Bug with shapecast function where one node would not be checked when using the node score function.
- Change the bvh visualizer so it automatically copies the local position and rotation of the target mesh.
generateAsyncfunction in the/src/workerfolder to help generate BVHs asynchronously with WebWorkers.
- three.js version to use v0.123.0, change
Matrix4.getInversetoMatrix4.invert.
- MeshBVH.serialize and deserialize functions so the bvh can be computed and transferred from a webworker.
lazyGeneration(defaults to true) option for faster tree initialization.- Support for a buffer-packed tree if
lazyGenerationis false or a tree has been deserialized for a more smaller memory footprint.
- CENTER tree computation to improve raycast performance and create more balanced trees.
- Uglify warning for inline defined functions.
- Changed three.js peer dependency version from ^ to >= to prevent warnings.
- Use the BufferGeometry bounding box if it exists and set it if it does not.
- Use the center of the triangles bounding box instead of the average of the vertices as the triangles center when binning the polygons.
- Bug where
closestPointToGeometrywould throw an error when target vectors were provided because a function name was misspelled.
- API for performing intersecting boxes, spheres, and geometry.
- API for checking the distance to geometry and points.
- Fixed issue where an index buffer of the incorrect type was created if there were more than 2^16 vertices.
- Fixed MeshBVHVisualizer not visualizing all the groups in the bvh.
- Error conditions when using
InterleavedAttributeBuffersfor both index and position geometry attributes. - The geometry index attribute is modified when building the
MeshBVH. And index attribute is created on geometry if it does not exist.
- Fix the bounds tree not respecting groups
- Add included files array to package.json.