Plane-constrained translation handles

This commit is contained in:
Danny McGee
2023-10-11 20:48:21 -04:00
parent fef5840343
commit 7d121af4a1
5 changed files with 127 additions and 39 deletions
+2 -10
View File
@@ -8,7 +8,7 @@ use bevy::{
use crate::{
input::{Action, CameraMotion, InputAction, Lifecycle},
math::NearlyEq,
math::{self, NearlyEq},
};
pub struct OrbitCamPlugin;
@@ -157,7 +157,7 @@ fn update_velocity(
} else if t.0.nearly_eq(1.) {
target_vel
} else {
Vec3::lerp(velocity.0, target_vel, curve_sin(t.0))
Vec3::lerp(velocity.0, target_vel, math::curve_sin(t.0))
};
}
}
@@ -281,11 +281,3 @@ fn do_rotate(win: &Window, delta: Vec2, xform: &mut Transform, orbit_cam: &mut O
// Update focus point
orbit_cam.focus = xform.translation + xform.forward() * orbit_cam.radius;
}
/// Fit a [0, 1] `t` interpolation parameter to a sine curve
///
/// https://www.desmos.com/calculator/k9x4c4cr5y
#[inline]
fn curve_sin(t: f32) -> f32 {
-1. * (f32::cos(t * consts::PI) / 2.) + 0.5
}