Bevy asset loader that transparently supports loading over http(s)

Overview

Bevy Web Asset

This is a tiny crate that that wraps the standard bevy asset loader, and adds the ability to load assets from http and https urls.

Supports both wasm (web-sys) and native.

If asset paths start with http:// or https://, then we try to do a web request to load the asset, otherwise, we just call the normal asset io.

This is nice if you want to keep your content on a server, even when developing native games. Use cases can be:

  • Tuning game balance post-launch
  • Seasonal events (halloween theme etc.)
  • Downloading dynamic content from 3rd party services (lospec, gltf repositories etc.)
  • Sharing user-created assets/mods over some service (level editor etc.)
  • Keeping initial download size small
  • Testing with different online assets during development

Usage

Adding the plugin is little bit tricky:

.add_plugins_with(DefaultPlugins, |group| {
    // The web asset plugin must be inserted in-between the
    // `CorePlugin' and `AssetPlugin`. It needs to be after the
    // CorePlugin, so that the IO task pool has already been constructed.
    // And it must be before the `AssetPlugin` so that the asset plugin
    // doesn't create another instance of an assert server. In general,
    // the AssetPlugin should still run so that other aspects of the
    // asset system are initialized correctly.
    group.add_before::
   (WebAssetPlugin)
});
  

But using it is quite simple, just use http urls instead of regular asset paths.

let font: Handle<Font> = asset_server.load("https://example.com/fonts/quicksand-light.ttf");
Comments
  • ocasional panic

    ocasional panic

    The unwrap here is causing a panic occasionally: https://github.com/johanhelsing/bevy_web_asset/blob/d4cd4f42f255c39db9f79434c283259e2313d74f/src/web_asset_io.rs#L26

    panicked at 'called `Result::unwrap()` on an `Err` value: JsValue(TypeError: NetworkError when attempting to fetch resource.
    )', /home/gilescope/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_web_asset-0.4.0/src/web_asset_io.rs:26:83
    
    bug good first issue 
    opened by gilescope 3
  • IoTaskPool resource not found in browser

    IoTaskPool resource not found in browser

    Got: panicked at 'IoTaskPool resource not found'.

    Anyone seen this error before? I'm on bevy 0.7 at the moment (waiting a bit longer to upgrade to 0.8).

    Is there some additional setup to do for wasm given things are a tad different on the browser?

    opened by gilescope 3
  • fix: Don't panic on NetworkErrors on wasm

    fix: Don't panic on NetworkErrors on wasm

    Instead warn before reporting the asset as AssetIoError::NotFound, same as we do on native.

    Ideally, we'd handle the actual errors, but this makes the two implementation behave similarly at least.

    Fixes: #4

    bug 
    opened by johanhelsing 0
  • Handle http error codes

    Handle http error codes

    Currently, if the response is a http error, we just blindly pass the payload on to the asset loader, which will most likely fail.

    On certain http error codes it probably makes sense to retry, on others it probably makes sense to log a warning/error and return and AssetIoError.

    Split from: #4 Related to: #6

    enhancement 
    opened by johanhelsing 0
  • Warn and retry when the server can't be reached

    Warn and retry when the server can't be reached

    When the user has a poor connection and the server can't be reached, we just warn and report the asset as AssetIoError::NotFound.

    However, it probably makes sense to retry if we couldn't reach the server.

    We should probably add a loop inside WebAssetIo::load_path to retry in those cases.

    Split from: #4

    enhancement good first issue 
    opened by johanhelsing 0
  • Regular file system hot reloading is not working

    Regular file system hot reloading is not working

    It's happening because the filesystem watcher implementation in bevy tries to downcast the asset io to FileAssetIO. Since we're wrapping it, that downcast fails, and nothing happens.

    Bevy issue: https://github.com/bevyengine/bevy/issues/1414

    bug 
    opened by johanhelsing 1
Releases(v0.5.0)
  • v0.5.0(Nov 13, 2022)

    What's Changed

    BREAKING: Due to changes to how plugin settings are handled in Bevy 0.9. The WebAssetPlugin is now added instead of AssetPlugin. Take care to disable AssetPlugin from DefaultPlugins (see readme or crate docs for details).

    • fix: Don't panic on NetworkErrors on wasm by @johanhelsing in https://github.com/johanhelsing/bevy_web_asset/pull/5
    • Update to Bevy 0.9 by @johanhelsing in https://github.com/johanhelsing/bevy_web_asset/pull/8
    • Readme is now serving double duty as top-level crate docs

    Full Changelog: https://github.com/johanhelsing/bevy_web_asset/compare/v0.4.0...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Jul 31, 2022)

