use crate::scene::NodeId;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AnimationProperty {
Translation,
Rotation,
Scale,
MorphWeights,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct AnimationTarget {
pub node: NodeId,
pub property: AnimationProperty,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Interpolation {
Step,
Linear,
CubicSpline,
}
#[derive(Clone, Debug)]
pub struct AnimationSampler {
pub keyframes: Vec<f32>,
pub values: AnimationValues,
pub interpolation: Interpolation,
}
#[derive(Clone, Debug, PartialEq)]
pub enum AnimationValues {
Vec3(Vec<[f32; 3]>),
Quat(Vec<[f32; 4]>),
Scalar(Vec<f32>),
}
impl AnimationValues {
pub fn len(&self) -> usize {
match self {
Self::Vec3(v) => v.len(),
Self::Quat(v) => v.len(),
Self::Scalar(v) => v.len(),
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
#[derive(Clone, Debug)]
pub struct AnimationChannel {
pub target: AnimationTarget,
pub sampler: AnimationSampler,
}
#[derive(Clone, Debug, Default)]
pub struct Animation {
pub name: Option<String>,
pub channels: Vec<AnimationChannel>,
}
impl Animation {
pub fn new(name: impl Into<Option<String>>) -> Self {
Self {
name: name.into(),
channels: Vec::new(),
}
}
}