Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a template for my Bevy projects, which have to be build with VSCode on Windows.

Crates

  1. Bevy
  2. bevy_embedded_assets: embed assets folder inside binary files (including web).
  3. bevy_asset_loader: load assets in a specific state and automatically transition to next state.

Details

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.

WASM Build

Run the following to build for web:

TODO: add variable into cli to replace bevy_project_template name in commands.

  1. Install or update wasm-bindgen , wasm-bindgen-cli , wasm-opt dependencies:
    • cargo install wasm-bindgen
    • cargo install wasm-bindgen-cli
    • cargo install wasm-opt
  2. Comment dynamic linking in cargo.toml and execute cargo build --release --target wasm32-unknown-unknown.
  3. 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
  4. Optimise the wasm build wasm-opt -Oz out/bevy_project_template_bg.wasm --output out/bevy_project_template_bg.wasm
  5. Inside wasm_out folder add index.html file. The contents can be any, but the file must include this: TODO.
  6. Optional (for Itch.io): zip produced files into an archive zip -FSj wasm_out/bevy_project_template.zip wasm_out/* TODO

Run locally

Reference: https://bevy-cheatbook.github.io/platforms/wasm.html

  1. Update nightly toolchain: rustup update
  2. Install wasm-server: cargo install wasm-server-runner
  3. Add target to Cargo.toml file:
    • [target.wasm32-unknown-unknown]
    • runner = "wasm-server-runner"
  4. cargo run --target wasm32-unknown-unknown

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages