ianmackenzie / elm-3d-scene

A high-level 3D rendering engine for Elm, with support for lighting, shadows, and realistic materials.
https://package.elm-lang.org/packages/ianmackenzie/elm-3d-scene/latest/
Mozilla Public License 2.0
207 stars 27 forks source link

Add model loading support? #30

Open ianmackenzie opened 4 years ago

ianmackenzie commented 4 years ago

This is a bit of a placeholder issue since my current thinking is that support for different file formats should live in their own packages, so (e.g.) a COLLADA package can be focused on parsing COLLADA files into nice Elm data types and elm-3d-scene can remain focused on rendering. That said, one way or another there should definitely be an easy way to load models into elm-3d-scene. Potential file formats to support include:

Please add a comment if there's a particular file format you'd like to see supported!

schoening commented 4 years ago

Models can also come with animations. Probably good to have in mind when deciding where to put an eventual “setAnimationFrame” function 😁

ianmackenzie commented 4 years ago

@schoening what kind of setAnimationFrame function were you thinking of?

schoening commented 4 years ago

@ianmackenzie a quick and dirty example from babylonjs, here you see I am setting the frame manually:

https://www.babylonjs-playground.com/#4HGNW#4

ianmackenzie commented 4 years ago

Ah gotcha - I thought you were referring to the browser's animation frame, e.g. https://package.elm-lang.org/packages/elm/browser/latest/Browser-Events#onAnimationFrame.

declension commented 4 years ago

Hi! What's the current best way / workaround to try loading STLs with elm-3d-scene?

ianmackenzie commented 4 years ago

Currently I think the two options are:

I realize those are both kind of non-answers - once elm-3d-scene 1.0 is out I'll hopefully have time to start looking at implementing some proper import packages.

b0oh commented 4 years ago

Hi! What's the current best way / workaround to try loading STLs with elm-3d-scene?

I am not sure if my experience is useful but I do it that way: parse stl to jscad: https://www.npmjs.com/package/@jscad/stl-deserializer that will return CSG object which will have polygons attribute that could be sent to an Elm app from ports and can be rendered there using elm-3d-scene. Hope that helps.