From 63fab851acf1fdd10b160b5b32428d2c40405659 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Fri, 28 Jun 2024 20:56:39 -0700 Subject: [PATCH] Editor fly camera --- src/camera.rs | 127 ++++++++++++++++++++++++++++++++++++++++++++++ src/conditions.rs | 5 +- src/editor.rs | 5 +- src/main.rs | 5 +- src/prelude.rs | 1 + 5 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 src/camera.rs diff --git a/src/camera.rs b/src/camera.rs new file mode 100644 index 0000000..95d19af --- /dev/null +++ b/src/camera.rs @@ -0,0 +1,127 @@ +use crate::prelude::*; + +/// Menu Plugin; empty struct for Plugin impl +pub(crate) struct CameraPlugin; + +impl Plugin for CameraPlugin { + fn build(&self, app: &mut App) { + app.add_systems( + Update, + move_editor_fly_camera.run_if(any_with_component::), + ); + app.add_systems( + Update, + rotate_editor_fly_camera.run_if(any_with_component::), + ); + } +} + +#[derive(Component)] +pub(crate) struct FlyCamera; + +/// Fly camera system for moving around like a drone +/// TODO: Only if key is pressed! +fn move_editor_fly_camera( + mut cameras: Query<(&Camera, &mut Transform), With>, + windows: Query<&Window>, + primary_window: Query>, + keys: Res>, + time: Res