bevyengine/bevy · error · GltfError
failed to generate morph targets: {0}
Error message
failed to generate morph targets: {0} What it means
GltfError::MorphTarget (#[from] bevy_mesh::morph::MorphBuildError) wraps failures while building morph-target vertex data and weights: mesh.set_morph_targets (loader/mod.rs:810) and MorphWeights::new (mod.rs:1902) require each target's attributes to match the expected POSITION/NORMAL/TANGENT layout and consistent counts; mismatches error out instead of producing a broken skinned mesh.
Source
Thrown at crates/bevy_gltf/src/loader/mod.rs:131
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.
#[derive(TypePath)]
pub struct GltfLoader {
/// List of compressed image formats handled by the loader.
pub supported_compressed_formats: CompressedImageFormats,
/// Custom vertex attributes that will be recognized when loading a glTF file.
///
/// Keys must be the attribute names as found in the glTF data, which must start with an underscore.View on GitHub (pinned to 396ca72708)
Solutions
- Re-export shape keys ensuring every target carries POSITION (+ NORMAL/TANGENT) with identical formats and counts.
- Delete unused shape keys before export to shrink the surface for mistakes.
- Validate morph accessors with gltf-validator (checks target attribute consistency).
- If morphs are not needed, export without shape keys.
Defensive patterns
Strategy: validation
Validate before calling
fn morph_targets_consistent(doc: &gltf::Document) -> bool {
doc.meshes().flat_map(|m| m.primitives()).all(|p| {
let base: Vec<_> = p.attributes().iter().map(|(s, _)| s.to_string()).collect();
p.morph_targets().all(|t| t.iter().all(|(s, _)| {
base.iter().any(|b| b == &s.to_string())
&& matches!(s, gltf::Semantic::Positions | gltf::Semantic::Normals | gltf::Semantic::Tangents)
}))
})
} Try / catch
match err {
GltfError::MorphTarget(e) => {
warn!("morph targets invalid ({e:?}); re-export shape keys with full POSITION/NORMAL/TANGENT sets");
}
other => return Err(other.into()),
} Prevention
- Delete unused shape keys before export.
- Keep target attribute formats identical to the base mesh.
- Run gltf-validator on morph-heavy assets.
When it happens
Trigger: A primitive whose morph targets omit some attributes (e.g. targets with POSITION but stray formats), target attributes with differing vertex counts/formats, or weights arrays inconsistent with the number of targets.
Common situations: Shape keys exported partially from DCCs; hand-crafted morph data; mixers combining targets from different meshes; aggressive optimizers rewriting morph accessors.
Related errors
- unsupported primitive mode
- failed to generate tangents: {0}
- Too many vertex components in morph target, max is {MAX_COMP
- Bevy only supports up to {} morph targets (individual poses)
- invalid glTF file: {0}
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/600b741ad63c013c.
Report an issue: GitHub.