Added feature to the camera that it follows the viewing direction both in the horizontal and vertical

pull/477/head
Alexande Becker 1 year ago
parent 1661c8543b
commit d358c28093

@ -157,7 +157,8 @@ impl CameraController {
// Move forward/backward and left/right
let (yaw_sin, yaw_cos) = camera.yaw.0.sin_cos();
let forward = Vector3::new(yaw_cos, 0.0, yaw_sin).normalize();
let pitch_sin = camera.pitch.0.sin();
let forward = Vector3::new(yaw_cos, pitch_sin, yaw_sin).normalize();
let right = Vector3::new(-yaw_sin, 0.0, yaw_cos).normalize();
camera.position += forward * (self.amount_forward - self.amount_backward) * self.speed * dt;
camera.position += right * (self.amount_right - self.amount_left) * self.speed * dt;

@ -211,7 +211,8 @@ impl CameraController {
// Move forward/backward and left/right
let (yaw_sin, yaw_cos) = camera.yaw.0.sin_cos();
let forward = Vector3::new(yaw_cos, 0.0, yaw_sin).normalize();
let pitch_sin = camera.pitch.0.sin();
let forward = Vector3::new(yaw_cos, pitch_sin, yaw_sin).normalize();
let right = Vector3::new(-yaw_sin, 0.0, yaw_cos).normalize();
camera.position += forward * (self.amount_forward - self.amount_backward) * self.speed * dt;
camera.position += right * (self.amount_right - self.amount_left) * self.speed * dt;

Loading…
Cancel
Save