Crate bevy_web_codecs

Crate bevy_web_codecs 

Source
Expand description

This crate is a more efficient web replacement of Bevy’s default image loaders by making use of the WebCodecs API to decode images and fallsback to the canvas API when its unavailable. This crate parallelizes image decoding and reduces the bundle size compared to bevy_image’s default decoders.

§Example

use bevy::prelude::*;
use bevy_web_codecs::WebCodecsPlugin;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, WebCodecsPlugin::default()))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn(Camera2d);

    commands.spawn(Sprite::from_image(asset_server.load("my_image.png")));
}

Modules§

image
Image loading and decoding

Structs§

WebCodecsPlugin
Plugin that initiates the WebImageLoader.