Compare commits
1 commit
main
...
GameOfLife
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0297c53f2 |
8 changed files with 88 additions and 174 deletions
147
Cargo.lock
generated
147
Cargo.lock
generated
|
|
@ -373,12 +373,6 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.22.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy"
|
name = "bevy"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
|
|
@ -423,7 +417,6 @@ dependencies = [
|
||||||
"bevy_derive",
|
"bevy_derive",
|
||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_mesh",
|
|
||||||
"bevy_platform",
|
"bevy_platform",
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"bevy_time",
|
"bevy_time",
|
||||||
|
|
@ -779,7 +772,6 @@ dependencies = [
|
||||||
"bevy_color",
|
"bevy_color",
|
||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
"bevy_gizmos_macros",
|
"bevy_gizmos_macros",
|
||||||
"bevy_light",
|
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"bevy_time",
|
"bevy_time",
|
||||||
|
|
@ -813,7 +805,6 @@ dependencies = [
|
||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_mesh",
|
"bevy_mesh",
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"bevy_shader",
|
"bevy_shader",
|
||||||
"bevy_sprite_render",
|
"bevy_sprite_render",
|
||||||
|
|
@ -823,42 +814,6 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bevy_gltf"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "08372f222676dba313061fc71128209b82f9711e7c5cba222b5c34bf1c5c70fe"
|
|
||||||
dependencies = [
|
|
||||||
"async-lock",
|
|
||||||
"base64",
|
|
||||||
"bevy_animation",
|
|
||||||
"bevy_app",
|
|
||||||
"bevy_asset",
|
|
||||||
"bevy_camera",
|
|
||||||
"bevy_color",
|
|
||||||
"bevy_ecs",
|
|
||||||
"bevy_image",
|
|
||||||
"bevy_light",
|
|
||||||
"bevy_math",
|
|
||||||
"bevy_mesh",
|
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_platform",
|
|
||||||
"bevy_reflect",
|
|
||||||
"bevy_render",
|
|
||||||
"bevy_scene",
|
|
||||||
"bevy_tasks",
|
|
||||||
"bevy_transform",
|
|
||||||
"fixedbitset",
|
|
||||||
"gltf",
|
|
||||||
"itertools 0.14.0",
|
|
||||||
"percent-encoding",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"smallvec",
|
|
||||||
"thiserror 2.0.18",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_image"
|
name = "bevy_image"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
|
|
@ -879,9 +834,7 @@ dependencies = [
|
||||||
"guillotiere",
|
"guillotiere",
|
||||||
"half",
|
"half",
|
||||||
"image",
|
"image",
|
||||||
"ktx2",
|
|
||||||
"rectangle-pack",
|
"rectangle-pack",
|
||||||
"ruzstd",
|
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -945,11 +898,9 @@ dependencies = [
|
||||||
"bevy_gilrs",
|
"bevy_gilrs",
|
||||||
"bevy_gizmos",
|
"bevy_gizmos",
|
||||||
"bevy_gizmos_render",
|
"bevy_gizmos_render",
|
||||||
"bevy_gltf",
|
|
||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_input",
|
"bevy_input",
|
||||||
"bevy_input_focus",
|
"bevy_input_focus",
|
||||||
"bevy_light",
|
|
||||||
"bevy_log",
|
"bevy_log",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_mesh",
|
"bevy_mesh",
|
||||||
|
|
@ -2637,42 +2588,6 @@ dependencies = [
|
||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3ce1918195723ce6ac74e80542c5a96a40c2b26162c1957a5cd70799b8cacf7"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
"gltf-json",
|
|
||||||
"lazy_static",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf-derive"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "14070e711538afba5d6c807edb74bcb84e5dbb9211a3bf5dea0dfab5b24f4c51"
|
|
||||||
dependencies = [
|
|
||||||
"inflections",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf-json"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e6176f9d60a7eab0a877e8e96548605dedbde9190a7ae1e80bbcc1c9af03ab14"
|
|
||||||
dependencies = [
|
|
||||||
"gltf-derive",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin_wgl_sys"
|
name = "glutin_wgl_sys"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
|
|
@ -2962,12 +2877,6 @@ dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "inflections"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inotify"
|
name = "inotify"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
|
@ -3055,9 +2964,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.85"
|
version = "0.3.87"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3"
|
checksum = "93f0862381daaec758576dcc22eb7bbf4d7efd67328553f3b45a412a51a3fb21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|
@ -3080,15 +2989,6 @@ version = "3.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ktx2"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ff7f53bdf698e7aa7ec916411bbdc8078135da11b66db5182675b2227f6c0d07"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.11.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|
@ -4296,15 +4196,6 @@ version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ruzstd"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01"
|
|
||||||
dependencies = [
|
|
||||||
"twox-hash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.23"
|
version = "1.0.23"
|
||||||
|
|
@ -4618,9 +4509,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.116"
|
version = "2.0.117"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb"
|
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -4985,12 +4876,6 @@ dependencies = [
|
||||||
"core_maths",
|
"core_maths",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "twox-hash"
|
|
||||||
version = "2.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typeid"
|
name = "typeid"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
@ -5128,9 +5013,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.108"
|
version = "0.2.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566"
|
checksum = "1de241cdc66a9d91bd84f097039eb140cdc6eec47e0cdbaf9d932a1dd6c35866"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -5141,9 +5026,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-futures"
|
name = "wasm-bindgen-futures"
|
||||||
version = "0.4.58"
|
version = "0.4.60"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f"
|
checksum = "a42e96ea38f49b191e08a1bab66c7ffdba24b06f9995b39a9dd60222e5b6f1da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
|
@ -5155,9 +5040,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.108"
|
version = "0.2.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608"
|
checksum = "e12fdf6649048f2e3de6d7d5ff3ced779cdedee0e0baffd7dff5cdfa3abc8a52"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
|
|
@ -5165,9 +5050,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.108"
|
version = "0.2.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55"
|
checksum = "0e63d1795c565ac3462334c1e396fd46dbf481c40f51f5072c310717bc4fb309"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|
@ -5178,9 +5063,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.108"
|
version = "0.2.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12"
|
checksum = "e9f9cdac23a5ce71f6bf9f8824898a501e511892791ea2a0c6b8568c68b9cb53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
@ -5329,9 +5214,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.85"
|
version = "0.3.87"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598"
|
checksum = "f2c7c5718134e770ee62af3b6b4a84518ec10101aad610c024b64d6ff29bb1ff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|
|
||||||
19
Cargo.toml
19
Cargo.toml
|
|
@ -2,6 +2,21 @@
|
||||||
members = ["app", "server"]
|
members = ["app", "server"]
|
||||||
resolver = "3"
|
resolver = "3"
|
||||||
|
|
||||||
|
# Enable more optimization in the release profile at the cost of compile time.
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "thin"
|
# Compile the entire crate as one unit.
|
||||||
opt-level = 'z'
|
# Slows compile times, marginal improvements.
|
||||||
|
codegen-units = 1
|
||||||
|
# Do a second optimization pass over the entire program, including dependencies.
|
||||||
|
# Slows compile times, marginal improvements.
|
||||||
|
lto = true
|
||||||
|
|
||||||
|
# Optimize for size in the wasm-release profile to reduce load times and bandwidth usage on web.
|
||||||
|
[profile.wasm-release]
|
||||||
|
# Default to release profile values.
|
||||||
|
inherits = "release"
|
||||||
|
# Optimize with size in mind (also try "z", sometimes it is better).
|
||||||
|
# Slightly slows compile times, great improvements to file size and runtime performance.
|
||||||
|
opt-level = "z"
|
||||||
|
# Strip all debugging information from the binary to slightly reduce file size.
|
||||||
|
strip = "debuginfo"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.18", default-features = false, features = [
|
bevy = { version = "0.18", default-features = false, features = [
|
||||||
"3d",
|
"2d",
|
||||||
"tonemapping_luts",
|
"keyboard",
|
||||||
"web",
|
"web",
|
||||||
"webgl2",
|
"webgl2",
|
||||||
] }
|
] }
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,18 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
const ALIVE_COLOR: [u8; 4] = [0, 255, 136, 255];
|
||||||
|
const DEAD_COLOR: [u8; 4] = [18, 18, 32, 255];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
|
title: "Game of Life".into(),
|
||||||
fit_canvas_to_parent: true,
|
fit_canvas_to_parent: true,
|
||||||
prevent_default_event_handling: false,
|
|
||||||
canvas: Some("#bevy-canvas".into()),
|
canvas: Some("#bevy-canvas".into()),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_systems(Startup, setup)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(
|
|
||||||
mut commands: Commands,
|
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
||||||
) {
|
|
||||||
commands.spawn((
|
|
||||||
Mesh3d(meshes.add(Circle::new(4.0))),
|
|
||||||
MeshMaterial3d(materials.add(Color::WHITE)),
|
|
||||||
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
|
|
||||||
));
|
|
||||||
|
|
||||||
commands.spawn((
|
|
||||||
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
|
|
||||||
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
|
||||||
Transform::from_xyz(0.0, 0.5, 0.0),
|
|
||||||
));
|
|
||||||
|
|
||||||
commands.spawn((
|
|
||||||
PointLight {
|
|
||||||
shadows_enabled: true,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Transform::from_xyz(4.0, 8.0, 4.0),
|
|
||||||
));
|
|
||||||
|
|
||||||
commands.spawn((
|
|
||||||
Camera3d::default(),
|
|
||||||
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,27 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PROFILE="${1:-release}"
|
PROFILE="${1:-wasm-release}"
|
||||||
|
|
||||||
if [ "$PROFILE" = "dev" ]; then
|
if [ "$PROFILE" = "dev" ]; then
|
||||||
PROFILE_DIR="debug"
|
PROFILE_DIR="debug"
|
||||||
CARGO_FLAGS=""
|
CARGO_FLAGS=""
|
||||||
else
|
else
|
||||||
PROFILE_DIR="release"
|
PROFILE_DIR=$PROFILE
|
||||||
CARGO_FLAGS="--release"
|
CARGO_FLAGS="--profile wasm-release"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cargo build $CARGO_FLAGS --target wasm32-unknown-unknown -p app
|
cargo build $CARGO_FLAGS --target wasm32-unknown-unknown -p app
|
||||||
|
|
||||||
mkdir -p static
|
mkdir -p static
|
||||||
wasm-bindgen --out-name 3dscene \
|
wasm-bindgen --out-name app \
|
||||||
--out-dir static \
|
--out-dir static \
|
||||||
--target web \
|
--target web \
|
||||||
"target/wasm32-unknown-unknown/$PROFILE_DIR/app.wasm"
|
"target/wasm32-unknown-unknown/$PROFILE_DIR/app.wasm"
|
||||||
|
|
||||||
|
# Optimize the WASM file for size
|
||||||
|
if [ "$PROFILE" = "wasm-release" ]; then
|
||||||
|
wasm-opt -Oz -o static/app_bg.wasm static/app_bg.wasm
|
||||||
|
fi
|
||||||
|
|
||||||
cp web/index.html static/
|
cp web/index.html static/
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
rustToolchain
|
rustToolchain
|
||||||
pkgs.wasm-bindgen-cli
|
pkgs.wasm-bindgen-cli
|
||||||
|
pkgs.binaryen
|
||||||
|
pkgs.just
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
justfile
Normal file
35
justfile
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Default: build WASM app for release
|
||||||
|
default:
|
||||||
|
just build
|
||||||
|
|
||||||
|
# Build the WASM app (default: release)
|
||||||
|
build profile="wasm-release":
|
||||||
|
./build-wasm.sh {{ profile }}
|
||||||
|
|
||||||
|
# Build for development (faster compile, no wasm-opt)
|
||||||
|
build-dev:
|
||||||
|
./build-wasm.sh dev
|
||||||
|
|
||||||
|
# Build the server binary
|
||||||
|
build-server:
|
||||||
|
cargo build --release -p server
|
||||||
|
|
||||||
|
# Build everything: WASM app + server
|
||||||
|
build-all profile="wasm-release":
|
||||||
|
./build-wasm.sh {{ profile }}
|
||||||
|
cargo build --release -p server
|
||||||
|
|
||||||
|
# Serve the site locally (builds WASM first, then runs server on :3000)
|
||||||
|
serve profile="wasm-release":
|
||||||
|
./build-wasm.sh {{ profile }}
|
||||||
|
cargo run --release -p server
|
||||||
|
|
||||||
|
# Development: build WASM (dev profile) and run server with hot reload
|
||||||
|
dev:
|
||||||
|
./build-wasm.sh dev
|
||||||
|
cargo run --release -p server
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
cargo clean
|
||||||
|
rm -rf static/*
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>3D Scene</title>
|
<title>Bevy App</title>
|
||||||
<style>
|
<style>
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<body>
|
<body>
|
||||||
<canvas id="bevy-canvas"></canvas>
|
<canvas id="bevy-canvas"></canvas>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init from './3dscene.js';
|
import init from './app.js';
|
||||||
init();
|
init();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue