{"record":{"id":"7acedad420563c5a","repo":"bevyengine/bevy","slug":"mesh-has-no-indices","errorCode":null,"errorMessage":"Mesh has no indices","messagePattern":"Mesh has no indices","errorType":"validation","errorClass":"MeshToMeshletMeshConversionError","httpStatus":null,"severity":"error","filePath":"crates/bevy_pbr/src/meshlet/from_mesh.rs","lineNumber":1100,"sourceCode":"\n// https://www.w3.org/TR/WGSL/#pack2x16snorm-builtin\nfn pack2x16snorm(v: Vec2) -> u32 {\n    let v = v.clamp(Vec2::NEG_ONE, Vec2::ONE);\n    let v = (v * 32767.0 + 0.5).floor().as_i16vec2();\n    bytemuck::cast(v)\n}\n\n/// An error produced by [`MeshletMesh::from_mesh`].\n#[derive(Error, Debug)]\npub enum MeshToMeshletMeshConversionError {\n    #[error(\"Mesh primitive topology is not TriangleList\")]\n    WrongMeshPrimitiveTopology,\n    #[error(\"Mesh vertex attributes must be {required:?}, but got {provided:?}\")]\n    WrongMeshVertexAttributes {\n        required: [MeshVertexAttribute; 3],\n        provided: Vec<MeshVertexAttribute>,\n    },\n    #[error(\"Mesh has no indices\")]\n    MeshMissingIndices,\n}\n","sourceCodeStart":1082,"sourceCodeEnd":1103,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_pbr/src/meshlet/from_mesh.rs#L1082-L1103","documentation":"`validate_input_mesh` in crates/bevy_pbr/src/meshlet/from_mesh.rs:274 requires `mesh.indices()` to return `Some(Indices::U16(_))` or `Some(Indices::U32(_))` before `MeshletMesh::from_mesh` can run. Meshletization works on triangle index lists, so a mesh with only a vertex buffer (no index buffer) is rejected with `MeshToMeshletMeshConversionError::MeshMissingIndices`.","triggerScenarios":"Calling `MeshletMesh::from_mesh` on a mesh built without `mesh.insert_indices(...)` — custom procedural geometry where only `insert_attribute(Mesh::ATTRIBUTE_POSITION, ...)` was called, or a triangle soup that never got an index list.","commonSituations":"Hand-rolled mesh builders (terrain chunks, procedural geometry loaders) that skip the index step; meshes converted from formats that store only vertex data; refactors that drop the `insert_indices` call.","solutions":["Check `mesh.indices()` in a debug assert before converting","If you only have vertices, insert a sequential index list: `mesh.insert_indices(Indices::U32((0..vertex_count as u32).collect()))`","If you have triangle data elsewhere, build and insert the index buffer before `from_mesh`"],"exampleFix":"// before: vertex-only mesh -> MeshMissingIndices\nlet mut mesh = Mesh::new(PrimitiveTopology::TriangleList);\nmesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);\n\n// after: add an index buffer\nlet vertex_count = positions.len() as u32;\nmesh.insert_indices(Indices::U32((0..vertex_count).collect()));","handlingStrategy":"validation","validationCode":"if mesh.indices().is_none() {\n    let count = mesh.count_vertices();\n    mesh.insert_indices(Indices::U32((0..count as u32).collect()));\n}\nlet meshlet = MeshletMesh::from_mesh(mesh, &viewer)?;","typeGuard":null,"tryCatchPattern":"match MeshletMesh::from_mesh(mesh, &viewer) {\n    Err(MeshToMeshletMeshConversionError::MeshMissingIndices) => {\n        warn!(?asset_path, \"mesh has no indices; skipping meshlet conversion\");\n        // fall back to rendering the plain Mesh\n    }\n    other => other?,\n}","preventionTips":["Assert `mesh.indices().is_some()` in mesh-builder unit tests","Centralize mesh construction so every builder ends with insert_indices","Treat a vertex-only mesh as a bug: add a debug_assert in your asset pipeline"],"tags":["bevy","meshlet","mesh","index-buffer"],"backgroundTag":"missing-mesh-index-buffer","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}