kitgit

tirbofish/dropbear · diff

e0542db · tk

removed nalgebra and used glam instead because nalgebra was a pain to deal with. gotta deal with the depth buffer being borked and my keybinds being borked as well. oh and the gizmo works pretty well.

Unverified

diff --git a/.gitignore b/.gitignore
index 5ce925a..4456c17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ target
 .idea/
 Cargo.lock
 dropbear-engine/src/resources/textures/Autism.png
+.vscode
diff --git a/Cargo.toml b/Cargo.toml
index be27182..6c9d293 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,10 +13,10 @@ anyhow = "1.0"
 app_dirs2 = "2.5"
 async-trait = "0.1"
 bytemuck = { version = "1.23", features = ["derive"] }
-chrono = "0.4.41"
+chrono = "0.4"
 dropbear-engine = { path = "dropbear-engine" }
 egui = "0.32"
-egui-toast-fork = "0.18.0"
+egui-toast-fork = "0.18"
 egui-wgpu = { version = "0.32", features = ["winit"] }
 egui-winit = "0.32"
 egui_dnd = "0.13"
@@ -25,12 +25,14 @@ egui_extras = { version = "0.32", features = ["all_loaders"] }
 env_logger = "0.11"
 futures = "0.3"
 gilrs = "0.11"
-git2 = "0.20.2"
+git2 = "0.20"
+glam = "0.30"
 hecs = {version = "0.10", features = ["serde"]}
 log = "0.4"
 mint = "0.5"
 model_to_image = "0.1"
-nalgebra = { version = "0.33", features = ["mint"] }
+# changing to glam coz nalgebra is too much of a hassle
+# nalgebra = { version = "0.33", features = ["mint"] }
 num-traits = "0.2"
 once_cell = "1.21"
 pollster = "0.4"
diff --git a/dropbear-engine/Cargo.toml b/dropbear-engine/Cargo.toml
index 83c5a47..be0eec1 100644
--- a/dropbear-engine/Cargo.toml
+++ b/dropbear-engine/Cargo.toml
@@ -19,10 +19,11 @@ egui_extras.workspace = true
 env_logger.workspace = true
 futures.workspace = true
 gilrs.workspace = true
+glam.workspace = true
 hecs.workspace = true
 log.workspace = true
 mint.workspace = true
-nalgebra.workspace = true
+# nalgebra.workspace = true
 num-traits.workspace = true
 pollster.workspace = true
 russimp.workspace = true
