#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SpringConfig {
pub stiffness: f32,
pub damping: f32,
pub mass: f32,
pub epsilon: f32,
}
impl Default for SpringConfig {
fn default() -> Self {
Self {
stiffness: 100.0,
damping: 10.0,
mass: 1.0,
epsilon: 0.001,
}
}
}
impl SpringConfig {
pub fn gentle() -> Self {
Self {
stiffness: 60.0,
damping: 14.0,
mass: 1.0,
epsilon: 0.001,
}
}
pub fn wobbly() -> Self {
Self {
stiffness: 180.0,
damping: 12.0,
mass: 1.0,
epsilon: 0.001,
}
}
pub fn stiff() -> Self {
Self {
stiffness: 210.0,
damping: 20.0,
mass: 1.0,
epsilon: 0.001,
}
}
pub fn slow() -> Self {
Self {
stiffness: 37.0,
damping: 14.0,
mass: 1.0,
epsilon: 0.001,
}
}
pub fn snappy() -> Self {
Self {
stiffness: 300.0,
damping: 30.0,
mass: 1.0,
epsilon: 0.001,
}
}
}