mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
5eb292dc10
# Bevy Asset V2 Proposal ## Why Does Bevy Need A New Asset System? Asset pipelines are a central part of the gamedev process. Bevy's current asset system is missing a number of features that make it non-viable for many classes of gamedev. After plenty of discussions and [a long community feedback period](https://github.com/bevyengine/bevy/discussions/3972), we've identified a number missing features: * **Asset Preprocessing**: it should be possible to "preprocess" / "compile" / "crunch" assets at "development time" rather than when the game starts up. This enables offloading expensive work from deployed apps, faster asset loading, less runtime memory usage, etc. * **Per-Asset Loader Settings**: Individual assets cannot define their own loaders that override the defaults. Additionally, they cannot provide per-asset settings to their loaders. This is a huge limitation, as many asset types don't provide all information necessary for Bevy _inside_ the asset. For example, a raw PNG image says nothing about how it should be sampled (ex: linear vs nearest). * **Asset `.meta` files**: assets should have configuration files stored adjacent to the asset in question, which allows the user to configure asset-type-specific settings. These settings should be accessible during the pre-processing phase. Modifying a `.meta` file should trigger a re-processing / re-load of the asset. It should be possible to configure asset loaders from the meta file. * **Processed Asset Hot Reloading**: Changes to processed assets (or their dependencies) should result in re-processing them and re-loading the results in live Bevy Apps. * **Asset Dependency Tracking**: The current bevy_asset has no good way to wait for asset dependencies to load. It punts this as an exercise for consumers of the loader apis, which is unreasonable and error prone. There should be easy, ergonomic ways to wait for assets to load and block some logic on an asset's entire dependency tree loading. * **Runtime Asset Loading**: it should be (optionally) possible to load arbitrary assets dynamically at runtime. This necessitates being able to deploy and run the asset server alongside Bevy Apps on _all platforms_. For example, we should be able to invoke the shader compiler at runtime, stream scenes from sources like the internet, etc. To keep deployed binaries (and startup times) small, the runtime asset server configuration should be configurable with different settings compared to the "pre processor asset server". * **Multiple Backends**: It should be possible to load assets from arbitrary sources (filesystems, the internet, remote asset serves, etc). * **Asset Packing**: It should be possible to deploy assets in compressed "packs", which makes it easier and more efficient to distribute assets with Bevy Apps. * **Asset Handoff**: It should be possible to hold a "live" asset handle, which correlates to runtime data, without actually holding the asset in memory. Ex: it must be possible to hold a reference to a GPU mesh generated from a "mesh asset" without keeping the mesh data in CPU memory * **Per-Platform Processed Assets**: Different platforms and app distributions have different capabilities and requirements. Some platforms need lower asset resolutions or different asset formats to operate within the hardware constraints of the platform. It should be possible to define per-platform asset processing profiles. And it should be possible to deploy only the assets required for a given platform. These features have architectural implications that are significant enough to require a full rewrite. The current Bevy Asset implementation got us this far, but it can take us no farther. This PR defines a brand new asset system that implements most of these features, while laying the foundations for the remaining features to be built. ## Bevy Asset V2 Here is a quick overview of the features introduced in this PR. * **Asset Preprocessing**: Preprocess assets at development time into more efficient (and configurable) representations * **Dependency Aware**: Dependencies required to process an asset are tracked. If an asset's processed dependency changes, it will be reprocessed * **Hot Reprocessing/Reloading**: detect changes to asset source files, reprocess them if they have changed, and then hot-reload them in Bevy Apps. * **Only Process Changes**: Assets are only re-processed when their source file (or meta file) has changed. This uses hashing and timestamps to avoid processing assets that haven't changed. * **Transactional and Reliable**: Uses write-ahead logging (a technique commonly used by databases) to recover from crashes / forced-exits. Whenever possible it avoids full-reprocessing / only uncompleted transactions will be reprocessed. When the processor is running in parallel with a Bevy App, processor asset writes block Bevy App asset reads. Reading metadata + asset bytes is guaranteed to be transactional / correctly paired. * **Portable / Run anywhere / Database-free**: The processor does not rely on an in-memory database (although it uses some database techniques for reliability). This is important because pretty much all in-memory databases have unsupported platforms or build complications. * **Configure Processor Defaults Per File Type**: You can say "use this processor for all files of this type". * **Custom Processors**: The `Processor` trait is flexible and unopinionated. It can be implemented by downstream plugins. * **LoadAndSave Processors**: Most asset processing scenarios can be expressed as "run AssetLoader A, save the results using AssetSaver X, and then load the result using AssetLoader B". For example, load this png image using `PngImageLoader`, which produces an `Image` asset and then save it using `CompressedImageSaver` (which also produces an `Image` asset, but in a compressed format), which takes an `Image` asset as input. This means if you have an `AssetLoader` for an asset, you are already half way there! It also means that you can share AssetSavers across multiple loaders. Because `CompressedImageSaver` accepts Bevy's generic Image asset as input, it means you can also use it with some future `JpegImageLoader`. * **Loader and Saver Settings**: Asset Loaders and Savers can now define their own settings types, which are passed in as input when an asset is loaded / saved. Each asset can define its own settings. * **Asset `.meta` files**: configure asset loaders, their settings, enable/disable processing, and configure processor settings * **Runtime Asset Dependency Tracking** Runtime asset dependencies (ex: if an asset contains a `Handle<Image>`) are tracked by the asset server. An event is emitted when an asset and all of its dependencies have been loaded * **Unprocessed Asset Loading**: Assets do not require preprocessing. They can be loaded directly. A processed asset is just a "normal" asset with some extra metadata. Asset Loaders don't need to know or care about whether or not an asset was processed. * **Async Asset IO**: Asset readers/writers use async non-blocking interfaces. Note that because Rust doesn't yet support async traits, there is a bit of manual Boxing / Future boilerplate. This will hopefully be removed in the near future when Rust gets async traits. * **Pluggable Asset Readers and Writers**: Arbitrary asset source readers/writers are supported, both by the processor and the asset server. * **Better Asset Handles** * **Single Arc Tree**: Asset Handles now use a single arc tree that represents the lifetime of the asset. This makes their implementation simpler, more efficient, and allows us to cheaply attach metadata to handles. Ex: the AssetPath of a handle is now directly accessible on the handle itself! * **Const Typed Handles**: typed handles can be constructed in a const context. No more weird "const untyped converted to typed at runtime" patterns! * **Handles and Ids are Smaller / Faster To Hash / Compare**: Typed `Handle<T>` is now much smaller in memory and `AssetId<T>` is even smaller. * **Weak Handle Usage Reduction**: In general Handles are now considered to be "strong". Bevy features that previously used "weak `Handle<T>`" have been ported to `AssetId<T>`, which makes it statically clear that the features do not hold strong handles (while retaining strong type information). Currently Handle::Weak still exists, but it is very possible that we can remove that entirely. * **Efficient / Dense Asset Ids**: Assets now have efficient dense runtime asset ids, which means we can avoid expensive hash lookups. Assets are stored in Vecs instead of HashMaps. There are now typed and untyped ids, which means we no longer need to store dynamic type information in the ID for typed handles. "AssetPathId" (which was a nightmare from a performance and correctness standpoint) has been entirely removed in favor of dense ids (which are retrieved for a path on load) * **Direct Asset Loading, with Dependency Tracking**: Assets that are defined at runtime can still have their dependencies tracked by the Asset Server (ex: if you create a material at runtime, you can still wait for its textures to load). This is accomplished via the (currently optional) "asset dependency visitor" trait. This system can also be used to define a set of assets to load, then wait for those assets to load. * **Async folder loading**: Folder loading also uses this system and immediately returns a handle to the LoadedFolder asset, which means folder loading no longer blocks on directory traversals. * **Improved Loader Interface**: Loaders now have a specific "top level asset type", which makes returning the top-level asset simpler and statically typed. * **Basic Image Settings and Processing**: Image assets can now be processed into the gpu-friendly Basic Universal format. The ImageLoader now has a setting to define what format the image should be loaded as. Note that this is just a minimal MVP ... plenty of additional work to do here. To demo this, enable the `basis-universal` feature and turn on asset processing. * **Simpler Audio Play / AudioSink API**: Asset handle providers are cloneable, which means the Audio resource can mint its own handles. This means you can now do `let sink_handle = audio.play(music)` instead of `let sink_handle = audio_sinks.get_handle(audio.play(music))`. Note that this might still be replaced by https://github.com/bevyengine/bevy/pull/8424. **Removed Handle Casting From Engine Features**: Ex: FontAtlases no longer use casting between handle types ## Using The New Asset System ### Normal Unprocessed Asset Loading By default the `AssetPlugin` does not use processing. It behaves pretty much the same way as the old system. If you are defining a custom asset, first derive `Asset`: ```rust #[derive(Asset)] struct Thing { value: String, } ``` Initialize the asset: ```rust app.init_asset:<Thing>() ``` Implement a new `AssetLoader` for it: ```rust #[derive(Default)] struct ThingLoader; #[derive(Serialize, Deserialize, Default)] pub struct ThingSettings { some_setting: bool, } impl AssetLoader for ThingLoader { type Asset = Thing; type Settings = ThingSettings; fn load<'a>( &'a self, reader: &'a mut Reader, settings: &'a ThingSettings, load_context: &'a mut LoadContext, ) -> BoxedFuture<'a, Result<Thing, anyhow::Error>> { Box::pin(async move { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; // convert bytes to value somehow Ok(Thing { value }) }) } fn extensions(&self) -> &[&str] { &["thing"] } } ``` Note that this interface will get much cleaner once Rust gets support for async traits. `Reader` is an async futures_io::AsyncRead. You can stream bytes as they come in or read them all into a `Vec<u8>`, depending on the context. You can use `let handle = load_context.load(path)` to kick off a dependency load, retrieve a handle, and register the dependency for the asset. Then just register the loader in your Bevy app: ```rust app.init_asset_loader::<ThingLoader>() ``` Now just add your `Thing` asset files into the `assets` folder and load them like this: ```rust fn system(asset_server: Res<AssetServer>) { let handle = Handle<Thing> = asset_server.load("cool.thing"); } ``` You can check load states directly via the asset server: ```rust if asset_server.load_state(&handle) == LoadState::Loaded { } ``` You can also listen for events: ```rust fn system(mut events: EventReader<AssetEvent<Thing>>, handle: Res<SomeThingHandle>) { for event in events.iter() { if event.is_loaded_with_dependencies(&handle) { } } } ``` Note the new `AssetEvent::LoadedWithDependencies`, which only fires when the asset is loaded _and_ all dependencies (and their dependencies) have loaded. Unlike the old asset system, for a given asset path all `Handle<T>` values point to the same underlying Arc. This means Handles can cheaply hold more asset information, such as the AssetPath: ```rust // prints the AssetPath of the handle info!("{:?}", handle.path()) ``` ### Processed Assets Asset processing can be enabled via the `AssetPlugin`. When developing Bevy Apps with processed assets, do this: ```rust app.add_plugins(DefaultPlugins.set(AssetPlugin::processed_dev())) ``` This runs the `AssetProcessor` in the background with hot-reloading. It reads assets from the `assets` folder, processes them, and writes them to the `.imported_assets` folder. Asset loads in the Bevy App will wait for a processed version of the asset to become available. If an asset in the `assets` folder changes, it will be reprocessed and hot-reloaded in the Bevy App. When deploying processed Bevy apps, do this: ```rust app.add_plugins(DefaultPlugins.set(AssetPlugin::processed())) ``` This does not run the `AssetProcessor` in the background. It behaves like `AssetPlugin::unprocessed()`, but reads assets from `.imported_assets`. When the `AssetProcessor` is running, it will populate sibling `.meta` files for assets in the `assets` folder. Meta files for assets that do not have a processor configured look like this: ```rust ( meta_format_version: "1.0", asset: Load( loader: "bevy_render::texture::image_loader::ImageLoader", settings: ( format: FromExtension, ), ), ) ``` This is metadata for an image asset. For example, if you have `assets/my_sprite.png`, this could be the metadata stored at `assets/my_sprite.png.meta`. Meta files are totally optional. If no metadata exists, the default settings will be used. In short, this file says "load this asset with the ImageLoader and use the file extension to determine the image type". This type of meta file is supported in all AssetPlugin modes. If in `Unprocessed` mode, the asset (with the meta settings) will be loaded directly. If in `ProcessedDev` mode, the asset file will be copied directly to the `.imported_assets` folder. The meta will also be copied directly to the `.imported_assets` folder, but with one addition: ```rust ( meta_format_version: "1.0", processed_info: Some(( hash: 12415480888597742505, full_hash: 14344495437905856884, process_dependencies: [], )), asset: Load( loader: "bevy_render::texture::image_loader::ImageLoader", settings: ( format: FromExtension, ), ), ) ``` `processed_info` contains `hash` (a direct hash of the asset and meta bytes), `full_hash` (a hash of `hash` and the hashes of all `process_dependencies`), and `process_dependencies` (the `path` and `full_hash` of every process_dependency). A "process dependency" is an asset dependency that is _directly_ used when processing the asset. Images do not have process dependencies, so this is empty. When the processor is enabled, you can use the `Process` metadata config: ```rust ( meta_format_version: "1.0", asset: Process( processor: "bevy_asset::processor::process::LoadAndSave<bevy_render::texture::image_loader::ImageLoader, bevy_render::texture::compressed_image_saver::CompressedImageSaver>", settings: ( loader_settings: ( format: FromExtension, ), saver_settings: ( generate_mipmaps: true, ), ), ), ) ``` This configures the asset to use the `LoadAndSave` processor, which runs an AssetLoader and feeds the result into an AssetSaver (which saves the given Asset and defines a loader to load it with). (for terseness LoadAndSave will likely get a shorter/friendlier type name when [Stable Type Paths](#7184) lands). `LoadAndSave` is likely to be the most common processor type, but arbitrary processors are supported. `CompressedImageSaver` saves an `Image` in the Basis Universal format and configures the ImageLoader to load it as basis universal. The `AssetProcessor` will read this meta, run it through the LoadAndSave processor, and write the basis-universal version of the image to `.imported_assets`. The final metadata will look like this: ```rust ( meta_format_version: "1.0", processed_info: Some(( hash: 905599590923828066, full_hash: 9948823010183819117, process_dependencies: [], )), asset: Load( loader: "bevy_render::texture::image_loader::ImageLoader", settings: ( format: Format(Basis), ), ), ) ``` To try basis-universal processing out in Bevy examples, (for example `sprite.rs`), change `add_plugins(DefaultPlugins)` to `add_plugins(DefaultPlugins.set(AssetPlugin::processed_dev()))` and run with the `basis-universal` feature enabled: `cargo run --features=basis-universal --example sprite`. To create a custom processor, there are two main paths: 1. Use the `LoadAndSave` processor with an existing `AssetLoader`. Implement the `AssetSaver` trait, register the processor using `asset_processor.register_processor::<LoadAndSave<ImageLoader, CompressedImageSaver>>(image_saver.into())`. 2. Implement the `Process` trait directly and register it using: `asset_processor.register_processor(thing_processor)`. You can configure default processors for file extensions like this: ```rust asset_processor.set_default_processor::<ThingProcessor>("thing") ``` There is one more metadata type to be aware of: ```rust ( meta_format_version: "1.0", asset: Ignore, ) ``` This will ignore the asset during processing / prevent it from being written to `.imported_assets`. The AssetProcessor stores a transaction log at `.imported_assets/log` and uses it to gracefully recover from unexpected stops. This means you can force-quit the processor (and Bevy Apps running the processor in parallel) at arbitrary times! `.imported_assets` is "local state". It should _not_ be checked into source control. It should also be considered "read only". In practice, you _can_ modify processed assets and processed metadata if you really need to test something. But those modifications will not be represented in the hashes of the assets, so the processed state will be "out of sync" with the source assets. The processor _will not_ fix this for you. Either revert the change after you have tested it, or delete the processed files so they can be re-populated. ## Open Questions There are a number of open questions to be discussed. We should decide if they need to be addressed in this PR and if so, how we will address them: ### Implied Dependencies vs Dependency Enumeration There are currently two ways to populate asset dependencies: * **Implied via AssetLoaders**: if an AssetLoader loads an asset (and retrieves a handle), a dependency is added to the list. * **Explicit via the optional Asset::visit_dependencies**: if `server.load_asset(my_asset)` is called, it will call `my_asset.visit_dependencies`, which will grab dependencies that have been manually defined for the asset via the Asset trait impl (which can be derived). This means that defining explicit dependencies is optional for "loaded assets". And the list of dependencies is always accurate because loaders can only produce Handles if they register dependencies. If an asset was loaded with an AssetLoader, it only uses the implied dependencies. If an asset was created at runtime and added with `asset_server.load_asset(MyAsset)`, it will use `Asset::visit_dependencies`. However this can create a behavior mismatch between loaded assets and equivalent "created at runtime" assets if `Assets::visit_dependencies` doesn't exactly match the dependencies produced by the AssetLoader. This behavior mismatch can be resolved by completely removing "implied loader dependencies" and requiring `Asset::visit_dependencies` to supply dependency data. But this creates two problems: * It makes defining loaded assets harder and more error prone: Devs must remember to manually annotate asset dependencies with `#[dependency]` when deriving `Asset`. For more complicated assets (such as scenes), the derive likely wouldn't be sufficient and a manual `visit_dependencies` impl would be required. * Removes the ability to immediately kick off dependency loads: When AssetLoaders retrieve a Handle, they also immediately kick off an asset load for the handle, which means it can start loading in parallel _before_ the asset finishes loading. For large assets, this could be significant. (although this could be mitigated for processed assets if we store dependencies in the processed meta file and load them ahead of time) ### Eager ProcessorDev Asset Loading I made a controversial call in the interest of fast startup times ("time to first pixel") for the "processor dev mode configuration". When initializing the AssetProcessor, current processed versions of unchanged assets are yielded immediately, even if their dependencies haven't been checked yet for reprocessing. This means that non-current-state-of-filesystem-but-previously-valid assets might be returned to the App first, then hot-reloaded if/when their dependencies change and the asset is reprocessed. Is this behavior desirable? There is largely one alternative: do not yield an asset from the processor to the app until all of its dependencies have been checked for changes. In some common cases (load dependency has not changed since last run) this will increase startup time. The main question is "by how much" and is that slower startup time worth it in the interest of only yielding assets that are true to the current state of the filesystem. Should this be configurable? I'm starting to think we should only yield an asset after its (historical) dependencies have been checked for changes + processed as necessary, but I'm curious what you all think. ### Paths Are Currently The Only Canonical ID / Do We Want Asset UUIDs? In this implementation AssetPaths are the only canonical asset identifier (just like the previous Bevy Asset system and Godot). Moving assets will result in re-scans (and currently reprocessing, although reprocessing can easily be avoided with some changes). Asset renames/moves will break code and assets that rely on specific paths, unless those paths are fixed up. Do we want / need "stable asset uuids"? Introducing them is very possible: 1. Generate a UUID and include it in .meta files 2. Support UUID in AssetPath 3. Generate "asset indices" which are loaded on startup and map UUIDs to paths. 4 (maybe). Consider only supporting UUIDs for processed assets so we can generate quick-to-load indices instead of scanning meta files. The main "pro" is that assets referencing UUIDs don't need to be migrated when a path changes. The main "con" is that UUIDs cannot be "lazily resolved" like paths. They need a full view of all assets to answer the question "does this UUID exist". Which means UUIDs require the AssetProcessor to fully finish startup scans before saying an asset doesnt exist. And they essentially require asset pre-processing to use in apps, because scanning all asset metadata files at runtime to resolve a UUID is not viable for medium-to-large apps. It really requires a pre-generated UUID index, which must be loaded before querying for assets. I personally think this should be investigated in a separate PR. Paths aren't going anywhere ... _everyone_ uses filesystems (and filesystem-like apis) to manage their asset source files. I consider them permanent canonical asset information. Additionally, they behave well for both processed and unprocessed asset modes. Given that Bevy is supporting both, this feels like the right canonical ID to start with. UUIDS (and maybe even other indexed-identifier types) can be added later as necessary. ### Folder / File Naming Conventions All asset processing config currently lives in the `.imported_assets` folder. The processor transaction log is in `.imported_assets/log`. Processed assets are added to `.imported_assets/Default`, which will make migrating to processed asset profiles (ex: a `.imported_assets/Mobile` profile) a non-breaking change. It also allows us to create top-level files like `.imported_assets/log` without it being interpreted as an asset. Meta files currently have a `.meta` suffix. Do we like these names and conventions? ### Should the `AssetPlugin::processed_dev` configuration enable `watch_for_changes` automatically? Currently it does (which I think makes sense), but it does make it the only configuration that enables watch_for_changes by default. ### Discuss on_loaded High Level Interface: This PR includes a very rough "proof of concept" `on_loaded` system adapter that uses the `LoadedWithDependencies` event in combination with `asset_server.load_asset` dependency tracking to support this pattern ```rust fn main() { App::new() .init_asset::<MyAssets>() .add_systems(Update, on_loaded(create_array_texture)) .run(); } #[derive(Asset, Clone)] struct MyAssets { #[dependency] picture_of_my_cat: Handle<Image>, #[dependency] picture_of_my_other_cat: Handle<Image>, } impl FromWorld for ArrayTexture { fn from_world(world: &mut World) -> Self { picture_of_my_cat: server.load("meow.png"), picture_of_my_other_cat: server.load("meeeeeeeow.png"), } } fn spawn_cat(In(my_assets): In<MyAssets>, mut commands: Commands) { commands.spawn(SpriteBundle { texture: my_assets.picture_of_my_cat.clone(), ..default() }); commands.spawn(SpriteBundle { texture: my_assets.picture_of_my_other_cat.clone(), ..default() }); } ``` The implementation is _very_ rough. And it is currently unsafe because `bevy_ecs` doesn't expose some internals to do this safely from inside `bevy_asset`. There are plenty of unanswered questions like: * "do we add a Loadable" derive? (effectively automate the FromWorld implementation above) * Should `MyAssets` even be an Asset? (largely implemented this way because it elegantly builds on `server.load_asset(MyAsset { .. })` dependency tracking). We should think hard about what our ideal API looks like (and if this is a pattern we want to support). Not necessarily something we need to solve in this PR. The current `on_loaded` impl should probably be removed from this PR before merging. ## Clarifying Questions ### What about Assets as Entities? This Bevy Asset V2 proposal implementation initially stored Assets as ECS Entities. Instead of `AssetId<T>` + the `Assets<T>` resource it used `Entity` as the asset id and Asset values were just ECS components. There are plenty of compelling reasons to do this: 1. Easier to inline assets in Bevy Scenes (as they are "just" normal entities + components) 2. More flexible queries: use the power of the ECS to filter assets (ex: `Query<Mesh, With<Tree>>`). 3. Extensible. Users can add arbitrary component data to assets. 4. Things like "component visualization tools" work out of the box to visualize asset data. However Assets as Entities has a ton of caveats right now: * We need to be able to allocate entity ids without a direct World reference (aka rework id allocator in Entities ... i worked around this in my prototypes by just pre allocating big chunks of entities) * We want asset change events in addition to ECS change tracking ... how do we populate them when mutations can come from anywhere? Do we use Changed queries? This would require iterating over the change data for all assets every frame. Is this acceptable or should we implement a new "event based" component change detection option? * Reconciling manually created assets with asset-system managed assets has some nuance (ex: are they "loaded" / do they also have that component metadata?) * "how do we handle "static" / default entity handles" (ties in to the Entity Indices discussion: https://github.com/bevyengine/bevy/discussions/8319). This is necessary for things like "built in" assets and default handles in things like SpriteBundle. * Storing asset information as a component makes it easy to "invalidate" asset state by removing the component (or forcing modifications). Ideally we have ways to lock this down (some combination of Rust type privacy and ECS validation) In practice, how we store and identify assets is a reasonably superficial change (porting off of Assets as Entities and implementing dedicated storage + ids took less than a day). So once we sort out the remaining challenges the flip should be straightforward. Additionally, I do still have "Assets as Entities" in my commit history, so we can reuse that work. I personally think "assets as entities" is a good endgame, but it also doesn't provide _significant_ value at the moment and it certainly isn't ready yet with the current state of things. ### Why not Distill? [Distill](https://github.com/amethyst/distill) is a high quality fully featured asset system built in Rust. It is very natural to ask "why not just use Distill?". It is also worth calling out that for awhile, [we planned on adopting Distill / I signed off on it](https://github.com/bevyengine/bevy/issues/708). However I think Bevy has a number of constraints that make Distill adoption suboptimal: * **Architectural Simplicity:** * Distill's processor requires an in-memory database (lmdb) and RPC networked API (using Cap'n Proto). Each of these introduces API complexity that increases maintenance burden and "code grokability". Ignoring tests, documentation, and examples, Distill has 24,237 lines of Rust code (including generated code for RPC + database interactions). If you ignore generated code, it has 11,499 lines. * Bevy builds the AssetProcessor and AssetServer using pluggable AssetReader/AssetWriter Rust traits with simple io interfaces. They do not necessitate databases or RPC interfaces (although Readers/Writers could use them if that is desired). Bevy Asset V2 (at the time of writing this PR) is 5,384 lines of Rust code (ignoring tests, documentation, and examples). Grain of salt: Distill does have more features currently (ex: Asset Packing, GUIDS, remote-out-of-process asset processor). I do plan to implement these features in Bevy Asset V2 and I personally highly doubt they will meaningfully close the 6115 lines-of-code gap. * This complexity gap (which while illustrated by lines of code, is much bigger than just that) is noteworthy to me. Bevy should be hackable and there are pillars of Distill that are very hard to understand and extend. This is a matter of opinion (and Bevy Asset V2 also has complicated areas), but I think Bevy Asset V2 is much more approachable for the average developer. * Necessary disclaimer: counting lines of code is an extremely rough complexity metric. Read the code and form your own opinions. * **Optional Asset Processing:** Not all Bevy Apps (or Bevy App developers) need / want asset preprocessing. Processing increases the complexity of the development environment by introducing things like meta files, imported asset storage, running processors in the background, waiting for processing to finish, etc. Distill _requires_ preprocessing to work. With Bevy Asset V2 processing is fully opt-in. The AssetServer isn't directly aware of asset processors at all. AssetLoaders only care about converting bytes to runtime Assets ... they don't know or care if the bytes were pre-processed or not. Processing is "elegantly" (forgive my self-congratulatory phrasing) layered on top and builds on the existing Asset system primitives. * **Direct Filesystem Access to Processed Asset State:** Distill stores processed assets in a database. This makes debugging / inspecting the processed outputs harder (either requires special tooling to query the database or they need to be "deployed" to be inspected). Bevy Asset V2, on the other hand, stores processed assets in the filesystem (by default ... this is configurable). This makes interacting with the processed state more natural. Note that both Godot and Unity's new asset system store processed assets in the filesystem. * **Portability**: Because Distill's processor uses lmdb and RPC networking, it cannot be run on certain platforms (ex: lmdb is a non-rust dependency that cannot run on the web, some platforms don't support running network servers). Bevy should be able to process assets everywhere (ex: run the Bevy Editor on the web, compile + process shaders on mobile, etc). Distill does partially mitigate this problem by supporting "streaming" assets via the RPC protocol, but this is not a full solve from my perspective. And Bevy Asset V2 can (in theory) also stream assets (without requiring RPC, although this isn't implemented yet) Note that I _do_ still think Distill would be a solid asset system for Bevy. But I think the approach in this PR is a better solve for Bevy's specific "asset system requirements". ### Doesn't async-fs just shim requests to "sync" `std::fs`? What is the point? "True async file io" has limited / spotty platform support. async-fs (and the rust async ecosystem generally ... ex Tokio) currently use async wrappers over std::fs that offload blocking requests to separate threads. This may feel unsatisfying, but it _does_ still provide value because it prevents our task pools from blocking on file system operations (which would prevent progress when there are many tasks to do, but all threads in a pool are currently blocking on file system ops). Additionally, using async APIs for our AssetReaders and AssetWriters also provides value because we can later add support for "true async file io" for platforms that support it. _And_ we can implement other "true async io" asset backends (such as networked asset io). ## Draft TODO - [x] Fill in missing filesystem event APIs: file removed event (which is expressed as dangling RenameFrom events in some cases), file/folder renamed event - [x] Assets without loaders are not moved to the processed folder. This breaks things like referenced `.bin` files for GLTFs. This should be configurable per-non-asset-type. - [x] Initial implementation of Reflect and FromReflect for Handle. The "deserialization" parity bar is low here as this only worked with static UUIDs in the old impl ... this is a non-trivial problem. Either we add a Handle::AssetPath variant that gets "upgraded" to a strong handle on scene load or we use a separate AssetRef type for Bevy scenes (which is converted to a runtime Handle on load). This deserves its own discussion in a different pr. - [x] Populate read_asset_bytes hash when run by the processor (a bit of a special case .. when run by the processor the processed meta will contain the hash so we don't need to compute it on the spot, but we don't want/need to read the meta when run by the main AssetServer) - [x] Delay hot reloading: currently filesystem events are handled immediately, which creates timing issues in some cases. For example hot reloading images can sometimes break because the image isn't finished writing. We should add a delay, likely similar to the [implementation in this PR](https://github.com/bevyengine/bevy/pull/8503). - [x] Port old platform-specific AssetIo implementations to the new AssetReader interface (currently missing Android and web) - [x] Resolve on_loaded unsafety (either by removing the API entirely or removing the unsafe) - [x] Runtime loader setting overrides - [x] Remove remaining unwraps that should be error-handled. There are number of TODOs here - [x] Pretty AssetPath Display impl - [x] Document more APIs - [x] Resolve spurious "reloading because it has changed" events (to repro run load_gltf with `processed_dev()`) - [x] load_dependency hot reloading currently only works for processed assets. If processing is disabled, load_dependency changes are not hot reloaded. - [x] Replace AssetInfo dependency load/fail counters with `loading_dependencies: HashSet<UntypedAssetId>` to prevent reloads from (potentially) breaking counters. Storing this will also enable "dependency reloaded" events (see [Next Steps](#next-steps)) - [x] Re-add filesystem watcher cargo feature gate (currently it is not optional) - [ ] Migration Guide - [ ] Changelog ## Followup TODO - [ ] Replace "eager unchanged processed asset loading" behavior with "don't returned unchanged processed asset until dependencies have been checked". - [ ] Add true `Ignore` AssetAction that does not copy the asset to the imported_assets folder. - [ ] Finish "live asset unloading" (ex: free up CPU asset memory after uploading an image to the GPU), rethink RenderAssets, and port renderer features. The `Assets` collection uses `Option<T>` for asset storage to support its removal. (1) the Option might not actually be necessary ... might be able to just remove from the collection entirely (2) need to finalize removal apis - [ ] Try replacing the "channel based" asset id recycling with something a bit more efficient (ex: we might be able to use raw atomic ints with some cleverness) - [ ] Consider adding UUIDs to processed assets (scoped just to helping identify moved assets ... not exposed to load queries ... see [Next Steps](#next-steps)) - [ ] Store "last modified" source asset and meta timestamps in processed meta files to enable skipping expensive hashing when the file wasn't changed - [ ] Fix "slow loop" handle drop fix - [ ] Migrate to TypeName - [x] Handle "loader preregistration". See #9429 ## Next Steps * **Configurable per-type defaults for AssetMeta**: It should be possible to add configuration like "all png image meta should default to using nearest sampling" (currently this hard-coded per-loader/processor Settings::default() impls). Also see the "Folder Meta" bullet point. * **Avoid Reprocessing on Asset Renames / Moves**: See the "canonical asset ids" discussion in [Open Questions](#open-questions) and the relevant bullet point in [Draft TODO](#draft-todo). Even without canonical ids, folder renames could avoid reprocessing in some cases. * **Multiple Asset Sources**: Expand AssetPath to support "asset source names" and support multiple AssetReaders in the asset server (ex: `webserver://some_path/image.png` backed by an Http webserver AssetReader). The "default" asset reader would use normal `some_path/image.png` paths. Ideally this works in combination with multiple AssetWatchers for hot-reloading * **Stable Type Names**: this pr removes the TypeUuid requirement from assets in favor of `std::any::type_name`. This makes defining assets easier (no need to generate a new uuid / use weird proc macro syntax). It also makes reading meta files easier (because things have "friendly names"). We also use type names for components in scene files. If they are good enough for components, they are good enough for assets. And consistency across Bevy pillars is desirable. However, `std::any::type_name` is not guaranteed to be stable (although in practice it is). We've developed a [stable type path](https://github.com/bevyengine/bevy/pull/7184) to resolve this, which should be adopted when it is ready. * **Command Line Interface**: It should be possible to run the asset processor in a separate process from the command line. This will also require building a network-server-backed AssetReader to communicate between the app and the processor. We've been planning to build a "bevy cli" for awhile. This seems like a good excuse to build it. * **Asset Packing**: This is largely an additive feature, so it made sense to me to punt this until we've laid the foundations in this PR. * **Per-Platform Processed Assets**: It should be possible to generate assets for multiple platforms by supporting multiple "processor profiles" per asset (ex: compress with format X on PC and Y on iOS). I think there should probably be arbitrary "profiles" (which can be separate from actual platforms), which are then assigned to a given platform when generating the final asset distribution for that platform. Ex: maybe devs want a "Mobile" profile that is shared between iOS and Android. Or a "LowEnd" profile shared between web and mobile. * **Versioning and Migrations**: Assets, Loaders, Savers, and Processors need to have versions to determine if their schema is valid. If an asset / loader version is incompatible with the current version expected at runtime, the processor should be able to migrate them. I think we should try using Bevy Reflect for this, as it would allow us to load the old version as a dynamic Reflect type without actually having the old Rust type. It would also allow us to define "patches" to migrate between versions (Bevy Reflect devs are currently working on patching). The `.meta` file already has its own format version. Migrating that to new versions should also be possible. * **Real Copy-on-write AssetPaths**: Rust's actual Cow (clone-on-write type) currently used by AssetPath can still result in String clones that aren't actually necessary (cloning an Owned Cow clones the contents). Bevy's asset system requires cloning AssetPaths in a number of places, which result in actual clones of the internal Strings. This is not efficient. AssetPath internals should be reworked to exhibit truer cow-like-behavior that reduces String clones to the absolute minimum. * **Consider processor-less processing**: In theory the AssetServer could run processors "inline" even if the background AssetProcessor is disabled. If we decide this is actually desirable, we could add this. But I don't think its a priority in the short or medium term. * **Pre-emptive dependency loading**: We could encode dependencies in processed meta files, which could then be used by the Asset Server to kick of dependency loads as early as possible (prior to starting the actual asset load). Is this desirable? How much time would this save in practice? * **Optimize Processor With UntypedAssetIds**: The processor exclusively uses AssetPath to identify assets currently. It might be possible to swap these out for UntypedAssetIds in some places, which are smaller / cheaper to hash and compare. * **One to Many Asset Processing**: An asset source file that produces many assets currently must be processed into a single "processed" asset source. If labeled assets can be written separately they can each have their own configured savers _and_ they could be loaded more granularly. Definitely worth exploring! * **Automatically Track "Runtime-only" Asset Dependencies**: Right now, tracking "created at runtime" asset dependencies requires adding them via `asset_server.load_asset(StandardMaterial::default())`. I think with some cleverness we could also do this for `materials.add(StandardMaterial::default())`, making tracking work "everywhere". There are challenges here relating to change detection / ensuring the server is made aware of dependency changes. This could be expensive in some cases. * **"Dependency Changed" events**: Some assets have runtime artifacts that need to be re-generated when one of their dependencies change (ex: regenerate a material's bind group when a Texture needs to change). We are generating the dependency graph so we can definitely produce these events. Buuuuut generating these events will have a cost / they could be high frequency for some assets, so we might want this to be opt-in for specific cases. * **Investigate Storing More Information In Handles**: Handles can now store arbitrary information, which makes it cheaper and easier to access. How much should we move into them? Canonical asset load states (via atomics)? (`handle.is_loaded()` would be very cool). Should we store the entire asset and remove the `Assets<T>` collection? (`Arc<RwLock<Option<Image>>>`?) * **Support processing and loading files without extensions**: This is a pretty arbitrary restriction and could be supported with very minimal changes. * **Folder Meta**: It would be nice if we could define per folder processor configuration defaults (likely in a `.meta` or `.folder_meta` file). Things like "default to linear filtering for all Images in this folder". * **Replace async_broadcast with event-listener?** This might be approximately drop-in for some uses and it feels more light weight * **Support Running the AssetProcessor on the Web**: Most of the hard work is done here, but there are some easy straggling TODOs (make the transaction log an interface instead of a direct file writer so we can write a web storage backend, implement an AssetReader/AssetWriter that reads/writes to something like LocalStorage). * **Consider identifying and preventing circular dependencies**: This is especially important for "processor dependencies", as processing will silently never finish in these cases. * **Built-in/Inlined Asset Hot Reloading**: This PR regresses "built-in/inlined" asset hot reloading (previously provided by the DebugAssetServer). I'm intentionally punting this because I think it can be cleanly implemented with "multiple asset sources" by registering a "debug asset source" (ex: `debug://bevy_pbr/src/render/pbr.wgsl` asset paths) in combination with an AssetWatcher for that asset source and support for "manually loading pats with asset bytes instead of AssetReaders". The old DebugAssetServer was quite nasty and I'd love to avoid that hackery going forward. * **Investigate ways to remove double-parsing meta files**: Parsing meta files currently involves parsing once with "minimal" versions of the meta file to extract the type name of the loader/processor config, then parsing again to parse the "full" meta. This is suboptimal. We should be able to define custom deserializers that (1) assume the loader/processor type name comes first (2) dynamically looks up the loader/processor registrations to deserialize settings in-line (similar to components in the bevy scene format). Another alternative: deserialize as dynamic Reflect objects and then convert. * **More runtime loading configuration**: Support using the Handle type as a hint to select an asset loader (instead of relying on AssetPath extensions) * **More high level Processor trait implementations**: For example, it might be worth adding support for arbitrary chains of "asset transforms" that modify an in-memory asset representation between loading and saving. (ex: load a Mesh, run a `subdivide_mesh` transform, followed by a `flip_normals` transform, then save the mesh to an efficient compressed format). * **Bevy Scene Handle Deserialization**: (see the relevant [Draft TODO item](#draft-todo) for context) * **Explore High Level Load Interfaces**: See [this discussion](#discuss-on_loaded-high-level-interface) for one prototype. * **Asset Streaming**: It would be great if we could stream Assets (ex: stream a long video file piece by piece) * **ID Exchanging**: In this PR Asset Handles/AssetIds are bigger than they need to be because they have a Uuid enum variant. If we implement an "id exchanging" system that trades Uuids for "efficient runtime ids", we can cut down on the size of AssetIds, making them more efficient. This has some open design questions, such as how to spawn entities with "default" handle values (as these wouldn't have access to the exchange api in the current system). * **Asset Path Fixup Tooling**: Assets that inline asset paths inside them will break when an asset moves. The asset system provides the functionality to detect when paths break. We should build a framework that enables formats to define "path migrations". This is especially important for scene files. For editor-generated files, we should also consider using UUIDs (see other bullet point) to avoid the need to migrate in these cases. --------- Co-authored-by: BeastLe9enD <beastle9end@outlook.de> Co-authored-by: Mike <mike.hsu@gmail.com> Co-authored-by: Nicola Papale <nicopap@users.noreply.github.com>
2313 lines
59 KiB
TOML
2313 lines
59 KiB
TOML
[package]
|
|
name = "bevy"
|
|
version = "0.12.0-dev"
|
|
edition = "2021"
|
|
categories = ["game-engines", "graphics", "gui", "rendering"]
|
|
description = "A refreshingly simple data-driven game engine and app framework"
|
|
exclude = ["assets/", "tools/", ".github/", "crates/", "examples/wasm/assets/"]
|
|
homepage = "https://bevyengine.org"
|
|
keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
|
|
license = "MIT OR Apache-2.0"
|
|
readme = "README.md"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
rust-version = "1.70.0"
|
|
|
|
[workspace]
|
|
exclude = [
|
|
"benches",
|
|
"crates/bevy_ecs_compile_fail_tests",
|
|
"crates/bevy_macros_compile_fail_tests",
|
|
"crates/bevy_reflect_compile_fail_tests",
|
|
]
|
|
members = [
|
|
"crates/*",
|
|
"examples/mobile",
|
|
"tools/ci",
|
|
"tools/build-templated-pages",
|
|
"tools/build-wasm-example",
|
|
"tools/example-showcase",
|
|
"errors",
|
|
]
|
|
|
|
[features]
|
|
default = [
|
|
"animation",
|
|
"bevy_asset",
|
|
"bevy_audio",
|
|
"bevy_gilrs",
|
|
"bevy_scene",
|
|
"bevy_winit",
|
|
"bevy_core_pipeline",
|
|
"bevy_pbr",
|
|
"bevy_gltf",
|
|
"bevy_render",
|
|
"bevy_sprite",
|
|
"bevy_text",
|
|
"bevy_ui",
|
|
"multi-threaded",
|
|
"png",
|
|
"hdr",
|
|
"ktx2",
|
|
"zstd",
|
|
"vorbis",
|
|
"x11",
|
|
"bevy_gizmos",
|
|
"android_shared_stdcxx",
|
|
"tonemapping_luts",
|
|
"default_font",
|
|
"webgl2",
|
|
]
|
|
|
|
# Force dynamic linking, which improves iterative compile times
|
|
dynamic_linking = ["dep:bevy_dylib", "bevy_internal/dynamic_linking"]
|
|
|
|
# Provides animation functionality
|
|
bevy_animation = ["bevy_internal/bevy_animation"]
|
|
|
|
# Provides asset functionality
|
|
bevy_asset = ["bevy_internal/bevy_asset"]
|
|
|
|
# Provides audio functionality
|
|
bevy_audio = ["bevy_internal/bevy_audio"]
|
|
|
|
# Provides cameras and other basic render pipeline features
|
|
bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline", "bevy_asset", "bevy_render"]
|
|
|
|
# Plugin for dynamic loading (using [libloading](https://crates.io/crates/libloading))
|
|
bevy_dynamic_plugin = ["bevy_internal/bevy_dynamic_plugin"]
|
|
|
|
# Adds gamepad support
|
|
bevy_gilrs = ["bevy_internal/bevy_gilrs"]
|
|
|
|
# [glTF](https://www.khronos.org/gltf/) support
|
|
bevy_gltf = ["bevy_internal/bevy_gltf", "bevy_asset", "bevy_scene", "bevy_pbr"]
|
|
|
|
# Adds PBR rendering
|
|
bevy_pbr = ["bevy_internal/bevy_pbr", "bevy_asset", "bevy_render", "bevy_core_pipeline"]
|
|
|
|
# Provides rendering functionality
|
|
bevy_render = ["bevy_internal/bevy_render"]
|
|
|
|
# Provides scene functionality
|
|
bevy_scene = ["bevy_internal/bevy_scene", "bevy_asset"]
|
|
|
|
# Provides sprite functionality
|
|
bevy_sprite = ["bevy_internal/bevy_sprite", "bevy_render", "bevy_core_pipeline"]
|
|
|
|
# Provides text functionality
|
|
bevy_text = ["bevy_internal/bevy_text", "bevy_asset", "bevy_sprite"]
|
|
|
|
# A custom ECS-driven UI framework
|
|
bevy_ui = ["bevy_internal/bevy_ui", "bevy_core_pipeline", "bevy_text", "bevy_sprite"]
|
|
|
|
# winit window and input backend
|
|
bevy_winit = ["bevy_internal/bevy_winit"]
|
|
|
|
# Adds support for rendering gizmos
|
|
bevy_gizmos = ["bevy_internal/bevy_gizmos"]
|
|
|
|
# Tracing support, saving a file in Chrome Tracing format
|
|
trace_chrome = ["trace", "bevy_internal/trace_chrome"]
|
|
|
|
# Tracing support, exposing a port for Tracy
|
|
trace_tracy = ["trace", "bevy_internal/trace_tracy"]
|
|
|
|
# Tracing support, with memory profiling, exposing a port for Tracy
|
|
trace_tracy_memory = ["trace", "bevy_internal/trace_tracy", "bevy_internal/trace_tracy_memory"]
|
|
|
|
# Tracing support
|
|
trace = ["bevy_internal/trace"]
|
|
|
|
# Save a trace of all wgpu calls
|
|
wgpu_trace = ["bevy_internal/wgpu_trace"]
|
|
|
|
# EXR image format support
|
|
exr = ["bevy_internal/exr"]
|
|
|
|
# HDR image format support
|
|
hdr = ["bevy_internal/hdr"]
|
|
|
|
# PNG image format support
|
|
png = ["bevy_internal/png"]
|
|
|
|
# TGA image format support
|
|
tga = ["bevy_internal/tga"]
|
|
|
|
# JPEG image format support
|
|
jpeg = ["bevy_internal/jpeg"]
|
|
|
|
# BMP image format support
|
|
bmp = ["bevy_internal/bmp"]
|
|
|
|
# WebP image format support
|
|
webp = ["bevy_internal/webp"]
|
|
|
|
# Basis Universal compressed texture support
|
|
basis-universal = ["bevy_internal/basis-universal"]
|
|
|
|
# DDS compressed texture support
|
|
dds = ["bevy_internal/dds"]
|
|
|
|
# KTX2 compressed texture support
|
|
ktx2 = ["bevy_internal/ktx2"]
|
|
|
|
# PNM image format support, includes pam, pbm, pgm and ppm
|
|
pnm = ["bevy_internal/pnm"]
|
|
|
|
# For KTX2 supercompression
|
|
zlib = ["bevy_internal/zlib"]
|
|
|
|
# For KTX2 supercompression
|
|
zstd = ["bevy_internal/zstd"]
|
|
|
|
# FLAC audio format support
|
|
flac = ["bevy_internal/flac"]
|
|
|
|
# MP3 audio format support
|
|
mp3 = ["bevy_internal/mp3"]
|
|
|
|
# OGG/VORBIS audio format support
|
|
vorbis = ["bevy_internal/vorbis"]
|
|
|
|
# WAV audio format support
|
|
wav = ["bevy_internal/wav"]
|
|
|
|
# MP3 audio format support (through minimp3)
|
|
minimp3 = ["bevy_internal/minimp3"]
|
|
|
|
# AAC audio format support (through symphonia)
|
|
symphonia-aac = ["bevy_internal/symphonia-aac"]
|
|
|
|
# AAC, FLAC, MP3, MP4, OGG/VORBIS, and WAV audio formats support (through symphonia)
|
|
symphonia-all = ["bevy_internal/symphonia-all"]
|
|
|
|
# FLAC audio format support (through symphonia)
|
|
symphonia-flac = ["bevy_internal/symphonia-flac"]
|
|
|
|
# MP4 audio format support (through symphonia)
|
|
symphonia-isomp4 = ["bevy_internal/symphonia-isomp4"]
|
|
|
|
# OGG/VORBIS audio format support (through symphonia)
|
|
symphonia-vorbis = ["bevy_internal/symphonia-vorbis"]
|
|
|
|
# WAV audio format support (through symphonia)
|
|
symphonia-wav = ["bevy_internal/symphonia-wav"]
|
|
|
|
# Enable serialization support through serde
|
|
serialize = ["bevy_internal/serialize"]
|
|
|
|
# Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread.
|
|
multi-threaded = ["bevy_internal/multi-threaded"]
|
|
|
|
# Wayland display server support
|
|
wayland = ["bevy_internal/wayland"]
|
|
|
|
# X11 display server support
|
|
x11 = ["bevy_internal/x11"]
|
|
|
|
# Enable rendering of font glyphs using subpixel accuracy
|
|
subpixel_glyph_atlas = ["bevy_internal/subpixel_glyph_atlas"]
|
|
|
|
# Enable systems that allow for automated testing on CI
|
|
bevy_ci_testing = ["bevy_internal/bevy_ci_testing"]
|
|
|
|
# Enable animation support, and glTF animation loading
|
|
animation = ["bevy_internal/animation", "bevy_animation"]
|
|
|
|
# Enable using a shared stdlib for cxx on Android
|
|
android_shared_stdcxx = ["bevy_internal/android_shared_stdcxx"]
|
|
|
|
# Enable detailed trace event logging. These trace events are expensive even when off, thus they require compile time opt-in
|
|
detailed_trace = ["bevy_internal/detailed_trace"]
|
|
|
|
# Include tonemapping Look Up Tables KTX2 files
|
|
tonemapping_luts = ["bevy_internal/tonemapping_luts"]
|
|
|
|
# Enable AccessKit on Unix backends (currently only works with experimental screen readers and forks.)
|
|
accesskit_unix = ["bevy_internal/accesskit_unix"]
|
|
|
|
# Enable assertions to check the validity of parameters passed to glam
|
|
glam_assert = ["bevy_internal/glam_assert"]
|
|
|
|
# Include a default font, containing only ASCII characters, at the cost of a 20kB binary size increase
|
|
default_font = ["bevy_internal/default_font"]
|
|
|
|
# Enable support for shaders in GLSL
|
|
shader_format_glsl = ["bevy_internal/shader_format_glsl"]
|
|
|
|
# Enable support for shaders in SPIR-V
|
|
shader_format_spirv = ["bevy_internal/shader_format_spirv"]
|
|
|
|
# Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm
|
|
webgl2 = ["bevy_internal/webgl"]
|
|
|
|
# Enables watching the filesystem for Bevy Asset hot-reloading
|
|
filesystem_watcher = ["bevy_internal/filesystem_watcher"]
|
|
|
|
[dependencies]
|
|
bevy_dylib = { path = "crates/bevy_dylib", version = "0.12.0-dev", default-features = false, optional = true }
|
|
bevy_internal = { path = "crates/bevy_internal", version = "0.12.0-dev", default-features = false }
|
|
|
|
[dev-dependencies]
|
|
anyhow = "1.0.4"
|
|
rand = "0.8.0"
|
|
ron = "0.8.0"
|
|
serde = { version = "1", features = ["derive"] }
|
|
bytemuck = "1.7"
|
|
# Needed to poll Task examples
|
|
futures-lite = "1.11.3"
|
|
crossbeam-channel = "0.5.0"
|
|
argh = "0.1.12"
|
|
|
|
[[example]]
|
|
name = "hello_world"
|
|
path = "examples/hello_world.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.hello_world]
|
|
hidden = true
|
|
|
|
# 2D Rendering
|
|
[[example]]
|
|
name = "bloom_2d"
|
|
path = "examples/2d/bloom_2d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.bloom_2d]
|
|
name = "2D Bloom"
|
|
description = "Illustrates bloom post-processing in 2d"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "move_sprite"
|
|
path = "examples/2d/move_sprite.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.move_sprite]
|
|
name = "Move Sprite"
|
|
description = "Changes the transform of a sprite"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "rotation"
|
|
path = "examples/2d/rotation.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.rotation]
|
|
name = "2D Rotation"
|
|
description = "Demonstrates rotating entities in 2D with quaternions"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "mesh2d"
|
|
path = "examples/2d/mesh2d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mesh2d]
|
|
name = "Mesh 2D"
|
|
description = "Renders a 2d mesh"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "mesh2d_manual"
|
|
path = "examples/2d/mesh2d_manual.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mesh2d_manual]
|
|
name = "Manual Mesh 2D"
|
|
description = "Renders a custom mesh \"manually\" with \"mid-level\" renderer apis"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "mesh2d_vertex_color_texture"
|
|
path = "examples/2d/mesh2d_vertex_color_texture.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mesh2d_vertex_color_texture]
|
|
name = "Mesh 2D With Vertex Colors"
|
|
description = "Renders a 2d mesh with vertex color attributes"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "2d_shapes"
|
|
path = "examples/2d/2d_shapes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.2d_shapes]
|
|
name = "2D Shapes"
|
|
description = "Renders a rectangle, circle, and hexagon"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "custom_gltf_vertex_attribute"
|
|
path = "examples/2d/custom_gltf_vertex_attribute.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_gltf_vertex_attribute]
|
|
name = "Custom glTF vertex attribute 2D"
|
|
description = "Renders a glTF mesh in 2D with a custom vertex attribute"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "2d_gizmos"
|
|
path = "examples/2d/2d_gizmos.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.2d_gizmos]
|
|
name = "2D Gizmos"
|
|
description = "A scene showcasing 2D gizmos"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "sprite"
|
|
path = "examples/2d/sprite.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.sprite]
|
|
name = "Sprite"
|
|
description = "Renders a sprite"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "sprite_flipping"
|
|
path = "examples/2d/sprite_flipping.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.sprite_flipping]
|
|
name = "Sprite Flipping"
|
|
description = "Renders a sprite flipped along an axis"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "sprite_sheet"
|
|
path = "examples/2d/sprite_sheet.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.sprite_sheet]
|
|
name = "Sprite Sheet"
|
|
description = "Renders an animated sprite"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "text2d"
|
|
path = "examples/2d/text2d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text2d]
|
|
name = "Text 2D"
|
|
description = "Generates text in 2D"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "texture_atlas"
|
|
path = "examples/2d/texture_atlas.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.texture_atlas]
|
|
name = "Texture Atlas"
|
|
description = "Generates a texture atlas (sprite sheet) from individual sprites"
|
|
category = "2D Rendering"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "transparency_2d"
|
|
path = "examples/2d/transparency_2d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transparency_2d]
|
|
name = "Transparency in 2D"
|
|
description = "Demonstrates transparency in 2d"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "pixel_perfect"
|
|
path = "examples/2d/pixel_perfect.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.pixel_perfect]
|
|
name = "Pixel Perfect"
|
|
description = "Demonstrates pixel perfect in 2d"
|
|
category = "2D Rendering"
|
|
wasm = true
|
|
|
|
# 3D Rendering
|
|
[[example]]
|
|
name = "3d_scene"
|
|
path = "examples/3d/3d_scene.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.3d_scene]
|
|
name = "3D Scene"
|
|
description = "Simple 3D scene with basic shapes and lighting"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "3d_shapes"
|
|
path = "examples/3d/3d_shapes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.3d_shapes]
|
|
name = "3D Shapes"
|
|
description = "A scene showcasing the built-in 3D shapes"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "generate_custom_mesh"
|
|
path = "examples/3d/generate_custom_mesh.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.generate_custom_mesh]
|
|
name = "Generate Custom Mesh"
|
|
description = "Simple showcase of how to generate a custom mesh with a custom texture"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "anti_aliasing"
|
|
path = "examples/3d/anti_aliasing.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.anti_aliasing]
|
|
name = "Anti-aliasing"
|
|
description = "Compares different anti-aliasing methods"
|
|
category = "3D Rendering"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "3d_gizmos"
|
|
path = "examples/3d/3d_gizmos.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.3d_gizmos]
|
|
name = "3D Gizmos"
|
|
description = "A scene showcasing 3D gizmos"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "atmospheric_fog"
|
|
path = "examples/3d/atmospheric_fog.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.atmospheric_fog]
|
|
name = "Atmospheric Fog"
|
|
description = "A scene showcasing the atmospheric fog effect"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "fog"
|
|
path = "examples/3d/fog.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.fog]
|
|
name = "Fog"
|
|
description = "A scene showcasing the distance fog effect"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "blend_modes"
|
|
path = "examples/3d/blend_modes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.blend_modes]
|
|
name = "Blend Modes"
|
|
description = "Showcases different blend modes"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "lighting"
|
|
path = "examples/3d/lighting.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.lighting]
|
|
name = "Lighting"
|
|
description = "Illustrates various lighting options in a simple scene"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "lines"
|
|
path = "examples/3d/lines.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.lines]
|
|
name = "Lines"
|
|
description = "Create a custom material to draw 3d lines"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "ssao"
|
|
path = "examples/3d/ssao.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.ssao]
|
|
name = "Screen Space Ambient Occlusion"
|
|
description = "A scene showcasing screen space ambient occlusion"
|
|
category = "3D Rendering"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "spotlight"
|
|
path = "examples/3d/spotlight.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.spotlight]
|
|
name = "Spotlight"
|
|
description = "Illustrates spot lights"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "bloom_3d"
|
|
path = "examples/3d/bloom_3d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.bloom_3d]
|
|
name = "3D Bloom"
|
|
description = "Illustrates bloom configuration using HDR and emissive materials"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "load_gltf"
|
|
path = "examples/3d/load_gltf.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.load_gltf]
|
|
name = "Load glTF"
|
|
description = "Loads and renders a glTF file as a scene"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "tonemapping"
|
|
path = "examples/3d/tonemapping.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.tonemapping]
|
|
name = "Tonemapping"
|
|
description = "Compares tonemapping options"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "orthographic"
|
|
path = "examples/3d/orthographic.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.orthographic]
|
|
name = "Orthographic View"
|
|
description = "Shows how to create a 3D orthographic view (for isometric-look in games or CAD applications)"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "parenting"
|
|
path = "examples/3d/parenting.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.parenting]
|
|
name = "Parenting"
|
|
description = "Demonstrates parent->child relationships and relative transformations"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "pbr"
|
|
path = "examples/3d/pbr.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.pbr]
|
|
name = "Physically Based Rendering"
|
|
description = "Demonstrates use of Physically Based Rendering (PBR) properties"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "parallax_mapping"
|
|
path = "examples/3d/parallax_mapping.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.parallax_mapping]
|
|
name = "Parallax Mapping"
|
|
description = "Demonstrates use of a normal map and depth map for parallax mapping"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "render_to_texture"
|
|
path = "examples/3d/render_to_texture.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.render_to_texture]
|
|
name = "Render to Texture"
|
|
description = "Shows how to render to a texture, useful for mirrors, UI, or exporting images"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shadow_biases"
|
|
path = "examples/3d/shadow_biases.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shadow_biases]
|
|
name = "Shadow Biases"
|
|
description = "Demonstrates how shadow biases affect shadows in a 3d scene"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shadow_caster_receiver"
|
|
path = "examples/3d/shadow_caster_receiver.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shadow_caster_receiver]
|
|
name = "Shadow Caster and Receiver"
|
|
description = "Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "skybox"
|
|
path = "examples/3d/skybox.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.skybox]
|
|
name = "Skybox"
|
|
description = "Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats."
|
|
category = "3D Rendering"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "spherical_area_lights"
|
|
path = "examples/3d/spherical_area_lights.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.spherical_area_lights]
|
|
name = "Spherical Area Lights"
|
|
description = "Demonstrates how point light radius values affect light behavior"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "split_screen"
|
|
path = "examples/3d/split_screen.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.split_screen]
|
|
name = "Split Screen"
|
|
description = "Demonstrates how to render two cameras to the same window to accomplish \"split screen\""
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "texture"
|
|
path = "examples/3d/texture.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.texture]
|
|
name = "Texture"
|
|
description = "Shows configuration of texture materials"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "transparency_3d"
|
|
path = "examples/3d/transparency_3d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transparency_3d]
|
|
name = "Transparency in 3D"
|
|
description = "Demonstrates transparency in 3d"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "two_passes"
|
|
path = "examples/3d/two_passes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.two_passes]
|
|
name = "Two Passes"
|
|
description = "Renders two 3d passes to the same window from different perspectives"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "update_gltf_scene"
|
|
path = "examples/3d/update_gltf_scene.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.update_gltf_scene]
|
|
name = "Update glTF Scene"
|
|
description = "Update a scene from a glTF file, either by spawning the scene as a child of another entity, or by accessing the entities of the scene"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "vertex_colors"
|
|
path = "examples/3d/vertex_colors.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.vertex_colors]
|
|
name = "Vertex Colors"
|
|
description = "Shows the use of vertex colors"
|
|
category = "3D Rendering"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "wireframe"
|
|
path = "examples/3d/wireframe.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.wireframe]
|
|
name = "Wireframe"
|
|
description = "Showcases wireframe rendering"
|
|
category = "3D Rendering"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "no_prepass"
|
|
path = "tests/3d/no_prepass.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.no_prepass]
|
|
hidden = true
|
|
|
|
# Animation
|
|
[[example]]
|
|
name = "animated_fox"
|
|
path = "examples/animation/animated_fox.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.animated_fox]
|
|
name = "Animated Fox"
|
|
description = "Plays an animation from a skinned glTF"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "morph_targets"
|
|
path = "examples/animation/morph_targets.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.morph_targets]
|
|
name = "Morph Targets"
|
|
description = "Plays an animation from a glTF file with meshes with morph targets"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "animated_transform"
|
|
path = "examples/animation/animated_transform.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.animated_transform]
|
|
name = "Animated Transform"
|
|
description = "Create and play an animation defined by code that operates on the `Transform` component"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "cubic_curve"
|
|
path = "examples/animation/cubic_curve.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.cubic_curve]
|
|
name = "Cubic Curve"
|
|
description = "Bezier curve example showing a cube following a cubic curve"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "custom_skinned_mesh"
|
|
path = "examples/animation/custom_skinned_mesh.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_skinned_mesh]
|
|
name = "Custom Skinned Mesh"
|
|
description = "Skinned mesh example with mesh and joints data defined in code"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "gltf_skinned_mesh"
|
|
path = "examples/animation/gltf_skinned_mesh.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.gltf_skinned_mesh]
|
|
name = "glTF Skinned Mesh"
|
|
description = "Skinned mesh example with mesh and joints data loaded from a glTF file"
|
|
category = "Animation"
|
|
wasm = true
|
|
|
|
# Application
|
|
[[example]]
|
|
name = "custom_loop"
|
|
path = "examples/app/custom_loop.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_loop]
|
|
name = "Custom Loop"
|
|
description = "Demonstrates how to create a custom runner (to update an app manually)"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "drag_and_drop"
|
|
path = "examples/app/drag_and_drop.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.drag_and_drop]
|
|
name = "Drag and Drop"
|
|
description = "An example that shows how to handle drag and drop in an app"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "empty"
|
|
path = "examples/app/empty.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.empty]
|
|
name = "Empty"
|
|
description = "An empty application (does nothing)"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "empty_defaults"
|
|
path = "examples/app/empty_defaults.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.empty_defaults]
|
|
name = "Empty with Defaults"
|
|
description = "An empty application with default plugins"
|
|
category = "Application"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "headless"
|
|
path = "examples/app/headless.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.headless]
|
|
name = "Headless"
|
|
description = "An application that runs without default plugins"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "logs"
|
|
path = "examples/app/logs.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.logs]
|
|
name = "Logs"
|
|
description = "Illustrate how to use generate log output"
|
|
category = "Application"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "plugin"
|
|
path = "examples/app/plugin.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.plugin]
|
|
name = "Plugin"
|
|
description = "Demonstrates the creation and registration of a custom plugin"
|
|
category = "Application"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "plugin_group"
|
|
path = "examples/app/plugin_group.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.plugin_group]
|
|
name = "Plugin Group"
|
|
description = "Demonstrates the creation and registration of a custom plugin group"
|
|
category = "Application"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "return_after_run"
|
|
path = "examples/app/return_after_run.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.return_after_run]
|
|
name = "Return after Run"
|
|
description = "Show how to return to main after the Bevy app has exited"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "thread_pool_resources"
|
|
path = "examples/app/thread_pool_resources.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.thread_pool_resources]
|
|
name = "Thread Pool Resources"
|
|
description = "Creates and customizes the internal thread pool"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "no_renderer"
|
|
path = "examples/app/no_renderer.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.no_renderer]
|
|
name = "No Renderer"
|
|
description = "An application that runs with default plugins and displays an empty window, but without an actual renderer"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "without_winit"
|
|
path = "examples/app/without_winit.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.without_winit]
|
|
name = "Without Winit"
|
|
description = "Create an application without winit (runs single time, no event loop)"
|
|
category = "Application"
|
|
wasm = false
|
|
|
|
# Assets
|
|
[[example]]
|
|
name = "asset_loading"
|
|
path = "examples/asset/asset_loading.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.asset_loading]
|
|
name = "Asset Loading"
|
|
description = "Demonstrates various methods to load assets"
|
|
category = "Assets"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "custom_asset"
|
|
path = "examples/asset/custom_asset.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_asset]
|
|
name = "Custom Asset"
|
|
description = "Implements a custom asset loader"
|
|
category = "Assets"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "custom_asset_reader"
|
|
path = "examples/asset/custom_asset_reader.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_asset_reader]
|
|
name = "Custom Asset IO"
|
|
description = "Implements a custom AssetReader"
|
|
category = "Assets"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "hot_asset_reloading"
|
|
path = "examples/asset/hot_asset_reloading.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.hot_asset_reloading]
|
|
name = "Hot Reloading of Assets"
|
|
description = "Demonstrates automatic reloading of assets when modified on disk"
|
|
category = "Assets"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "asset_processing"
|
|
path = "examples/asset/processing/processing.rs"
|
|
doc-scrape-examples = true
|
|
required-features = ["filesystem_watcher"]
|
|
|
|
[package.metadata.example.asset_processing]
|
|
name = "Asset Processing"
|
|
description = "Demonstrates how to process and load custom assets"
|
|
category = "Assets"
|
|
wasm = false
|
|
|
|
# Async Tasks
|
|
[[example]]
|
|
name = "async_compute"
|
|
path = "examples/async_tasks/async_compute.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.async_compute]
|
|
name = "Async Compute"
|
|
description = "How to use `AsyncComputeTaskPool` to complete longer running tasks"
|
|
category = "Async Tasks"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "external_source_external_thread"
|
|
path = "examples/async_tasks/external_source_external_thread.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.external_source_external_thread]
|
|
name = "External Source of Data on an External Thread"
|
|
description = "How to use an external thread to run an infinite task and communicate with a channel"
|
|
category = "Async Tasks"
|
|
wasm = false
|
|
|
|
# Audio
|
|
[[example]]
|
|
name = "audio"
|
|
path = "examples/audio/audio.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.audio]
|
|
name = "Audio"
|
|
description = "Shows how to load and play an audio file"
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "audio_control"
|
|
path = "examples/audio/audio_control.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.audio_control]
|
|
name = "Audio Control"
|
|
description = "Shows how to load and play an audio file, and control how it's played"
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "decodable"
|
|
path = "examples/audio/decodable.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.decodable]
|
|
name = "Decodable"
|
|
description = "Shows how to create and register a custom audio source by implementing the `Decodable` type."
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "spatial_audio_2d"
|
|
path = "examples/audio/spatial_audio_2d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.spatial_audio_2d]
|
|
name = "Spatial Audio 2D"
|
|
description = "Shows how to play spatial audio, and moving the emitter in 2D"
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "spatial_audio_3d"
|
|
path = "examples/audio/spatial_audio_3d.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.spatial_audio_3d]
|
|
name = "Spatial Audio 3D"
|
|
description = "Shows how to play spatial audio, and moving the emitter in 3D"
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "pitch"
|
|
path = "examples/audio/pitch.rs"
|
|
|
|
[package.metadata.example.pitch]
|
|
name = "Pitch"
|
|
description = "Shows how to directly play a simple pitch"
|
|
category = "Audio"
|
|
wasm = true
|
|
|
|
# Diagnostics
|
|
[[example]]
|
|
name = "log_diagnostics"
|
|
path = "examples/diagnostics/log_diagnostics.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.log_diagnostics]
|
|
name = "Log Diagnostics"
|
|
description = "Add a plugin that logs diagnostics, like frames per second (FPS), to the console"
|
|
category = "Diagnostics"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "custom_diagnostic"
|
|
path = "examples/diagnostics/custom_diagnostic.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_diagnostic]
|
|
name = "Custom Diagnostic"
|
|
description = "Shows how to create a custom diagnostic"
|
|
category = "Diagnostics"
|
|
wasm = true
|
|
|
|
# ECS (Entity Component System)
|
|
[[example]]
|
|
name = "ecs_guide"
|
|
path = "examples/ecs/ecs_guide.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.ecs_guide]
|
|
name = "ECS Guide"
|
|
description = "Full guide to Bevy's ECS"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "apply_deferred"
|
|
path = "examples/ecs/apply_deferred.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.apply_deferred]
|
|
name = "Apply System Buffers"
|
|
description = "Show how to use `apply_deferred` system"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "component_change_detection"
|
|
path = "examples/ecs/component_change_detection.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.component_change_detection]
|
|
name = "Component Change Detection"
|
|
description = "Change detection on components"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "custom_query_param"
|
|
path = "examples/ecs/custom_query_param.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_query_param]
|
|
name = "Custom Query Parameters"
|
|
description = "Groups commonly used compound queries and query filters into a single type"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "event"
|
|
path = "examples/ecs/event.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.event]
|
|
name = "Event"
|
|
description = "Illustrates event creation, activation, and reception"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "fixed_timestep"
|
|
path = "examples/ecs/fixed_timestep.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.fixed_timestep]
|
|
name = "Fixed Timestep"
|
|
description = "Shows how to create systems that run every fixed timestep, rather than every tick"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "generic_system"
|
|
path = "examples/ecs/generic_system.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.generic_system]
|
|
name = "Generic System"
|
|
description = "Shows how to create systems that can be reused with different types"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "hierarchy"
|
|
path = "examples/ecs/hierarchy.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.hierarchy]
|
|
name = "Hierarchy"
|
|
description = "Creates a hierarchy of parents and children entities"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "iter_combinations"
|
|
path = "examples/ecs/iter_combinations.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.iter_combinations]
|
|
name = "Iter Combinations"
|
|
description = "Shows how to iterate over combinations of query results"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "parallel_query"
|
|
path = "examples/ecs/parallel_query.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.parallel_query]
|
|
name = "Parallel Query"
|
|
description = "Illustrates parallel queries with `ParallelIterator`"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "removal_detection"
|
|
path = "examples/ecs/removal_detection.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.removal_detection]
|
|
name = "Removal Detection"
|
|
description = "Query for entities that had a specific component removed earlier in the current frame"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "run_conditions"
|
|
path = "examples/ecs/run_conditions.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.run_conditions]
|
|
name = "Run Conditions"
|
|
description = "Run systems only when one or multiple conditions are met"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "startup_system"
|
|
path = "examples/ecs/startup_system.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.startup_system]
|
|
name = "Startup System"
|
|
description = "Demonstrates a startup system (one that runs once when the app starts up)"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "state"
|
|
path = "examples/ecs/state.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.state]
|
|
name = "State"
|
|
description = "Illustrates how to use States to control transitioning from a Menu state to an InGame state"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "system_piping"
|
|
path = "examples/ecs/system_piping.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.system_piping]
|
|
name = "System Piping"
|
|
description = "Pipe the output of one system into a second, allowing you to handle any errors gracefully"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "system_closure"
|
|
path = "examples/ecs/system_closure.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.system_closure]
|
|
name = "System Closure"
|
|
description = "Show how to use closures as systems, and how to configure `Local` variables by capturing external state"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "system_param"
|
|
path = "examples/ecs/system_param.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.system_param]
|
|
name = "System Parameter"
|
|
description = "Illustrates creating custom system parameters with `SystemParam`"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "timers"
|
|
path = "examples/ecs/timers.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.timers]
|
|
name = "Timers"
|
|
description = "Illustrates ticking `Timer` resources inside systems and handling their state"
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
# Games
|
|
[[example]]
|
|
name = "alien_cake_addict"
|
|
path = "examples/games/alien_cake_addict.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.alien_cake_addict]
|
|
name = "Alien Cake Addict"
|
|
description = "Eat the cakes. Eat them all. An example 3D game"
|
|
category = "Games"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "breakout"
|
|
path = "examples/games/breakout.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.breakout]
|
|
name = "Breakout"
|
|
description = "An implementation of the classic game \"Breakout\""
|
|
category = "Games"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "contributors"
|
|
path = "examples/games/contributors.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.contributors]
|
|
name = "Contributors"
|
|
description = "Displays each contributor as a bouncy bevy-ball!"
|
|
category = "Games"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "game_menu"
|
|
path = "examples/games/game_menu.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.game_menu]
|
|
name = "Game Menu"
|
|
description = "A simple game menu"
|
|
category = "Games"
|
|
wasm = true
|
|
|
|
# Input
|
|
[[example]]
|
|
name = "char_input_events"
|
|
path = "examples/input/char_input_events.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.char_input_events]
|
|
name = "Char Input Events"
|
|
description = "Prints out all chars as they are inputted"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "gamepad_input"
|
|
path = "examples/input/gamepad_input.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.gamepad_input]
|
|
name = "Gamepad Input"
|
|
description = "Shows handling of gamepad input, connections, and disconnections"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "gamepad_input_events"
|
|
path = "examples/input/gamepad_input_events.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.gamepad_input_events]
|
|
name = "Gamepad Input Events"
|
|
description = "Iterates and prints gamepad input and connection events"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "gamepad_rumble"
|
|
path = "examples/input/gamepad_rumble.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.gamepad_rumble]
|
|
name = "Gamepad Rumble"
|
|
description = "Shows how to rumble a gamepad using force feedback"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "keyboard_input"
|
|
path = "examples/input/keyboard_input.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.keyboard_input]
|
|
name = "Keyboard Input"
|
|
description = "Demonstrates handling a key press/release"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "keyboard_modifiers"
|
|
path = "examples/input/keyboard_modifiers.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.keyboard_modifiers]
|
|
name = "Keyboard Modifiers"
|
|
description = "Demonstrates using key modifiers (ctrl, shift)"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "keyboard_input_events"
|
|
path = "examples/input/keyboard_input_events.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.keyboard_input_events]
|
|
name = "Keyboard Input Events"
|
|
description = "Prints out all keyboard events"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "mouse_input"
|
|
path = "examples/input/mouse_input.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mouse_input]
|
|
name = "Mouse Input"
|
|
description = "Demonstrates handling a mouse button press/release"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "mouse_input_events"
|
|
path = "examples/input/mouse_input_events.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mouse_input_events]
|
|
name = "Mouse Input Events"
|
|
description = "Prints out all mouse events (buttons, movement, etc.)"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "mouse_grab"
|
|
path = "examples/input/mouse_grab.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.mouse_grab]
|
|
name = "Mouse Grab"
|
|
description = "Demonstrates how to grab the mouse, locking the cursor to the app's screen"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "touch_input"
|
|
path = "examples/input/touch_input.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.touch_input]
|
|
name = "Touch Input"
|
|
description = "Displays touch presses, releases, and cancels"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "touch_input_events"
|
|
path = "examples/input/touch_input_events.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.touch_input_events]
|
|
name = "Touch Input Events"
|
|
description = "Prints out all touch inputs"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "text_input"
|
|
path = "examples/input/text_input.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text_input]
|
|
name = "Text Input"
|
|
description = "Simple text input with IME support"
|
|
category = "Input"
|
|
wasm = false
|
|
|
|
# Reflection
|
|
[[example]]
|
|
name = "reflection"
|
|
path = "examples/reflection/reflection.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.reflection]
|
|
name = "Reflection"
|
|
description = "Demonstrates how reflection in Bevy provides a way to dynamically interact with Rust types"
|
|
category = "Reflection"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "generic_reflection"
|
|
path = "examples/reflection/generic_reflection.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.generic_reflection]
|
|
name = "Generic Reflection"
|
|
description = "Registers concrete instances of generic types that may be used with reflection"
|
|
category = "Reflection"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "reflection_types"
|
|
path = "examples/reflection/reflection_types.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.reflection_types]
|
|
name = "Reflection Types"
|
|
description = "Illustrates the various reflection types available"
|
|
category = "Reflection"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "trait_reflection"
|
|
path = "examples/reflection/trait_reflection.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.trait_reflection]
|
|
name = "Trait Reflection"
|
|
description = "Allows reflection with trait objects"
|
|
category = "Reflection"
|
|
wasm = false
|
|
|
|
# Scene
|
|
[[example]]
|
|
name = "scene"
|
|
path = "examples/scene/scene.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.scene]
|
|
name = "Scene"
|
|
description = "Demonstrates loading from and saving scenes to files"
|
|
category = "Scene"
|
|
wasm = false
|
|
|
|
# Shaders
|
|
[[package.metadata.example_category]]
|
|
name = "Shaders"
|
|
description = """
|
|
These examples demonstrate how to implement different shaders in user code.
|
|
|
|
A shader in its most common usage is a small program that is run by the GPU per-vertex in a mesh (a vertex shader) or per-affected-screen-fragment (a fragment shader.) The GPU executes these programs in a highly parallel way.
|
|
|
|
There are also compute shaders which are used for more general processing leveraging the GPU's parallelism.
|
|
"""
|
|
|
|
[[example]]
|
|
name = "custom_vertex_attribute"
|
|
path = "examples/shader/custom_vertex_attribute.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.custom_vertex_attribute]
|
|
name = "Custom Vertex Attribute"
|
|
description = "A shader that reads a mesh's custom vertex attribute"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "post_processing"
|
|
path = "examples/shader/post_processing.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.post_processing]
|
|
name = "Post Processing - Custom Render Pass"
|
|
description = "A custom post processing effect, using a custom render pass that runs after the main pass"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shader_defs"
|
|
path = "examples/shader/shader_defs.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_defs]
|
|
name = "Shader Defs"
|
|
description = "A shader that uses \"shaders defs\" (a bevy tool to selectively toggle parts of a shader)"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shader_material"
|
|
path = "examples/shader/shader_material.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_material]
|
|
name = "Material"
|
|
description = "A shader and a material that uses it"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shader_prepass"
|
|
path = "examples/shader/shader_prepass.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_prepass]
|
|
name = "Material Prepass"
|
|
description = "A shader that uses the various textures generated by the prepass"
|
|
category = "Shaders"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "shader_material_screenspace_texture"
|
|
path = "examples/shader/shader_material_screenspace_texture.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_material_screenspace_texture]
|
|
name = "Material - Screenspace Texture"
|
|
description = "A shader that samples a texture with view-independent UV coordinates"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shader_material_glsl"
|
|
path = "examples/shader/shader_material_glsl.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_material_glsl]
|
|
name = "Material - GLSL"
|
|
description = "A shader that uses the GLSL shading language"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "shader_instancing"
|
|
path = "examples/shader/shader_instancing.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.shader_instancing]
|
|
name = "Instancing"
|
|
description = "A shader that renders a mesh multiple times in one draw call"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "animate_shader"
|
|
path = "examples/shader/animate_shader.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.animate_shader]
|
|
name = "Animated"
|
|
description = "A shader that uses dynamic data like the time since startup"
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "compute_shader_game_of_life"
|
|
path = "examples/shader/compute_shader_game_of_life.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.compute_shader_game_of_life]
|
|
name = "Compute - Game of Life"
|
|
description = "A compute shader that simulates Conway's Game of Life"
|
|
category = "Shaders"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "array_texture"
|
|
path = "examples/shader/array_texture.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.array_texture]
|
|
name = "Array Texture"
|
|
description = "A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture."
|
|
category = "Shaders"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "texture_binding_array"
|
|
path = "examples/shader/texture_binding_array.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.texture_binding_array]
|
|
name = "Texture Binding Array (Bindless Textures)"
|
|
description = "A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures)."
|
|
category = "Shaders"
|
|
wasm = false
|
|
|
|
# Stress tests
|
|
[[package.metadata.example_category]]
|
|
name = "Stress Tests"
|
|
description = """
|
|
These examples are used to test the performance and stability of various parts of the engine in an isolated way.
|
|
|
|
Due to the focus on performance it's recommended to run the stress tests in release mode:
|
|
|
|
```sh
|
|
cargo run --release --example <example name>
|
|
```
|
|
"""
|
|
|
|
[[example]]
|
|
name = "bevymark"
|
|
path = "examples/stress_tests/bevymark.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.bevymark]
|
|
name = "Bevymark"
|
|
description = "A heavy sprite rendering workload to benchmark your system with Bevy"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_animated_sprites"
|
|
path = "examples/stress_tests/many_animated_sprites.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_animated_sprites]
|
|
name = "Many Animated Sprites"
|
|
description = "Displays many animated sprites in a grid arrangement with slight offsets to their animation timers. Used for performance testing."
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_buttons"
|
|
path = "examples/stress_tests/many_buttons.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_buttons]
|
|
name = "Many Buttons"
|
|
description = "Test rendering of many UI elements"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_cubes"
|
|
path = "examples/stress_tests/many_cubes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_cubes]
|
|
name = "Many Cubes"
|
|
description = "Simple benchmark to test per-entity draw overhead. Run with the `sphere` argument to test frustum culling"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_gizmos"
|
|
path = "examples/stress_tests/many_gizmos.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_gizmos]
|
|
name = "Many Gizmos"
|
|
description = "Test rendering of many gizmos"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_foxes"
|
|
path = "examples/stress_tests/many_foxes.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_foxes]
|
|
name = "Many Foxes"
|
|
description = "Loads an animated fox model and spawns lots of them. Good for testing skinned mesh performance. Takes an unsigned integer argument for the number of foxes to spawn. Defaults to 1000"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_glyphs"
|
|
path = "examples/stress_tests/many_glyphs.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_glyphs]
|
|
name = "Many Glyphs"
|
|
description = "Simple benchmark to test text rendering."
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_lights"
|
|
path = "examples/stress_tests/many_lights.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_lights]
|
|
name = "Many Lights"
|
|
description = "Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights"
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "many_sprites"
|
|
path = "examples/stress_tests/many_sprites.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.many_sprites]
|
|
name = "Many Sprites"
|
|
description = "Displays many sprites in a grid arrangement! Used for performance testing. Use `--colored` to enable color tinted sprites."
|
|
category = "Stress Tests"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "transform_hierarchy"
|
|
path = "examples/stress_tests/transform_hierarchy.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transform_hierarchy]
|
|
name = "Transform Hierarchy"
|
|
description = "Various test cases for hierarchy and transform propagation performance"
|
|
category = "Stress Tests"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "text_pipeline"
|
|
path = "examples/stress_tests/text_pipeline.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text_pipeline]
|
|
name = "Text Pipeline"
|
|
description = "Text Pipeline benchmark"
|
|
category = "Stress Tests"
|
|
wasm = false
|
|
|
|
# Tools
|
|
[[example]]
|
|
name = "scene_viewer"
|
|
path = "examples/tools/scene_viewer/main.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.scene_viewer]
|
|
name = "Scene Viewer"
|
|
description = "A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory"
|
|
category = "Tools"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "gamepad_viewer"
|
|
path = "examples/tools/gamepad_viewer.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.gamepad_viewer]
|
|
name = "Gamepad Viewer"
|
|
description = "Shows a visualization of gamepad buttons, sticks, and triggers"
|
|
category = "Tools"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "nondeterministic_system_order"
|
|
path = "examples/ecs/nondeterministic_system_order.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.nondeterministic_system_order]
|
|
name = "Nondeterministic System Order"
|
|
description = "Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this."
|
|
category = "ECS (Entity Component System)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "3d_rotation"
|
|
path = "examples/transforms/3d_rotation.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.3d_rotation]
|
|
name = "3D Rotation"
|
|
description = "Illustrates how to (constantly) rotate an object around an axis"
|
|
category = "Transforms"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "scale"
|
|
path = "examples/transforms/scale.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.scale]
|
|
name = "Scale"
|
|
description = "Illustrates how to scale an object in each direction"
|
|
category = "Transforms"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "transform"
|
|
path = "examples/transforms/transform.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transform]
|
|
name = "Transform"
|
|
description = "Shows multiple transformations of objects"
|
|
category = "Transforms"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "translation"
|
|
path = "examples/transforms/translation.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.translation]
|
|
name = "Translation"
|
|
description = "Illustrates how to move an object along an axis"
|
|
category = "Transforms"
|
|
wasm = true
|
|
|
|
# UI (User Interface)
|
|
[[example]]
|
|
name = "borders"
|
|
path = "examples/ui/borders.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.borders]
|
|
name = "Borders"
|
|
description = "Demonstrates how to create a node with a border"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "button"
|
|
path = "examples/ui/button.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.button]
|
|
name = "Button"
|
|
description = "Illustrates creating and updating a button"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "display_and_visibility"
|
|
path = "examples/ui/display_and_visibility.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.display_and_visibility]
|
|
name = "Display and Visibility"
|
|
description = "Demonstrates how Display and Visibility work in the UI."
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "window_fallthrough"
|
|
path = "examples/ui/window_fallthrough.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.window_fallthrough]
|
|
name = "Window Fallthrough"
|
|
description = "Illustrates how to access `winit::window::Window`'s `hittest` functionality."
|
|
category = "UI (User Interface)"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "font_atlas_debug"
|
|
path = "examples/ui/font_atlas_debug.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.font_atlas_debug]
|
|
name = "Font Atlas Debug"
|
|
description = "Illustrates how FontAtlases are populated (used to optimize text rendering internally)"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "overflow"
|
|
path = "examples/ui/overflow.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.overflow]
|
|
name = "Overflow"
|
|
description = "Simple example demonstrating overflow behavior"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "overflow_debug"
|
|
path = "examples/ui/overflow_debug.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.overflow_debug]
|
|
name = "Overflow and Clipping Debug"
|
|
description = "An example to debug overflow and clipping behavior"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "relative_cursor_position"
|
|
path = "examples/ui/relative_cursor_position.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.relative_cursor_position]
|
|
name = "Relative Cursor Position"
|
|
description = "Showcases the RelativeCursorPosition component"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "size_constraints"
|
|
path = "examples/ui/size_constraints.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.size_constraints]
|
|
name = "Size Constraints"
|
|
description = "Demonstrates how the to use the size constraints to control the size of a UI node."
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "text"
|
|
path = "examples/ui/text.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text]
|
|
name = "Text"
|
|
description = "Illustrates creating and updating text"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "text_debug"
|
|
path = "examples/ui/text_debug.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text_debug]
|
|
name = "Text Debug"
|
|
description = "An example for debugging text layout"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "flex_layout"
|
|
path = "examples/ui/flex_layout.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.flex_layout]
|
|
name = "Flex Layout"
|
|
description = "Demonstrates how the AlignItems and JustifyContent properties can be composed to layout nodes and position text"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "text_wrap_debug"
|
|
path = "examples/ui/text_wrap_debug.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.text_wrap_debug]
|
|
name = "Text Wrap Debug"
|
|
description = "Demonstrates text wrapping"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "grid"
|
|
path = "examples/ui/grid.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.grid]
|
|
name = "CSS Grid"
|
|
description = "An example for CSS Grid layout"
|
|
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "transparency_ui"
|
|
path = "examples/ui/transparency_ui.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transparency_ui]
|
|
name = "Transparency UI"
|
|
description = "Demonstrates transparency for UI"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "z_index"
|
|
path = "examples/ui/z_index.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.z_index]
|
|
name = "UI Z-Index"
|
|
description = "Demonstrates how to control the relative depth (z-position) of UI elements"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "ui"
|
|
path = "examples/ui/ui.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.ui]
|
|
name = "UI"
|
|
description = "Illustrates various features of Bevy UI"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "ui_scaling"
|
|
path = "examples/ui/ui_scaling.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.ui_scaling]
|
|
name = "UI Scaling"
|
|
description = "Illustrates how to scale the UI"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "ui_texture_atlas"
|
|
path = "examples/ui/ui_texture_atlas.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.ui_texture_atlas]
|
|
name = "UI Texture Atlas"
|
|
description = "Illustrates how to use TextureAtlases in UI"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "viewport_debug"
|
|
path = "examples/ui/viewport_debug.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.viewport_debug]
|
|
name = "Viewport Debug"
|
|
description = "An example for debugging viewport coordinates"
|
|
category = "UI (User Interface)"
|
|
wasm = true
|
|
|
|
# Window
|
|
[[example]]
|
|
name = "clear_color"
|
|
path = "examples/window/clear_color.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.clear_color]
|
|
name = "Clear Color"
|
|
description = "Creates a solid color window"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "low_power"
|
|
path = "examples/window/low_power.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.low_power]
|
|
name = "Low Power"
|
|
description = "Demonstrates settings to reduce power use for bevy applications"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "multiple_windows"
|
|
path = "examples/window/multiple_windows.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.multiple_windows]
|
|
name = "Multiple Windows"
|
|
description = "Demonstrates creating multiple windows, and rendering to them"
|
|
category = "Window"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "scale_factor_override"
|
|
path = "examples/window/scale_factor_override.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.scale_factor_override]
|
|
name = "Scale Factor Override"
|
|
description = "Illustrates how to customize the default window settings"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "screenshot"
|
|
path = "examples/window/screenshot.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.screenshot]
|
|
name = "Screenshot"
|
|
description = "Shows how to save screenshots to disk"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "transparent_window"
|
|
path = "examples/window/transparent_window.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.transparent_window]
|
|
name = "Transparent Window"
|
|
description = "Illustrates making the window transparent and hiding the window decoration"
|
|
category = "Window"
|
|
wasm = false
|
|
|
|
[[example]]
|
|
name = "window_settings"
|
|
path = "examples/window/window_settings.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.window_settings]
|
|
name = "Window Settings"
|
|
description = "Demonstrates customizing default window settings"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[[example]]
|
|
name = "resizing"
|
|
path = "tests/window/resizing.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.resizing]
|
|
hidden = true
|
|
|
|
[[example]]
|
|
name = "minimising"
|
|
path = "tests/window/minimising.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.minimising]
|
|
hidden = true
|
|
|
|
[[example]]
|
|
name = "window_resizing"
|
|
path = "examples/window/window_resizing.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[[example]]
|
|
name = "fallback_image"
|
|
path = "examples/shader/fallback_image.rs"
|
|
doc-scrape-examples = true
|
|
|
|
[package.metadata.example.fallback_image]
|
|
hidden = true
|
|
|
|
[package.metadata.example.window_resizing]
|
|
name = "Window Resizing"
|
|
description = "Demonstrates resizing and responding to resizing a window"
|
|
category = "Window"
|
|
wasm = true
|
|
|
|
[profile.wasm-release]
|
|
inherits = "release"
|
|
opt-level = "z"
|
|
lto = "fat"
|
|
codegen-units = 1
|
|
|
|
[profile.stress-test]
|
|
inherits = "release"
|
|
lto = "fat"
|
|
panic = "abort"
|
|
|
|
[package.metadata.docs.rs]
|
|
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|