vrm-runtime 0.1.0

Renderer-agnostic VRM 1.0 loader, validator, animation system, and runtime
Documentation
//! Minimal example: load a VRM file, step one frame and print the final
//! render meshes (morphs, skinning and world transforms already applied).
//!
//! Run with:
//! `cargo run --example basic -- <path/to/avatar.vrm>`

use vrm_runtime::{AvatarAsset, AvatarRuntime};

fn main() {
    let path = std::env::args().nth(1).expect("usage: basic <avatar.vrm>");
    let avatar = AvatarAsset::load(&path).expect("failed to load avatar");

    println!("avatar: {}", avatar.meta().name());
    println!("primitives: {}", avatar.primitives().len());

    let mut runtime = AvatarRuntime::new(avatar);

    // One frame with spring bones and constraints enabled by default.
    let frame = runtime.update(1.0 / 60.0).expect("valid delta time");

    // Bake fully transformed, renderer-ready CPU meshes on demand.
    let meshes = frame.bake_cpu();
    for mesh in &meshes {
        println!(
            "mesh(node {}): vertices={} indices={} topology={:?} material={:?}",
            mesh.node_id,
            mesh.positions.len(),
            mesh.indices.len(),
            mesh.topology,
            mesh.material_id,
        );
    }
}