satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

Serve custom textures embedded in js/wasm/mem instead of as separate request #67

Open satoshinm opened 7 years ago

satoshinm commented 7 years ago

https://github.com/satoshinm/WebSandboxMC/issues/56 added server-side texture support, but the client first uses its built-in textures, then downloads and unpacks a texture.zip from the server. This adds latency, would be faster to modify the emscripten output itself to have the custom texture png.

Only problem is: where is the data included within the emscripten .js or .wasm or .mem file? It doesn't seem to be in .mem, at least with release-build-js, though that's where I would expect static data... so it must be in the .js, for some reason a huge array of bytes?! Probably cleaner to find in the .wasm file and replace the binary data, but the plugin isn't serving webassembly yet (https://github.com/satoshinm/WebSandboxMC/issues/57), and even if it was, what about the js fallback.

What are the tools available to programmatically alter emscriptenifed bundles?

satoshinm commented 7 years ago

https://github.com/satoshinm/NetCraft/issues/165 --preload-file is more efficient than --embed-file

There is now a craft.data file, with shaders and textures. http://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html#emcc-preload-file documents a http://kripken.github.io/emscripten-site/docs/porting/files/packaging_files.html#packaging-files-file-packager file_packager.py tool which can be run manually to generate it. In principle it ought to be possible for a server administrator to run this tool, generating their own craft.data, saving in the plugin data directory, which will then be served including for textures.

satoshinm commented 7 years ago

This should be already possible, but requires testing to be sure + instructions to document how to create/modify the craft.data file