pub struct Animation {Show 15 fields
pub asset_id: AssetId,
pub target: Option<SkinnedMeshHandle>,
pub source: String,
pub animation_index: u32,
pub animation_name: String,
pub sample_rate: f32,
pub duration: f32,
pub looping: bool,
pub weight: f32,
pub fade_in_secs: f32,
pub root_motion: bool,
pub root_motion_y: bool,
pub root_track: Vec<RootKey>,
pub tracks: Vec<AnimationTrack>,
pub morph_track: Vec<MorphKey>,
}Expand description
A skeletal animation clip that animates one SkinnedMesh.
The clip plays every frame, sampling each track and deforming the target mesh’s skeleton. Joints with no track hold their bind pose.
Several Animation assets may target the same SkinnedMesh;
they are then blended into one pose, weighted by each clip’s weight (a
normalised weighted average). A single clip plays at full strength
regardless of its weight.
File import. A clip may be authored entirely by hand (tracks filled
out, source left empty) or imported from the same glTF (.glb /
.gltf) or .fbx file that backs the target SkinnedMesh.
Set source to the file path and the build imports duration + tracks
from it. animation_index picks one clip when the file contains several
(default 0); animation_name names it for matching against the file’s
clip names: when set it takes precedence over the index. FBX curves are
baked at sample_rate keys per second. Channels whose target node is not
a joint of the file’s first skinned node are dropped. The same file should
back the target SkinnedMesh so the joint indices agree.
Animation {
duration: 2.0,
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
target: Option<SkinnedMeshHandle>The SkinnedMesh asset this clip animates.
source: StringOptional path to a .glb, .gltf, or .fbx file. When set, the
build imports duration + tracks from it; inline-authored clips
leave this empty.
animation_index: u32Index of the animation to import when source is set and the file
contains several. Ignored when animation_name is non-empty.
animation_name: StringName of the animation to import. When set, the matching clip in the
source file is looked up by name; takes precedence over
animation_index.
sample_rate: f32Keys per second baked from sources whose curves need resampling at import (FBX). glTF keyframes pass through untouched. Default 30.
duration: f32Clip length in seconds. Overridden by glTF import.
looping: boolWhen true, playback wraps after duration.
weight: f32Blend weight used when several clips target the same SkinnedMesh. Ignored when this is the only clip on its target.
fade_in_secs: f32When non-zero, the clip’s contribution ramps from 0 to its declared
weight over this many seconds after the world starts. Zero (the
default) plays the clip at full weight from the first frame.
root_motion: boolWhen true, the build strips the root joint’s travel out of the pose
and bakes it into root_track: the pose stays anchored in place and
the runtime moves the character by the curve’s frame-to-frame delta
instead (the SkinnedMesh capsule is the usual
consumer). X and Z travel is always stripped; Y only with
root_motion_y.
root_motion_y: boolAlso strip the root joint’s vertical travel into root_track. Leave
false (the default) so jumps and crouches stay authored in the pose.
root_track: Vec<RootKey>The displacement curve baked out of the root joint by the build when
root_motion is set. Filled by the build; not usually authored by
hand.
tracks: Vec<AnimationTrack>Per-joint keyframe channels.
morph_track: Vec<MorphKey>Morph-target weight keys for the target mesh, in time order. Each key holds one weight per morph target of the SkinnedMesh. Filled by the glTF import; empty when the clip animates no morph targets.
Implementations§
Trait Implementations§
Source§impl Component for Animation
impl Component for Animation
Source§const NAME: &'static str = "Animation"
const NAME: &'static str = "Animation"
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<Animation, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Animation, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for Animation
impl ComponentSlot for Animation
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§impl<'de> Deserialize<'de> for Animation
impl<'de> Deserialize<'de> for Animation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Animation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Animation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Animation> for ComponentAsset
impl From<Animation> for ComponentAsset
Source§fn from(c: Animation) -> ComponentAsset
fn from(c: Animation) -> ComponentAsset
impl RuntimeComponent for Animation
Source§impl Serialize for Animation
impl Serialize for Animation
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Animation
impl RefUnwindSafe for Animation
impl Send for Animation
impl Sync for Animation
impl Unpin for Animation
impl UnsafeUnpin for Animation
impl UnwindSafe for Animation
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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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().