gkjohnson/three-bvh-csg

Possibility of fast evaluation of whether a point lies inside the bound volume

Closed this issue · 1 comments

Is there a way to quickly find whether a point lies inside a mesh with the BVH structure?
The aim is to iterate the vertices of and intersection mesh without actually doing a Boolean operation. If they lie within the mesh then I just need a true or a false.
This would need to be done fast and nearly real time.

This is more related to three-mesh-bvh than CSG. But you can use a raycast to determine whether a point is inside a mesh as long as it's solid and two-manifold. See these lines from the voxelization example:

https://github.com/gkjohnson/three-mesh-bvh/blob/9718501eee2619f1015fa332d7bddafaf6cf562a/example/voxelize.js#L282-L285

// If we hit a face backside we know we're inside the mesh. Alternatively we
// could check if we hit an odd number of faces when checking all intersections.
const res = bvh.raycastFirst( ray, 2 );
if ( res && res.face.normal.dot( ray.direction ) > 0.0 ) {

  // point is inside

}