diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-07 16:50:44 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-07 16:50:44 +0100 |
commit | 0a0abfe7b093d91447fb7070820a0e6d56d6c22d (patch) | |
tree | 17cdfd63bce8d717cd35d4d88646b837fbffc594 /client/src | |
parent | d0d8c07e1915b47610bf91176d908c9b46a5ab54 (diff) | |
download | weareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar weareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar.bz2 weareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar.zst |
normal texture
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/camera.rs | 7 | ||||
-rw-r--r-- | client/src/window.rs | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/client/src/camera.rs b/client/src/camera.rs index 289e773..1471a48 100644 --- a/client/src/camera.rs +++ b/client/src/camera.rs @@ -18,8 +18,8 @@ impl Camera { } pub fn update(&mut self, input_move: Vec3, input_rot: Vec2, dt: f32) { self.pos += input_move * dt; - self.rot.x += input_rot.x * 0.002; - self.rot.y += input_rot.y * 0.002; + self.rot.x += input_rot.y * 0.002; + self.rot.y += input_rot.x * 0.002; } pub fn to_matrix(&self) -> Mat4 { // let tdir = @@ -28,10 +28,11 @@ impl Camera { Mat4::perspective_infinite_reverse_rh(self.fov, self.aspect, 0.1) * Mat4::from_mat3(Mat3::from_euler( - EulerRot::ZXY, + EulerRot::YXZ, self.rot.x, self.rot.y, self.rot.z, )) + * Mat4::from_translation(-self.pos) } } diff --git a/client/src/window.rs b/client/src/window.rs index 8b3ee9e..fb9f375 100644 --- a/client/src/window.rs +++ b/client/src/window.rs @@ -13,12 +13,14 @@ use winit::{ pub struct WindowState { init: Option<TcpStream>, window: Option<(Window, State<'static>)>, + lock: bool, } impl WindowState { pub fn new(init: TcpStream) -> Self { Self { window: None, init: Some(init), + lock: false, } } } @@ -56,7 +58,13 @@ impl ApplicationHandler for WindowState { if event.state == ElementState::Pressed { match event.physical_key { PhysicalKey::Code(KeyCode::Escape) => { - win.set_cursor_grab(CursorGrabMode::Locked).unwrap(); + win.set_cursor_grab(if self.lock { + CursorGrabMode::None + } else { + CursorGrabMode::Locked + }) + .unwrap(); + self.lock = !self.lock; } _ => (), } |