tangrams / tangram-play

Text editor web app for Tangram scenes
https://tangram.city/play/
MIT License
96 stars 27 forks source link

Support loading of assets (images, etc) needed by a scene #264

Open bcamper opened 8 years ago

bcamper commented 8 years ago

We can use the FileReader API to allow loading of local files. We already support drag and drop loading, but better local file support would be useful for loading local resources (images, etc.), and for future multi-file scenes.

https://developer.mozilla.org/en-US/docs/Web/API/FileReader http://caniuse.com/#feat=filereader https://www.w3.org/TR/FileAPI/#dfn-filereader

louh commented 8 years ago

Can you say more about how you think this might work?

It's my understanding that FileReader is only available on user interaction - that is, I can't just drop a scene file and then my browser goes hunting through my hard drive for assets. But with the right prompting, users can drop a bundle of files into the browser, or load them all using the dialog box. We could then need to store each of these files in memory and map local resources to those references. This might mean some form of URL replacement in the scene file with Data-URI equivalents before sending it to Tangram.

Let me know if you had a different thing in mind?

bcamper commented 8 years ago

Wow I can't remember even putting this in so I am not sure :D

louh commented 8 years ago

I'm going to rename this issue to refer to handling assets such as images, sprites, untiled data sources, and so forth. We've opened issue #321 for the multiple-file scenes. I'm not sure the solution for both of these is generic enough to handle any sort of file for any purpose (but it might be), or if it's easier to address each one separately.