pub struct MaterialSpringState { /* private fields */ }Expand description
A velocity-continuous spring for interactive controls whose target may change mid-flight.
Call Self::advance with frame time, then Self::retarget on an input change. Retargeting
preserves both the current position and its physical velocity, including when the target
reverses direction. No allocations or numerical integration are involved.
Implementations§
Source§impl MaterialSpringState
impl MaterialSpringState
pub fn new(spec: MaterialSpringSpec, value: f64) -> Self
pub fn current(&self) -> MaterialSpringSample
pub fn target(&self) -> f64
pub fn retarget(&mut self, target: f64)
Sourcepub fn set_spec(&mut self, spec: MaterialSpringSpec)
pub fn set_spec(&mut self, spec: MaterialSpringSpec)
Changes the motion scheme without discontinuously resetting the live state.
pub fn set_reduced_motion(&mut self, reduced_motion: bool)
pub fn advance(&mut self, seconds: f64) -> MaterialSpringSample
pub fn is_at_rest( &self, position_threshold: f64, velocity_threshold: f64, ) -> bool
pub fn finish(&mut self)
Trait Implementations§
Source§impl Clone for MaterialSpringState
impl Clone for MaterialSpringState
impl Copy for MaterialSpringState
Auto Trait Implementations§
impl Freeze for MaterialSpringState
impl RefUnwindSafe for MaterialSpringState
impl Send for MaterialSpringState
impl Sync for MaterialSpringState
impl Unpin for MaterialSpringState
impl UnsafeUnpin for MaterialSpringState
impl UnwindSafe for MaterialSpringState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read more