regl-project / regl

👑 Functional WebGL
https://regl-project.github.io/
MIT License
5.21k stars 322 forks source link

Asset handling improvements #340

Open mikolalysenko opened 7 years ago

mikolalysenko commented 7 years ago

We should improve the workflow for getting data into regl. There are already a bunch of importers on npm but it is all very scattered. We should try to pull the best of this work together and create a comprehensive guide for translating assets from various formats into some form which is compatible with regl.

vorg commented 7 years ago

Is there specific data or format you have in mind? I'm trying to focus my efforts recently on glTF for scenes and geometry.

marklundin commented 7 years ago

@mikolalysenko do you have any references on good importers. It would be good to collate and cherry pick features.

marklundin commented 7 years ago

Thinking off the top of my head here...

Keeping things functional, it would be great to separate concerns (loading/parsing) and build up a collection of decoders that could be used with things like the fetch api.

fetch('asset.zip')
 .then(resp => Deflate(resp))
 .then(data => DecodeOBJ(data))

This composable approach is not restricted to fetch, it also opens up things like async programming, streams and service workers where decoding can happen off the main thread, although it doesn't prevent them from using alternative loading/importing mechanisms (XHR/inline assets). Also, it makes the loading/decoding transparent to the developer by not abstracting it behind a class. It would also allow contributors to continue adding decoders for new formats as needs arise.

cvan commented 7 years ago

I found @substack's vglobe regl tutorial very helpful. Along those lines, I think added built-in support for loading glTF (or ideally to regl-project/resl in regl-project/resl#8 would be great). I added this comment with some helpful links: https://github.com/regl-project/resl/issues/8#issuecomment-266713131

For glTF-specific discussions, I'd recommend keeping the discussion in regl-project/resl#8, but I thought I'd point to my comment there.

Let me know if anyone can point folks in the right direction to add proper glTF support; I can probably consult with some folks and get some folks here on the Mozilla VR team to add support. Other glTF enthusiasts who are experimenting in this space are @xirvr, @emadurandal, @GrimoireGL, @takahirox, etc. If anyone's interested to add glTF to regl, feel free to hit me up on Twitter (@cvanw), and let's chat! :smile:

munrocket commented 5 years ago

GLTF loader in REGL https://github.com/gamedev-js/regltf