camera speed, window settings
This commit is contained in:
parent
3838b5d7c6
commit
b741202111
2 changed files with 22 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use cgmath::num_traits::clamp;
|
use cgmath::num_traits::clamp;
|
||||||
use winit::event::*;
|
use winit::{dpi::PhysicalPosition, event::*};
|
||||||
|
|
||||||
pub struct Camera {
|
pub struct Camera {
|
||||||
pub position: cgmath::Point3<f32>,
|
pub position: cgmath::Point3<f32>,
|
||||||
|
@ -211,6 +211,24 @@ impl CameraController {
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WindowEvent::MouseWheel { delta, .. } => match delta {
|
||||||
|
MouseScrollDelta::LineDelta(_, scroll) => {
|
||||||
|
if *scroll > 0.0 {
|
||||||
|
self.speed *= 2.0;
|
||||||
|
} else {
|
||||||
|
self.speed /= 2.0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
MouseScrollDelta::PixelDelta(PhysicalPosition { y: scroll, .. }) => {
|
||||||
|
if *scroll > 0.0 {
|
||||||
|
self.speed *= 2.0;
|
||||||
|
} else {
|
||||||
|
self.speed /= 2.0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,9 @@ use winit::{
|
||||||
pub async fn run() {
|
pub async fn run() {
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
||||||
|
window.set_cursor_grab(true).unwrap();
|
||||||
|
window.set_cursor_visible(false);
|
||||||
|
window.set_decorations(false);
|
||||||
let mut state = State::new(&window).await;
|
let mut state = State::new(&window).await;
|
||||||
let mut last_render = Instant::now();
|
let mut last_render = Instant::now();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue