vrm-runtime 0.1.0

Renderer-agnostic VRM 1.0 loader, validator, animation system, and runtime
Documentation
/// The per-vertex deltas of one blend shape target (expression morph).
///
/// Position deltas are mandatory; normal and tangent deltas are optional
/// (the runtime falls back to the base attributes when absent).
#[derive(Debug, Clone)]
pub struct MorphTarget {
    position_deltas: Vec<[f32; 3]>,
    normal_deltas: Option<Vec<[f32; 3]>>,
    tangent_deltas: Option<Vec<[f32; 3]>>,
}

impl MorphTarget {
    pub(crate) fn new(
        position_deltas: Vec<[f32; 3]>,
        normal_deltas: Option<Vec<[f32; 3]>>,
        tangent_deltas: Option<Vec<[f32; 3]>>,
    ) -> Self {
        Self {
            position_deltas,
            normal_deltas,
            tangent_deltas,
        }
    }

    /// Returns the position delta for every base vertex.
    pub fn position_deltas(&self) -> &[[f32; 3]] {
        &self.position_deltas
    }

    /// Returns optional normal deltas aligned with the base vertices.
    pub fn normal_deltas(&self) -> Option<&[[f32; 3]]> {
        self.normal_deltas.as_deref()
    }

    /// Returns optional tangent deltas aligned with the base vertices.
    pub fn tangent_deltas(&self) -> Option<&[[f32; 3]]> {
        self.tangent_deltas.as_deref()
    }
}