bevyengine/bevy · error · GltfError

Missing sampler for animation {0}

Error message

Missing sampler for animation {0}

What it means

Raised while building AnimationClips (feature bevy_animation) when an animation channel's reader produces no sampler input: reader.read_inputs() returns None, so the keyframe timestamps cannot be read, and GltfError::MissingAnimationSampler(animation.index()) is returned at loader/mod.rs:340 (and again at 561 for the named-animation pass). Concretely the channel's sampler 'input' accessor is missing or unreadable from the loaded buffer data.

Source

Thrown at crates/bevy_gltf/src/loader/mod.rs:124

    InvalidBufferUri(String, ParseAssetPathError),
    /// Invalid image mime type.
    #[error("invalid image mime type: {0}")]
    #[from(ignore)]
    InvalidImageMimeType(String),
    /// Error when loading a texture. Might be due to a disabled image file format feature.
    #[error("You may need to add the feature for the file format: {0}")]
    ImageError(#[from] TextureError),
    /// The image URI was unable to be resolved with respect to the asset path.
    #[error("invalid image uri: {0}. asset path error={1}")]
    InvalidImageUri(String, ParseAssetPathError),
    /// Failed to read bytes from an asset path.
    #[error("failed to read bytes from an asset path: {0}")]
    ReadAssetBytesError(#[from] ReadAssetBytesError),
    /// Failed to load asset from an asset path.
    #[error("failed to load asset from an asset path: {0}")]
    AssetLoadError(#[from] AssetLoadError),
    /// Missing sampler for an animation.
    #[error("Missing sampler for animation {0}")]
    #[from(ignore)]
    MissingAnimationSampler(usize),
    /// Failed to generate tangents.
    #[error("failed to generate tangents: {0}")]
    GenerateTangentsError(#[from] bevy_mesh::GenerateTangentsError),
    /// Failed to generate morph targets.
    #[error("failed to generate morph targets: {0}")]
    MorphTarget(#[from] bevy_mesh::morph::MorphBuildError),
    /// Circular children in Nodes
    #[error("GLTF model must be a tree, found cycle instead at node indices: {0:?}")]
    #[from(ignore)]
    CircularChildren(String),
    /// Failed to load a file.
    #[error("failed to load file: {0}")]
    Io(#[from] Error),
}

/// Loads glTF files with all of their data as their corresponding bevy representations.

View on GitHub (pinned to 396ca72708)

Solutions

  1. Validate the file with gltf-validator and fix/re-export the animation track it flags.
  2. Delete the offending animation in a DCC if it is unused.
  3. Load with animations disabled via GltfLoaderSettings { load_animations: false } to get the mesh while you repair the clip.
  4. Ensure animation buffer data ships with the model (no missing .bin).

Example fix

// (before)
let h = asset_server.load("models/rigged.gltf");
// (after) skip the broken clip, keep the mesh
let h = asset_server.load_with_settings(
    "models/rigged.gltf",
    |s: &mut GltfLoaderSettings| s.load_animations = false,
);
Defensive patterns

Strategy: validation

Validate before calling

fn animations_have_inputs(path: &std::path::Path) -> bool {
    let (doc, mut blob, _) = gltf::import(path).unwrap();
    let data = blob.drain(..).map(Vec::from).collect::<Vec<_>>();
    doc.animations().all(|a| a.channels().all(|c| {
        c.reader(|b| data.get(b.index()).map(|v| v.as_slice()))
            .read_inputs().is_some()
    }))
}

Try / catch

match err {
    GltfError::MissingAnimationSampler(idx) => {
        warn!("animation {idx} has no sampler input; load with load_animations = false until fixed");
    }
    other => return Err(other.into()),
}

Prevention

When it happens

Trigger: Animation JSON whose sampler.input points to a nonexistent accessor index, an input accessor whose buffer data could not be loaded, or exporters emitting empty sampler inputs. (Distinct from sparse inputs, which only warn and skip at mod.rs:333-336.)

Common situations: Hand-written or procedurally generated animations, broken shape-key/mocap exporters, models whose animation buffers were stripped during optimization.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/c688b7d849f352dd. Report an issue: GitHub.