Skip to content
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

Orphaned Triangles After Operation #183

Closed
JakeDluhy opened this issue Dec 1, 2023 · 6 comments · Fixed by #184
Closed

Orphaned Triangles After Operation #183

JakeDluhy opened this issue Dec 1, 2023 · 6 comments · Fixed by #184
Labels
bug Something isn't working
Milestone

Comments

@JakeDluhy
Copy link

JakeDluhy commented Dec 1, 2023

I believe this may be related to #182, as it may explain the larger bounding box. I am exploring using three-bvh-csg with React and have built up a scene where I extrude a shape and then cut off the bottom (don't get me started on extrude geometry not having a single side option). It looks great:
Screenshot 2023-12-01 at 10 40 30 AM

I also want to export to an STL, however when I do that there are some weird things that show up. In short, when I add it to blender I am able to see the issue:
Screenshot 2023-12-01 at 10 38 01 AM

There are some orphaned triangles in a very weird way. It kind of looks like they're in the shape of a projection of the first object (extruded shape) onto the second one (a large box geometry underneath). Here's another example:
Screenshot 2023-12-01 at 9 05 28 AM

I created a minimal reproduction using just JS here: https://codepen.io/jakedluhy/pen/YzBJgPp. I didn't create an actual THREE scene, since the scene itself looks fine. Let me know if you would like me to add that.

EDIT: One more detail - all of those orphaned triangles all have the exact same point for the vertices

@gkjohnson
Copy link
Owner

Thanks for the details!

I didn't create an actual THREE scene, since the scene itself looks fine. Let me know if you would like me to add that.

It would be useful to add a simple scene with a bounding box to inspect the issue more easily.

@JakeDluhy
Copy link
Author

Ok I retooled the example with a scene and a bounding box: https://codepen.io/jakedluhy/pen/YzBJgPp?editors=0010

Unfortunately the zoom/dolly isn't working for the controls (I think because there's a multiple versions of THREE.js issue due to weird Codepen imports). Let me know if you need anything else!

@gkjohnson gkjohnson added the bug Something isn't working label Dec 4, 2023
@gkjohnson gkjohnson added this to the v0.0.14 milestone Dec 4, 2023
@gkjohnson
Copy link
Owner

gkjohnson commented Dec 4, 2023

Yes looks like there are extra points being added:

image

The same thing seems to happen with ADDITION and DIFFERENCE:

image

There are no extra points with INTERSECTION, though:

image

Commenting out the first performSplitTriangleOperations removes the excess points so there may be a bug in that section of code. So this at least helps narrow down which point in the operation these points are being generated from. I'll have to dig in more later

@gkjohnson
Copy link
Owner

It looks like this has been happening all the way back to v0.0.3 (didn't check earlier versions) with the SUBTRACTION operation.

However with the ADDITION operation this only started happening in v0.0.12. The extra points were not present in v0.0.11.

@gkjohnson
Copy link
Owner

It looks like this is occurring because the provided geometry contains degenerate triangles with an area of 0, 0, 0 causing the barycoordinate calculations to be incorrect. I think by some measures this may be at odds with the idea that a geometry needs to be watertight / two-manifold but this shouldn't be too big of an issue to handle.

@JakeDluhy
Copy link
Author

Thanks so much for jumping on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants