I was trying to load a wasm that is part of the project. Unfortunately, it didn’t work, giving an error when the loader is trying to locate the binary in the Window global space during loadWasmModuleAsync(). Something about lib is not a function. I think the Window.mylib is undefined.
I originally wrote the script in Typescript and compiled to wasm binary using AssemblyScript. However, it doesn’t auto-generate the glue script, like Emscripten does. It has own loader, which I don’t know know how to plug into Playcanvas. I then wrote it in C++ and compiled with Emscripten, then assgined the glue file to the wasm property, gave it a name aaaand… it didn’t work. It gives me the error I mentioned in the beginning. I also tried to write it in Rust and compile using wasm-pack, but that generates a module package, which is not working with browsers natively, and I didn’t try to browserify it. I feel like Emscripten gave me the output that was the closest to what Playcanvas expects? I’d prefer assembly script, though, or rust, since they generally produce binaries with smaller sizes.
I asked the question in the Discord originally, but decided to put it here, for reference. What would be the right way to load own WASM binaries which are part of the project assets?
I actually saw this example, but couldn’t make it to work, because it uses a helper to resolve the path to the wasm:
I think that __PUBLIC_PATH__ is set during the build time. That path is then given to loadWasmModuleAsync() which loads it. This works if I do an engine-only build.
But how do I resolve the file path from the project in the editor? Or what url do I give to the loader?
I will try to use a custom loader, and will post here.