{"record":{"id":"bd00e57887301122","repo":"bevyengine/bevy","slug":"source-mesh-position-data-is-not-float32x3","errorCode":null,"errorMessage":"Source mesh position data is not Float32x3","messagePattern":"Source mesh position data is not Float32x3","errorType":"exception","errorClass":"MeshTrianglesError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/index.rs","lineNumber":71,"sourceCode":"    #[error(\"Mesh winding inversion does not work for primitive topology `PointList`\")]\n    WrongTopology,\n\n    /// This error occurs when you try to invert the winding for a mesh with\n    /// * [`PrimitiveTopology::TriangleList`](super::PrimitiveTopology::TriangleList), but the indices are not in chunks of 3.\n    /// * [`PrimitiveTopology::LineList`](super::PrimitiveTopology::LineList), but the indices are not in chunks of 2.\n    #[error(\"Indices weren't in chunks according to topology\")]\n    AbruptIndicesEnd,\n    #[error(\"Mesh access error: {0}\")]\n    MeshAccessError(#[from] MeshAccessError),\n}\n\n/// An error that occurred while trying to extract a collection of triangles from a [`Mesh`](super::Mesh).\n#[derive(Debug, Error)]\npub enum MeshTrianglesError {\n    #[error(\"Source mesh does not have primitive topology TriangleList or TriangleStrip\")]\n    WrongTopology,\n\n    #[error(\"Source mesh position data is not Float32x3\")]\n    PositionsFormat,\n\n    #[error(\"Face index data references vertices that do not exist\")]\n    BadIndices,\n    #[error(\"mesh access error: {0}\")]\n    MeshAccessError(#[from] MeshAccessError),\n}\n\n/// An array of indices into the [`VertexAttributeValues`](super::VertexAttributeValues) for a mesh.\n///\n/// It describes the order in which the vertex attributes should be joined into faces.\n#[derive(Debug, Clone, Reflect, PartialEq)]\n#[reflect(Clone)]\n#[cfg_attr(feature = \"serialize\", derive(Serialize, Deserialize))]\npub enum Indices {\n    U16(Vec<u16>),\n    U32(Vec<u32>),\n}","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/index.rs#L53-L89","documentation":"Mesh::triangles() reads the POSITION attribute through VertexAttributeValues::as_float3() (crates/bevy_mesh/src/mesh.rs:2555). If the position data is stored in any variant other than Float32x3, as_float3 returns None and MeshTrianglesError::PositionsFormat is returned, because triangle extraction needs f32 xyz triples.","triggerScenarios":"Calling mesh.triangles() on a mesh whose POSITION attribute is stored as a non-Float32x3 variant, typically from deserialized/reflect-built meshes or manually constructed attribute data.","commonSituations":"Meshes loaded from custom binary formats that store positions as doubles or packed formats; hot-reloaded or scene-serialized meshes where attribute formats drifted; test fixtures built with raw VertexAttributeValues.","solutions":["Insert positions as Vec<Vec3> / Float32x3 so the attribute matches Mesh::ATTRIBUTE_POSITION.format","Check mesh.attribute(Mesh::ATTRIBUTE_POSITION) and its variant before calling triangles()","Re-insert the POSITION attribute as Float32x3 data before extraction"],"exampleFix":"// before\nlet tris: Vec<Triangle3d> = mesh.triangles()?.collect(); // Err(PositionsFormat)\n\n// after\n// ensure Float32x3 positions before extraction\nlet positions: Vec<[f32; 3]> = read_positions_as_f32();\nmesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);\nlet tris: Vec<Triangle3d> = mesh.triangles()?.collect();","handlingStrategy":"validation","validationCode":"fn positions_are_float32x3(mesh: &Mesh) -> bool {\n    mesh.attribute(Mesh::ATTRIBUTE_POSITION)\n        .is_some_and(|values| values.as_float3().is_some())\n}\n\nif positions_are_float32x3(&mesh) {\n    let tris: Vec<_> = mesh.triangles()?.collect();\n}","typeGuard":"fn float32x3_positions(mesh: &Mesh) -> Option<&[[f32; 3]]> {\n    mesh.attribute(Mesh::ATTRIBUTE_POSITION)?.as_float3()\n}","tryCatchPattern":"match mesh.triangles() {\n    Ok(iter) => { /* use triangles */ }\n    Err(MeshTrianglesError::PositionsFormat) => { /* re-insert POSITION as Float32x3 and retry */ }\n    Err(other) => { /* topology / access errors */ }\n}","preventionTips":["Always insert positions as Vec<Vec3> / [f32; 3] data","Validate attribute formats right after custom mesh import","Compare against Mesh::ATTRIBUTE_POSITION.format when building meshes programmatically"],"tags":["bevy","bevy-mesh","rust","mesh","vertex-format","positions","triangles"],"backgroundTag":"vertex-format-mismatch","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}