#[non_exhaustive]pub struct AnimationPlayer {
pub clip: Option<Arc<AnimationClip>>,
pub elapsed_time: f32,
pub speed: f32,
pub playing: bool,
pub looping: bool,
pub target_entities: HashMap<String, Entity>,
}Expand description
Component that drives an AnimationClip over time.
Attach this to the root entity of a hierarchy; the animation system advances
Self::elapsed_time, resolves each track’s target_name to a child entity
(caching the result in Self::target_entities), and writes the sampled
transform values to those entities.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.clip: Option<Arc<AnimationClip>>The clip currently being played, if any.
elapsed_time: f32Current playback position, in seconds.
speed: f32Playback speed multiplier (1.0 is real time).
playing: boolWhether playback is currently advancing.
looping: boolWhether the clip restarts from the beginning when it ends.
target_entities: HashMap<String, Entity>Cache mapping each track’s target_name to the resolved entity.
Implementations§
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn new() -> AnimationPlayer
pub fn new() -> AnimationPlayer
Creates a player with default settings (equivalent to Default::default).
Sourcepub fn play(&mut self, clip: Arc<AnimationClip>) -> &mut AnimationPlayer
pub fn play(&mut self, clip: Arc<AnimationClip>) -> &mut AnimationPlayer
Starts playing clip from the beginning, clearing any cached target entities.
Sourcepub fn pause(&mut self) -> &mut AnimationPlayer
pub fn pause(&mut self) -> &mut AnimationPlayer
Pauses playback, leaving Self::elapsed_time untouched.
Sourcepub fn resume(&mut self) -> &mut AnimationPlayer
pub fn resume(&mut self) -> &mut AnimationPlayer
Resumes playback from the current position.
Sourcepub fn with_speed(self, speed: f32) -> AnimationPlayer
pub fn with_speed(self, speed: f32) -> AnimationPlayer
Builder: sets the playback Self::speed multiplier.
A non-finite speed (NaN/±∞) is rejected and falls back to 1.0 so
it cannot poison Self::elapsed_time during playback.
Sourcepub fn looping(self, looping: bool) -> AnimationPlayer
pub fn looping(self, looping: bool) -> AnimationPlayer
Builder: sets whether playback Self::looping.
Sourcepub fn advance(&mut self, dt: f32, duration: f32)
pub fn advance(&mut self, dt: f32, duration: f32)
Advances playback by dt seconds against a clip of duration seconds.
A non-finite Self::speed (NaN/±∞) falls back to 1.0 so it cannot
poison Self::elapsed_time. When Self::looping, elapsed_time wraps
within the clip length; otherwise it is clamped to [0, duration] and
playback stops the instant it reaches an end, so a non-looping clip does
not overshoot its final frame by one tick.
Reverse playback (speed < 0) is supported: looping wraps with
rem_euclid (a plain % keeps the dividend’s sign, so a negative time
stays negative and the sampler pins the pose at frame 0 — see the sibling
skeletal fix in gizmo-renderer::animation_system); non-looping reverse
completes at the clip start (elapsed_time <= 0) instead of running
unbounded-negative with playing stuck true.
Trait Implementations§
Source§impl Clone for AnimationPlayer
impl Clone for AnimationPlayer
Source§fn clone(&self) -> AnimationPlayer
fn clone(&self) -> AnimationPlayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for AnimationPlayer
impl Component for AnimationPlayer
fn storage_type() -> StorageType
Source§impl Debug for AnimationPlayer
impl Debug for AnimationPlayer
Source§impl Default for AnimationPlayer
impl Default for AnimationPlayer
Source§fn default() -> AnimationPlayer
fn default() -> AnimationPlayer
Auto Trait Implementations§
impl Freeze for AnimationPlayer
impl RefUnwindSafe for AnimationPlayer
impl Send for AnimationPlayer
impl Sync for AnimationPlayer
impl Unpin for AnimationPlayer
impl UnsafeUnpin for AnimationPlayer
impl UnwindSafe for AnimationPlayer
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
Source§impl<T> BundleExt for Twhere
T: Bundle,
impl<T> BundleExt for Twhere
T: Bundle,
fn with<C>(self, component: C) -> DynamicBundle<Self, C>where
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().