Three-mesh-bvh: A plugin for fast geometry raycasting and spatial queries!

The three-gpu-pathtracer project built on three-mesh-bvh has just had it’s initial release! It now supports a new slew of material properties including transmission, specular, metalness, and more! There’s still a lot more progress to be made. I made a separate thread here with more project details -

image

6 Likes

v0.5.10 of three-mesh-bvh has just been released! This version adds a utility called StaticGeometryGenerator for baking and merging skinned and morph target meshes into static geometry so a BVH can be built. Pathtraced skinned geometry coming soon? :eyes:

Demo here: Skinned Mesh BVH Demo

ezgif-2-73938c8a33

7 Likes

I’ve just added a new demo that demonstrates how to generate projected, triangle-clipped geometry edges onto a plane to produce a line geometry - accelerated using the BVH! Each potential edge is clipped by the triangles above it to produce the visible portion that would be seen from above. This could be useful for generating 2d, line vectorized versions of geometry for things like mechanical drawings or object footprints for floor plans. Using the BVH here speeds up the search for triangles by multiple orders of magnitude to keep things updating quickly!

Here’s the demo!

https://gkjohnson.github.io/three-mesh-bvh/example/bundle/edgeProjection.html

And of course some screenshots:

13 Likes

Unbelievable! I’m speechless. :drooling_face:

That is so dope!

Hello @gkjohnson,
Thanks for this great sharing, the performance is so great.

I am trying to integreate your lasso selection feature into my platform, but my project does not use typescript, is there a library that can be included directly to use the function such as MeshBVH shapecast?

Thanks and look forward your replay.

Best regards
Kun-Yao

Typescript is not required for three-mesh-bvh so you can use this package and the shapecast function.

3 Likes

Dude, you do some incredible stuff. Nice work!

1 Like

There have been some really awesome projects getting coming out over the last few weeks that all use three-mesh-bvh from our own @N8Three, @drcmda, and @_LucasJones on Twitter! With a shader-based raytracing we can start to see som NVidia RTX-like rendering capabilities being applied in the browser especially with these shadow and gem rendering projects. Looking forward to seeing what’s next!

 

A beautiful diamond material modeling internal reflection with path tracing

A collaborative effort between N8Three and drcmda

 

Bent normal generation for specular occlusion

 

An amazing lightmap baking project

5 Likes

Revision v0.5.18 of three-mesh-bvh has been published! The big addition in this release is the ability to perform closest point-to-point queries against the BVH on the GPU in addition to a new demo showing how to generate and raymarch render a signed distance field into a 3d texture! Signed distance fields can be used for a variety of things including rendering implicit surfaces, particle animation, lighting effects, and more!

SDF Demo Here!

Rendering the SDF via Raymarching

Grid of SDF Texture Layers

Animated SDF Texture Layers

3 Likes

I am using a raycaster to hide and show the markers and use Three-mesh-bvh, but for this model with or without it I get the same frame rate which is very low and I am using only three makers, the more I add the worse it performs, is there something wrong with the model, or what is happening?

The performance is bad but it happens only with this model, other models that I tried work perfectly.

https://webdesign-flash.ro/p/emv/

This thread isn’t intended for questions. Please make a new thread and provide a live editable demo of what you’re having issues with.

I apologize, I was not aware of that, I will create a separate thred.

It’s been awhile since an update post but I’ve just released v0.7.1 of three-mesh-bvh. There have been quite a few other releases that focus primarily on fixes and features for “three-gpu-pathtracer” and “three-bvh-csg”, such as a new “indirect” flag that allows you to generate a BVH without generating or modifying the geometry index buffer.

The big improvement for this release, though, is the addition of a new “ParallelMeshBVHWorker” which allows for parallelizing the generation of a BVH using WebWorkers and SharedArrayBuffers. Depending on the BVH the settings you can see significant improvement in the time to generate a worker. Using the default “CENTER” BVH split strategy you’ll see over 2x speed improvement, and when using SAH you can see over 4x speed improvement during build. On my machine building a complex SAH BVH goes from a main-thread blocking 11 seconds to to an asynchronous, non-blocking operation that takes under 3 seconds.

You can see the demo showing the parallelized generation here!

5 Likes

Thanks again for all the upgrades.
I’m currently testing how the plugin fare as specific/dedicated physics engine and it’s far beyond my expectations. And by that I mean, black-magic-sorcery-level kind of results :+1:

3 Likes

Awesome plugin, I used it to check collision between 2 Mesh with random shape.
It’s work. But now I want to slide the box selecting when they collision(other way, they cannot overlap)
I used intersectsGeometry to check collision. If true, I prevent drag mode.
Is there any way to the box selecting(yellow box) keep moving outside of anther object(means: not overlap to blue-yellow box in my ex).
Thank for your help~
Expected - Keep moving outside of other box after collision
Expected - Keep moving outside of other box after collision

There’s no way to do this out of the box - please make a dedicated thread if you’d like guidance on how to implement it.

2 Likes

Yeah, I got it, Thank U~

Hello @gkjohnson , the face selection is not working for orthographic camera…, here is the example i am talking about three-mesh-bvh - Geometry Collect Triangles

Hi @gkjohnson . Thank you for awesome plugin.
Casting a raycaster from the position of object1 to the position of object2 and finding the collision point is great for Meshes with basic shapes. However, for Meshes with complex shapes, how can I find the collision point? I have tried searching but haven’t found a solution yet. Am I missing something?