{"record":{"id":"137cf84de5f3afd2","repo":"bevyengine/bevy","slug":"bevy-only-supports-up-to-morph-targets-individ","errorCode":null,"errorMessage":"Bevy only supports up to {} morph targets (individual poses), tried to create a model with {target_count} morph targets","messagePattern":"Bevy only supports up to (.+?) morph targets \\(individual poses\\), tried to create a model with (.+?) morph targets","errorType":"exception","errorClass":"MorphBuildError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/morph.rs","lineNumber":35,"sourceCode":"/// The maximum number of morph target components, if morph target textures are\n/// in use on the current platform.\n///\n/// NOTE: \"component\" refers to the element count of math objects,\n/// Vec3 has 3 components, Mat2 has 4 components.\nconst MAX_COMPONENTS: u32 = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH;\n\n#[derive(Error, Clone, Debug)]\npub enum MorphBuildError {\n    #[error(\n        \"Too many vertex components in morph target, max is {MAX_COMPONENTS}, \\\n        got {vertex_count}×{component_count} = {}\",\n        *vertex_count * *component_count as usize\n    )]\n    TooManyAttributes {\n        vertex_count: usize,\n        component_count: u32,\n    },\n    #[error(\n        \"Bevy only supports up to {} morph targets (individual poses), tried to \\\n        create a model with {target_count} morph targets\",\n        MAX_MORPH_WEIGHTS\n    )]\n    TooManyTargets { target_count: usize },\n}\n\n/// Controls the [morph targets] for all child [`Mesh3d`](crate::Mesh3d)\n/// entities. In most cases, [`MorphWeights`] should be considered the \"source\n/// of truth\" when writing [morph targets] for meshes. However you can choose to\n/// write child [`MeshMorphWeights`] if your situation requires more\n/// granularity. Just note that if you set [`MorphWeights`], it will overwrite\n/// child [`MeshMorphWeights`] values.\n///\n/// `MorphWeights` works together with the [`MeshMorphWeights`] component. When\n/// a `MeshMorphWeights` is set to `MeshMorphWeights::Reference`, it references\n/// another entity that is expected to contain a `MorphWeights` component. This\n/// allows multiple meshes to share a single `MorphWeights` component.","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/morph.rs#L17-L53","documentation":"MorphBuildError::TooManyTargets (crates/bevy_mesh/src/morph.rs:35) enforces MAX_MORPH_WEIGHTS = 256 morph targets per model. It is returned by MorphWeights::new when weights.len() > 256 and again by MorphTargetImage::new when targets.len() / vertex_count > 256. The weights are uploaded in a fixed-size buffer, so more poses cannot be represented.","triggerScenarios":"Constructing MorphWeights with a Vec<f32> longer than 256 entries, or loading a glTF whose mesh carries more than 256 morph targets (targets * vertex_count entries in the target array).","commonSituations":"DCC exports with hundreds of corrective blendshapes accumulated over production; scripts that generate one morph target per viseme/phoneme combination; combining several morph sets into one model without pruning.","solutions":["Prune the blendshape list in your DCC tool/exporter to at most 256 targets (delete unused or baked corrective shapes)","Split the model so each mesh entity carries at most 256 of its own targets","Bake rarely-used or always-together targets into fewer combined shapes before export"],"exampleFix":"// before\nlet weights = MorphWeights::new(all_300_shapes, Some(handle.clone())); // Err(TooManyTargets { target_count: 300 })\n\n// after: prune to <= 256\nlet pruned: Vec<f32> = all_300_shapes.iter().copied().take(256).collect();\nlet weights = MorphWeights::new(pruned, Some(handle.clone())).unwrap();","handlingStrategy":"validation","validationCode":"const MAX_TARGETS: usize = 256; // bevy_mesh::morph::MAX_MORPH_WEIGHTS\n\nlet weights: Vec<f32> = weights.into_iter().take(MAX_TARGETS).collect();\nlet morph = MorphWeights::new(weights, Some(handle.clone()))?;","typeGuard":null,"tryCatchPattern":"if let Err(MorphBuildError::TooManyTargets { target_count }) =\n    MorphWeights::new(weights, Some(handle.clone()))\n{\n    bevy::log::error!(\"{target_count} morph targets > 256; prune blendshapes\");\n}","preventionTips":["Export at most 256 blendshapes per mesh from your DCC tool","Bake corrective/always-together shapes into combined targets","Assert weights.len() <= 256 in asset importers before constructing MorphWeights"],"tags":["bevy","mesh","morph-targets","limit-exceeded","animation"],"backgroundTag":"morph-target-limit-exceeded","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}