-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the WASM location configurable #22
Comments
I wonder if there is a way to actually bundle/encapsulate |
I wish there was a way, it would be definitely cleaner 🤔 But as far as I know, the WASM file is not interpreted the same way as JS (they are precompiled), so I suspect that for that we need to do a couple of reverse-engineering hacks (e. g. generate the WASM file in runtime). Would this runtime-generation be worth for eliminating the wasm file? Honestly, I have no idea. |
have a look at this: https://github.com/mrdoob/three.js/blob/dev/examples/jsm/libs/meshopt_decoder.module.js#L8-L15 isnt the wasm code here ? |
Hum, might be. Feel free to dig into this, could be nice if it removes the WASM file handling! |
Would vote against this, the WASM file as a standalone web resource enables browsers to cache the compiled code, reducing subsequent startup times by skipping compilation. More info here: https://v8.dev/blog/wasm-code-caching I am by no means a chrome expert, but I expect this caching to break if we somehow bundle the wasm inside the js resource, they specifically mention:
Could be this info is out of date though, no idea. |
So far we have been working on the assumption that the WASM file is in the root directory of the project. However, this may not always be the case, and it would be interesting if the user could define where their WASM file is. I've had to set this up by hand for the Three.js IFC Loader, and I think it would be interesting to incorporate it into web-ifc.
The path to the WASM file resides in the
wasmBinaryFile
variable generated by Emscripten.The solution provided for Three.js was to add a global variable containing the relative path of the WASM that could be set through a function of the API. Something like:
This setter function will be also present in web-ifc-three. This way, we will be able to use the Loader like this:
A minimal example of how this looks can be found here.
I suppose that the SetWasmPath can be added to web-ifc-api.ts. As for the global variable and the wasmBinaryFile initialization, we can probably write a JS file with a script to add these two lines to the bundled file.
The text was updated successfully, but these errors were encountered: