#bevy-plugin #assets #blob #web #loading #url #wasm-bindgen

bevy_blob_loader

Bevy plugin for loading assets from JavaScript blob URLs

6 releases

0.0.6 Aug 20, 2024
0.0.5 Jul 9, 2024
0.0.4 Mar 6, 2024
0.0.3 Jan 3, 2024

#1793 in Game dev

Download history 20/week @ 2024-07-27 5/week @ 2024-08-03 1/week @ 2024-08-10 227/week @ 2024-08-17 116/week @ 2024-08-24 31/week @ 2024-08-31 87/week @ 2024-09-07 84/week @ 2024-09-14 42/week @ 2024-09-21 25/week @ 2024-09-28 6/week @ 2024-10-05 15/week @ 2024-10-12 28/week @ 2024-10-19 3/week @ 2024-10-26 20/week @ 2024-11-02 6/week @ 2024-11-09

58 downloads per month
Used in bevy_web_file_drop

MIT/Apache

10KB
139 lines

bevy_blob_loader

Bevy plugin for loading assets from JavaScript blob URLs. Should only be added when targeting the web, otherwise wasm-bindgen will panic.


lib.rs:

This crate provides a Bevy plugin for loading assets from JavaScript blob URLs. This is useful for taking input from the user within a browser, such as a file upload or drag-and-drop.

Usage

After adding [BlobLoaderPlugin] to your Bevy app, you can load assets from blob URLs like so:

use bevy::prelude::*;
use bevy_blob_loader::path::serialize_url;

fn my_system(asset_server: Res<AssetServer>) {
  let blob_url = "blob:http://example.com/1234-5678-9012-3456";

  // Note, we have to serialize the URL into a special format for Bevy to recognize it.
  // This takes in the file extension of the asset, which Bevy uses to determine how to
  // process the fetched asset.
  let serialized = serialize_url(&blob_url, "png");

  let handle: Handle<Image> = asset_server.load(serialized);
}

Dependencies

~32MB
~596K SLoC