elm-3d-scene icon indicating copy to clipboard operation
elm-3d-scene copied to clipboard

Add model loading support?

Open ianmackenzie opened this issue 4 years ago • 7 comments

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:

  • OBJ
  • COLLADA (.dae)
  • FBX
  • glTF
  • STL

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

ianmackenzie avatar Oct 10 '19 20:10 ianmackenzie

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

schoening avatar Oct 11 '19 05:10 schoening

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

ianmackenzie avatar Oct 11 '19 17:10 ianmackenzie

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

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

schoening avatar Oct 12 '19 00:10 schoening

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.

ianmackenzie avatar Oct 12 '19 01:10 ianmackenzie

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

declension avatar Mar 12 '20 11:03 declension

Currently I think the two options are:

  • Write a quick and dirty parser yourself (that likely only works on your specific files)
  • Pre-process the files offline to convert STL into a JSON format which you can then easily decode in Elm

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.

ianmackenzie avatar Mar 12 '20 18:03 ianmackenzie

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.

b0oh avatar Mar 16 '20 13:03 b0oh