diff --git a/engine/src/scene/general/camera_control.rs b/engine/src/scene/general/camera_control.rs index e5ba39f..ab4ef96 100644 --- a/engine/src/scene/general/camera_control.rs +++ b/engine/src/scene/general/camera_control.rs @@ -1,6 +1,6 @@ use crate::prelude::*; use anyhow::Result; -use cgmath::{vec3, Deg, Matrix4, Vector3}; +use cgmath::{vec3, Deg, Matrix4, Vector2, Vector3}; pub struct CameraControl { zoom_levels: Vec, @@ -81,6 +81,15 @@ impl CameraControl { self.mouse_position_start = None; } + pub fn stick_movement(&mut self, stick: Vector2, view: &mut View) -> Result<()> { + self.rotation = Deg(((self.rotation.0 + stick.x) as u32 % 360) as f32); + self.arc = Deg((self.arc.0 as i32 + stick.y as i32) + .min(CameraControl::MAX_PITCH) + .max(CameraControl::MIN_PITCH) as f32); + + self.set_camera_offset(view) + } + pub fn mouse_move(&mut self, x: u32, y: u32, view: &mut View) -> Result<()> { self.mouse_position = (x, y);