gkjohnson / three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
MIT License
2.39k stars 247 forks source link

worker and geometry groups #392

Closed VegarRingdalAibel closed 2 years ago

VegarRingdalAibel commented 2 years ago

Hi

I just tried to replace geometry.computeBoundsTree() with the workers, but getting weird results when I try and highlight data by using parts of the index groups in merged geometry.

Its like worker does not take into account groups of merged geometry. Or maybe I just have messed up something else 😂

gkjohnson commented 2 years ago

Hi @VegarRingdalAibel! Thanks for the report. Sounds like a bug. Are you interested in submitting a PR with the fix? I think we just need a change in two places. One here to pass a copy of the BufferGeometry.groups object to the web worker:

https://github.com/gkjohnson/three-mesh-bvh/blob/c42bcbe148bad0bd3e0af240b0e5d0325ba5e348/src/workers/GenerateMeshBVHWorker.js#L93-L103

And one around here to assign the groups to the new geometry object:

https://github.com/gkjohnson/three-mesh-bvh/blob/c42bcbe148bad0bd3e0af240b0e5d0325ba5e348/src/workers/generateAsync.worker.js#L32-L38

vegarringdal commented 2 years ago

Did a PR, you can have a look/make edits if you feel something should be changed :-)