diff --git a/dropbear-engine/src/camera.rs b/dropbear-engine/src/camera.rs
index bdcb0c1..7a183c6 100644
--- a/dropbear-engine/src/camera.rs
+++ b/dropbear-engine/src/camera.rs
@@ -1,4 +1,5 @@
-use nalgebra::{Matrix4, Perspective3, Point3, UnitQuaternion, Vector3};
+use glam::{DMat4, DQuat, DVec3, Mat4};
+// use nalgebra::{Matrix4, Perspective3, Point3, UnitQuaternion, Vector3};
 use wgpu::{
     BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
     BindGroupLayoutEntry, BindingType, Buffer, BufferBindingType, ShaderStages,
@@ -7,24 +8,24 @@ use wgpu::{
 use crate::graphics::Graphics;
 
 #[rustfmt::skip]
-pub const OPENGL_TO_WGPU_MATRIX: Matrix4<f32> = Matrix4::new(
-    1.0, 0.0, 0.0, 0.0,
-    0.0, 1.0, 0.0, 0.0,
-    0.0, 0.0, 0.5, 0.0,
-    0.0, 0.0, 0.5, 1.0,
-);
+pub const OPENGL_TO_WGPU_MATRIX: [[f64; 4]; 4] = [
+    [1.0, 0.0, 0.0, 0.0],
+    [0.0, 1.0, 0.0, 0.0],
+    [0.0, 0.0, 0.5, 0.0],
+    [0.0, 0.0, 0.5, 1.0],
+];
 
 #[derive(Default)]
 pub struct Camera {
-    pub eye: Point3<f32>,
-    pub target: Point3<f32>,
-    pub up: Vector3<f32>,
-    pub aspect: f32,
-    pub fov_y: f32,
-    pub znear: f32,
-    pub zfar: f32,
-    pub yaw: f32,
-    pub pitch: f32,
+    pub eye: DVec3,
+    pub target: DVec3,
+    pub up: DVec3,
+    pub aspect: f64,
+    pub fov_y: f64,
+    pub znear: f64,
+    pub zfar: f64,
+    pub yaw: f64,
+    pub pitch: f64,
 
     pub uniform: CameraUniform,
     buffer: Option<Buffer>,
@@ -32,25 +33,25 @@ pub struct Camera {
     layout: Option<BindGroupLayout>,
     bind_group: Option<BindGroup>,
 
-    pub speed: f32,
-    pub sensitivity: f32,
+    pub speed: f64,
+    pub sensitivity: f64,
 
-    pub view_mat: Matrix4<f32>,
-    pub proj_mat: Matrix4<f32>,
+    pub view_mat: DMat4,
+    pub proj_mat: DMat4,
 }
 
 impl Camera {
     pub fn new(
         graphics: &Graphics,
-        eye: Point3<f32>,
-        target: Point3<f32>,
-        up: Vector3<f32>,
-        aspect: f32,
-        fov_y: f32,
-        znear: f32,
-        zfar: f32,
-        speed: f32,
-        sensitivity: f32,
+        eye: DVec3,
+        target: DVec3,
+        up: DVec3,
+        aspect: f64,
+        fov_y: f64,
+        znear: f64,
+        zfar: f64,
+        speed: f64,
+        sensitivity: f64,
     ) -> Self {
         let uniform = CameraUniform::new();
         let mut camera = Self {
@@ -82,10 +83,10 @@ impl Camera {
     pub fn predetermined(graphics: &Graphics) -> Self {
         Self::new(
             graphics,
-            Point3::new(0.0, 1.0, 2.0),
-            Point3::new(0.0, 0.0, 0.0),
-            Vector3::y(),
-            (graphics.state.config.width / graphics.state.config.height) as f32,
+            DVec3::new(0.0, 1.0, 2.0),
+            DVec3::new(0.0, 0.0, 0.0),
+            DVec3::Y,
+            (graphics.state.config.width / graphics.state.config.height).into(),
             45.0,
             0.1,
             100.0,
@@ -94,9 +95,9 @@ impl Camera {
         )
     }
 
-    pub fn rotation(&self) -> UnitQuaternion<f32> {
-        let yaw = UnitQuaternion::from_axis_angle(&Vector3::y_axis(), self.yaw);
-        let pitch = UnitQuaternion::from_axis_angle(&Vector3::x_axis(), self.pitch);
+    pub fn rotation(&self) -> DQuat {
+        let yaw = DQuat::from_axis_angle(DVec3::Y, self.yaw);
+        let pitch = DQuat::from_axis_angle(DVec3::X, self.pitch);
         yaw * pitch
     }
 
@@ -112,20 +113,28 @@ impl Camera {
         self.bind_group.as_ref().unwrap()
     }
 
-    pub fn forward(&self) -> Vector3<f32> {
+    pub fn forward(&self) -> DVec3 {
         (self.target - self.eye).normalize()
     }
 
-    pub fn position(&self) -> Point3<f32> {
+    pub fn position(&self) -> DVec3 {
         self.eye
     }
 
-    fn build_vp(&mut self) -> Matrix4<f32> {
-        let view = Matrix4::<f32>::look_at_rh(&self.eye, &self.target, &self.up);
-        let proj = Perspective3::new(self.aspect, self.fov_y.to_radians(), self.znear, self.zfar);
+    fn build_vp(&mut self) -> DMat4 {
+        let view = DMat4::look_at_lh(
+            self.eye, self.target, self.up
+        );
+        let proj = DMat4::perspective_infinite_reverse_lh(
+            self.fov_y,
+            self.aspect,
+            self.znear
+        );
+
         self.view_mat = view.clone();
-        self.proj_mat = proj.clone().to_homogeneous();
-        let result = OPENGL_TO_WGPU_MATRIX * proj.to_homogeneous() * view;
+        self.proj_mat = proj.clone();
+
+        let result = DMat4::from_cols_array_2d(&OPENGL_TO_WGPU_MATRIX) * proj * view;
         result
     }
 
@@ -174,7 +183,7 @@ impl Camera {
 
     pub fn update_view_proj(&mut self) {
         let mvp = self.build_vp();
-        self.uniform.view_proj = mvp.into();
+        self.uniform.view_proj = mvp.as_mat4().to_cols_array_2d();
     }
 
     pub fn move_forwards(&mut self) {
@@ -191,14 +200,14 @@ impl Camera {
 
     pub fn move_right(&mut self) {
         let forward = (self.target - self.eye).normalize();
-        let right = forward.cross(&self.up).normalize();
+        let right = forward.cross(self.up).normalize();
         self.eye += right * self.speed;
         self.target += right * self.speed;
     }
 
     pub fn move_left(&mut self) {
         let forward = (self.target - self.eye).normalize();
-        let right = forward.cross(&self.up).normalize();
+        let right = forward.cross(self.up).normalize();
         self.eye -= right * self.speed;
         self.target -= right * self.speed;
     }
@@ -215,13 +224,13 @@ impl Camera {
         self.target -= up * self.speed;
     }
 
-    pub fn track_mouse_delta(&mut self, dx: f32, dy: f32) {
+    pub fn track_mouse_delta(&mut self, dx: f64, dy: f64) {
         let sensitivity = self.sensitivity;
         self.yaw += dx * sensitivity;
         self.pitch -= dy * sensitivity;
-        let max_pitch = std::f32::consts::FRAC_PI_2 - 0.01;
+        let max_pitch = std::f64::consts::FRAC_PI_2 - 0.01;
         self.pitch = self.pitch.clamp(-max_pitch, max_pitch);
-        let dir = Vector3::new(
+        let dir = DVec3::new(
             self.yaw.cos() * self.pitch.cos(),
             self.pitch.sin(),
             self.yaw.sin() * self.pitch.cos(),
@@ -239,7 +248,7 @@ pub struct CameraUniform {
 impl CameraUniform {
     pub fn new() -> Self {
         Self {
-            view_proj: Matrix4::<f32>::identity().into(),
+            view_proj: Mat4::IDENTITY.to_cols_array_2d()
         }
     }
 }
diff --git a/dropbear-engine/src/entity.rs b/dropbear-engine/src/entity.rs
index d4c6561..33178e6 100644
--- a/dropbear-engine/src/entity.rs
+++ b/dropbear-engine/src/entity.rs
@@ -1,6 +1,7 @@
 use std::path::PathBuf;
 
-use nalgebra::{Matrix4, UnitQuaternion, Vector3};
+use glam::{DMat4, DQuat, DVec3, Mat4};
+// use nalgebra::{Matrix4, UnitQuaternion, Vector3};
 use wgpu::{BindGroup, Buffer, RenderPass, util::DeviceExt};
 
 use crate::{
@@ -22,54 +23,48 @@ pub struct AdoptedEntity {
 
 #[derive(Debug, Clone)]
 pub struct Transform {
-    pub position: Vector3<f32>,
-    pub rotation: UnitQuaternion<f32>,
-    pub scale: Vector3<f32>,
+    pub position: DVec3,
+    pub rotation: DQuat,
+    pub scale: DVec3,
 }
 
 impl Default for Transform {
     fn default() -> Self {
         Self {
-            position: Vector3::new(0.0, 0.0, 0.0),
-            rotation: UnitQuaternion::identity(),
-            scale: Vector3::new(1.0, 1.0, 1.0),
+            position: DVec3::new(0.0, 0.0, 0.0),
+            rotation: DQuat::IDENTITY,
+            scale: DVec3::new(1.0, 1.0, 1.0),
         }
     }
 }
 
 impl Transform {
     pub fn new() -> Self {
-        Self {
-            position: Vector3::new(0.0, 0.0, 0.0),
-            rotation: UnitQuaternion::identity(),
-            scale: Vector3::new(1.0, 1.0, 1.0),
-        }
+        Self::default()
     }
 
-    pub fn matrix(&self) -> Matrix4<f32> {
-        Matrix4::new_translation(&self.position)
-            * self.rotation.to_homogeneous()
-            * Matrix4::new_nonuniform_scaling(&self.scale)
+    pub fn matrix(&self) -> DMat4 {        
+        DMat4::from_scale_rotation_translation(self.scale, self.rotation, self.position)
     }
 
-    pub fn rotate_x(&mut self, angle_rad: f32) {
-        self.rotation *= UnitQuaternion::from_euler_angles(angle_rad, 0.0, 0.0);
+    pub fn rotate_x(&mut self, angle_rad: f64) {
+        self.rotation *= DQuat::from_euler(glam::EulerRot::XYZ, angle_rad, 0.0, 0.0);
     }
 
-    pub fn rotate_y(&mut self, angle_rad: f32) {
-        self.rotation *= UnitQuaternion::from_euler_angles(0.0, angle_rad, 0.0);
+    pub fn rotate_y(&mut self, angle_rad: f64) {
+        self.rotation *= DQuat::from_euler(glam::EulerRot::XYZ, 0.0, angle_rad, 0.0);
     }
 
-    pub fn rotate_z(&mut self, angle_rad: f32) {
-        self.rotation *= UnitQuaternion::from_euler_angles(0.0, 0.0, angle_rad);
+    pub fn rotate_z(&mut self, angle_rad: f64) {
+        self.rotation *= DQuat::from_euler(glam::EulerRot::XYZ, 0.0, 0.0, angle_rad);
     }
 
-    pub fn translate(&mut self, translation: Vector3<f32>) {
+    pub fn translate(&mut self, translation: DVec3) {
         self.position += translation;
     }
 
-    pub fn scale(&mut self, scale: Vector3<f32>) {
-        self.scale.component_mul_assign(&scale);
+    pub fn scale(&mut self, scale: DVec3) {
+        self.scale *= scale;
     }
 }
 
@@ -97,7 +92,7 @@ impl AdoptedEntity {
                     }],
                 });
 
-        let instance = Instance::new(Vector3::identity(), UnitQuaternion::identity());
+        let instance = Instance::new(DVec3::ONE, DQuat::IDENTITY);
 
         let instance_buffer =
             graphics
@@ -123,7 +118,7 @@ impl AdoptedEntity {
     }
 
     pub fn update(&mut self, graphics: &Graphics, transform: &Transform) {
-        self.uniform.model = transform.matrix().into();
+        self.uniform.model = transform.matrix().as_mat4().to_cols_array_2d();
 
         if let Some(buffer) = &self.uniform_buffer {
             graphics
@@ -166,7 +161,7 @@ pub struct ModelUniform {
 impl ModelUniform {
     pub fn new() -> Self {
         Self {
-            model: Matrix4::<f32>::identity().into(),
+            model: Mat4::IDENTITY.to_cols_array_2d(),
         }
     }
 }
diff --git a/dropbear-engine/src/graphics.rs b/dropbear-engine/src/graphics.rs
index 03cd678..a96fec0 100644
--- a/dropbear-engine/src/graphics.rs
+++ b/dropbear-engine/src/graphics.rs
@@ -1,8 +1,9 @@
 use std::{fs, path::PathBuf};
 
 use egui::Context;
+use glam::{DMat4, DQuat, DVec3};
 use image::GenericImageView;
-use nalgebra::{Matrix4, UnitQuaternion, Vector3};
+// use nalgebra::{Matrix4, UnitQuaternion, Vector3};
 use wgpu::{
     BindGroup, BindGroupLayout, Buffer, BufferAddress, BufferUsages, Color, CommandEncoder,
     CompareFunction, DepthBiasState, Device, Extent3d, LoadOp, Operations, RenderPass,
@@ -27,7 +28,11 @@ pub struct Graphics<'a> {
 pub const NO_TEXTURE: &'static [u8] = include_bytes!("no-texture.png");
 
 impl<'a> Graphics<'a> {
-    pub fn new(state: &'a mut State, view: &'a TextureView, encoder: &'a mut CommandEncoder) -> Self {
+    pub fn new(
+        state: &'a mut State,
+        view: &'a TextureView,
+        encoder: &'a mut CommandEncoder,
+    ) -> Self {
         let screen_size = (state.config.width as f32, state.config.height as f32);
         Self {
             state,
@@ -391,14 +396,14 @@ impl Texture {
 
 #[derive(Default)]
 pub struct Instance {
-    pub position: Vector3<f32>,
-    pub rotation: UnitQuaternion<f32>,
+    pub position: DVec3,
+    pub rotation: DQuat,
 
     buffer: Option<Buffer>,
 }
 
 impl Instance {
-    pub fn new(position: Vector3<f32>, rotation: UnitQuaternion<f32>) -> Self {
+    pub fn new(position: DVec3, rotation: DQuat) -> Self {
         Self {
             position,
             rotation,
@@ -408,9 +413,9 @@ impl Instance {
 
     pub fn to_raw(&self) -> InstanceRaw {
         let rotation = self.rotation;
-        let model_matrix = Matrix4::new_translation(&self.position) * rotation.to_homogeneous();
+        let model_matrix = DMat4::from_translation(self.position) * DMat4::from_quat(rotation);
         InstanceRaw {
-            model: model_matrix.into(),
+            model: model_matrix.as_mat4().to_cols_array_2d(),
         }
     }
 
@@ -418,9 +423,8 @@ impl Instance {
         self.buffer.as_ref().unwrap()
     }
 
-    pub fn from_matrix(mat: Matrix4<f32>) -> Self {
-        let position = mat.fixed_view::<3, 1>(0, 3).into();
-        let rotation = UnitQuaternion::from_matrix(&mat.fixed_view::<3, 3>(0, 0).into_owned());
+    pub fn from_matrix(mat: DMat4) -> Self {
+        let (_, rotation, position) = mat.to_scale_rotation_translation();
         Instance {
             position,
             rotation,
diff --git a/eucalyptus/Cargo.toml b/eucalyptus/Cargo.toml
index 6e5a26d..22ba815 100644
--- a/eucalyptus/Cargo.toml
+++ b/eucalyptus/Cargo.toml
@@ -23,10 +23,11 @@ egui_dock-fork.workspace = true
 egui_extras.workspace = true
 gilrs.workspace = true
 git2.workspace = true
+glam.workspace = true
 hecs.workspace = true
 log.workspace = true
 model_to_image.workspace = true
-nalgebra.workspace = true
+# nalgebra.workspace = true
 once_cell.workspace = true
 rfd.workspace = true
 rhai.workspace = true
diff --git a/eucalyptus/src/editor/dock.rs b/eucalyptus/src/editor/dock.rs
index 69ecc6c..880d7c9 100644
--- a/eucalyptus/src/editor/dock.rs
+++ b/eucalyptus/src/editor/dock.rs
@@ -1,19 +1,22 @@
 use super::*;
 use std::{
-    collections::HashSet, fs, sync::{LazyLock, Mutex}
+    collections::HashSet,
+    fs,
+    sync::{LazyLock, Mutex},
 };
 
-use dropbear_engine::{
-    entity::Transform, graphics::NO_TEXTURE
-};
+use dropbear_engine::{entity::Transform, graphics::NO_TEXTURE};
 use egui;
-use egui_extras;
-use log;
 use egui_dock_fork::TabViewer;
+use egui_extras;
 use egui_toast_fork::{Toast, ToastKind};
-use nalgebra::{UnitQuaternion, Vector3};
+use log;
+// use nalgebra::{Matrix4, Perspective3, UnitQuaternion, Vector3};
 use serde::{Deserialize, Serialize};
-use transform_gizmo_egui::{mint::RowMatrix4, Gizmo, GizmoConfig, GizmoExt, GizmoMode};
+use transform_gizmo_egui::{
+    Gizmo, GizmoConfig, GizmoExt, GizmoMode,
+    math::{DMat4, DVec3},
+};
 
 use crate::{
     APP_INFO,
@@ -93,68 +96,109 @@ impl<'a> TabViewer for EditorTabViewer<'a> {
                 let new_tex_width = size.x.max(1.0) as u32;
                 let new_tex_height = size.y.max(1.0) as u32;
 
-                if self.tex_size.width != new_tex_height || self.tex_size.height != new_tex_height {
+                if self.tex_size.width != new_tex_width || self.tex_size.height != new_tex_height {
                     // log::debug!("Sending resize signal");
                     *self.resize_signal = (true, new_tex_width, new_tex_height);
 
                     self.tex_size.width = new_tex_width;
                     self.tex_size.height = new_tex_height;
 
-                    let new_aspect = new_tex_width as f32 / new_tex_height as f32;
+                    let new_aspect = new_tex_width as f64 / new_tex_height as f64;
                     self.camera.aspect = new_aspect;
                 }
 
+                let image_response = ui.add(
+                    egui::Image::new((
+                        self.view,
+                        [self.tex_size.width as f32, self.tex_size.height as f32].into(),
+                    ))
+                    .sense(egui::Sense::click_and_drag()),
+                );
+                log::debug!("Viewport rect: {:?}", image_response.rect);
+                log::debug!(
+                    "Camera matrices - View: {:?}, Proj: {:?}",
+                    self.camera.view_mat,
+                    self.camera.proj_mat
+                );
+
                 // TODO: Figure out how to get the guizmos working because this is fucking annoying to deal with
                 // Note to self: fuck you >:(
                 // Note to self: ok wow thats pretty rude im trying my best >﹏<
+                // Note to self: finally holy shit i got it working
                 self.gizmo.update_config(GizmoConfig {
-                    view_matrix: RowMatrix4::from(Into::<[[f64; 4]; 4]>::into(self.camera.view_mat.cast::<f64>())),
-                    projection_matrix: RowMatrix4::from(Into::<[[f64; 4]; 4]>::into(self.camera.view_mat.cast::<f64>())),
-                    viewport: ui.clip_rect(),
+                    view_matrix: DMat4::look_at_lh(
+                        DVec3::new(
+                            self.camera.eye.x as f64,
+                            self.camera.eye.y as f64,
+                            self.camera.eye.z as f64,
+                        ),
+                        DVec3::new(
+                            self.camera.target.x as f64,
+                            self.camera.target.y as f64,
+                            self.camera.target.z as f64,
+                        ),
+                        DVec3::new(
+                            self.camera.up.x as f64,
+                            self.camera.up.y as f64,
+                            self.camera.up.z as f64,
+                        ),
+                    )
+                    .into(),
+                    projection_matrix: DMat4::perspective_infinite_reverse_lh(
+                        self.camera.fov_y as f64,
+                        self.camera.aspect as f64,
+                        self.camera.znear as f64,
+                    )
+                    .into(),
+                    viewport: image_response.rect,
                     modes: GizmoMode::all(),
                     orientation: transform_gizmo_egui::GizmoOrientation::Global,
                     ..Default::default()
-                });                
+                });
 
-                let image_response = ui.add(
-                    egui::Image::new((self.view, [self.tex_size.width as f32, self.tex_size.height as f32].into()))
-                        .sense(egui::Sense::click_and_drag())
-                );
-                log::debug!("Viewport rect: {:?}", image_response.rect);
-                log::debug!("Camera matrices - View: {:?}, Proj: {:?}", self.camera.view_mat, self.camera.proj_mat);
+                println!("View Matrix: {:#?}", self.camera.view_mat);
+                println!("Projection Matrix: {:#?}", self.camera.proj_mat);
 
                 if let Some(entity_id) = self.selected_entity {
-        if let Ok(transform) = self.world.query_one_mut::<&mut Transform>(*entity_id) {
-            let gizmo_transform = transform_gizmo_egui::math::Transform::from_scale_rotation_translation(
-                transform.scale.cast::<f64>(), 
-                transform.rotation.cast::<f64>(), 
-                transform.position.cast::<f64>(),
-            );
-
-            if let Some((result, new_transforms)) = self.gizmo.interact(ui, &[gizmo_transform]) {
-                if let Some(new_transform) = new_transforms.first() {
-                    transform.position = Vector3::from([
-                        new_transform.translation.x as f32,
-                        new_transform.translation.y as f32,
-                        new_transform.translation.z as f32,
-                    ]);
-                    transform.rotation = UnitQuaternion::from_quaternion(nalgebra::Quaternion::new(
-                        new_transform.rotation.s as f32,
-                        new_transform.rotation.v.x as f32, 
-                        new_transform.rotation.v.y as f32, 
-                        new_transform.rotation.v.z as f32
-                    ));
-                    transform.scale = Vector3::from([
-                        new_transform.scale.x as f32,
-                        new_transform.scale.y as f32,
-                        new_transform.scale.z as f32,
-                    ]);
-                    log::debug!("Gizmo updated entity {:?}: {:?}", entity_id, result);
+                    log::debug!("Entity selected: {:?}", entity_id);
+                    if let Ok(transform) =
+                        self.world.query_one_mut::<&mut Transform>(*entity_id)
+                    {
+                        log::debug!(
+                            "Transform - pos: {:?}, rot: {:?}, scale: {:?}",
+                            transform.position,
+                            transform.rotation,
+                            transform.scale
+                        );
+
+                        let gizmo_transform =
+                            transform_gizmo_egui::math::Transform::from_scale_rotation_translation(
+                                transform.scale,
+                                transform.rotation,
+                                transform.position,
+                            );
+
+                        log::debug!("Gizmo transform created: {:?}", gizmo_transform);
+                        log::debug!("Calling gizmo.interact...");
+
+                        if let Some((result, new_transforms)) =
+                            self.gizmo.interact(ui, &[gizmo_transform])
+                        {
+                            log::debug!("Gizmo interaction successful: {:?}", result);
+                            if let Some(new_transform) = new_transforms.first() {
+                                transform.position = new_transform.translation.into();
+                                transform.rotation = new_transform.rotation.into();
+                                transform.scale = new_transform.scale.into();
+                                log::debug!("Gizmo updated entity {:?}: {:?}", entity_id, result);
+                            }
+                        } else { }
+                    } else {
+                        log::warn!("Unable to query entity: {:?}", entity_id);
+                    }
+                } else {
+                    log::debug!("No entity selected");
                 }
             }
-        }
-    }
-            }
             EditorTab::ModelEntityList => {
                 ui.label("Model/Entity List");
                 // TODO: deal with show_entity_tree and figure out how to convert hecs::World
diff --git a/eucalyptus/src/editor/input.rs b/eucalyptus/src/editor/input.rs
index a168021..2ca45ac 100644
--- a/eucalyptus/src/editor/input.rs
+++ b/eucalyptus/src/editor/input.rs
@@ -1,17 +1,13 @@
 use super::*;
-use dropbear_engine::{
-    input::{Controller, Keyboard, Mouse},
-};
+use dropbear_engine::input::{Controller, Keyboard, Mouse};
 use gilrs::{Button, GamepadId};
 use log;
-use winit::{dpi::PhysicalPosition, event::MouseButton, event_loop::ActiveEventLoop, keyboard::KeyCode};
+use winit::{
+    dpi::PhysicalPosition, event::MouseButton, event_loop::ActiveEventLoop, keyboard::KeyCode,
+};
 
 impl Keyboard for Editor {
-    fn key_down(
-        &mut self,
-        key: KeyCode,
-        _event_loop: &ActiveEventLoop,
-    ) {
+    fn key_down(&mut self, key: KeyCode, _event_loop: &ActiveEventLoop) {
         match key {
             // KeyCode::Escape => event_loop.exit(),
             KeyCode::Escape => {
@@ -74,11 +70,7 @@ impl Keyboard for Editor {
         }
     }
 
-    fn key_up(
-        &mut self,
-        key: KeyCode,
-        _event_loop: &ActiveEventLoop,
-    ) {
+    fn key_up(&mut self, key: KeyCode, _event_loop: &ActiveEventLoop) {
         self.pressed_keys.remove(&key);
     }
 }
@@ -107,27 +99,31 @@ impl Mouse for Editor {
 }
 
 impl Controller for Editor {
-    fn button_down(
-        &mut self,
-        _button: Button,
-        _id: GamepadId,
-    ) {
+    fn button_down(&mut self, button: Button, _id: GamepadId) {
+        match button {
+            Button::South => {
+                self.camera.move_up();
+            }
+            Button::East => {
+                self.camera.move_down();
+            }
+            Button::LeftTrigger2 => {
+                self.camera.move_up();
+            }
+            Button::RightTrigger2 => {
+                self.camera.move_down();
+            }
+            _ => {
+                log::debug!("Controller button pressed: {:?}", button);
+            }
+        }
     }
 
-    fn button_up(
-        &mut self,
-        _button: Button,
-        _id: GamepadId,
-    ) {
-    }
+    fn button_up(&mut self, _button: Button, _id: GamepadId) {}
 
-    fn left_stick_changed(&mut self, _x: f32, _y: f32, _id: GamepadId) {
-        // used for moving the camera
-    }
+    fn left_stick_changed(&mut self, _x: f32, _y: f32, _id: GamepadId) {}
 
-    fn right_stick_changed(&mut self, _x: f32, _y: f32, _id: GamepadId) {
-        // used for moving the player
-    }
+    fn right_stick_changed(&mut self, _x: f32, _y: f32, _id: GamepadId) {}
 
     fn on_connect(&mut self, _id: GamepadId) {}
 
diff --git a/eucalyptus/src/editor/mod.rs b/eucalyptus/src/editor/mod.rs
index 0d13b72..ff30ea9 100644
--- a/eucalyptus/src/editor/mod.rs
+++ b/eucalyptus/src/editor/mod.rs
@@ -10,18 +10,16 @@ use std::{
     sync::{Arc, LazyLock, Mutex},
 };
 
-use dropbear_engine::{
-    camera::Camera, scene::SceneCommand, 
-};
+use dropbear_engine::{camera::Camera, scene::SceneCommand};
 use egui::{self, Context};
+use egui_dock_fork::{DockArea, DockState, NodeIndex, Style};
+use egui_toast_fork::{ToastOptions, Toasts};
 use hecs::World;
 use log;
+use once_cell::sync::Lazy;
 use transform_gizmo_egui::Gizmo;
 use wgpu::{Color, Extent3d, RenderPipeline};
 use winit::{keyboard::KeyCode, window::Window};
-use egui_dock_fork::{DockArea, DockState, NodeIndex, Style};
-use egui_toast_fork::{ToastOptions, Toasts};
-use once_cell::sync::Lazy;
 
 use crate::states::{EntityNode, PROJECT};
 
@@ -46,7 +44,6 @@ pub struct Editor {
     is_viewport_focused: bool,
     pressed_keys: HashSet<KeyCode>,
     // is_cursor_locked: bool,
-
     window: Option<Arc<Window>>,
 
     show_new_project: bool,
diff --git a/eucalyptus/src/editor/scene.rs b/eucalyptus/src/editor/scene.rs
index 49d5246..62f5637 100644
--- a/eucalyptus/src/editor/scene.rs
+++ b/eucalyptus/src/editor/scene.rs
@@ -6,10 +6,11 @@ use dropbear_engine::{
     graphics::{Graphics, Shader},
     scene::{Scene, SceneCommand},
 };
+use glam::DVec3;
 use log;
-use winit::{event_loop::ActiveEventLoop, keyboard::KeyCode};
+// use nalgebra::{Point3, Vector3};
 use wgpu::Color;
-use nalgebra::{Point3, Vector3};
+use winit::{event_loop::ActiveEventLoop, keyboard::KeyCode};
 
 use super::*;
 use crate::states::{Node, RESOURCES, ScriptComponent};
@@ -57,12 +58,12 @@ impl Scene for Editor {
             log::warn!("cube path is empty :(")
         }
 
-        let aspect = self.size.width as f32 / self.size.height as f32;
+        let aspect = self.size.width as f64 / self.size.height as f64;
         let camera = Camera::new(
             graphics,
-            Point3::new(0.0, 1.0, 2.0),
-            Point3::new(0.0, 0.0, 0.0),
-            Vector3::y(),
+            DVec3::new(0.0, 1.0, 2.0),
+            DVec3::new(0.0, 0.0, 0.0),
+            DVec3::Y,
             aspect,
             45.0,
             0.1,
@@ -75,11 +76,7 @@ impl Scene for Editor {
         let model_layout = graphics.create_model_uniform_bind_group_layout();
         let pipeline = graphics.create_render_pipline(
             &shader,
-            vec![
-                texture_bind_group,
-                camera.layout(),
-                &model_layout,
-            ],
+            vec![texture_bind_group, camera.layout(), &model_layout],
         );
 
         self.camera = camera;
@@ -99,21 +96,21 @@ impl Scene for Editor {
         // }
 
         // if self.is_cursor_locked {
-            for key in &self.pressed_keys {
-                match key {
-                    KeyCode::KeyW => self.camera.move_forwards(),
-                    KeyCode::KeyA => self.camera.move_left(),
-                    KeyCode::KeyD => self.camera.move_right(),
-                    KeyCode::KeyS => self.camera.move_back(),
-                    KeyCode::ShiftLeft => self.camera.move_down(),
-                    KeyCode::Space => self.camera.move_up(),
-                    _ => {}
-                }
+        for key in &self.pressed_keys {
+            match key {
+                KeyCode::KeyW => self.camera.move_forwards(),
+                KeyCode::KeyA => self.camera.move_left(),
+                KeyCode::KeyD => self.camera.move_right(),
+                KeyCode::KeyS => self.camera.move_back(),
+                KeyCode::ShiftLeft => self.camera.move_down(),
+                KeyCode::Space => self.camera.move_up(),
+                _ => {}
             }
+        }
         // }
 
         let new_size = graphics.state.viewport_texture.size;
-        let new_aspect = new_size.width as f32 / new_size.height as f32;
+        let new_aspect = new_size.width as f64 / new_size.height as f64;
         self.camera.aspect = new_aspect;
 
         self.camera.update(graphics);
@@ -144,7 +141,7 @@ impl Scene for Editor {
             // graphics.state.resize(self.resize_signal.1, self.resize_signal.2);
             // self.resize_signal.0 = false;
         }
-        
+
         self.window = Some(graphics.state.window.clone());
         if let Ok(mut toasts) = GLOBAL_TOASTS.lock() {
             toasts.show(graphics.get_egui_context());
diff --git a/eucalyptus/src/menu.rs b/eucalyptus/src/menu.rs
index b53df6e..c7a615c 100644
--- a/eucalyptus/src/menu.rs
+++ b/eucalyptus/src/menu.rs
@@ -8,12 +8,14 @@ use dropbear_engine::{
     input::{Controller, Keyboard, Mouse},
     scene::{Scene, SceneCommand},
 };
-use log::{self, debug};
-use gilrs;
 use egui::{self, FontId, Frame, RichText};
 use egui_toast_fork::{ToastOptions, Toasts};
+use gilrs;
 use git2::Repository;
-use winit::{dpi::PhysicalPosition, event::MouseButton, event_loop::ActiveEventLoop, keyboard::KeyCode};
+use log::{self, debug};
+use winit::{
+    dpi::PhysicalPosition, event::MouseButton, event_loop::ActiveEventLoop, keyboard::KeyCode,
+};
 
 use crate::states::{PROJECT, ProjectConfig};
 
@@ -114,8 +116,7 @@ impl MainMenu {
                         } else {
                             Err(anyhow!("Project path not found"))
                         }
-                    }
-                    else {
+                    } else {
                         if !full_path.exists() {
                             fs::create_dir_all(&full_path)
                                 .map_err(|e| anyhow!(e))
@@ -323,22 +324,13 @@ impl Scene for MainMenu {
 }
 
 impl Keyboard for MainMenu {
-    fn key_down(
-        &mut self,
-        _key: KeyCode,
-        _event_loop: &ActiveEventLoop,
-    ) {
+    fn key_down(&mut self, _key: KeyCode, _event_loop: &ActiveEventLoop) {
         // if key == dropbear_engine::winit::keyboard::KeyCode::Escape {
         //     event_loop.exit();
         // }
     }
 
-    fn key_up(
-        &mut self,
-        _key: KeyCode,
-        _event_loop: &ActiveEventLoop,
-    ) {
-    }
+    fn key_up(&mut self, _key: KeyCode, _event_loop: &ActiveEventLoop) {}
 }
 
 impl Mouse for MainMenu {
diff --git a/eucalyptus/src/states.rs b/eucalyptus/src/states.rs
index d87977a..5a04cec 100644
--- a/eucalyptus/src/states.rs
+++ b/eucalyptus/src/states.rs
@@ -12,9 +12,9 @@ use std::{
 };
 
 use chrono::Utc;
+use egui_dock_fork::DockState;
 use hecs;
 use log;
-use egui_dock_fork::DockState;
 use once_cell::sync::Lazy;
 use ron::ser::PrettyConfig;
 use serde::{Deserialize, Serialize};
diff --git a/eucalyptus/src/utils.rs b/eucalyptus/src/utils.rs
index 64a3f11..11be79a 100644
--- a/eucalyptus/src/utils.rs
+++ b/eucalyptus/src/utils.rs
@@ -5,8 +5,8 @@ use std::{
 };
 
 use anyhow::anyhow;
-use egui::{Context};
 use dropbear_engine::scene::SceneCommand;
+use egui::Context;
 use egui_toast_fork::{Toast, ToastOptions, Toasts};
 use git2::Repository;