Skip to content

Commit

Permalink
try wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Oct 12, 2023
1 parent 4fa37f9 commit 5d5457a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: []
branches: [main]
permissions:
contents: read
pages: write
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
run: cargo install wasm-bindgen-cli

- name: Run build
run: cargo build --release --target wasm32-unknown-unknown
run: cargo build --profile wasm-release --target wasm32-unknown-unknown
- name: WASM
run: wasm-bindgen --out-dir out/ --target web ./target/wasm32-unknown-unknown/release/Simulation.wasm
# - name: Copy Assets
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
/.lapce
/.idea
/.idea
9 changes: 0 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runner = "wasm-server-runner"

[dependencies]
#bevy = { git = "https://github.com/bevyengine/bevy", branch = "release-0.11.3", features = ["dynamic_linking"] }
bevy = { version = "0.11.3", features = ["dynamic_linking"] }
bevy = { version = "0.11.3" }
bevy_easings = "0.11.1"
#bevy_panorbit_camera = { git = "https://github.com/jan-tennert/bevy_panorbit_camera", rev = "7e3c3f8" }
bevy-inspector-egui = { version = "0.20", default-features = false }
Expand All @@ -25,6 +25,22 @@ bevy_egui = "0.22"
chrono = "0.4.23"
itertools = "0.11.0"

[profile.wasm-release]
# Use release profile as default values
inherits = "release"

# Optimize with size in mind, also try "s", sometimes it is better.
# This doesn't increase compilation times compared to -O3, great improvements
opt-level = "z"

# Do a second optimization pass removing duplicate or unused code from dependencies.
# Slows compile times, marginal improvements
lto = "fat"

# When building crates, optimize larger chunks at a time
# Slows compile times, marginal improvements
codegen-units = 1

[patch.crates-io]
bevy = { git = "https://github.com/jan-tennert/bevy", branch = "skybox-fix" }
bevy_ecs = { git = "https://github.com/jan-tennert/bevy", branch = "skybox-fix" }
Expand Down
27 changes: 27 additions & 0 deletions out/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<meta charset="UTF-8" />
<style>
body {
background: linear-gradient(
135deg,
white 0%,
white 49%,
black 49%,
black 51%,
white 51%,
white 100%
);
background-repeat: repeat;
background-size: 20px 20px;
}
canvas {
background-color: white;
}
</style>
</head>
<script type="module">
import init from './Simulation.js'
init()
</script>
</html>
9 changes: 1 addition & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ pub enum SimState {
fn main() {
App::new()
// .add_plugins(DefaultPlugins)
.add_plugins(DefaultPlugins
.set(RenderPlugin {
wgpu_settings: WgpuSettings {
backends: Some(Backends::VULKAN),
..default()
},
})
)
.add_plugins(DefaultPlugins)
.add_plugins(WorldInspectorPlugin::new())
// .add_plugins(DefaultPickingPlugins)
.add_plugins(PanOrbitCameraPlugin)
Expand Down

0 comments on commit 5d5457a

Please sign in to comment.