Owner
Johan Klokkhammer Helsing
Making names and taking games
Johan Klokkhammer Helsing
An asset for HardHat C2 written in Rust as an example/demo

Rivet An asset for HardHat C2 written in Rust as an example/demo Installation and Use Download cargo for the operating system the team server will be

HardHat Toolbox 5 Oct 24, 2023
An HTTP server wrapper for omnisette. Supports both V1 (Provision) and V3 of anisette servers.

omnisette-server An HTTP server wrapper for omnisette. Supports both V1 (Provision) and V3 of anisette servers. Setup First, download the Apple Music

SideStore Team 5 Mar 29, 2023
Layer 4 load balancer with dynamic configuration loading

Convey Layer 4 load balancer with dynamic configuration loading featuring proxy, passthrough and direct server return modes Features Stats page (at /s

Ben Parli 289 Jan 1, 2023
A simple cross-platform remote file management tool to upload and download files over HTTP/S

A simple cross-platform remote file management tool to upload and download files over HTTP/S

sexnine 13 Dec 30, 2022
A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.

x-server-stats A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-serv

Pratyaksh 11 Oct 17, 2022
GeoIP lookup server over HTTP.

geoip-http | geoip-http is a fast GeoIP lookup service in Rust, using the Axum web framework. It provides one possible server for tzupdate. Features F

Chris Down 4 Jun 3, 2023
📡Proxy HTTP/1.1 requests over a sensitive point-to-point link

ptproxy Motivation What's this? Why do I need this? What's a sensitive network link? What's wrong with a VPN? What's wrong with HTTP[S]? What's wrong

Alba Mendez 5 Jul 26, 2023
Yet another youtube (and more) down loader

Yet another youtube (and more) down loader

Cthulhux 203 Dec 25, 2022
Network Block Storage server, written in Rust. Supports pluggable and chainable underlying storage

nbd-rs Disclaimer DO NEVER USE THIS FOR PRODUCTION Do not use this for any data that you cannot afford to lose any moment. Expect data loss, corruptio

Rainlab Inc 10 Sep 30, 2022
A fast, stable, efficient, and lightweight intranet penetration, port forwarding tool supports multiple connections, cascading proxy, and transmission encryption

A fast, stable, efficient, and lightweight intranet penetration, port forwarding tool supports multiple connections, cascading proxy, and transmission encryption

editso 1.3k Dec 30, 2022
🔍 Fully-featured metrics collection agent for First Tech Challenge competitions. Supports Prometheus.

Scout Scout is a fully-featured free and open source metrics collector for FTC competitions. The project is licensed under the GNU LGPLv3 license. Fea

hivemind 3 Oct 24, 2023
A multi-targets ping tool and library, which supports 10,000 packets/second, accurate latency

mping-rs a multi-targets ping tool, which supports 10,000 packets/second, accurate latency. 一个高频ping工具,支持多个目标。 正常的ping一般用来做探测工具,mping还可以用来做压测工具。 Go版本:

smallnest 25 Oct 29, 2023
A tcp over http2 + tls proxy

mtunnel A tcp over http2 + tls proxy. Usage 1. get certificates, by following steps. 2. make your config client config: { "local_addr": "127.0.0.1

cssivision 9 Sep 5, 2022
🤖 brwrs is a new protocol running over TCP/IP that is intended to be a suitable candidate for terminal-only servers

brwrs is a new protocol running over TCP/IP that is intended to be a suitable candidate for terminal-only servers (plain text data). That is, although it can be accessed from a browser, brwrs will not correctly interpret the browser's GET request.

daCoUSB 3 Jul 30, 2021
A small utility to wake computers up or put them to sleep over the local network

WKSL - a wake and sleep utility An experiment in writing a small CLI utility in Rust. The program lets you wake a machine on your local network up fro

Henrik Ravn 0 Nov 14, 2021
MQTT over QUIC

MQuicTT ?? This is a pre-alpha project, tread carefully ?? A rustlang utility/library for MQTT over QUIC. QUIC allows us to send data over multiple co

null 29 Dec 16, 2022
Send files over TCP. Quick and simple. Made in Rust.

SFT Multithreaded utility to send files over TCP. The sender writes a header containing the filename, and then the contents of the file, buffered, to

Orel 0 Dec 24, 2021
Streaming data over unix sockets, in Rust

Unix-socket based client/server In order to dig into Sōzu channels, I had to dig into the workings of unix sockets. What this repo contains a small so

Emmanuel Bosquet 3 Nov 28, 2022
Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Siger Yang 2 Jun 7, 2022