Add Flycam::defocus()
This commit is contained in:
parent
23234c2263
commit
cffe12c930
|
@ -121,6 +121,18 @@ impl Flycam {
|
|||
self.aspect = (width as f32) / (height as f32);
|
||||
}
|
||||
|
||||
/// disable all key presses
|
||||
pub fn defocus(&mut self) {
|
||||
self.is_world_down_pressed = false;
|
||||
self.is_world_up_pressed = false;
|
||||
self.is_cam_down_pressed = false;
|
||||
self.is_cam_up_pressed = false;
|
||||
self.is_forward_pressed = false;
|
||||
self.is_left_pressed = false;
|
||||
self.is_backward_pressed = false;
|
||||
self.is_right_pressed = false;
|
||||
}
|
||||
|
||||
/// apply input and update camera movement
|
||||
pub fn update(&mut self) {
|
||||
let dt = self.last_update.elapsed();
|
||||
|
|
|
@ -250,6 +250,10 @@ impl Application {
|
|||
self.flycam.resize(new_size.width, new_size.height);
|
||||
}
|
||||
|
||||
pub fn on_lost_focus(&mut self) {
|
||||
self.flycam.defocus();
|
||||
}
|
||||
|
||||
pub fn on_surface_lost(&mut self) {
|
||||
self.viewport.resize(self.viewport.size);
|
||||
}
|
||||
|
@ -441,6 +445,9 @@ fn main() {
|
|||
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
|
||||
application.on_resize(**new_inner_size);
|
||||
}
|
||||
WindowEvent::Focused(false) => {
|
||||
application.on_lost_focus();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue