bevy/examples/3d
Aceeri ddfafab971 Windows as Entities (#5589)
# Objective

Fix https://github.com/bevyengine/bevy/issues/4530

- Make it easier to open/close/modify windows by setting them up as `Entity`s with a `Window` component.
- Make multiple windows very simple to set up. (just add a `Window` component to an entity and it should open)

## Solution

- Move all properties of window descriptor to ~components~ a component.
- Replace `WindowId` with `Entity`.
- ~Use change detection for components to update backend rather than events/commands. (The `CursorMoved`/`WindowResized`/... events are kept for user convenience.~
  Check each field individually to see what we need to update, events are still kept for user convenience.

---

## Changelog

- `WindowDescriptor` renamed to `Window`.
    - Width/height consolidated into a `WindowResolution` component.
    - Requesting maximization/minimization is done on the [`Window::state`] field.
- `WindowId` is now `Entity`.

## Migration Guide

- Replace `WindowDescriptor` with `Window`.
    - Change `width` and `height` fields in a `WindowResolution`, either by doing
      ```rust
      WindowResolution::new(width, height) // Explicitly
      // or using From<_> for tuples for convenience
      (1920., 1080.).into()
      ```
- Replace any `WindowCommand` code to just modify the `Window`'s fields directly  and creating/closing windows is now by spawning/despawning an entity with a `Window` component like so:
  ```rust
  let window = commands.spawn(Window { ... }).id(); // open window
  commands.entity(window).despawn(); // close window
  ```

## Unresolved
- ~How do we tell when a window is minimized by a user?~
  ~Currently using the `Resize(0, 0)` as an indicator of minimization.~
  No longer attempting to tell given how finnicky this was across platforms, now the user can only request that a window be maximized/minimized.
  
 ## Future work
 - Move `exit_on_close` functionality out from windowing and into app(?)
 - https://github.com/bevyengine/bevy/issues/5621
 - https://github.com/bevyengine/bevy/issues/7099
 - https://github.com/bevyengine/bevy/issues/7098


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2023-01-19 00:38:28 +00:00
..
3d_scene.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
3d_shapes.rs Add cylinder shape (#6809) 2022-12-11 18:22:05 +00:00
bloom.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
fxaa.rs Add FXAA postprocessing (#6393) 2022-11-02 06:51:28 +00:00
lighting.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
lines.rs Allow passing glam vector types as vertex attributes (#6442) 2022-11-04 03:45:17 +00:00
load_gltf.rs Add global time scaling (#5752) 2022-10-22 18:52:29 +00:00
msaa.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
orthographic.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
parenting.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
pbr.rs Add a more familiar hex color entry (#7060) 2023-01-04 23:40:42 +00:00
render_to_texture.rs Rename camera "priority" to "order" (#6908) 2022-12-25 00:39:30 +00:00
shadow_biases.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
shadow_caster_receiver.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
skybox.rs Make AsBindGroup unsized (#6937) 2022-12-16 01:40:15 +00:00
spherical_area_lights.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
split_screen.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
spotlight.rs Add global time scaling (#5752) 2022-10-22 18:52:29 +00:00
texture.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
transparency_3d.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
two_passes.rs Rename camera "priority" to "order" (#6908) 2022-12-25 00:39:30 +00:00
update_gltf_scene.rs Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors (#6185) 2022-10-31 15:57:50 +00:00
vertex_colors.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
wireframe.rs Move 'startup' Resource WgpuSettings into the RenderPlugin (#6946) 2022-12-20 16:17:11 +00:00