Open pzingg opened 4 years ago
Hi Peter, that's very much the next step once elm-3d-scene
1.0 is out! The rough plan is:
Curve2d
, Curve3d
and Surface3d
types to elm-geometry
to represent parametric curves and surfacesRegion2d
(a region bounded by a set of Curve2d
s) and Body3d
(a body bounded by a set of Surface3d
) types to elm-geometry
elm-geometry
so you can do things like construct a Body3d
by extruding a Region2d
along an axis or revolving it around an axis, construct a Surface3d
by placing a Region2d
on a SketchPlane3d
, or construct a Surface3d
by extruding/revolving a Curve3d
Scene3d.curve
, Scene3d.surface
and Scene3d.body
functions to elm-3d-scene
to render the corresponding types to within a given accuracy (or eventually a set of accuracies, with dynamic level of detail handled automatically)My ultimate goal for elm-geometry
, elm-3d-scene
etc. is indeed to have a really nice ecosystem for building up 3D shapes with Elm code (roughly "CAD with code instead of a mouse"), which sounds pretty in line with what you're suggesting.
Polygons and polygon extrusions would then be a special case of regions and bodies - for example you might have a function like Region2d.polygon : Polygon2d -> Region2d
which you could then extrude as you describe. But I also really want to support defining regions and bodies with curved boundaries, where conversion to triangles only happens implicitly when rendering.
Hope that makes sense - definitely happy to talk through these ideas as this is the area I'm really excited about using Elm for!
By the way, the entire reason I added Polygon2d.triangulate
was in fact to be able to (eventually) render Body3d
values - since ultimately rendering a body will involve converting various Region2d
values to polygons (with some desired accuracy) and then triangulating the resulting polygons so they can be rendered with WebGL.
I notice that in ianmackenzie/elm-geometry you have
Polygon2d.triangulate
. Was wondering how hard it would be to add two more primitives to Scene3d:quad
, just a planar triangulated meshcylinder
orblock
with planar triangulated meshes on top and bottom, and a strip mesh around the extruded sides.I would like to be able to add extrusions other than blocks and cylinders (I really enjoyed rebuilding my hand crafted WebGL scene using this library, BTW).
Suggestion: rather than the way
quad
is defined by four unconstrained 3d points, it would probably be better to define these two new mesh primitives usingPolygon2d
points projected onto a sketch plane, to enforce planarity. The polygonExtrusion would also add alength
property.