-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
MeshVolume exploration #32237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
MeshVolume exploration #32237
Conversation
…rt, function or class Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rt, function or class Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rt, function or class Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| // Check if the point is inside or outside by raycasting | ||
| // Skip expensive raycasts for points far from surface (definitely outside) | ||
| let isInside = false; | ||
|
|
||
| if ( dist < this.margin ) { | ||
|
|
||
| // If we hit a back face then we're inside | ||
| let insideCount = 0; | ||
| ray.origin.copy( point ); | ||
|
|
||
| for ( let i = 0; i < 6; i ++ ) { | ||
|
|
||
| ray.direction.copy( directions[ i ] ); | ||
| const hit = bvh.raycastFirst( ray, DoubleSide ); | ||
| if ( hit && hit.face.normal.dot( ray.direction ) > 0.0 ) { | ||
|
|
||
| insideCount ++; | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| isInside = insideCount > 3; | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that checking "insidedness" can only really reliably work if the source model is water tight - has no intersecting triangles, etc. Otherwise you might get an odd pos / neg pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know!
| break; | ||
| } | ||
|
|
||
| float stepSize = distanceToSurface * 0.5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why halve the step to the surface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure!
Without it the render would get that near clipping artifact:
https://x.com/mrdoob/status/1987814636306198581

Description
I was always curious to see how would it be to convert a mesh into a SDF 3D texture and then render it using
MeshStandardMaterial. Finally gave it a try today.Screen.Recording.2025-11-10.at.9.41.24.PM.mov