try_export_collada_from_meshes

Function try_export_collada_from_meshes 

Source
pub fn try_export_collada_from_meshes(
    positions: &[f32],
    normals: &[f32],
    indices: &[u32],
    vertex_counts: &[u32],
    index_counts: &[u32],
    colors: &[f32],
    origins: &[f64],
) -> Result<Vec<u8>, ExportError>
Expand description

Build a Google-Earth-compatible COLLADA 1.4.1 .dae from already-produced (Y-up) meshes, flattened into parallel arrays exactly like export_glb_from_meshes. Per mesh i: vertex_counts[i] vertices + index_counts[i] indices taken in order from the concatenated positions/normals/indices; colors is RGBA per mesh, origins xyz per mesh (world = origin + position). Returns the .dae bytes (UTF-8 XML).

Fails closed when no triangle survives. An empty document is not merely useless, it is SCHEMA-INVALID: COLLADA 1.4.1 declares <library_effects>, <library_materials>, <library_geometries> and <visual_scene> each with minOccurs="1" children, and write_dae emits all four regardless. Two inputs reach it: an empty visible set, and a mesh whose only triangle is degenerate (the vertex dedup collapses two of its corners and the triangle is dropped AFTER its material was registered, so effects and materials are non-empty while geometries is empty). The GLB twin fails closed on the same condition (gltf::from_meshes, #1438/#1516). The count that decides is taken from the material buckets AFTER every drop rule has run, not from the caller’s index_counts, which says only what was offered.