gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
623 stars 49 forks source link

T-vertices after subtracting mesh from a plane #202

Closed xavierjs closed 9 months ago

xavierjs commented 9 months ago

Hello,

First, thank you for this library, it is very fast and really good. When I subtract a mesh from a plane to get the plane with a hole matching the mesh clipped shape, I noticed that there are T-vertices.

I use HOLLOW_SUBTRACTION operator. I did a small screenshot video by opening the mesh exported with THREE.GLTFExporter with Blender:

https://github.com/gkjohnson/three-bvh-csg/assets/1659000/675a54eb-bea5-49ed-b3d2-64dc62daf876

However, the generated geometry is right. It is just that the T-vertices make it difficult to compute the contour or to simplify. Is T-vertices removal is on your roadmap? Or there is a way to avoid them?

I am using the v0.0.16 NPM package

Thank you in advance

gkjohnson commented 9 months ago

This is the nature of the current triangle clipping algorithm. Issues https://github.com/gkjohnson/three-bvh-csg/issues/51 and https://github.com/gkjohnson/three-bvh-csg/issues/97 outline some solutions but I have no specific timeline for implementation, if at all. If this is something you're interested in contributing I can point you to the areas of the codebase to start.

xavierjs commented 9 months ago

Hi @gkjohnson Thank you for your reply.

I will work on a small open three.js lib to detect & remove T-vertices. I did some research and I found nothing. It is an issue in some cases for meshes done with your lib, but also in other cases like 3D printing. So I think it is better to do a separate project.

I will post the link here once done.

gkjohnson commented 9 months ago

Sounds great! If you'd like to contribute it this project, as well, I'd be happy to publish this kind post-process retopology step along side the CSG operations as a utility since it's related.

xavierjs commented 8 months ago

Hi @gkjohnson,

I have developed a small lib to remove T-vertices. Here is the link to the Github repo: https://github.com/WebAR-rocks/three-tvert-killer There is an NPM package. It is released under MIT software license. I hope it will be helpful for other folks.