From 07794aa993adce26e89e8a430eb8c19b98ff72b8 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Fri, 25 Oct 2024 17:22:37 +0300 Subject: [PATCH] feat(lighting): add ambient light --- Cargo.lock | 72 +++++++++++++++----------------------------- Cargo.toml | 2 +- src/lib.rs | 4 +-- src/maze/plugin.rs | 5 +++ src/maze/prism.rs | 16 ++-------- src/maze/resource.rs | 6 ++-- 6 files changed, 38 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0188ca..5c39b4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ checksum = "df099ccb16cd014ff054ac1bf392c67feeef57164b05c42f037cd40f5d4357f4" dependencies = [ "clipboard-win", "core-graphics", - "image 0.25.2", + "image", "log", "objc2", "objc2-app-kit", @@ -324,9 +324,9 @@ dependencies = [ [[package]] name = "bevy-inspector-egui" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46ba955761969dbc9a79d3583a175609b4e370303bc0f9a5846397dcb7f05fd" +checksum = "cac12a22e5de801323bc5bc344949de086b9b8db02c34e109f128ffd41514e5d" dependencies = [ "bevy-inspector-egui-derive", "bevy_app", @@ -349,17 +349,17 @@ dependencies = [ "bytemuck", "egui", "fuzzy-matcher", - "image 0.24.9", - "once_cell", + "image", "pretty-type-name", "smallvec", + "winit", ] [[package]] name = "bevy-inspector-egui-derive" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06683f27065a27065ef8cebe77d7b347c9d0511a091deafd6dd77c5535434934" +checksum = "89f3be3ba88a25445c0c10684709b1ccd07e37f5f6b5d1b8dcf11d34548f1d61" dependencies = [ "proc-macro2", "quote", @@ -643,14 +643,13 @@ dependencies = [ [[package]] name = "bevy_egui" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128438a8163e49528207aabf20d3ff0890fd6be0f0054626915995efac87922b" +checksum = "d0b8c164da1303ac3e6dc8d1a649be3e4399f12fd132f7665f3d018884236f9c" dependencies = [ "arboard", "bevy", "bytemuck", - "console_log", "crossbeam-channel", "egui", "js-sys", @@ -986,7 +985,7 @@ dependencies = [ "encase", "futures-lite", "hexasphere", - "image 0.25.2", + "image", "js-sys", "ktx2", "naga", @@ -1484,12 +1483,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "com" version = "0.6.0" @@ -1550,16 +1543,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "console_log" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f" -dependencies = [ - "log", - "web-sys", -] - [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1777,9 +1760,9 @@ checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" [[package]] name = "ecolor" -version = "0.28.1" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e6b451ff1143f6de0f33fc7f1b68fecfd2c7de06e104de96c4514de3f5396f8" +checksum = "775cfde491852059e386c4e1deb4aef381c617dc364184c6f6afee99b87c402b" dependencies = [ "bytemuck", "emath", @@ -1787,9 +1770,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.28.1" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c97e70a2768de630f161bb5392cbd3874fcf72868f14df0e002e82e06cb798" +checksum = "53eafabcce0cb2325a59a98736efe0bf060585b437763f8c476957fb274bb974" dependencies = [ "ahash", "emath", @@ -1805,9 +1788,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "emath" -version = "0.28.1" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6a21708405ea88f63d8309650b4d77431f4bc28fb9d8e6f77d3963b51249e6" +checksum = "b1fe0049ce51d0fb414d029e668dd72eb30bc2b739bf34296ed97bd33df544f3" dependencies = [ "bytemuck", ] @@ -1846,19 +1829,26 @@ dependencies = [ [[package]] name = "epaint" -version = "0.28.1" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0dcc0a0771e7500e94cd1cb797bd13c9f23b9409bdc3c824e2cbc562b7fa01" +checksum = "a32af8da821bd4f43f2c137e295459ee2e1661d87ca8779dfa0eaf45d870e20f" dependencies = [ "ab_glyph", "ahash", "bytemuck", "ecolor", "emath", + "epaint_default_fonts", "nohash-hasher", "parking_lot", ] +[[package]] +name = "epaint_default_fonts" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "483440db0b7993cf77a20314f08311dbe95675092405518c0677aa08c151a3ea" + [[package]] name = "equivalent" version = "1.0.1" @@ -2375,18 +2365,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "image" -version = "0.24.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "num-traits", -] - [[package]] name = "image" version = "0.25.2" diff --git a/Cargo.toml b/Cargo.toml index a8d8225..4d6e8ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ tracing = { version = "0.1", features = [ ] } hexx = { version = "0.18", features = ["bevy_reflect", "grid"] } bevy_prototype_lyon = "0.12" -bevy-inspector-egui = { version = "0.26", optional = true } +bevy-inspector-egui = { version = "0.27", optional = true } [features] diff --git a/src/lib.rs b/src/lib.rs index 83b126f..843efe6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ impl Plugin for AppPlugin { }) .set(AudioPlugin { global_volume: GlobalVolume { - volume: Volume::new(0.3), + volume: Volume::new(0.), }, ..default() }), @@ -91,7 +91,7 @@ fn spawn_camera(mut commands: Commands) { commands.spawn(( Name::new("Camera"), Camera3dBundle { - transform: Transform::from_xyz(0., 100., 0.).looking_at(Vec3::ZERO, Vec3::Y), + transform: Transform::from_xyz(0., 100., 100.).looking_at(Vec3::ZERO, Vec3::Y), ..default() }, // Render all UI to this camera. diff --git a/src/maze/plugin.rs b/src/maze/plugin.rs index 11584e0..8ff67cf 100644 --- a/src/maze/plugin.rs +++ b/src/maze/plugin.rs @@ -1,5 +1,6 @@ use bevy::{ ecs::{system::RunSystemOnce, world::Command}, + pbr::wireframe::WireframePlugin, prelude::*, }; @@ -12,6 +13,10 @@ impl Plugin for MazePlugin { fn build(&self, app: &mut App) { app.add_plugins(prism::plugin); app.add_plugins(grid::plugin); + app.insert_resource(AmbientLight { + brightness: f32::MAX, + color: Color::WHITE, + }); } } diff --git a/src/maze/prism.rs b/src/maze/prism.rs index 8fd4119..d5b27f9 100644 --- a/src/maze/prism.rs +++ b/src/maze/prism.rs @@ -1,4 +1,4 @@ -use bevy::prelude::*; +use bevy::{pbr::wireframe::Wireframe, prelude::*}; use std::f32::consts::FRAC_PI_2; use super::{ @@ -6,19 +6,7 @@ use super::{ tile::Tile, }; -pub(super) fn plugin(app: &mut App) { - app.add_systems(Startup, spawn_light); -} - -pub(super) fn spawn_light(mut commands: Commands) { - commands.spawn(( - Name::new("Light Source"), - PointLightBundle { - transform: Transform::from_xyz(0., 50., 0.), - ..default() - }, - )); -} +pub(super) fn plugin(_app: &mut App) {} pub(super) fn setup( mut commands: Commands, diff --git a/src/maze/resource.rs b/src/maze/resource.rs index e6485d2..b12ad2b 100644 --- a/src/maze/resource.rs +++ b/src/maze/resource.rs @@ -15,7 +15,7 @@ pub struct MazeConfig { impl Default for MazeConfig { fn default() -> Self { let mut rng = thread_rng(); - let radius = 5; + let radius = 11; let start_pos = Hex::new( rng.gen_range(-radius..radius), rng.gen_range(-radius..radius), @@ -28,8 +28,8 @@ impl Default for MazeConfig { debug!("End pos: ({},{})", end_pos.x, end_pos.y); Self { radius: radius as u32, - size: 5., - height: 5., + size: 1., + height: 15., start_pos, end_pos, }