gkjohnson / three-bvh-csg

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

Wireframe display occasionally includes "spikes" off of the model #112

Closed gkjohnson closed 1 year ago

gkjohnson commented 1 year ago

Especially with cylinders. Possibly really thin triangles not clipping correctly?

gkjohnson commented 1 year ago

It's likely due to this line:

https://github.com/gkjohnson/three-bvh-csg/blob/3597e272d0ed1573dc60de7aa9a9e83d29576f74/src/core/operationsUtils.js#L115

Specifically

_edge.distance() > 1e-5

effectively skipping clipping if an edge is too short...

gkjohnson commented 1 year ago

It seems these are just very thin triangles and removing the above line does not fix it. Thought it shouldn't be needed:

image image
gkjohnson commented 1 year ago

It seems this is a one sided triangle:

image

And it's unclear whether the "spike" triangle is completely separate or part of a stretch triangle that extends into the model. Should use vertex colors to determine. It's possible these triangles are suffering from a bad normal calculation or a ray landing between triangles:

image
gkjohnson commented 1 year ago

It seems to be a complete triangle:

image

With an "intersection edge" running through it - though it's unclear if the edge belongs to that triangle:

image