diff --git a/crates/unavi-app/assets/images/dev-white.png.meta b/crates/unavi-app/assets/images/dev-white.png.meta index 94b41566c..ae129c49d 100644 --- a/crates/unavi-app/assets/images/dev-white.png.meta +++ b/crates/unavi-app/assets/images/dev-white.png.meta @@ -1,7 +1,7 @@ ( meta_format_version: "1.0", asset: Load( - loader: "bevy_render::texture::image_loader::ImageLoader", + loader: "bevy_image::image_loader::ImageLoader", settings: ( format: FromExtension, is_srgb: true, diff --git a/crates/unavi-app/default.nix b/crates/unavi-app/default.nix index 6596ae685..bcefeebc5 100644 --- a/crates/unavi-app/default.nix +++ b/crates/unavi-app/default.nix @@ -75,6 +75,8 @@ let ]; postInstall = '' + mv $out/bin/* $out + rm -r $out/bin cp -r crates/unavi-app/assets $out cp LICENSE $out ''; diff --git a/crates/unavi-app/src/lib.rs b/crates/unavi-app/src/lib.rs index ea171bdfa..8b8347847 100644 --- a/crates/unavi-app/src/lib.rs +++ b/crates/unavi-app/src/lib.rs @@ -3,6 +3,7 @@ use std::sync::LazyLock; use directories::ProjectDirs; pub mod icon; +pub mod scene; pub mod update; pub static DIRS: LazyLock = LazyLock::new(|| { diff --git a/crates/unavi-app/src/main.rs b/crates/unavi-app/src/main.rs index 256f188bf..7be530631 100644 --- a/crates/unavi-app/src/main.rs +++ b/crates/unavi-app/src/main.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use unavi_app::{icon::set_window_icon, update::check_for_updates}; +use unavi_app::update::check_for_updates; fn main() { if cfg!(not(debug_assertions)) { @@ -21,7 +21,14 @@ fn main() { }) .finish(&mut app); - app.add_systems(Startup, set_window_icon); + app.add_systems( + Startup, + ( + unavi_app::icon::set_window_icon, + unavi_app::scene::spawn_lights, + unavi_app::scene::spawn_scene, + ), + ); app.run(); } diff --git a/crates/unavi-app/src/scene.rs b/crates/unavi-app/src/scene.rs new file mode 100644 index 000000000..5a8a32d75 --- /dev/null +++ b/crates/unavi-app/src/scene.rs @@ -0,0 +1,53 @@ +use bevy::{prelude::*, render::mesh::VertexAttributeValues}; + +pub fn spawn_lights(mut commands: Commands, mut ambient: ResMut) { + ambient.brightness = 40.0; + ambient.color = Color::linear_rgb(0.95, 0.95, 1.0); + + commands.spawn(( + DirectionalLight { + color: Color::linear_rgb(1.0, 1.0, 0.98), + illuminance: 5000.0, + shadows_enabled: true, + ..default() + }, + Transform::from_xyz(-4.5, 10.0, 7.0).looking_at(Vec3::ZERO, Vec3::Y), + )); +} + +pub fn spawn_scene( + asset_server: Res, + mut commands: Commands, + mut materials: ResMut>, + mut meshes: ResMut>, +) { + let ground_size = 30.0; + + let ground_texture = asset_server.load("images/dev-white.png"); + let ground_texture_scale = ground_size / 4.0; + + let mut ground_mesh = Mesh::from(Cuboid { + half_size: Vec3::new(ground_size / 2.0, 0.05, ground_size / 2.0), + }); + + match ground_mesh.attribute_mut(Mesh::ATTRIBUTE_UV_0).unwrap() { + VertexAttributeValues::Float32x2(uvs) => { + for uv in uvs { + uv[0] *= ground_texture_scale; + uv[1] *= ground_texture_scale; + } + } + _ => unreachable!(), + } + + commands.spawn(( + Mesh3d(meshes.add(ground_mesh)), + MeshMaterial3d(materials.add(StandardMaterial { + base_color_texture: Some(ground_texture), + ..default() + })), + Transform::from_xyz(0.0, -0.1, 0.0), + )); + + commands.spawn((Camera3d::default(), Transform::from_xyz(0.0, 1.0, 0.0))); +} diff --git a/flake.nix b/flake.nix index bed89f9a7..00c131b6c 100644 --- a/flake.nix +++ b/flake.nix @@ -66,7 +66,10 @@ formatter = treefmtEval.config.build.wrapper; apps = rec { - app = flake-utils.lib.mkApp { drv = unavi-app.package; }; + app = flake-utils.lib.mkApp { + drv = unavi-app.package; + exePath = "/unavi-app"; + }; default = app; };