Bevy Version: | 0.11 | (outdated!) |
---|
As this page is outdated, please refer to Bevy's official migration guides while reading, to cover the differences: 0.11 to 0.12, 0.12 to 0.13, 0.13 to 0.14. 0.14 to 0.15.
I apologize for the inconvenience. I will update the page as soon as I find the time.
List of Bevy Builtins
This page is a quick condensed listing of all the important things provided by Bevy.
- SystemParams
- Assets
- File Formats
- GLTF Asset Labels
- Shader Imports
wgpu
Backends- Schedules
- Run Conditions
- Plugins
- Bundles
- Resources (Configuration)
- Resources (Engine User)
- Resources (Input)
- Events (Input)
- Events (Engine)
- Events (System/Control)
- Components
SystemParams
These are all the special types that can be used as system parameters.
In regular systems:
Commands
: Manipulate the ECS using commandsQuery<T, F = ()>
(can contain tuples of up to 15 types): Access to entities and componentsRes<T>
: Shared access to a resourceResMut<T>
: Exclusive (mutable) access to a resourceOption<Res<T>>
: Shared access to a resource that may not existOption<ResMut<T>>
: Exclusive (mutable) access to a resource that may not existLocal<T>
: Data local to the systemEventReader<T>
: Receive eventsEventWriter<T>
: Send events&World
: Read-only direct access to the ECS WorldParamSet<...>
(with up to 8 params): Resolve conflicts between incompatible system parametersDeferred<T>
: Custom "deferred mutation", similar toCommands
, but for your own thingsRemovedComponents<T>
: Removal detectionGizmos
: A way to draw lines and shapes on the screen for debugging and dev purposesDiagnostics
: A way to report measurements/debug data to Bevy for tracking and visualizationSystemName
: The name (string) of the system, may be useful for debuggingParallelCommands
: Abstraction to help useCommands
when you will do your own parallelismWorldId
: The World ID of the world the system is running onComponentIdFor<T>
: Get theComponentId
of a given component typeEntities
: Low-level ECS metadata: All entitiesComponents
: Low-level ECS metadata: All componentsBundles
: Low-level ECS metadata: All bundlesArchetypes
: Low-level ECS metadata: All archetypesSystemChangeTick
: Low-level ECS metadata: Tick used for change detectionNonSend<T>
: Shared access to Non-Send
(main thread only) dataNonSendMut<T>
: Exclusive access to Non-Send
(main thread only) dataOption<NonSend<T>>
: Shared access to Non-Send
(main thread only) data that may not existOption<NonSendMut<T>>
: Exclusive access to Non-Send
(main thread only) data that may not existStaticSystemParam
: Helper for generic system abstractions, to avoid lifetime annotations- tuples containing any of these types, with up to 16 members
- [
&mut World
]: Full direct access to the ECS World - [
Local<T>
]: Data local to the system - [
&mut SystemState<P>
][SystemState
]: Emulates a regular system, allowing you to easily access data from the World.P
are the system parameters. - [
&mut QueryState<Q, F = ()>
][QueryState
]: Allows you to perform queries on the World, similar to a [Query
] in regular systems.
Your function can have a maximum of 16 total parameters. If you need more, group them into tuples to work around the limit. Tuples can contain up to 16 members, but can be nested indefinitely.
Systems running during the Extract schedule can also use
Extract<T>
, to access data from the Main World instead of the
Render World. T
can be any read-only system parameter type.
Assets
(more info about working with assets)
These are the Asset types registered by Bevy by default.
Image
: Pixel data, used as a texture for 2D and 3D rendering; also contains theSamplerDescriptor
for texture filtering settingsTextureAtlas
: 2D "Sprite Sheet" defining sub-images within a single larger imageMesh
: 3D Mesh (geometry data), contains vertex attributes (like position, UVs, normals)Shader
: GPU shader code, in one of the supported languages (WGSL/SPIR-V/GLSL)ColorMaterial
: Basic "2D material": contains color, optionally an imageStandardMaterial
: "3D material" with support for Physically-Based RenderingAnimationClip
: Data for a single animation sequence, can be used withAnimationPlayer
Font
: Font data used for text renderingScene
: Scene composed of literal ECS entities to instantiateDynamicScene
: Scene composed with dynamic typing and reflectionGltf
: GLTF Master Asset: index of the entire contents of a GLTF fileGltfNode
: Logical GLTF object in a sceneGltfMesh
: Logical GLTF 3D model, consisting of multipleGltfPrimitive
sGltfPrimitive
: Single unit to be rendered, contains the Mesh and Material to useAudioSource
: Audio data forbevy_audio
FontAtlasSet
: (internal use for text rendering)SkinnedMeshInverseBindposes
: (internal use for skeletal animation)
File Formats
These are the asset file formats (asset loaders) supported by Bevy. Support for each one can be enabled/disabled using cargo features. Some are enabled by default, many are not.
Image formats (loaded as Image
assets):
Format | Cargo feature | Default? | Filename extensions |
---|---|---|---|
PNG | "png" | Yes | .png |
HDR | "hdr" | Yes | .hdr |
KTX2 | "ktx2" | Yes | .ktx2 |
KTX2+zstd | "ktx2", "zstd" | Yes | .ktx2 |
JPEG | "jpeg" | No | .jpg , .jpeg |
WebP | "webp" | No | .webp |
OpenEXR | "exr" | No | .exr |
TGA | "tga" | No | .tga |
PNM | "pnm" | No | .pam , .pbm , .pgm , .ppm |
BMP | "bmp" | No | .bmp |
DDS | "dds" | No | .dds |
KTX2+zlib | "ktx2", "zlib" | No | .ktx2 |
Basis | "basis-universal" | No | .basis |
Audio formats (loaded as AudioSource
assets):
Format | Cargo feature | Default? | Filename extensions |
---|---|---|---|
OGG Vorbis | "vorbis" | Yes | .ogg , .oga , .spx |
FLAC | "flac" | No | .flac |
WAV | "wav" | No | .wav |
MP3 | "mp3" | No | .mp3 |
3D asset (model or scene) formats:
Format | Cargo feature | Default? | Filename extensions |
---|---|---|---|
GLTF | "bevy_gltf" | Yes | .gltf , .glb |
Shader formats (loaded as Shader
assets):
Format | Cargo feature | Default? | Filename extensions |
---|---|---|---|
WGSL | n/a | Yes | .wgsl |
GLSL | "shader_format_glsl" | No | .vert , .frag , .comp |
SPIR-V | "shader_format_spirv" | No | .spv |
Font formats (loaded as Font
assets):
Format | Cargo feature | Default? | Filename extensions |
---|---|---|---|
TrueType | n/a | Yes | .ttf |
OpenType | n/a | Yes | .otf |
Bevy Scenes:
Format | Filename extensions |
---|---|
RON-serialized scene | .scn ,.scn.ron |
There are unofficial plugins available for adding support for even more file formats.
GLTF Asset Labels
Asset path labels to refer to GLTF sub-assets.
The following asset labels are supported ({}
is the numerical index):
Scene{}
: GLTF Scene as BevyScene
Node{}
: GLTF Node asGltfNode
Mesh{}
: GLTF Mesh asGltfMesh
Mesh{}/Primitive{}
: GLTF Primitive as BevyMesh
Mesh{}/Primitive{}/MorphTargets
: Morph target animation data for a GLTF PrimitiveTexture{}
: GLTF Texture as BevyImage
Material{}
: GLTF Material as BevyStandardMaterial
DefaultMaterial
: as above, if the GLTF file contains a default material with no indexAnimation{}
: GLTF Animation as BevyAnimationClip
Skin{}
: GLTF mesh skin as BevySkinnedMeshInverseBindposes
Shader Imports
TODO
wgpu
Backends
wgpu
(and hence Bevy) supports the following backends:
Platform | Backends (in order of priority) |
---|---|
Linux | Vulkan, GLES3 |
Windows | DirectX 12, Vulkan, GLES3 |
macOS | Metal |
iOS | Metal |
Android | Vulkan, GLES3 |
Web | WebGPU, WebGL2 |
On GLES3 and WebGL2, some renderer features are unsupported and performance is worse.
WebGPU is experimental and few browsers support it.
Schedules
Internally, Bevy has these built-in schedules:
Main
: runs every frame update cycle, to perform general app logicExtractSchedule
: runs afterMain
, to copy data from the Main World into the Render WorldRender
: runs afterExtractSchedule
, to perform all rendering/graphics, in parallel with the nextMain
run
The Main
schedule simply runs a sequence of other schedules:
On the first run (first frame update of the app):
On every run (controlled via the MainScheduleOrder
resource):
First
: any initialization that must be done at the start of every framePreUpdate
: for engine-internal systems intended to run before user logicStateTransition
: perform any pending state transitionsRunFixedUpdateLoop
: runs theFixedUpdate
schedule as many times as neededUpdate
: for all user logic (your systems) that should run every framePostUpdate
: for engine-internal systems intended to run after user logicLast
: any final cleanup that must be done at the end of every frame
FixedUpdate
is for all user logic (your systems) that should run at a fixed timestep.
StateTransition
runs the
OnEnter(...)
/OnTransition(...)
/OnExit(...)
schedules for your states, when you want to change state.
The Render
schedule is organized using sets (RenderSet
):
ExtractCommands
: apply deferred buffers from systems that ran inExtractSchedule
Prepare
/PrepareFlush
: set up data on the GPU (buffers, textures, etc.)Queue
/QueueFlush
: generate the render jobs to be run (usually phase items)PhaseSort
/PhaseSortFlush
: sort and batch phase items for efficient renderingRender
/RenderFlush
: execute the render graph to actually trigger the GPU to do workCleanup
/CleanupFlush
: clear any data from the render World that should not persist to the next frame
The *Flush
variants are just to apply any deferred buffers after every step, if needed.
Run Conditions
TODO
Plugins
TODO
Bundles
Bevy's built-in bundle types, for spawning different common kinds of entities.
Any tuples of up to 15 Component
types are valid bundles.
General:
SpatialBundle
: Contains the required transform and visibility components that must be included on all entities that need rendering or hierarchyTransformBundle
: Contains only the transform types, subset ofSpatialBundle
VisibilityBundle
: Contains only the visibility types, subset ofSpatialBundle
Scenes:
SceneBundle
: Used for spawning scenesDynamicSceneBundle
: Used for spawning dynamic scenes
Audio:
AudioBundle
: Play [audio][cb::audio] from anAudioSource
assetSpatialAudioBundle
: Play positional audio from anAudioSource
assetAudioSourceBundle
: Play audio from a custom data source/streamSpatialAudioSourceBundle
: Play positional audio from a custom data source/stream
Bevy 3D:
Camera3dBundle
: 3D camera, can use perspective (default) or orthographic projectionTemporalAntiAliasBundle
: Add this to a 3D camera to enable TAAScreenSpaceAmbientOcclusionBundle
: Add this to a 3D camera to enable SSAOMaterialMeshBundle
: 3D Object/Primitive: a Mesh and a custom Material to draw it withPbrBundle
:MaterialMeshBundle
with the default Physically-Based Material (StandardMaterial
)DirectionalLightBundle
: 3D directional light (like the sun)PointLightBundle
: 3D point light (like a lamp or candle)SpotLightBundle
: 3D spot light (like a projector or flashlight)
Bevy 2D:
Camera2dBundle
: 2D camera, uses orthographic projection + other special configuration for 2DSpriteBundle
: 2D sprite (Image
asset type)SpriteSheetBundle
: 2D sprite (TextureAtlas
asset type)MaterialMesh2dBundle
: 2D shape, with custom Mesh and Material (similar to 3D objects)Text2dBundle
: Text to be drawn in the 2D world (not the UI)
Bevy UI:
NodeBundle
: Empty node element (like HTML<div>
)ButtonBundle
: Button elementImageBundle
: Image element (Image
asset type)AtlasImageBundle
: Image element (TextureAtlas
asset type)TextBundle
: Text element
Resources
(more info about working with resources)
Configuration Resources
These resources allow you to change the settings for how various parts of Bevy work.
These may be inserted at the start, but should also be fine to change at runtime (from a system):
ClearColor
: Global renderer background color to clear the window at the start of each frameGlobalVolume
: The overall volume for playing audioAmbientLight
: Global renderer "fake lighting", so that shadows don't look too dark / blackMsaa
: Global renderer setting for Multi-Sample Anti-Aliasing (some platforms might only support the values 1 and 4)UiScale
: Global scale value to make all UIs bigger/smallerGizmoConfig
: Controls how gizmos are renderedWireframeConfig
: Global toggle to make everything be rendered as wireframeGamepadSettings
: Gamepad input device settings, like joystick deadzones and button sensitivitiesWinitSettings
: Settings for the OS Windowing backend, including update loop / power-management settingsTimeUpdateStrategy
: Used to control how theTime
is updatedSchedules
: Stores all schedules, letting you register additional functionality at runtimeMainScheduleOrder
: The sequence of schedules that will run every frame update
Settings that are not modifiable at runtime are not represented using resources. Instead, they are configured via the respective plugins.
Engine Resources
These resources provide access to different features of the game engine at runtime.
Access them from your systems, if you need their state, or to control the respective parts of Bevy. These resources are in the Main World. See here for the resources in the Render World.
Time
: Global time-related information (current frame delta time, time since startup, etc.)FixedTime
: Tracks remaining time until the next fixed updateAssetServer
: Control the asset system: Load assets, check load status, etc.Assets<T>
: Contains the actual data of the loaded assets of a given typeState<T>
: The current value of a states typeNextState<T>
: Used to queue a transition to another stateGamepads
: Tracks the IDs for all currently-detected (connected) gamepad devicesSceneSpawner
: Direct control over spawning Scenes into the main app WorldFrameCount
: The total number of framesScreenshotManager
: Used to request a screenshot of a window to be taken/savedAppTypeRegistry
: Access to the Reflection Type RegistryAsyncComputeTaskPool
: Task pool for running background CPU tasksComputeTaskPool
: Task pool where the main app schedule (all the systems) runsIoTaskPool
: Task pool where background i/o tasks run (like asset loading)WinitWindows
(non-send): Raw state of thewinit
backend for each windowNonSendMarker
: Dummy resource to ensure a system always runs on the main thread
Render World Resources
These resources are present in the Render World. They can be accessed from rendering systems (that run during render stages).
MainWorld
: (extract schedule only!) access data from the Main WorldRenderGraph
: The Bevy Render GraphPipelineCache
: Bevy's manager of render pipelines. Used to store render pipelines used by the app, to avoid recreating them more than once.TextureCache
: Bevy's manager of temporary textures. Useful when you need textures to use internally during rendering.DrawFunctions<P>
: Stores draw functions for a given phase item typeRenderAssets<T>
: Contains handles to the GPU representations of currently loaded asset dataDefaultImageSampler
: The default sampler forImage
asset texturesFallbackImage
: Dummy 1x1 pixel white texture. Useful for shaders that normally need a texture, when you don't have one available.
There are many other resources in the Render World, which are not mentioned here, either because they are internal to Bevy's rendering algorithms, or because they are just extracted copies of the equivalent resources in the Main World.
Low-Level wgpu
Resources
Using these resources, you can have direct access to the wgpu
APIs for controlling the GPU.
These are available in both the Main World and the Render World.
RenderDevice
: The GPU device, used for creating hardware resources for rendering/compute- [
RenderQueue
][bevy::RenderQueue]: The GPU queue for submitting work to the hardware RenderAdapter
: Handle to the physical GPU hardwareRenderAdapterInfo
: Information about the GPU hardware that Bevy is running on
Input Handling Resources
These resources represent the current state of different input devices. Read them from your systems to handle user input.
Input<KeyCode>
: Keyboard key state, as a binary Input valueInput<MouseButton>
: Mouse button state, as a binary Input valueInput<GamepadButton>
: Gamepad buttons, as a binary Input valueAxis<GamepadAxis>
: Analog Axis gamepad inputs (joysticks and triggers)Axis<GamepadButton>
: Gamepad buttons, represented as an analog Axis valueTouches
: The state of all fingers currently touching the touchscreenGamepads
: Registry of all the connectedGamepad
IDs
Events
(more info about working with events)
Input Events
These events fire on activity with input devices. Read them to [handle user input][cb::input].
MouseButtonInput
: Changes in the state of mouse buttonsMouseWheel
: Scrolling by a number of pixels or lines (MouseScrollUnit
)MouseMotion
: Relative movement of the mouse (pixels from previous frame), regardless of the OS pointer/cursorCursorMoved
: New position of the OS mouse pointer/cursorKeyboardInput
: Changes in the state of keyboard keys (keypresses, not text)ReceivedCharacter
: Unicode text input from the OS (correct handling of the user's language and layout)Ime
: Unicode text input from IME (support for advanced text input in different scripts)TouchInput
: Change in the state of a finger touching the touchscreenGamepadEvent
: Changes in the state of a gamepad or any of its buttons or axesGamepadRumbleRequest
: Send these events to control gamepad rumbleTouchpadMagnify
: Pinch-to-zoom gesture on laptop touchpad (macOS)TouchpadRotate
: Two-finger rotate gesture on laptop touchpad (macOS)
Engine Events
Events related to various internal things happening during the normal runtime of a Bevy app.
AssetEvent<T>
: Sent by Bevy when asset data has been added/modified/removed; can be used to detect changes to assetsHierarchyEvent
: Sent by Bevy when entity parents/children changeAppExit
: Tell Bevy to shut down
System and Control Events
Events from the OS / windowing system, or to control Bevy.
RequestRedraw
: In an app that does not refresh continuously, request one more update before going to sleepFileDragAndDrop
: The user drag-and-dropped a file into our appCursorEntered
: OS mouse pointer/cursor entered one of our windowsCursorLeft
: OS mouse pointer/cursor exited one of our windowsWindowCloseRequested
: OS wants to close one of our windowsWindowCreated
: New application window openedWindowClosed
: Bevy window closedWindowDestroyed
: OS window freed/dropped after window closeWindowFocused
: One of our windows is now focusedWindowMoved
: OS/user moved one of our windowsWindowResized
: OS/user resized one of our windowsWindowScaleFactorChanged
: One of our windows has changed its DPI scaling factorWindowBackendScaleFactorChanged
: OS reports change in DPI scaling factor for a window
Components
The complete list of individual component types is too specific to be useful to list here.
See: (List in API Docs)