aerys / minko

3D framework for web, desktop and mobile devices.
http://minko.io
Other
906 stars 210 forks source link

HTML5 FileLoader + fopen #189

Closed fjallraven closed 9 years ago

fjallraven commented 9 years ago

Hi

This is more an emscripten question, but thought I post here in case any other Minko users will stumble on the same thing.

I have a plugin handler for a couple of filetypes stored on my server, add them to the loader queue as normal.

After this is loaded what will the internal path for empscripten file calls be?

For instance let's say I want to do File f = fopen("myloadedfile.exr", "rb")

I know I get the file data from the plugin parser callback but would be nice to be able to do this as well.

Thank you for your great work!

JMLX42 commented 9 years ago

Hello,

if the file is embedded with the app data (ie if it's in the /asset dir of your project), it will be loaded from the packed *.data file that will be generated by Emscripten along with the JS app. If the file is not embedded with the app data (ie it's on a remote HTTP server), it will be loaded using HTTP and an XHR request.

When the file is loaded, if there is a registered parser for its file extension, the file will be parsed and the corresponding parser will fill the AssetLibrary accordingly. For an *.exr file, the DevIL plugin should parse it and add the corresponding texture to the AssetLibrary.

If there is no compatible parser, the corresponding binary blob of the file is stored in the AssetLibrary as a "blob". I guess we could also provide a way to access the underlying AbstractProtocole, the File object and its data.

Keep in mind that "loading a file" and "fopen" have very different meanings. For now we've been focusing on "loading an asset" more than "loading a file" or "performing a request". But with minor changes to the public API it should be possible since that's how it works internally of course.

Does it answer your questions ?

Regards,

fjallraven commented 9 years ago

Thank you!

Currently have a plugin that will later simply call emscripten_wget(..) for these special files

JMLX42 commented 9 years ago

What do you miss in the existing asset loading API? emscripten_wget() is not cross-platform so we have to make sure mainstream use cases are covered by the API.

fjallraven commented 9 years ago

Mostly for convenience/laziness on my side, lot of the code I'm porting is calling fopen. But was mostly wondering if anyone knew if emscripten created a file pointer after emscripten_async_wget2_data().

Thank you