Skip to content

Commit

Permalink
Updated to bevy 0.4 and added webgl/wasm support.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnPeel committed Dec 31, 2020
1 parent 8b3bff7 commit a390334
Show file tree
Hide file tree
Showing 17 changed files with 585 additions and 344 deletions.
3 changes: 0 additions & 3 deletions .cargo/config

This file was deleted.

20 changes: 20 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# NOTE: For maximum performance, build using a nightly compiler
# If you are using rust stable, remove the "-Zshare-generics=y" below.

[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]

# NOTE: you must manually install https://github.com/michaeleisel/zld on mac. you can easily do this with the "brew" package manager:
# `brew install michaeleisel/zld/zld`
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld", "-Zshare-generics=y", "-Zrun-dsymutil=no"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=y"]

# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
#[profile.dev]
#debug = 1
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"cSpell.words": [
"Boid",
"Inconsolata",
"bidimensional",
"boids",
"spacefield",
"vsync",
"wasm",
"webgl"
]
}
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
[package]
name = "bevy_test"
version = "0.1.0"
version = "0.1.1"
authors = ["John Peel <[email protected]>"]
edition = "2018"

[features]
default = [
"bevy/bevy_winit",
"bevy/render",
"bevy/png",
]

native = [
"bevy/bevy_wgpu",
]

web = [
"bevy_webgl2"
]

[dependencies]
bevy = "0.1.3"
rand = "0.7"
bevy = { version = "0.4", default-features = false }
bevy_webgl2 = { version = "0.4", optional = true }
rand = "0.8"
44 changes: 44 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[env]
ENV_DIR = {source="${CARGO_MAKE_PROFILE}", default_value = "debug", mapping = {release = "release"}}
CARGO_TARGET_DIR = {value = "target", condition = {env_not_set = ["CARGO_TARGET_DIR"]}}
CARGO_WASM_PATH = "${CARGO_TARGET_DIR}/wasm32-unknown-unknown/${ENV_DIR}/${CARGO_MAKE_CRATE_NAME}.wasm"
CARGO_PROFILE = "dev"
TARGET_DIR = "target"
CARGO_MANIFEST_DIR = "${CARGO_MAKE_WORKING_DIRECTORY}"

[env.release]
CARGO_RELEASE_ARGS = "--release"

[tasks.show-env]
command = "env"

[tasks.basic-http-server]
install_crate = {crate_name = "basic-http-server", binary = "basic-http-server", test_arg="--help"}

[tasks.wasm-bindgen-cli]
install_crate = {crate_name = "wasm-bindgen-cli", binary = "wasm-bindgen", test_arg="--help"}

[tasks.cargo-build-web]
args = ["build", "--target", "wasm32-unknown-unknown", "--features", "web", "@@split(CARGO_RELEASE_ARGS, )"]
command = "cargo"

[tasks.build-web]
args = ["--out-dir", "${TARGET_DIR}", "--out-name", "wasm", "--target", "web", "--no-typescript", "${CARGO_WASM_PATH}"]
command = "wasm-bindgen"
dependencies = ["cargo-build-web", "wasm-bindgen-cli"]

[tasks.build-native]
args = ["build", "--features", "native", "@@split(CARGO_RELEASE_ARGS, )"]
command = "cargo"

[tasks.run]
command = "${CARGO_TARGET_DIR}/${ENV_DIR}/${CARGO_MAKE_BINARY_EXECUTABLE_NAME}"
dependencies = ["build-native"]

[tasks.serve]
command = "basic-http-server"
args = ["-x"]
dependencies = ["build-web", "basic-http-server"]

[tasks.test]
disabled = true
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Steering behaviors flocking example using bevy & Rust.

This repo is setup for Fast Compiles with bevy. See: https://bevyengine.org/learn/book/getting-started/setup/#enable-fast-compiles-optional
This repo is setup for Fast Compiles with bevy. See: https://bevyengine.org/learn/book/getting-started/setup/#enable-fast-compiles-optional

You will need cargo-make to run any of the following commands.
It can be installed with `cargo install cargo-make`

Run native with: `cargo make run`
Run wasm/webgl with: `cargo make serve`
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Flocking Example</title>
</head>
<body>
<script type="module">
import init from "./target/wasm.js";
init();
</script>
</body>
</html>
38 changes: 0 additions & 38 deletions src/fps_plugin.rs

This file was deleted.

Loading

0 comments on commit a390334

Please sign in to comment.