Open PSteinhaus opened 3 years ago
The recommended way to interop with JS: https://github.com/not-fl3/miniquad/wiki/JavaScript-interop
I am not a huge fan of using any third-party binaries for wasm and prefer just do cargo build --target wasm32-unknown-unknown
. In case of gwg
the only dependency requiring wasm-bindgen is getrandom
(https://github.com/ggez/good-web-game/blob/master/Cargo.toml#L37). I would recommend switching to oorandom
However, if you really want to bring wasm-bindgen
binary into the gwg
build process here there is a good example for it: https://github.com/smokku/gwg-bindgen
Hmm, I removed getrandom
, but the problem remains:
However, if you really want to bring
wasm-bindgen
binary into thegwg
build process here there is a good example for it: https://github.com/smokku/gwg-bindgen
If I try to follow the example (using current good-web-game instead of the example repo and using the latest gl.js) I run into the following:
Ah, it seems to be gilrs
that's dependent on wasm-bindgen: https://gitlab.com/gilrs-project/gilrs#wasm
Ok, using conditional compilation I managed to keep gamepad support, while only disabling it for web and mobile. It's probably not very elegant, but it works, good-web-game finally runs on the web once again!
But since gilrs
is really the only dependency needing wasm-bindgen shouldn't it be possible to write my own bindings for it, keeping users from having to struggle with wasm-bindgen? As I said I'm a wasm and js noob, so I've no idea really, but in theory this should be possible, right? Or perhaps the more sensible way would be to just get wasm-bindgen to work once and then store the generated bindings somewhere, so that users don't have to generate them themselves when after building their projects?
yes, @Bombfuse made a gamepad library that works without wasm-bindgen: github.com/bombfuse/gamepad/
Gamepad currently doesnt support WASM but I was in the middle of completing it previously. It is planned eventually to support WASM controllers without bindgen though
Yeah, I stumbled over that library and was close to asking whether you plan on continuing it, because it'd be really useful for gwg. Good to hear that you do : )
Apparently some dependencies used require wasm-bindgen to get them to work on WASM.
Since I've never worked with WebAssembly or Javascript before it's safe to say that I'm the wrong person for this job, though.
Therefore I hereby humbly ask for help.