BatchedMesh 1 milion instances using a BVH

Hi guys, I added to my npm package @three.ez/batched-mesh-extensions an extension to create and use a BVH to speed up raycasting and frustum culling of BatchedMesh.

Here is the example (should runs smooth on mobile too):

Repository:

9 Likes

can this be used with GitHub - gkjohnson/three-mesh-bvh: A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes. ? i already have the bvh on my meshes

1 Like

Hi @arpu, thanks for asking! :grin:

three-mesh-bvh creates a BVH to store the geometry triangles (useful for complex geometries).
My library instead creates a BVH to store the bounding boxes (AABB) of all instances (useful for a lot of instances).

The two BVHs work perfectly together.

My bvh filters out the instances (avoiding iterating them all) that need to be checked using the bvh of three-mesh-bvh.

I helped @gkjohnson to implement BatchedMesh support of three-mesh-bvh, so I more or less know how it works (my BVH implementation is based also on his work).

There is just one small complication: both libraries override the BatchedMesh.raycast method, so to make them compatible I will have to make some additional changes.

So at the moment they are not compatible, but they will be soon :heart:.

6 Likes

Hi!

I updated the library. It’s now compatible with three-mesh-bvh and the WebGPURenderer :partying_face:

4 Likes