1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::*;
use crate::renderer::*;
pub struct FirstPersonControl {
control: CameraControl,
}
impl FirstPersonControl {
pub fn new(speed: f32) -> Self {
Self {
control: CameraControl {
left_drag_horizontal: CameraAction::Yaw {
speed: std::f32::consts::PI / 1800.0,
},
left_drag_vertical: CameraAction::Pitch {
speed: std::f32::consts::PI / 1800.0,
},
scroll_vertical: CameraAction::Forward { speed },
..Default::default()
},
}
}
pub fn handle_events(&mut self, camera: &mut Camera, events: &mut [Event]) -> bool {
self.control.handle_events(camera, events)
}
}