bevy/examples
Mariusz Kryński a3012d94bb
WASM asset loading (#559)
wasm assets
2020-09-25 15:26:23 -07:00
..
2d Fix set_scale and set_rotation in new Transform api (#500) 2020-09-16 00:19:14 -07:00
3d transform: add "setter" builder functions, make naming clearer, and fix examples (#516) 2020-09-19 13:35:48 -07:00
app asset: use bevy_tasks in AssetServer (#550) 2020-09-21 20:23:09 -07:00
asset Transform Rewrite (#374) 2020-09-14 14:00:32 -07:00
audio add more example comments 2020-07-28 13:45:36 -07:00
diagnostics add more example comments 2020-07-28 13:45:36 -07:00
ecs Fix set_scale and set_rotation in new Transform api (#500) 2020-09-16 00:19:14 -07:00
game simplify transform usage where possible (#494) 2020-09-14 18:20:20 -07:00
input Added gamepad support using Gilrs (#280) 2020-09-18 14:43:47 -07:00
scene ecs: use generational entity ids and other optimizations (#504) 2020-09-17 17:16:38 -07:00
shader update async-executor (#484) 2020-09-14 14:01:41 -07:00
ui fix font atlas overflow (#495) 2020-09-15 18:06:10 -07:00
wasm WASM asset loading (#559) 2020-09-25 15:26:23 -07:00
window Transform Rewrite (#374) 2020-09-14 14:00:32 -07:00
hello_world.rs cargo fmt 2020-07-26 21:10:18 +02:00
README.md Create winit canvas under WebAssembly (#506) 2020-09-18 20:11:26 -07:00

Examples

These examples demonstrate the main features of Bevy and how to use them. To run an example, use the command cargo run --example <Example>, and add the option --features x11 or --features wayland to force the example to run on a specific window compositor, e.g.

cargo run --features wayland --example hello_world

Hello, World!

Example Main Description
hello_world hello_world.rs Runs a minimal example that outputs "hello world"

2D Rendering

Example Main Description
sprite 2d/sprite.rs Renders a sprite
sprite_sheet 2d/sprite_sheet.rs Renders an animated sprite
texture_atlas 2d/texture_atlas.rs Generates a texture atlas (sprite sheet) from individual sprites

3D Rendering

Example File Description
load_model 3d/load_model.rs Loads and renders a simple model
msaa 3d/msaa.rs Configures MSAA (Multi-Sample Anti-Aliasing) for smoother edges
parenting 3d/parenting.rs Demonstrates parent->child relationships and relative transformations
3d_scene 3d/3d_scene.rs Simple 3D scene with basic shapes and lighting
spawner 3d/spawner.rs Renders a large number of cubes with changing position and material
texture 3d/texture.rs Shows configuration of texture materials
z_sort_debug 3d/z_sort_debug.rs Visualizes camera Z-ordering

Application

Example File Description
empty app/empty.rs An empty application (does nothing)
empty_defaults app/empty_defaults.rs An empty application with default plugins
headless app/headless.rs An application that runs without default plugins
plugin app/plugin.rs Demonstrates the creation and registration of a custom plugin
thread_pool_resources app/thread_pool_resources.rs Creates and customizes the internal thread pool

Assets

Example File Description
asset_loading asset/asset_loading.rs Demonstrates various methods to load assets
hot_asset_reloading asset/hot_asset_reloading.rs Demonstrates automatic reloading of assets when modified on disk

Audio

Example File Description
audio audio/audio.rs Shows how to load and play an audio file

Diagnostics

Example File Description
custom_diagnostic diagnostics/custom_diagnostic.rs Shows how to create a custom diagnostic
print_diagnostics diagnostics/print_diagnostics.rs Add a plugin that prints diagnostics to the console

ECS (Entity Component System)

Example File Description
event ecs/event.rs Illustrates event creation, activation, and reception
ecs_guide ecs/ecs_guide.rs Full guide to Bevy's ECS
parallel_query ecs/parallel_query.rs Illustrates parallel queries with ParallelIterator
startup_system ecs/startup_system.rs Demonstrates a startup system (one that runs once when the app starts up)

Games

Example File Description
breakout game/breakout.rs An implementation of the classic game "Breakout"

Input

Example File Description
mouse_input input/mouse_input.rs Demonstrates handling a mouse button press/release
mouse_input_events input/mouse_input_events.rs Prints out all mouse events (buttons, movement, etc.)
keyboard_input input/keyboard_input.rs Demonstrates handling a key press/release
keyboard_input_events input/keyboard_input_events.rs Prints out all keyboard events

Scene

Example File Description
scene scene/scene.rs Demonstrates loading from and saving scenes to files
properties scene/properties.rs Demonstrates Properties (similar to reflections in other languages) in Bevy

Shaders

Example File Description
shader_custom_material shader/shader_custom_material.rs Illustrates creating a custom material and a shader that uses it
shader_defs shader/shader_defs.rs Demonstrates creating a custom material that uses "shaders defs" (a tool to selectively toggle parts of a shader)

UI (User Interface)

Example File Description
button ui/button.rs Illustrates creating and updating a button
text ui/text.rs Illustrates creating and updating text
font_atlas_debug ui/font_atlas_debug.rs Illustrates how FontAtlases are populated (used to optimize text rendering internally)
ui ui/ui.rs Illustrates various features of Bevy UI

Window

Example File Description
clear_color window/clear_color.rs Creates a solid color window
multiple_windows window/multiple_windows.rs Creates two windows and cameras viewing the same mesh
window_settings window/window_settings.rs Demonstrates customizing default window settings

WASM

pre-req

$ rustup target add wasm32-unknown-unknown
$ cargo install wasm-bindgen-cli

build & run

Following is an example for headless_wasm. For other examples in wasm/ directory, change the headless_wasm in the following commands and edit examples/wasm/index.html to point to the correct .js file.

$ cargo build --example headless_wasm --target wasm32-unknown-unknown --no-default-features
$ wasm-bindgen --out-dir examples/wasm/target --target web target/wasm32-unknown-unknown/debug/examples/headless_wasm.wasm

Then serve examples/wasm dir to browser. i.e.

$ basic-http-server examples/wasm