Git Product home page Git Product logo

bevy_web_asset's Introduction

Bevy Web Asset

crates.io MIT/Apache 2.0 crates.io docs.rs

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

NOTE: You need to add the plugin before DefaultPlugins:

Bevy 0.7 users, see 0.3.0 readme for how to add the plugin.

App::new()
    // The web asset plugin must be inserted before the `AssetPlugin` so
    // that the asset plugin doesn't create another instance of an asset
    // server. In general, the AssetPlugin should still run so that other
    // aspects of the asset system are initialized correctly.
    .add_plugin(WebAssetPlugin)
    .add_plugins(DefaultPlugins)
    .add_startup_system(setup)
    .run();
});

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");

Or:

commands.spawn_bundle(SpriteBundle {
    // Simply use a url where you would normally use an asset folder relative path
    texture: asset_server.load("https://johanhelsing.studio/assets/favicon.png"),
    ..default()
});

Bevy version support

I intend to support the latest bevy release in the main branch.

Fixes against the Bevy main branch goes in the the bevy-main branch and are merged back into main whenever bevy is released.

bevy bevy_web_asset
main bevy-main
0.8 0.4, main
0.7 0.3
0.6 0.2
0.5 0.1

bevy_web_asset's People

Contributors

johanhelsing avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.