Expand description
load reads .gltf/.glb files into an
animsmith_core::Document, write::write emits a document as
glTF/GLB, and the fix module provides byte-surgical quaternion
repairs. Malformed inputs report LoadError; output failures
report WriteError.
This crate is the glTF/GLB format edge around animsmith-core.
Loading preserves authored animation values for checks and also carries
meshes, skins, materials, and embedded textures into
Document::assets.
Writing is a model round-trip for convert and transform; use
fix::FixSession when a repair must preserve every non-animation byte
of the original container.
§Quick start
Load a document and run the shared core checks:
fn lint_clip(
path: &std::path::Path,
) -> Result<Vec<animsmith_core::Finding>, Box<dyn std::error::Error>> {
let doc = animsmith_gltf::load(path)?;
let roles = animsmith_core::detect_profile(&doc.skeleton).unwrap_or_default();
let config = animsmith_core::Config::default();
let grids = animsmith_core::MetricGrids::new(&doc);
let ctx = animsmith_core::CheckCtx::new(&grids, &roles, &config);
Ok(animsmith_core::run_checks(&ctx, &animsmith_core::all_checks()))
}Compose byte-surgical repairs through one session:
fn repair_quaternions(
input: &std::path::Path,
output: &std::path::Path,
) -> Result<(), Box<dyn std::error::Error>> {
use animsmith_gltf::fix::{FixSession, Repair};
let mut session = FixSession::read(input)?;
session.apply(Repair::QuatNorm);
session.apply(Repair::QuatFlip);
session.write(input, output)?;
Ok(())
}§Build and API status
This crate has no public feature flags and supports the workspace MSRV,
Rust 1.88. Its Rust API is pre-1.0; see animsmith-core’s crate-level API
status for the shared stability boundary.
See the GitHub embedding guide for crate selection and the pipeline scenario guide for raw-to-game-ready workflows.
Modules§
- fix
- Byte-surgical clip repairs: mutate only the animation accessor bytes that need to change and copy everything else through verbatim. A fixed character GLB keeps its meshes, skins, materials, and textures byte-identical — the output diff is exactly the repaired keys.
- write
- Minimal glTF 2.0 writer for
convert/transform: emits the skeleton (node hierarchy + rest TRS), each clip’s writable animation tracks, and whatever scene assets theDocumentcarries (Document::assets— triangulated meshes, skins, factor-only materials, and embedded base-color textures). A document with default-empty assets writes animation + skeleton only, so animation data can still enter glTF-based tooling (including animsmith itself) straight from a DCC export.
Enums§
- FixError
fixerrors are classified by defect, not by phase:LoadErrormeans the input was unreadable or malformed (even when detected while assembling the output, e.g. re-deriving GLB chunk bounds or validating an input-supplied buffer URI);WriteErrormeans emitting the output failed.- Load
Error - Errors returned while loading
.gltfor.glbinput. - Write
Error - Errors returned while writing a core document as glTF/GLB.
Functions§
- load
- Load a
.glbor.gltffile into a coreDocument, including the scene assets (meshes, skins, materials, and embedded base-color textures) its geometry describes — the symmetric read side ofwrite::write, and the same one-call shapeanimsmith_fbx::loaduses. Consumers that judge only animation (lint,inspect) simply ignoreDocument::assets. Non-triangle primitives are skipped rather than reinterpreted.