pub fn build_mesh_and_material(
        &mut self,
        sprite: &Sprite,
        texture: TextureHandle,
        size: (f32, f32),
    ) -> (MeshHandle, Material) {
        let half_width = (sprite.right - sprite.left) * 0.5;
        let half_height = (sprite.bottom - sprite.top) * 0.5;

        let vertices =
            Shape::Plane(None).generate::<Vec<PosTex>>(Some((half_width, half_height, 0.0)));
        let mesh = self.loader
            .load_from_data(vertices, (), &self.asset_storage);

        let material = Material {
            albedo: texture,
            albedo_offset: TextureOffset {
                u: (sprite.left / size.0, sprite.right / size.0),
                v: (1.0 - sprite.bottom / size.1, 1.0 - sprite.top / size.1),
            },
            ..self.material_defaults.0.clone()
        };

        (mesh, material)
    }
/// Creates a MeshHandle and Material from the sprite and texture data.
/// Useful if you plan on re-using the same sprite a lot and don't want to
/// load the assets each time.
Creates a MeshHandle and Material from the sprite and texture data.
Useful if you plan on re-using the same sprite a lot and don't want to
load the assets each time.
Creates a MeshHandle and Material from the sprite and texture data . Useful if you plan on re - using the same sprite a lot and don ' t want to load the assets each time .
pub fn build_mesh_and_material(
        &mut self,
        sprite: &Sprite,
        texture: TextureHandle,
        size: (f32, f32),
    ) -> (MeshHandle, Material) {
        let half_width = (sprite.right - sprite.left) * 0.5;
        let half_height = (sprite.bottom - sprite.top) * 0.5;
        let vertices =
            Shape::Plane(None).generate::<Vec<PosTex>>(Some((half_width, half_height, 0.0)));
        let mesh = self.loader
            .load_from_data(vertices, (), &self.asset_storage);
        let material = Material {
            albedo: texture,
            albedo_offset: TextureOffset {
                u: (sprite.left / size.0, sprite.right / size.0),
                v: (1.0 - sprite.bottom / size.1, 1.0 - sprite.top / size.1),
            },
            ..self.material_defaults.0.clone()
        };
        (mesh, material)
    }
pub fn build_mesh_and_material ( & mut self , sprite : & Sprite , texture : TextureHandle , size : ( f32 , f32 ) , ) -> ( MeshHandle , Material ) { let half_width = ( sprite . right - sprite . left ) * 0.5 ; let half_height = ( sprite . bottom - sprite . top ) * 0.5 ; let vertices = Shape :: Plane ( None ) . generate :: < Vec < PosTex > > ( Some ( ( half_width , half_height , 0.0 ) ) ) ; let mesh = self . loader . load_from_data ( vertices , ( ) , & self . asset_storage ) ; let material = Material { albedo : texture , albedo_offset : TextureOffset { u : ( sprite . left / size . 0 , sprite . right / size . 0 ) , v : ( 1.0 - sprite . bottom / size . 1 , 1.0 - sprite . top / size . 1 ) , } , .. self . material_defaults . 0 . clone ( ) } ; ( mesh , material ) }
Creates a MeshHandle and Material from the sprite and texture data.
Creates a MeshHandle and Material from the sprite and texture data .
&mut self
sprite
&Sprite
texture
TextureHandle
size
(f32, f32)
&mut self
sprite
&Sprite
texture
TextureHandle
size
(f32, f32)