bevy/examples/3d
Nicola Papale f7f7e326e5
Add methods to directly load assets from World (#12023)
# Objective

`FromWorld` is often used to group loading and creation of assets for
resources.

With this setup, users often end up repetitively calling
`.resource::<AssetServer>` and `.resource_mut::<Assets<T>>`, and may
have difficulties handling lifetimes of the returned references.

## Solution

Add extension methods to `World` to add and load assets, through a new
extension trait defined in `bevy_asset`.

### Other considerations

* This might be a bit too "magic", as it makes implicit the resource
access.
* We could also implement `DirectAssetAccessExt` on `App`, but it didn't
feel necessary, as `FromWorld` is the principal use-case here.

---

## Changelog

* Add the `DirectAssetAccessExt` trait, which adds the `add_asset`,
`load_asset` and `load_asset_with_settings` method to the `World` type.
2024-02-27 00:28:26 +00:00
..
3d_scene.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
3d_shapes.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
3d_viewport_to_world.rs Add Direction3dA and move direction types out of primitives (#12018) 2024-02-26 13:57:49 +00:00
animated_material.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
anti_aliasing.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
atmospheric_fog.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
blend_modes.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
bloom_3d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
deferred_rendering.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
deterministic.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
fog.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
generate_custom_mesh.rs New Exposure and Lighting Defaults (and calibrate examples) (#11868) 2024-02-15 20:42:48 +00:00
irradiance_volumes.rs Add methods to directly load assets from World (#12023) 2024-02-27 00:28:26 +00:00
lighting.rs Increase 3D Lighting example's light intensity (#11982) 2024-02-25 19:18:56 +00:00
lightmaps.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
lines.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
load_gltf.rs New Exposure and Lighting Defaults (and calibrate examples) (#11868) 2024-02-15 20:42:48 +00:00
orthographic.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
parallax_mapping.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
parenting.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
pbr.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
reflection_probes.rs Add methods to directly load assets from World (#12023) 2024-02-27 00:28:26 +00:00
render_to_texture.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
shadow_biases.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
shadow_caster_receiver.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
skybox.rs Improve lighting in more examples (#12021) 2024-02-26 17:32:23 +00:00
spherical_area_lights.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
split_screen.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
spotlight.rs Improve lighting in more examples (#12021) 2024-02-26 17:32:23 +00:00
ssao.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
texture.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
tonemapping.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
transmission.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
transparency_3d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
two_passes.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
update_gltf_scene.rs New Exposure and Lighting Defaults (and calibrate examples) (#11868) 2024-02-15 20:42:48 +00:00
vertex_colors.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
wireframe.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00