|
|
@ -134,17 +134,6 @@ impl CameraController {
|
|
|
|
self.rotate_vertical = mouse_dy as f32;
|
|
|
|
self.rotate_vertical = mouse_dy as f32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// pub fn process_scroll(&mut self, delta: &MouseScrollDelta) {
|
|
|
|
|
|
|
|
// self.scroll = -match delta {
|
|
|
|
|
|
|
|
// // I'm assuming a line is about 100 pixels
|
|
|
|
|
|
|
|
// MouseScrollDelta::LineDelta(_, scroll) => scroll * 100.0,
|
|
|
|
|
|
|
|
// MouseScrollDelta::PixelDelta(LogicalPosition {
|
|
|
|
|
|
|
|
// y: scroll,
|
|
|
|
|
|
|
|
// ..
|
|
|
|
|
|
|
|
// }) => *scroll as f32,
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn update_camera(&mut self, camera: &mut Camera, dt: f32) {
|
|
|
|
pub fn update_camera(&mut self, camera: &mut Camera, dt: f32) {
|
|
|
|
// Move forward/backward and left/right
|
|
|
|
// Move forward/backward and left/right
|
|
|
|
let (yaw_sin, yaw_cos) = camera.yaw.0.sin_cos();
|
|
|
|
let (yaw_sin, yaw_cos) = camera.yaw.0.sin_cos();
|
|
|
@ -168,15 +157,6 @@ impl CameraController {
|
|
|
|
camera.position += view_vector * (self.amount_forward - self.amount_backward) * self.speed * dt;
|
|
|
|
camera.position += view_vector * (self.amount_forward - self.amount_backward) * self.speed * dt;
|
|
|
|
camera.position += left_vector * (self.amount_left - self.amount_right) * self.speed * dt;
|
|
|
|
camera.position += left_vector * (self.amount_left - self.amount_right) * self.speed * dt;
|
|
|
|
|
|
|
|
|
|
|
|
// I'm not a huge fan of this
|
|
|
|
|
|
|
|
// // Move in/out (aka. "zoom")
|
|
|
|
|
|
|
|
// // Note: this isn't an actual zoom. The camera's position
|
|
|
|
|
|
|
|
// // changes when zooming. I've added this to make it easier
|
|
|
|
|
|
|
|
// // to get closer to an object you want to focus on.
|
|
|
|
|
|
|
|
// let (pitch_sin, pitch_cos) = camera.pitch.0.sin_cos();
|
|
|
|
|
|
|
|
// let scrollward = Vector3::new(pitch_cos * yaw_cos, pitch_sin, pitch_cos * yaw_sin).normalize();
|
|
|
|
|
|
|
|
// camera.position += scrollward * self.scroll * self.speed * self.sensitivity * dt;
|
|
|
|
|
|
|
|
// self.scroll = 0.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move up/down. Since we don't use roll, we can just
|
|
|
|
// Move up/down. Since we don't use roll, we can just
|
|
|
|
// modify the y coordinate directly.
|
|
|
|
// modify the y coordinate directly.
|
|
|
@ -193,10 +173,10 @@ impl CameraController {
|
|
|
|
self.rotate_vertical = 0.0;
|
|
|
|
self.rotate_vertical = 0.0;
|
|
|
|
|
|
|
|
|
|
|
|
// Keep the camera's angle from going too high/low.
|
|
|
|
// Keep the camera's angle from going too high/low.
|
|
|
|
if camera.pitch < -Rad(0.0) {
|
|
|
|
if camera.pitch < -Rad(0.001) {
|
|
|
|
camera.pitch = -Rad(0.0);
|
|
|
|
camera.pitch = -Rad(0.001);
|
|
|
|
} else if camera.pitch > Rad(PI) {
|
|
|
|
} else if camera.pitch > Rad(PI - 0.001) {
|
|
|
|
camera.pitch = Rad(PI);
|
|
|
|
camera.pitch = Rad(PI - 0.001);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|