jabuwu / rusty_spine

Spine runtime for Rust (and wasm!) transpiled from the official C Runtime.
https://docs.rs/rusty_spine
Other
43 stars 4 forks source link

example of wasm #32

Open drpepper0106 opened 3 months ago

drpepper0106 commented 3 months ago

hey I'm new here and I got confused by the online demo at https://jabuwu.github.io/rusty_spine/ How the wasm get the context of the canvas? I did not got any code about this in js files. Could you show me the source code of the spine_bg.wasm?

jabuwu commented 3 months ago

Hey there. That online demo is pretty old, and I really need to spend some time cleaning things up. That was using Bevy, which makes it very easy to build for WASM. A more up-to-date version of that demo is here: https://github.com/jabuwu/bevy_spine_demos

It uses my bevy_spine plugin for Bevy. There's some examples there too, including this simple one that can also be built in WASM.

If you don't wish to use Bevy, then you'll need to use another library for all the canvas stuff, and integrate rusty_spine with that. The miniquad example in this repo outlines the work involved going that route.

Edit: Here's some info on running Bevy in WASM: https://bevy-cheatbook.github.io/platforms/wasm.html