Resources are global singletons stored in world.resources. Unlike components (which are per-entity), each resource type exists exactly once in the world.
All resources are accessed through world.resources:
#![allow(unused)]
fn main() {
fn run_systems(&mut self, world: &mut World) {
let dt = world.resources.window.timing.delta_time;
if world.resources.input.keyboard.is_key_pressed(KeyCode::Space) {
self.jump();
}
world.resources.graphics.bloom_enabled = true;
}
}
Resource Type Description
windowWindowWindow handle, timing, and display info
secondary_windowsSecondaryWindowsMulti-window state
window.timingWindowTimingFrame timing: delta_time, frames_per_second, uptime_milliseconds
Resource Type Description
inputInputKeyboard, mouse, and gamepad state
input.keyboardKeyboardKey states, is_key_pressed(), just_pressed()
input.mouseMousePosition, delta, button state, scroll
Resource Type Description
graphicsGraphicsAll rendering settings
graphics.atmosphereAtmosphereSky type (None, Color, Sky)
graphics.bloom_enabledboolBloom toggle
graphics.ssao_enabledboolSSAO toggle
graphics.color_gradingColorGradingTonemapping, gamma, saturation, brightness, contrast
Resource Type Description
mesh_cacheMeshCacheLoaded mesh data by name
material_registryMaterialRegistryRegistered materials
texture_cacheTextureCacheGPU textures
animation_cacheAnimationCacheAnimation clip data
prefab_cachePrefabCacheLoaded prefab templates
text_cacheTextCacheFont atlas and glyph data
Resource Type Description
active_cameraOption<Entity>Currently rendering camera
children_cacheHashMap<Entity, Vec<Entity>>Parent-to-children mapping
entity_namesHashMap<String, Entity>Name-to-entity lookup
transform_dirty_entitiesVec<Entity>Entities needing transform propagation
Resource Type Feature
physicsPhysicsWorldphysics
audioAudioEngineaudio
navmeshNavMeshWorldalways
Resource Type Description
event_busEventBusMessage passing between systems
command_queueVec<WorldCommand>Deferred GPU/scene operations
frame_scheduleFrameScheduleOrdered list of engine systems dispatched each frame
Resource Type Feature
xrXrResourcesopenxr
steamSteamResourcessteam
script_runtimeScriptRuntimescripting
sdf_worldSdfWorldsdf_sculpt
Some resources are only available when their feature flag is enabled:
#![allow(unused)]
fn main() {
#[cfg(feature = "physics")]
{
world.resources.physics.gravity = Vec3::new(0.0, -9.81, 0.0);
}
#[cfg(feature = "audio")]
{
world.resources.audio.master_volume = 0.8;
}
}
Operations that require GPU access or must be deferred are queued as commands:
#![allow(unused)]
fn main() {
world.queue_command(WorldCommand::LoadTexture {
name: "my_texture".to_string(),
rgba_data: texture_bytes,
width: 256,
height: 256,
});
world.queue_command(WorldCommand::DespawnRecursive { entity });
world.queue_command(WorldCommand::LoadHdrSkybox { hdr_data });
world.queue_command(WorldCommand::CaptureScreenshot { path: None });
}
Commands are processed during the render phase when GPU access is available.