fn derive_prim(
        prim: &gltf::Primitive,
        model: &gltf::Model,
        types: &mut [Self],
    ) -> Result<(), ModelError> {
        // set the vertex attributes to be array buffers
        for (_, &attr_id) in &prim.attributes {
            let accessor =
                model
                    .accessors
                    .get(attr_id as usize)
                    .ok_or_else(|| ModelError::BadIndex {
                        array: "accessors",
                        got: attr_id as usize,
                        max: model.accessors.len(),
                    })?;
            Self::set_accessor(accessor, types, Self::ArrayBuffer)?;
        }

        // set the vertex indicies to be an element array buffer
        if let Some(indicies) = prim.indices {
            let accessor =
                model
                    .accessors
                    .get(indicies as usize)
                    .ok_or_else(|| ModelError::BadIndex {
                        array: "accessors",
                        got: indicies as usize,
                        max: model.accessors.len(),
                    })?;
            Self::set_accessor(accessor, types, Self::ElementArrayBuffer)?;
        }

        Ok(())
    }
/// Derive the types of buffer for a mesh primative
Derive the types of buffer for a mesh primative
Derive the types of buffer for a mesh primative
fn derive_prim(
        prim: &gltf::Primitive,
        model: &gltf::Model,
        types: &mut [Self],
    ) -> Result<(), ModelError> {
        // set the vertex attributes to be array buffers
        for (_, &attr_id) in &prim.attributes {
            let accessor =
                model
                    .accessors
                    .get(attr_id as usize)
                    .ok_or_else(|| ModelError::BadIndex {
                        array: "accessors",
                        got: attr_id as usize,
                        max: model.accessors.len(),
                    })?;
            Self::set_accessor(accessor, types, Self::ArrayBuffer)?;
        }
        // set the vertex indicies to be an element array buffer
        if let Some(indicies) = prim.indices {
            let accessor =
                model
                    .accessors
                    .get(indicies as usize)
                    .ok_or_else(|| ModelError::BadIndex {
                        array: "accessors",
                        got: indicies as usize,
                        max: model.accessors.len(),
                    })?;
            Self::set_accessor(accessor, types, Self::ElementArrayBuffer)?;
        }
        Ok(())
    }
fn derive_prim ( prim : & gltf :: Primitive , model : & gltf :: Model , types : & mut [ Self ] , ) -> Result < ( ) , ModelError > { // set the vertex attributes to be array buffers for ( _ , & attr_id ) in & prim . attributes { let accessor = model . accessors . get ( attr_id as usize ) . ok_or_else ( | | ModelError :: BadIndex { array : " " , got : attr_id as usize , max : model . accessors . len ( ) , } ) ? ; Self :: set_accessor ( accessor , types , Self :: ArrayBuffer ) ? ; } // set the vertex indicies to be an element array buffer if let Some ( indicies ) = prim . indices { let accessor = model . accessors . get ( indicies as usize ) . ok_or_else ( | | ModelError :: BadIndex { array : " " , got : indicies as usize , max : model . accessors . len ( ) , } ) ? ; Self :: set_accessor ( accessor , types , Self :: ElementArrayBuffer ) ? ; } Ok ( ( ) ) }
Derive the types of buffer for a mesh primative
Derive the types of buffer for a mesh primative
prim
&gltf::Primitive
model
&gltf::Model
types
&mut [Self]
prim
&gltf::Primitive
model
&gltf::Model
types
&mut [Self]