- Bevy
- bevy_embedded_assets: embed assets folder inside binary files (including web).
- bevy_asset_loader: load assets in a specific state and automatically transition to next state.
Project contains ball.png asset file and main.rs file with code for scene setup.
.vscode contains tasks.json that is used for executing rust code with shortcut: CTRL + SHIFT + B.
.cargo contains code for dynamic linking and faster compiling.
rust-toolchain.toml is used for turning on the rust nightly compiler.
Run the following to build for web:
TODO: add variable into cli to replace bevy_project_template name in commands.
- Install or update wasm-bindgen , wasm-bindgen-cli , wasm-opt dependencies:
cargo install wasm-bindgencargo install wasm-bindgen-clicargo install wasm-opt
- Comment dynamic linking in cargo.toml and execute
cargo build --release --target wasm32-unknown-unknown. - Make javascript bindings using
wasm-bindgen --target web --out-dir ./wasm_out/ --out-name "bevy_project_template" ./target/wasm32-unknown-unknown/release/bevy_project_template.wasm - Optimise the wasm build
wasm-opt -Oz out/bevy_project_template_bg.wasm --output out/bevy_project_template_bg.wasm - Inside wasm_out folder add index.html file. The contents can be any, but the file must include this: TODO.
- Optional (for Itch.io): zip produced files into an archive
zip -FSj wasm_out/bevy_project_template.zip wasm_out/*TODO
Reference: https://bevy-cheatbook.github.io/platforms/wasm.html
- Update nightly toolchain:
rustup update - Install wasm-server:
cargo install wasm-server-runner - Add target to Cargo.toml file:
[target.wasm32-unknown-unknown]runner = "wasm-server-runner"
cargo run --target wasm32-unknown-unknown