bevy/examples/3d
Roman Salnikov eb9db21113
Camera-driven UI (#10559)
# Objective

Add support for presenting each UI tree on a specific window and
viewport, while making as few breaking changes as possible.

This PR is meant to resolve the following issues at once, since they're
all related.

- Fixes #5622 
- Fixes #5570 
- Fixes #5621 

Adopted #5892 , but started over since the current codebase diverged
significantly from the original PR branch. Also, I made a decision to
propagate component to children instead of recursively iterating over
nodes in search for the root.


## Solution

Add a new optional component that can be inserted to UI root nodes and
propagate to children to specify which camera it should render onto.
This is then used to get the render target and the viewport for that UI
tree. Since this component is optional, the default behavior should be
to render onto the single camera (if only one exist) and warn of
ambiguity if multiple cameras exist. This reduces the complexity for
users with just one camera, while giving control in contexts where it
matters.

## Changelog

- Adds `TargetCamera(Entity)` component to specify which camera should a
node tree be rendered into. If only one camera exists, this component is
optional.
- Adds an example of rendering UI to a texture and using it as a
material in a 3D world.
- Fixes recalculation of physical viewport size when target scale factor
changes. This can happen when the window is moved between displays with
different DPI.
- Changes examples to demonstrate assigning UI to different viewports
and windows and make interactions in an offset viewport testable.
- Removes `UiCameraConfig`. UI visibility now can be controlled via
combination of explicit `TargetCamera` and `Visibility` on the root
nodes.

---------

Co-authored-by: davier <bricedavier@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
2024-01-16 00:39:10 +00:00
..
3d_gizmos.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_scene.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_shapes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_viewport_to_world.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
anti_aliasing.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
atmospheric_fog.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
blend_modes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
bloom_3d.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
deferred_rendering.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
deterministic.rs Option to enable deterministic rendering (#11248) 2024-01-09 00:46:01 +00:00
fog.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
generate_custom_mesh.rs Fixed typo in generate_custom_mesh.rs example (#11293) 2024-01-11 11:29:31 +00:00
lighting.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
lightmaps.rs Implement lightmaps. (#10231) 2024-01-02 20:38:47 +00:00
lines.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
load_gltf.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
orthographic.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
parallax_mapping.rs Update glam, encase and hexasphere (#11082) 2024-01-08 22:58:45 +00:00
parenting.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
pbr.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
render_to_texture.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
shadow_biases.rs Extract examples CameraController into a module (#11338) 2024-01-14 13:50:33 +00:00
shadow_caster_receiver.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
skybox.rs Extract examples CameraController into a module (#11338) 2024-01-14 13:50:33 +00:00
spherical_area_lights.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
split_screen.rs Camera-driven UI (#10559) 2024-01-16 00:39:10 +00:00
spotlight.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
ssao.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
texture.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
tonemapping.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
transmission.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
transparency_3d.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
two_passes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
update_gltf_scene.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
vertex_colors.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
wireframe.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00