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

Add 3D solid model operations #31

Merged
merged 18 commits into from
Jan 28, 2024
Merged

Add 3D solid model operations #31

merged 18 commits into from
Jan 28, 2024

Conversation

jonathanhogg
Copy link
Owner

@jonathanhogg jonathanhogg commented Jan 23, 2024

This PR adds support for new !slice, !intersect, !union and !difference nodes in a !canvas3d scene that cut apart models and combine them with boolean operations. There are some important notes on this:

  • models must be solid, steps will be taken to combine edges and fill holes; if necessary, the nuclear option is to compute a convex hull around the model
  • because edges are combined, primitive models with sharp edges will lose their definition as their vertices are combined and vertex normals averaged – the operators will attempt to snap apart these edges again for rendering so as to retain smooth, natural shading (controlled by the smooth= and minimum_area= attributes
  • solid model geometric operations are expensive, but they will be aggressively cached – if the operations have to be re-executed constantly because of dynamic parameters then it is a good idea to step these parameters so that caching will do something useful

This PR re-adds a hard requirement on scipy and introduces new ones on manifold3d, mapbox_earcut, networkx, rtree and shapely.

This adds a new dependency on the `manifold3d` library and reintroduces a hard dependency on `scipy`.
Adds a couple more dependencies, sadly. Also refactoring to simplify 3D model management code.
Also up the default number of segments in the primitive models to 64. Default smooth shading angle to 0.05 (18°), which seems to generally work for most of my examples.
@jonathanhogg jonathanhogg changed the title Add 3D boolean operations on solid meshes Add 3D solid model operations Jan 28, 2024
Also, break-up the description of the 3D rendering into a sub-list as it's become unwieldy.
This is neater and more orthogonal. Also allowing `position`, `size` and `rotation` attributes on any model node. Renaming slice origin to `origin` to avoid a clash.
Slicing with a plane doesn't seem to like complex objects, so if `!slice` is given a bunch of models it makes more sense to slice them individually and then union them than try to slice the union. Also fix crash if any of the compound operators gets a `None` model.
@jonathanhogg jonathanhogg merged commit 8ab9530 into main Jan 28, 2024
3 checks passed
@jonathanhogg jonathanhogg deleted the enh_boolean_geometry branch January 28, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant