diff --git a/Cargo.toml b/Cargo.toml index 1775b2dd7b7d1..bd4efd833718d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -346,7 +346,7 @@ android_shared_stdcxx = ["bevy_internal/android_shared_stdcxx"] # Enable detailed trace event logging. These trace events are expensive even when off, thus they require compile time opt-in detailed_trace = ["bevy_internal/detailed_trace"] -# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`. +# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method for your `Camera2d` or `Camera3d`. tonemapping_luts = ["bevy_internal/tonemapping_luts", "ktx2", "zstd"] # Include SMAA Look Up Tables KTX2 Files diff --git a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs index 03ddf5c073915..5e3ef674d3bdf 100644 --- a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs +++ b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] + use crate::{ core_2d::graph::Core2d, tonemapping::{DebandDither, Tonemapping}, @@ -17,12 +19,25 @@ use bevy_render::{ }; use bevy_transform::prelude::{GlobalTransform, Transform}; +/// A 2D camera component. Enables the 2D render graph for a [`Camera`]. #[derive(Component, Default, Reflect, Clone, ExtractComponent)] #[extract_component_filter(With)] #[reflect(Component, Default)] +#[require( + Camera, + DebandDither, + CameraRenderGraph(|| CameraRenderGraph::new(Core2d)), + OrthographicProjection(OrthographicProjection::default_2d), + Frustum(|| OrthographicProjection::default_2d().compute_frustum(&GlobalTransform::from(Transform::default()))), + Tonemapping(|| Tonemapping::None), +)] pub struct Camera2d; #[derive(Bundle, Clone)] +#[deprecated( + since = "0.15.0", + note = "Use the `Camera2d` component instead. Inserting it will now also insert the other components required by it automatically." +)] pub struct Camera2dBundle { pub camera: Camera, pub camera_render_graph: CameraRenderGraph, diff --git a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs index 454892a30684c..81955f76b361e 100644 --- a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs +++ b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] + use crate::{ core_3d::graph::Core3d, tonemapping::{DebandDither, Tonemapping}, @@ -15,12 +17,22 @@ use bevy_render::{ use bevy_transform::prelude::{GlobalTransform, Transform}; use serde::{Deserialize, Serialize}; -/// Configuration for the "main 3d render graph". -/// The camera coordinate space is right-handed x-right, y-up, z-back. +/// A 3D camera component. Enables the main 3D render graph for a [`Camera`]. +/// +/// The camera coordinate space is right-handed X-right, Y-up, Z-back. /// This means "forward" is -Z. #[derive(Component, Reflect, Clone, ExtractComponent)] #[extract_component_filter(With)] #[reflect(Component, Default)] +#[require( + Camera, + DebandDither(|| DebandDither::Enabled), + CameraRenderGraph(|| CameraRenderGraph::new(Core3d)), + Projection, + Tonemapping, + ColorGrading, + Exposure +)] pub struct Camera3d { /// The depth clear operation to perform for the main 3d pass. pub depth_load_op: Camera3dDepthLoadOp, @@ -139,6 +151,10 @@ pub enum ScreenSpaceTransmissionQuality { /// The camera coordinate space is right-handed x-right, y-up, z-back. /// This means "forward" is -Z. #[derive(Bundle, Clone)] +#[deprecated( + since = "0.15.0", + note = "Use the `Camera3d` component instead. Inserting it will now also insert the other components required by it automatically." +)] pub struct Camera3dBundle { pub camera: Camera, pub camera_render_graph: CameraRenderGraph, diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index 0ce36763d6e66..ac91fca61dfcb 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -45,6 +45,7 @@ pub mod experimental { /// The core pipeline prelude. /// /// This includes the most common types in this crate, re-exported for your convenience. +#[expect(deprecated)] pub mod prelude { #[doc(hidden)] pub use crate::{ diff --git a/crates/bevy_core_pipeline/src/motion_blur/mod.rs b/crates/bevy_core_pipeline/src/motion_blur/mod.rs index c5a4a9f212e5a..2195e296f5590 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/mod.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/mod.rs @@ -59,11 +59,11 @@ pub struct MotionBlurBundle { /// camera. /// /// ``` -/// # use bevy_core_pipeline::{core_3d::Camera3dBundle, motion_blur::MotionBlur}; +/// # use bevy_core_pipeline::{core_3d::Camera3d, motion_blur::MotionBlur}; /// # use bevy_ecs::prelude::*; /// # fn test(mut commands: Commands) { /// commands.spawn(( -/// Camera3dBundle::default(), +/// Camera3d::default(), /// MotionBlur::default(), /// )); /// # } diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 7614b50153a40..972fd7836a3d7 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -263,7 +263,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline { error!( "AgX tonemapping requires the `tonemapping_luts` feature. Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended), - or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`." + or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`." ); shader_defs.push("TONEMAP_METHOD_AGX".into()); } @@ -275,7 +275,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline { error!( "TonyMcMapFace tonemapping requires the `tonemapping_luts` feature. Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended), - or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`." + or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`." ); shader_defs.push("TONEMAP_METHOD_TONY_MC_MAPFACE".into()); } @@ -284,7 +284,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline { error!( "BlenderFilmic tonemapping requires the `tonemapping_luts` feature. Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended), - or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`." + or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`." ); shader_defs.push("TONEMAP_METHOD_BLENDER_FILMIC".into()); } diff --git a/crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs b/crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs index d84143943c973..550cd1c29dde8 100644 --- a/crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs +++ b/crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs @@ -4,7 +4,7 @@ use core::any::{Any, TypeId}; use bevy_app::{App, Plugin, PostUpdate}; use bevy_color::Hsla; use bevy_core::Name; -use bevy_core_pipeline::core_2d::Camera2dBundle; +use bevy_core_pipeline::core_2d::Camera2d; use bevy_ecs::{prelude::*, system::SystemParam}; use bevy_gizmos::{config::GizmoConfigStore, prelude::Gizmos, AppGizmoBuilder}; use bevy_hierarchy::{Children, Parent}; @@ -88,17 +88,15 @@ fn update_debug_camera( } else { let spawn_cam = || { cmds.spawn(( - Camera2dBundle { - projection: OrthographicProjection { - far: 1000.0, - viewport_origin: Vec2::new(0.0, 0.0), - ..OrthographicProjection::default_3d() - }, - camera: Camera { - order: LAYOUT_DEBUG_CAMERA_ORDER, - clear_color: ClearColorConfig::None, - ..default() - }, + Camera2d, + OrthographicProjection { + far: 1000.0, + viewport_origin: Vec2::new(0.0, 0.0), + ..OrthographicProjection::default_3d() + }, + Camera { + order: LAYOUT_DEBUG_CAMERA_ORDER, + clear_color: ClearColorConfig::None, ..default() }, LAYOUT_DEBUG_LAYERS.clone(), diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index 56e11e854e13e..5075642da6d82 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -55,9 +55,6 @@ use core::{any::TypeId, ptr::NonNull}; /// would create incoherent behavior. /// This would be unexpected if bundles were treated as an abstraction boundary, as /// the abstraction would be unmaintainable for these cases. -/// For example, both `Camera3dBundle` and `Camera2dBundle` contain the `CameraRenderGraph` -/// component, but specifying different render graphs to use. -/// If the bundles were both added to the same entity, only one of these two bundles would work. /// /// For this reason, there is intentionally no [`Query`] to match whether an entity /// contains the components of a bundle. diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 9bb72e2356729..046c0550a5aae 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -9,7 +9,7 @@ use bevy_asset::{ }; use bevy_color::{Color, LinearRgba}; use bevy_core::Name; -use bevy_core_pipeline::prelude::Camera3dBundle; +use bevy_core_pipeline::prelude::Camera3d; use bevy_ecs::{ entity::{Entity, EntityHashMap}, world::World, @@ -1413,15 +1413,15 @@ fn load_node( Projection::Perspective(perspective_projection) } }; - node.insert(Camera3dBundle { + node.insert(( + Camera3d::default(), projection, transform, - camera: Camera { + Camera { is_active: !*active_camera_found, ..Default::default() }, - ..Default::default() - }); + )); *active_camera_found = true; } diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index c2ff30bb56411..198d218334dc2 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -29,10 +29,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// # fn system(mut commands: Commands) { /// commands.spawn(( /// // Setup your camera as usual -/// Camera3dBundle { -/// // ... camera options -/// # ..Default::default() -/// }, +/// Camera3d::default(), /// // Add fog to the same entity /// DistanceFog { /// color: Color::WHITE, diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 702a3aea4b7c5..b34dcb4717f65 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -8,27 +8,29 @@ use crate::{ render_resource::TextureView, texture::GpuImage, view::{ - ColorGrading, ExtractedView, ExtractedWindows, GpuCulling, RenderLayers, VisibleEntities, + ColorGrading, ExtractedView, ExtractedWindows, GpuCulling, Msaa, RenderLayers, Visibility, + VisibleEntities, }, - world_sync::RenderEntity, + world_sync::{RenderEntity, SyncToRenderWorld}, Extract, }; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ change_detection::DetectChanges, - component::Component, + component::{Component, ComponentId}, entity::Entity, event::EventReader, prelude::With, query::Has, reflect::ReflectComponent, system::{Commands, Query, Res, ResMut, Resource}, + world::DeferredWorld, }; use bevy_math::{ops, vec2, Dir3, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3}; use bevy_reflect::prelude::*; use bevy_render_macros::ExtractComponent; -use bevy_transform::components::GlobalTransform; +use bevy_transform::components::{GlobalTransform, Transform}; use bevy_utils::{tracing::warn, warn_once, HashMap, HashSet}; use bevy_window::{ NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized, @@ -274,10 +276,25 @@ pub enum ViewportConversionError { /// to transform the 3D objects into a 2D image, as well as the render target into which that image /// is produced. /// -/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the -/// `Camera3dBundle`. +/// Note that a [`Camera`] needs a [`CameraRenderGraph`] to render anything. +/// This is typically provided by adding a [`Camera2d`] or [`Camera3d`] component, +/// but custom render graphs can also be defined. Inserting a [`Camera`] with no render +/// graph will emit an error at runtime. +/// +/// [`Camera2d`]: https://docs.rs/crate/bevy_core_pipeline/latest/core_2d/struct.Camera2d.html +/// [`Camera3d`]: https://docs.rs/crate/bevy_core_pipeline/latest/core_3d/struct.Camera3d.html #[derive(Component, Debug, Reflect, Clone)] #[reflect(Component, Default, Debug)] +#[component(on_add = warn_on_no_render_graph)] +#[require( + Frustum, + CameraMainTextureUsages, + VisibleEntities, + Transform, + Visibility, + Msaa, + SyncToRenderWorld +)] pub struct Camera { /// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`]. pub viewport: Option, @@ -309,6 +326,12 @@ pub struct Camera { pub sub_camera_view: Option, } +fn warn_on_no_render_graph(world: DeferredWorld, entity: Entity, _: ComponentId) { + if !world.entity(entity).contains::() { + warn!("Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph."); + } +} + impl Default for Camera { fn default() -> Self { Self { diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index 66925005ef956..70a06ae635840 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -200,8 +200,7 @@ impl HalfSpace { /// This process is called frustum culling, and entities can opt out of it using /// the [`NoFrustumCulling`] component. /// -/// The frustum component is typically added from a bundle, either the `Camera2dBundle` -/// or the `Camera3dBundle`. +/// The frustum component is typically added automatically for cameras, either `Camera2d` or `Camera3d`. /// It is usually updated automatically by [`update_frusta`] from the /// [`CameraProjection`] component and [`GlobalTransform`] of the camera entity. /// diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 0e0fa98468ac5..646e28a748e12 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -27,7 +27,7 @@ use bevy_transform::prelude::{GlobalTransform, Transform}; use bevy_utils::HashSet; use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; -/// The bundle of components needed to draw text in a 2D scene via a 2D `Camera2dBundle`. +/// The bundle of components needed to draw text in a 2D scene via a `Camera2d`. /// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/2d/text2d.rs) #[derive(Bundle, Clone, Debug, Default)] pub struct Text2dBundle { diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 1965b24096d89..3e418c689d55a 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -464,7 +464,7 @@ mod tests { use taffy::TraversePartialTree; use bevy_asset::{AssetEvent, Assets}; - use bevy_core_pipeline::core_2d::Camera2dBundle; + use bevy_core_pipeline::core_2d::Camera2d; use bevy_ecs::{ entity::Entity, event::Events, @@ -539,7 +539,7 @@ mod tests { }, PrimaryWindow, )); - world.spawn(Camera2dBundle::default()); + world.spawn(Camera2d); let mut ui_schedule = Schedule::default(); ui_schedule.add_systems( @@ -646,7 +646,7 @@ mod tests { assert!(ui_surface.camera_entity_to_taffy.is_empty()); // respawn camera - let camera_entity = world.spawn(Camera2dBundle::default()).id(); + let camera_entity = world.spawn(Camera2d).id(); let ui_entity = world .spawn((NodeBundle::default(), TargetCamera(camera_entity))) @@ -970,13 +970,13 @@ mod tests { let (mut world, mut ui_schedule) = setup_ui_test_world(); - world.spawn(Camera2dBundle { - camera: Camera { + world.spawn(( + Camera2d, + Camera { order: 1, ..default() }, - ..default() - }); + )); world.spawn(( NodeBundle { diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index dac55d0dd4826..5812f6a40debc 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2437,7 +2437,7 @@ impl TargetCamera { /// # use bevy_ui::prelude::*; /// # use bevy_ecs::prelude::Commands; /// # use bevy_render::camera::{Camera, RenderTarget}; -/// # use bevy_core_pipeline::prelude::Camera2dBundle; +/// # use bevy_core_pipeline::prelude::Camera2d; /// # use bevy_window::{Window, WindowRef}; /// /// fn spawn_camera(mut commands: Commands) { @@ -2446,11 +2446,9 @@ impl TargetCamera { /// ..Default::default() /// }).id(); /// commands.spawn(( -/// Camera2dBundle { -/// camera: Camera { -/// target: RenderTarget::Window(WindowRef::Entity(another_window)), -/// ..Default::default() -/// }, +/// Camera2d, +/// Camera { +/// target: RenderTarget::Window(WindowRef::Entity(another_window)), /// ..Default::default() /// }, /// // We add the Marker here so all Ui will spawn in @@ -2502,7 +2500,7 @@ impl<'w, 's> DefaultUiCamera<'w, 's> { /// /// fn spawn_camera(mut commands: Commands) { /// commands.spawn(( -/// Camera2dBundle::default(), +/// Camera2d, /// // This will cause all Ui in this camera to be rendered without /// // anti-aliasing /// UiAntiAlias::Off, diff --git a/docs/cargo_features.md b/docs/cargo_features.md index bd29c14c43b27..4b5f6f04264cf 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -41,7 +41,7 @@ The default feature set enables most of the expected features of a game engine, |png|PNG image format support| |smaa_luts|Include SMAA Look Up Tables KTX2 Files| |sysinfo_plugin|Enables system information diagnostic plugin| -|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.| +|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method for your `Camera2d` or `Camera3d`.| |vorbis|OGG/VORBIS audio format support| |webgl2|Enable some limitations to be able to use WebGL2. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.| |x11|X11 display server support| diff --git a/errors/B0004.md b/errors/B0004.md index 4a658c7aa0184..9344d47b633ad 100644 --- a/errors/B0004.md +++ b/errors/B0004.md @@ -40,10 +40,10 @@ fn setup_cube( }); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } fn main() { @@ -83,10 +83,10 @@ fn setup_cube( }); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } fn main() { diff --git a/examples/2d/2d_shapes.rs b/examples/2d/2d_shapes.rs index 2d59bbf56ccd8..56683fe2cc8fb 100644 --- a/examples/2d/2d_shapes.rs +++ b/examples/2d/2d_shapes.rs @@ -27,7 +27,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); let shapes = [ meshes.add(Circle::new(50.0)), diff --git a/examples/2d/2d_viewport_to_world.rs b/examples/2d/2d_viewport_to_world.rs index 3913a5c5e9367..193fc281290a1 100644 --- a/examples/2d/2d_viewport_to_world.rs +++ b/examples/2d/2d_viewport_to_world.rs @@ -34,5 +34,5 @@ fn draw_cursor( } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); } diff --git a/examples/2d/bloom_2d.rs b/examples/2d/bloom_2d.rs index dcffdcafcc10a..fcd5534632f68 100644 --- a/examples/2d/bloom_2d.rs +++ b/examples/2d/bloom_2d.rs @@ -23,15 +23,13 @@ fn setup( asset_server: Res, ) { commands.spawn(( - Camera2dBundle { - camera: Camera { - hdr: true, // 1. HDR is required for bloom - ..default() - }, - tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended + Camera2d, + Camera { + hdr: true, // 1. HDR is required for bloom ..default() }, - Bloom::default(), // 3. Enable bloom for the camera + Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended + Bloom::default(), // 3. Enable bloom for the camera )); // Sprite diff --git a/examples/2d/bounding_2d.rs b/examples/2d/bounding_2d.rs index 1690a4827a2f5..0a44c6ae686fb 100644 --- a/examples/2d/bounding_2d.rs +++ b/examples/2d/bounding_2d.rs @@ -206,7 +206,7 @@ const OFFSET_X: f32 = 125.; const OFFSET_Y: f32 = 75.; fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(( SpatialBundle { transform: Transform::from_xyz(-OFFSET_X, OFFSET_Y, 0.), diff --git a/examples/2d/custom_gltf_vertex_attribute.rs b/examples/2d/custom_gltf_vertex_attribute.rs index 80323cb6ab4e1..6cb10bdb267e9 100644 --- a/examples/2d/custom_gltf_vertex_attribute.rs +++ b/examples/2d/custom_gltf_vertex_attribute.rs @@ -60,7 +60,7 @@ fn setup( )); // Add a camera - commands.spawn(Camera2dBundle { ..default() }); + commands.spawn(Camera2d); } /// This custom material uses barycentric coordinates from diff --git a/examples/2d/mesh2d.rs b/examples/2d/mesh2d.rs index 2857a4d722d57..fbc507e2ef4a0 100644 --- a/examples/2d/mesh2d.rs +++ b/examples/2d/mesh2d.rs @@ -14,7 +14,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(( Mesh2d(meshes.add(Rectangle::default())), MeshMaterial2d(materials.add(Color::from(PURPLE))), diff --git a/examples/2d/mesh2d_alpha_mode.rs b/examples/2d/mesh2d_alpha_mode.rs index ce552fd7115b4..5d6d2fbb5e5cc 100644 --- a/examples/2d/mesh2d_alpha_mode.rs +++ b/examples/2d/mesh2d_alpha_mode.rs @@ -20,7 +20,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); let texture_handle = asset_server.load("branding/icon.png"); let mesh_handle = meshes.add(Rectangle::from_size(Vec2::splat(256.0))); diff --git a/examples/2d/mesh2d_arcs.rs b/examples/2d/mesh2d_arcs.rs index 577c8398fffb3..975cc2cf8bbf0 100644 --- a/examples/2d/mesh2d_arcs.rs +++ b/examples/2d/mesh2d_arcs.rs @@ -39,13 +39,13 @@ fn setup( ) { let material = materials.add(asset_server.load("branding/icon.png")); - commands.spawn(Camera2dBundle { - camera: Camera { + commands.spawn(( + Camera2d, + Camera { clear_color: ClearColorConfig::Custom(DARK_SLATE_GREY.into()), ..default() }, - ..default() - }); + )); const UPPER_Y: f32 = 50.0; const LOWER_Y: f32 = -50.0; diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 0daf83d357d83..e3b471610b8b1 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -115,7 +115,7 @@ fn star( )); // Spawn the camera - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); } // Require `HasMaterial2d` to indicate that no placeholder material should be rendeed. diff --git a/examples/2d/mesh2d_vertex_color_texture.rs b/examples/2d/mesh2d_vertex_color_texture.rs index 9fa00db852f80..24a242075e59f 100644 --- a/examples/2d/mesh2d_vertex_color_texture.rs +++ b/examples/2d/mesh2d_vertex_color_texture.rs @@ -33,7 +33,7 @@ fn setup( let mesh_handle = meshes.add(mesh); // Spawn camera - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // Spawn the quad with vertex colors commands.spawn(( diff --git a/examples/2d/move_sprite.rs b/examples/2d/move_sprite.rs index 6f0efa53cbe76..9bbbe496584c5 100644 --- a/examples/2d/move_sprite.rs +++ b/examples/2d/move_sprite.rs @@ -17,7 +17,7 @@ enum Direction { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(( SpriteBundle { texture: asset_server.load("branding/icon.png"), diff --git a/examples/2d/pixel_grid_snap.rs b/examples/2d/pixel_grid_snap.rs index 5cac633a3cdcb..7e2fcffb5c5b0 100644 --- a/examples/2d/pixel_grid_snap.rs +++ b/examples/2d/pixel_grid_snap.rs @@ -119,16 +119,14 @@ fn setup_camera(mut commands: Commands, mut images: ResMut>) { // this camera renders whatever is on `PIXEL_PERFECT_LAYERS` to the canvas commands.spawn(( - Camera2dBundle { - camera: Camera { - // render before the "main pass" camera - order: -1, - target: RenderTarget::Image(image_handle.clone()), - ..default() - }, - msaa: Msaa::Off, + Camera2d, + Camera { + // render before the "main pass" camera + order: -1, + target: RenderTarget::Image(image_handle.clone()), ..default() }, + Msaa::Off, InGameCamera, PIXEL_PERFECT_LAYERS, )); @@ -145,14 +143,7 @@ fn setup_camera(mut commands: Commands, mut images: ResMut>) { // the "outer" camera renders whatever is on `HIGH_RES_LAYERS` to the screen. // here, the canvas and one of the sample sprites will be rendered by this camera - commands.spawn(( - Camera2dBundle { - msaa: Msaa::Off, - ..default() - }, - OuterCamera, - HIGH_RES_LAYERS, - )); + commands.spawn((Camera2d, Msaa::Off, OuterCamera, HIGH_RES_LAYERS)); } /// Rotates entities to demonstrate grid snapping. diff --git a/examples/2d/rotation.rs b/examples/2d/rotation.rs index 43227ed5027be..85a8542a98306 100644 --- a/examples/2d/rotation.rs +++ b/examples/2d/rotation.rs @@ -55,7 +55,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let enemy_b_handle = asset_server.load("textures/simplespace/enemy_B.png"); // 2D orthographic camera - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); let horizontal_margin = BOUNDS.x / 4.0; let vertical_margin = BOUNDS.y / 4.0; diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index 5fdf172a5be19..1866f2d4fbf19 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -10,7 +10,7 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(SpriteBundle { texture: asset_server.load("branding/bevy_bird_dark.png"), ..default() diff --git a/examples/2d/sprite_animation.rs b/examples/2d/sprite_animation.rs index 74d3a2bf43e8f..57d9870750d20 100644 --- a/examples/2d/sprite_animation.rs +++ b/examples/2d/sprite_animation.rs @@ -90,7 +90,7 @@ fn setup( asset_server: Res, mut texture_atlas_layouts: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // load the sprite sheet using the `AssetServer` let texture = asset_server.load("textures/rpg/chars/gabe/gabe-idle-run.png"); diff --git a/examples/2d/sprite_flipping.rs b/examples/2d/sprite_flipping.rs index 33ac914995a99..60bdfa8add974 100644 --- a/examples/2d/sprite_flipping.rs +++ b/examples/2d/sprite_flipping.rs @@ -10,7 +10,7 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(SpriteBundle { texture: asset_server.load("branding/bevy_bird_dark.png"), sprite: Sprite { diff --git a/examples/2d/sprite_sheet.rs b/examples/2d/sprite_sheet.rs index c1c55914b78f3..42a7cd4dc7419 100644 --- a/examples/2d/sprite_sheet.rs +++ b/examples/2d/sprite_sheet.rs @@ -46,7 +46,7 @@ fn setup( let texture_atlas_layout = texture_atlas_layouts.add(layout); // Use only the subset of sprites in the sheet that make up the run animation let animation_indices = AnimationIndices { first: 1, last: 6 }; - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.spawn(( SpriteBundle { transform: Transform::from_scale(Vec3::splat(6.0)), diff --git a/examples/2d/sprite_slice.rs b/examples/2d/sprite_slice.rs index 7afb0c975c4d6..7da31b4667876 100644 --- a/examples/2d/sprite_slice.rs +++ b/examples/2d/sprite_slice.rs @@ -98,7 +98,7 @@ fn spawn_sprites( } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); let font = asset_server.load("fonts/FiraSans-Bold.ttf"); let style = TextStyle { font: font.clone(), diff --git a/examples/2d/sprite_tile.rs b/examples/2d/sprite_tile.rs index c9b0fe5ecb811..57fecefe40c7d 100644 --- a/examples/2d/sprite_tile.rs +++ b/examples/2d/sprite_tile.rs @@ -19,7 +19,7 @@ struct AnimationState { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands.insert_resource(AnimationState { min: 128.0, max: 512.0, diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index bda91e19bb266..8bee817e0c574 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -42,7 +42,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }; let text_justification = JustifyText::Center; // 2d camera - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // Demonstrate changing translation commands.spawn(( Text2dBundle { diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index d910f0ae9d230..81ce1942f7614 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -94,7 +94,7 @@ fn setup( let atlas_nearest_padded_handle = texture_atlases.add(texture_atlas_nearest_padded); // setup 2d scene - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // padded textures are to the right, unpadded to the left diff --git a/examples/2d/transparency_2d.rs b/examples/2d/transparency_2d.rs index 069b73098e688..fbcc535ec38e3 100644 --- a/examples/2d/transparency_2d.rs +++ b/examples/2d/transparency_2d.rs @@ -11,7 +11,7 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); let sprite_handle = asset_server.load("branding/icon.png"); diff --git a/examples/2d/wireframe_2d.rs b/examples/2d/wireframe_2d.rs index b53b20ea1e6db..7b75de4ca1910 100644 --- a/examples/2d/wireframe_2d.rs +++ b/examples/2d/wireframe_2d.rs @@ -85,7 +85,7 @@ fn setup( )); // Camera - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // Text used to show controls commands.spawn( diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 437a8ff1ed0b0..5ea7e20b29662 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -36,8 +36,8 @@ fn setup( Transform::from_xyz(4.0, 8.0, 4.0), )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/3d_shapes.rs b/examples/3d/3d_shapes.rs index eae6d81aed95c..e9c2c8a7c0f0e 100644 --- a/examples/3d/3d_shapes.rs +++ b/examples/3d/3d_shapes.rs @@ -127,10 +127,10 @@ fn setup( MeshMaterial3d(materials.add(Color::from(SILVER))), )); - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 7., 14.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 7., 14.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), + )); #[cfg(not(target_arch = "wasm32"))] commands.spawn( diff --git a/examples/3d/3d_viewport_to_world.rs b/examples/3d/3d_viewport_to_world.rs index db11844e7e90d..8b4d4abe3ce14 100644 --- a/examples/3d/3d_viewport_to_world.rs +++ b/examples/3d/3d_viewport_to_world.rs @@ -69,8 +69,8 @@ fn setup( )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(15.0, 5.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(15.0, 5.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/animated_material.rs b/examples/3d/animated_material.rs index 53bb7163f745a..53b9f7253aed8 100644 --- a/examples/3d/animated_material.rs +++ b/examples/3d/animated_material.rs @@ -17,11 +17,8 @@ fn setup( mut materials: ResMut>, ) { commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(3.0, 1.0, 3.0) - .looking_at(Vec3::new(0.0, -0.5, 0.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(3.0, 1.0, 3.0).looking_at(Vec3::new(0.0, -0.5, 0.0), Vec3::Y), EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/anisotropy.rs b/examples/3d/anisotropy.rs index c7b92e0eec801..ba36c8294e763 100644 --- a/examples/3d/anisotropy.rs +++ b/examples/3d/anisotropy.rs @@ -64,11 +64,10 @@ fn main() { /// Creates the initial scene. fn setup(mut commands: Commands, asset_server: Res, app_status: Res) { - commands.spawn(Camera3dBundle { - transform: Transform::from_translation(CAMERA_INITIAL_POSITION) - .looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_translation(CAMERA_INITIAL_POSITION).looking_at(Vec3::ZERO, Vec3::Y), + )); spawn_directional_light(&mut commands); diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index 2e6fca92885a2..68872297e0659 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -301,15 +301,12 @@ fn setup( // Camera commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), + Camera3d::default(), + Camera { + hdr: true, ..default() }, + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), ContrastAdaptiveSharpening { enabled: false, ..default() diff --git a/examples/3d/atmospheric_fog.rs b/examples/3d/atmospheric_fog.rs index 43f2ce4fc81c4..d1bc5ba912a9e 100644 --- a/examples/3d/atmospheric_fog.rs +++ b/examples/3d/atmospheric_fog.rs @@ -25,11 +25,8 @@ fn main() { fn setup_camera_fog(mut commands: Commands) { commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(-1.0, 0.1, 1.0) - .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(-1.0, 0.1, 1.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), DistanceFog { color: Color::srgba(0.35, 0.48, 0.66, 1.0), directional_light_color: Color::srgba(1.0, 0.95, 0.85, 0.5), diff --git a/examples/3d/auto_exposure.rs b/examples/3d/auto_exposure.rs index 7b3a30df1dc98..2c5803815b0b7 100644 --- a/examples/3d/auto_exposure.rs +++ b/examples/3d/auto_exposure.rs @@ -39,14 +39,12 @@ fn setup( let metering_mask = asset_server.load("textures/basic_metering_mask.png"); commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(1.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), + Camera3d::default(), + Camera { + hdr: true, ..default() }, + Transform::from_xyz(1.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), AutoExposure { metering_mask: metering_mask.clone(), ..default() diff --git a/examples/3d/blend_modes.rs b/examples/3d/blend_modes.rs index cbf06c879fc11..b2b4e046ecc1d 100644 --- a/examples/3d/blend_modes.rs +++ b/examples/3d/blend_modes.rs @@ -152,10 +152,10 @@ fn setup( commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0))); // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 2.5, 10.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 2.5, 10.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // Controls Text diff --git a/examples/3d/bloom_3d.rs b/examples/3d/bloom_3d.rs index c237245e90c38..51207183a821f 100644 --- a/examples/3d/bloom_3d.rs +++ b/examples/3d/bloom_3d.rs @@ -28,15 +28,13 @@ fn setup_scene( mut materials: ResMut>, ) { commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, // 1. HDR is required for bloom - ..default() - }, - tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + Camera3d::default(), + Camera { + hdr: true, // 1. HDR is required for bloom ..default() }, + Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), // 3. Enable bloom for the camera Bloom::NATURAL, )); diff --git a/examples/3d/camera_sub_view.rs b/examples/3d/camera_sub_view.rs index 92e168a966d66..1e707676c1caa 100644 --- a/examples/3d/camera_sub_view.rs +++ b/examples/3d/camera_sub_view.rs @@ -72,8 +72,9 @@ fn setup( )); // Main perspective Camera - commands.spawn(Camera3dBundle { - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE), physical_position: UVec2::new(PADDING, PADDING * 2 + SMALL_SIZE), @@ -82,12 +83,12 @@ fn setup( ..default() }, transform, - ..default() - }); + )); // Perspective camera left half - commands.spawn(Camera3dBundle { - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), physical_position: UVec2::new(PADDING, PADDING), @@ -109,37 +110,35 @@ fn setup( ..default() }, transform, - ..default() - }); + )); // Perspective camera moving commands.spawn(( - Camera3dBundle { - camera: Camera { - viewport: Option::from(Viewport { - physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), - physical_position: UVec2::new(PADDING * 2 + SMALL_SIZE, PADDING), - ..default() - }), - sub_camera_view: Some(SubCameraView { - // Set the sub view camera to a fifth of the full view and - // move it in another system - full_size: UVec2::new(500, 500), - offset: Vec2::ZERO, - size: UVec2::new(100, 100), - }), - order: 2, + Camera3d::default(), + Camera { + viewport: Option::from(Viewport { + physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), + physical_position: UVec2::new(PADDING * 2 + SMALL_SIZE, PADDING), ..default() - }, - transform, + }), + sub_camera_view: Some(SubCameraView { + // Set the sub view camera to a fifth of the full view and + // move it in another system + full_size: UVec2::new(500, 500), + offset: Vec2::ZERO, + size: UVec2::new(100, 100), + }), + order: 2, ..default() }, + transform, MovingCameraMarker, )); // Perspective camera control - commands.spawn(Camera3dBundle { - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), physical_position: UVec2::new(PADDING * 3 + SMALL_SIZE * 2, PADDING), @@ -156,17 +155,16 @@ fn setup( ..default() }, transform, - ..default() - }); + )); // Main orthographic camera - commands.spawn(Camera3dBundle { - projection: OrthographicProjection { + commands.spawn(( + Camera3d::default(), + Projection::from(OrthographicProjection { scaling_mode: ScalingMode::FixedVertical(6.0), ..OrthographicProjection::default_3d() - } - .into(), - camera: Camera { + }), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE), physical_position: UVec2::new(PADDING * 2 + LARGE_SIZE, PADDING * 2 + SMALL_SIZE), @@ -176,17 +174,16 @@ fn setup( ..default() }, transform, - ..default() - }); + )); // Orthographic camera left half - commands.spawn(Camera3dBundle { - projection: OrthographicProjection { + commands.spawn(( + Camera3d::default(), + Projection::from(OrthographicProjection { scaling_mode: ScalingMode::FixedVertical(6.0), ..OrthographicProjection::default_3d() - } - .into(), - camera: Camera { + }), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), physical_position: UVec2::new(PADDING * 5 + SMALL_SIZE * 4, PADDING), @@ -206,47 +203,43 @@ fn setup( ..default() }, transform, - ..default() - }); + )); // Orthographic camera moving commands.spawn(( - Camera3dBundle { - projection: OrthographicProjection { - scaling_mode: ScalingMode::FixedVertical(6.0), - ..OrthographicProjection::default_3d() - } - .into(), - camera: Camera { - viewport: Option::from(Viewport { - physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), - physical_position: UVec2::new(PADDING * 6 + SMALL_SIZE * 5, PADDING), - ..default() - }), - sub_camera_view: Some(SubCameraView { - // Set the sub view camera to a fifth of the full view and - // move it in another system - full_size: UVec2::new(500, 500), - offset: Vec2::ZERO, - size: UVec2::new(100, 100), - }), - order: 6, + Camera3d::default(), + Projection::from(OrthographicProjection { + scaling_mode: ScalingMode::FixedVertical(6.0), + ..OrthographicProjection::default_3d() + }), + Camera { + viewport: Option::from(Viewport { + physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), + physical_position: UVec2::new(PADDING * 6 + SMALL_SIZE * 5, PADDING), ..default() - }, - transform, + }), + sub_camera_view: Some(SubCameraView { + // Set the sub view camera to a fifth of the full view and + // move it in another system + full_size: UVec2::new(500, 500), + offset: Vec2::ZERO, + size: UVec2::new(100, 100), + }), + order: 6, ..default() }, + transform, MovingCameraMarker, )); // Orthographic camera control - commands.spawn(Camera3dBundle { - projection: OrthographicProjection { + commands.spawn(( + Camera3d::default(), + Projection::from(OrthographicProjection { scaling_mode: ScalingMode::FixedVertical(6.0), ..OrthographicProjection::default_3d() - } - .into(), - camera: Camera { + }), + Camera { viewport: Option::from(Viewport { physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE), physical_position: UVec2::new(PADDING * 7 + SMALL_SIZE * 6, PADDING), @@ -263,8 +256,7 @@ fn setup( ..default() }, transform, - ..default() - }); + )); } fn move_camera_view( diff --git a/examples/3d/clearcoat.rs b/examples/3d/clearcoat.rs index 30dd0120a3b61..9602044e232be 100644 --- a/examples/3d/clearcoat.rs +++ b/examples/3d/clearcoat.rs @@ -189,19 +189,19 @@ fn spawn_light(commands: &mut Commands) { /// Spawns a camera with associated skybox and environment map. fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) { commands - .spawn(Camera3dBundle { - camera: Camera { + .spawn(( + Camera3d::default(), + Camera { hdr: true, ..default() }, - projection: Projection::Perspective(PerspectiveProjection { + Projection::Perspective(PerspectiveProjection { fov: 27.0 / 180.0 * PI, ..default() }), - transform: Transform::from_xyz(0.0, 0.0, 10.0), - tonemapping: AcesFitted, - ..default() - }) + Transform::from_xyz(0.0, 0.0, 10.0), + AcesFitted, + )) .insert(Skybox { brightness: 5000.0, image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/color_grading.rs b/examples/3d/color_grading.rs index d40225f2d3e9c..6762640b66861 100644 --- a/examples/3d/color_grading.rs +++ b/examples/3d/color_grading.rs @@ -352,16 +352,13 @@ fn add_text<'a>( fn add_camera(commands: &mut Commands, asset_server: &AssetServer, color_grading: ColorGrading) { commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), - color_grading, + Camera3d::default(), + Camera { + hdr: true, ..default() }, + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), + color_grading, DistanceFog { color: Color::srgb_u8(43, 44, 47), falloff: FogFalloff::Linear { diff --git a/examples/3d/deferred_rendering.rs b/examples/3d/deferred_rendering.rs index abdcd2da187c9..ec6d44c291f1d 100644 --- a/examples/3d/deferred_rendering.rs +++ b/examples/3d/deferred_rendering.rs @@ -34,18 +34,15 @@ fn setup( mut meshes: ResMut>, ) { commands.spawn(( - Camera3dBundle { - camera: Camera { - // Deferred both supports both hdr: true and hdr: false - hdr: false, - ..default() - }, - transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), - // MSAA needs to be off for Deferred rendering - msaa: Msaa::Off, + Camera3d::default(), + Camera { + // Deferred both supports both hdr: true and hdr: false + hdr: false, ..default() }, + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), + // MSAA needs to be off for Deferred rendering + Msaa::Off, DistanceFog { color: Color::srgb_u8(43, 44, 47), falloff: FogFalloff::Linear { diff --git a/examples/3d/depth_of_field.rs b/examples/3d/depth_of_field.rs index e56988858ebb7..4bfe584b010df 100644 --- a/examples/3d/depth_of_field.rs +++ b/examples/3d/depth_of_field.rs @@ -70,16 +70,16 @@ fn main() { fn setup(mut commands: Commands, asset_server: Res, app_settings: Res) { // Spawn the camera. Enable HDR and bloom, as that highlights the depth of // field effect. - let mut camera = commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 4.5, 8.25).looking_at(Vec3::ZERO, Vec3::Y), - camera: Camera { + let mut camera = commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 4.5, 8.25).looking_at(Vec3::ZERO, Vec3::Y), + Camera { hdr: true, ..default() }, - tonemapping: Tonemapping::TonyMcMapface, - ..default() - }); - camera.insert(Bloom::NATURAL); + Tonemapping::TonyMcMapface, + Bloom::NATURAL, + )); // Insert the depth of field settings. if let Some(depth_of_field) = Option::::from(*app_settings) { diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index 7ef09ef2a823f..e63f9e255e3d8 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -34,7 +34,7 @@ fn main() { fn setup_camera_fog(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), DistanceFog { color: Color::srgb(0.25, 0.25, 0.25), falloff: FogFalloff::Linear { diff --git a/examples/3d/fog_volumes.rs b/examples/3d/fog_volumes.rs index c161240b3de67..82e38e21989ae 100644 --- a/examples/3d/fog_volumes.rs +++ b/examples/3d/fog_volumes.rs @@ -61,23 +61,21 @@ fn setup(mut commands: Commands, asset_server: Res) { )); // Spawn a camera. - commands - .spawn(Camera3dBundle { - transform: Transform::from_xyz(-0.75, 1.0, 2.0) - .looking_at(vec3(0.0, 0.0, 0.0), Vec3::Y), - camera: Camera { - hdr: true, - ..default() - }, + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-0.75, 1.0, 2.0).looking_at(vec3(0.0, 0.0, 0.0), Vec3::Y), + Camera { + hdr: true, ..default() - }) - .insert(VolumetricFog { + }, + VolumetricFog { // Make this relatively high in order to increase the fog quality. step_count: 64, // Disable ambient light. ambient_intensity: 0.0, ..default() - }); + }, + )); } /// Rotates the camera a bit every frame. diff --git a/examples/3d/generate_custom_mesh.rs b/examples/3d/generate_custom_mesh.rs index c13cdf40ca9e3..5718ff5ab27e1 100644 --- a/examples/3d/generate_custom_mesh.rs +++ b/examples/3d/generate_custom_mesh.rs @@ -51,10 +51,7 @@ fn setup( Transform::from_xyz(1.8, 1.8, 1.8).looking_at(Vec3::ZERO, Vec3::Y); // Camera in 3D space. - commands.spawn(Camera3dBundle { - transform: camera_and_light_transform, - ..default() - }); + commands.spawn((Camera3d::default(), camera_and_light_transform)); // Light up the scene. commands.spawn((PointLight::default(), camera_and_light_transform)); diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index 77612d11d7524..f4ef9a229128b 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -231,16 +231,15 @@ fn spawn_main_scene(commands: &mut Commands, assets: &ExampleAssets) { } fn spawn_camera(commands: &mut Commands, assets: &ExampleAssets) { - commands - .spawn(Camera3dBundle { - transform: Transform::from_xyz(-10.012, 4.8605, 13.281).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }) - .insert(Skybox { + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-10.012, 4.8605, 13.281).looking_at(Vec3::ZERO, Vec3::Y), + Skybox { image: assets.skybox.clone(), brightness: 150.0, ..default() - }); + }, + )); } fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) { diff --git a/examples/3d/lighting.rs b/examples/3d/lighting.rs index 8269dc289e136..99bcf8ac96592 100644 --- a/examples/3d/lighting.rs +++ b/examples/3d/lighting.rs @@ -244,11 +244,11 @@ fn setup( ); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - exposure: Exposure::from_physical_camera(**parameters), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + Exposure::from_physical_camera(**parameters), + )); } fn update_exposure( diff --git a/examples/3d/lightmaps.rs b/examples/3d/lightmaps.rs index c77d0c72c24e5..a6899cb368e7f 100644 --- a/examples/3d/lightmaps.rs +++ b/examples/3d/lightmaps.rs @@ -16,10 +16,10 @@ fn setup(mut commands: Commands, asset_server: Res) { GltfAssetLabel::Scene(0).from_asset("models/CornellBox/CornellBox.glb"), ))); - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-278.0, 273.0, 800.0), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-278.0, 273.0, 800.0), + )); } fn add_lightmaps_to_meshes( diff --git a/examples/3d/lines.rs b/examples/3d/lines.rs index 985ec2c6fca4a..d755aa434a2bb 100644 --- a/examples/3d/lines.rs +++ b/examples/3d/lines.rs @@ -59,10 +59,10 @@ fn setup( )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } #[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)] diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index 07d7e3a99a00a..174eb5cab62c1 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -17,11 +17,8 @@ fn main() { fn setup(mut commands: Commands, asset_server: Res) { commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/load_gltf_extras.rs b/examples/3d/load_gltf_extras.rs index 250c230e71cb3..6ea8406fe2baf 100644 --- a/examples/3d/load_gltf_extras.rs +++ b/examples/3d/load_gltf_extras.rs @@ -17,10 +17,10 @@ fn main() { struct ExampleDisplay; fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), + )); commands.spawn(DirectionalLight { shadows_enabled: true, diff --git a/examples/3d/meshlet.rs b/examples/3d/meshlet.rs index f7c9bc3a52dfd..21d1bb0f9bdb2 100644 --- a/examples/3d/meshlet.rs +++ b/examples/3d/meshlet.rs @@ -49,12 +49,9 @@ fn setup( mut meshes: ResMut>, ) { commands.spawn(( - Camera3dBundle { - transform: Transform::from_translation(Vec3::new(1.8, 0.4, -0.1)) - .looking_at(Vec3::ZERO, Vec3::Y), - msaa: Msaa::Off, - ..default() - }, + Camera3d::default(), + Transform::from_translation(Vec3::new(1.8, 0.4, -0.1)).looking_at(Vec3::ZERO, Vec3::Y), + Msaa::Off, EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/motion_blur.rs b/examples/3d/motion_blur.rs index 8d2ebbcaf8a44..3f9e2f5004015 100644 --- a/examples/3d/motion_blur.rs +++ b/examples/3d/motion_blur.rs @@ -18,7 +18,7 @@ fn main() { fn setup_camera(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), // Add the `MotionBlur` component to a camera to enable motion blur. // Motion blur requires the depth and motion vector prepass, which this bundle adds. // Configure the amount and quality of motion blur per-camera using this component. diff --git a/examples/3d/orthographic.rs b/examples/3d/orthographic.rs index be24a361d34cf..4b4070285cbaa 100644 --- a/examples/3d/orthographic.rs +++ b/examples/3d/orthographic.rs @@ -16,16 +16,15 @@ fn setup( mut materials: ResMut>, ) { // camera - commands.spawn(Camera3dBundle { - projection: OrthographicProjection { + commands.spawn(( + Camera3d::default(), + Projection::from(OrthographicProjection { // 6 world units per window height. scaling_mode: ScalingMode::FixedVertical(6.0), ..OrthographicProjection::default_3d() - } - .into(), - transform: Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + }), + Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // plane commands.spawn(( diff --git a/examples/3d/parallax_mapping.rs b/examples/3d/parallax_mapping.rs index eee56aa817b13..1cc39aaad6553 100644 --- a/examples/3d/parallax_mapping.rs +++ b/examples/3d/parallax_mapping.rs @@ -212,10 +212,8 @@ fn setup( // Camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::ZERO, Vec3::Y), CameraController, )); diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 4be7173e41ad6..348de61a2d8c5 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -53,8 +53,8 @@ fn setup( // light commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, -4.0))); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/pbr.rs b/examples/3d/pbr.rs index fef786f562110..5442a026fb981 100644 --- a/examples/3d/pbr.rs +++ b/examples/3d/pbr.rs @@ -114,15 +114,12 @@ fn setup( // camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::default(), Vec3::Y), - projection: OrthographicProjection { - scaling_mode: ScalingMode::WindowSize(100.0), - ..OrthographicProjection::default_3d() - } - .into(), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::default(), Vec3::Y), + Projection::from(OrthographicProjection { + scaling_mode: ScalingMode::WindowSize(100.0), + ..OrthographicProjection::default_3d() + }), EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/pcss.rs b/examples/3d/pcss.rs index ee790004655c6..04b94a228b9bb 100644 --- a/examples/3d/pcss.rs +++ b/examples/3d/pcss.rs @@ -151,16 +151,12 @@ fn setup(mut commands: Commands, asset_server: Res, app_status: Res /// Spawns the camera, with the initial shadow filtering method. fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) { commands - .spawn(Camera3dBundle { - transform: Transform::from_xyz(-12.912 * 0.7, 4.466 * 0.7, -10.624 * 0.7) - .with_rotation(Quat::from_euler( - EulerRot::YXZ, - -134.76 / 180.0 * PI, - -0.175, - 0.0, - )), - ..default() - }) + .spawn(( + Camera3d::default(), + Transform::from_xyz(-12.912 * 0.7, 4.466 * 0.7, -10.624 * 0.7).with_rotation( + Quat::from_euler(EulerRot::YXZ, -134.76 / 180.0 * PI, -0.175, 0.0), + ), + )) .insert(ShadowFilteringMethod::Gaussian) // `TemporalJitter` is needed for TAA. Note that it does nothing without // `TemporalAntiAliasSettings`. diff --git a/examples/3d/post_processing.rs b/examples/3d/post_processing.rs index 8e033c0acf713..7355171ff33c9 100644 --- a/examples/3d/post_processing.rs +++ b/examples/3d/post_processing.rs @@ -59,15 +59,12 @@ fn setup(mut commands: Commands, asset_server: Res, app_settings: R /// Spawns the camera, including the [`ChromaticAberration`] component. fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) { commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), + Camera3d::default(), + Camera { + hdr: true, ..default() }, + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), DistanceFog { color: Color::srgb_u8(43, 44, 47), falloff: FogFalloff::Linear { diff --git a/examples/3d/query_gltf_primitives.rs b/examples/3d/query_gltf_primitives.rs index 9a58e74b9c082..11af68c71f69b 100644 --- a/examples/3d/query_gltf_primitives.rs +++ b/examples/3d/query_gltf_primitives.rs @@ -54,11 +54,8 @@ fn find_top_material_and_mesh( fn setup(mut commands: Commands, asset_server: Res) { commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.6, 1.6, 11.3) - .looking_at(Vec3::new(0.0, 0.0, 3.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(0.6, 1.6, 11.3).looking_at(Vec3::new(0.0, 0.0, 3.0), Vec3::Y), EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/reflection_probes.rs b/examples/3d/reflection_probes.rs index 1a4fd3cfe4cad..17c76576e7aa6 100644 --- a/examples/3d/reflection_probes.rs +++ b/examples/3d/reflection_probes.rs @@ -103,14 +103,14 @@ fn spawn_scene(commands: &mut Commands, asset_server: &AssetServer) { // Spawns the camera. fn spawn_camera(commands: &mut Commands) { - commands.spawn(Camera3dBundle { - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { hdr: true, ..default() }, - transform: Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y), + )); } // Creates the sphere mesh and spawns it. diff --git a/examples/3d/render_to_texture.rs b/examples/3d/render_to_texture.rs index 519792c5a2269..40ec99eac38c4 100644 --- a/examples/3d/render_to_texture.rs +++ b/examples/3d/render_to_texture.rs @@ -84,16 +84,13 @@ fn setup( )); commands.spawn(( - Camera3dBundle { - camera: Camera { - target: image_handle.clone().into(), - clear_color: Color::WHITE.into(), - ..default() - }, - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)) - .looking_at(Vec3::ZERO, Vec3::Y), + Camera3d::default(), + Camera { + target: image_handle.clone().into(), + clear_color: Color::WHITE.into(), ..default() }, + Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)).looking_at(Vec3::ZERO, Vec3::Y), first_pass_layer, )); @@ -117,10 +114,10 @@ fn setup( )); // The main pass camera. - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 0.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 0.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } /// Rotates the inner cube (first pass) diff --git a/examples/3d/rotate_environment_map.rs b/examples/3d/rotate_environment_map.rs index 68f20d5fb64c1..1071a119d30cf 100644 --- a/examples/3d/rotate_environment_map.rs +++ b/examples/3d/rotate_environment_map.rs @@ -93,19 +93,19 @@ fn spawn_light(commands: &mut Commands) { /// Spawns a camera with associated skybox and environment map. fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) { commands - .spawn(Camera3dBundle { - camera: Camera { + .spawn(( + Camera3d::default(), + Camera { hdr: true, ..default() }, - projection: Projection::Perspective(PerspectiveProjection { + Projection::Perspective(PerspectiveProjection { fov: 27.0 / 180.0 * PI, ..default() }), - transform: Transform::from_xyz(0.0, 0.0, 10.0), - tonemapping: AcesFitted, - ..default() - }) + Transform::from_xyz(0.0, 0.0, 10.0), + AcesFitted, + )) .insert(Skybox { brightness: 5000.0, image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/scrolling_fog.rs b/examples/3d/scrolling_fog.rs index 4085ba2097846..8b0427ff0079f 100644 --- a/examples/3d/scrolling_fog.rs +++ b/examples/3d/scrolling_fog.rs @@ -49,14 +49,10 @@ fn setup( ) { // Spawn camera with temporal anti-aliasing and a VolumetricFog configuration. commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.0, 2.0, 0.0) - .looking_at(Vec3::new(-5.0, 3.5, -6.0), Vec3::Y), - camera: Camera { - hdr: true, - ..default() - }, - msaa: Msaa::Off, + Camera3d::default(), + Transform::from_xyz(0.0, 2.0, 0.0).looking_at(Vec3::new(-5.0, 3.5, -6.0), Vec3::Y), + Camera { + hdr: true, ..default() }, TemporalAntiAliasing::default(), diff --git a/examples/3d/shadow_biases.rs b/examples/3d/shadow_biases.rs index bc0a62819a8de..6b5d2d86eaf76 100644 --- a/examples/3d/shadow_biases.rs +++ b/examples/3d/shadow_biases.rs @@ -73,11 +73,8 @@ fn setup( // camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(-1.0, 1.0, 1.0) - .looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(-1.0, 1.0, 1.0).looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y), CameraController::default(), ShadowFilteringMethod::Hardware2x2, )); diff --git a/examples/3d/shadow_caster_receiver.rs b/examples/3d/shadow_caster_receiver.rs index b9cb8382bd7b7..edc8631aa9abe 100644 --- a/examples/3d/shadow_caster_receiver.rs +++ b/examples/3d/shadow_caster_receiver.rs @@ -98,11 +98,10 @@ fn setup( )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-5.0, 5.0, 5.0) - .looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-5.0, 5.0, 5.0).looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y), + )); } fn toggle_light( diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index e499c809a55cf..aaf62d33035c6 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -71,10 +71,8 @@ fn setup(mut commands: Commands, asset_server: Res) { let skybox_handle = asset_server.load(CUBEMAPS[0].0); // camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), CameraController::default(), Skybox { image: skybox_handle.clone(), diff --git a/examples/3d/spherical_area_lights.rs b/examples/3d/spherical_area_lights.rs index e311d1af14156..c3e945a8f3492 100644 --- a/examples/3d/spherical_area_lights.rs +++ b/examples/3d/spherical_area_lights.rs @@ -19,10 +19,10 @@ fn setup( mut materials: ResMut>, ) { // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y), + )); // plane commands.spawn(( diff --git a/examples/3d/split_screen.rs b/examples/3d/split_screen.rs index 95b6ac52c5f18..b7ca9c5da5a61 100644 --- a/examples/3d/split_screen.rs +++ b/examples/3d/split_screen.rs @@ -68,14 +68,11 @@ fn setup( { let camera = commands .spawn(( - Camera3dBundle { - transform: Transform::from_translation(*camera_pos) - .looking_at(Vec3::ZERO, Vec3::Y), - camera: Camera { - // Renders cameras with different priorities to prevent ambiguities - order: index as isize, - ..default() - }, + Camera3d::default(), + Transform::from_translation(*camera_pos).looking_at(Vec3::ZERO, Vec3::Y), + Camera { + // Renders cameras with different priorities to prevent ambiguities + order: index as isize, ..default() }, CameraPosition { diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index b4a900f79deef..48d891252cdfd 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -117,14 +117,14 @@ fn setup( } // camera - commands.spawn(Camera3dBundle { - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { hdr: true, ..default() }, - transform: Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), + )); commands.spawn( TextBundle::from_section(INSTRUCTIONS, TextStyle::default()).with_style(Style { diff --git a/examples/3d/ssao.rs b/examples/3d/ssao.rs index e8b1397848608..5ae09985690cf 100644 --- a/examples/3d/ssao.rs +++ b/examples/3d/ssao.rs @@ -27,15 +27,13 @@ fn setup( mut materials: ResMut>, ) { commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(-2.0, 2.0, -2.0).looking_at(Vec3::ZERO, Vec3::Y), - msaa: Msaa::Off, + Camera3d::default(), + Camera { + hdr: true, ..default() }, + Transform::from_xyz(-2.0, 2.0, -2.0).looking_at(Vec3::ZERO, Vec3::Y), + Msaa::Off, ScreenSpaceAmbientOcclusion::default(), TemporalAntiAliasing::default(), )); diff --git a/examples/3d/ssr.rs b/examples/3d/ssr.rs index eabb0f31c9cfc..4153ab619b7b6 100644 --- a/examples/3d/ssr.rs +++ b/examples/3d/ssr.rs @@ -225,16 +225,15 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) { // rendering by adding depth and deferred prepasses. Turn on FXAA to make // the scene look a little nicer. Finally, add screen space reflections. commands - .spawn(Camera3dBundle { - transform: Transform::from_translation(vec3(-1.25, 2.25, 4.5)) - .looking_at(Vec3::ZERO, Vec3::Y), - camera: Camera { + .spawn(( + Camera3d::default(), + Transform::from_translation(vec3(-1.25, 2.25, 4.5)).looking_at(Vec3::ZERO, Vec3::Y), + Camera { hdr: true, ..default() }, - msaa: Msaa::Off, - ..default() - }) + Msaa::Off, + )) .insert(EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 31606609bedf8..4b3e70dd5bffd 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -71,8 +71,8 @@ fn setup( Transform::from_xyz(0.0, 0.0, -1.5).with_rotation(Quat::from_rotation_x(-PI / 5.0)), )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index aa27c822b1646..8129b3e8e0aaf 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -58,14 +58,12 @@ fn setup( ) { // camera commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: camera_transform.0, + Camera3d::default(), + Camera { + hdr: true, ..default() }, + camera_transform.0, DistanceFog { color: Color::srgb_u8(43, 44, 47), falloff: FogFalloff::Linear { diff --git a/examples/3d/transmission.rs b/examples/3d/transmission.rs index 62b5cca5b2b0c..ae637d2267aba 100644 --- a/examples/3d/transmission.rs +++ b/examples/3d/transmission.rs @@ -302,25 +302,23 @@ fn setup( // Camera commands.spawn(( - Camera3dBundle { - camera: Camera { - hdr: true, - ..default() - }, - transform: Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y), - color_grading: ColorGrading { - global: ColorGradingGlobal { - post_saturation: 1.2, - ..default() - }, + Camera3d::default(), + Camera { + hdr: true, + ..default() + }, + Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y), + ColorGrading { + global: ColorGradingGlobal { + post_saturation: 1.2, ..default() }, - tonemapping: Tonemapping::TonyMcMapface, - exposure: Exposure { ev100: 6.0 }, - #[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))] - msaa: Msaa::Off, ..default() }, + Tonemapping::TonyMcMapface, + Exposure { ev100: 6.0 }, + #[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))] + Msaa::Off, #[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))] TemporalAntiAliasing::default(), EnvironmentMapLight { diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index f08f593fdbbc0..ab5426e13328e 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -90,10 +90,10 @@ fn setup( )); // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } /// Fades the alpha channel of all materials between 0 and 1 over time. diff --git a/examples/3d/two_passes.rs b/examples/3d/two_passes.rs index ac97a240b7c8c..f80125472e7b0 100644 --- a/examples/3d/two_passes.rs +++ b/examples/3d/two_passes.rs @@ -38,20 +38,20 @@ fn setup( )); // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(10.0, 10., -5.0).looking_at(Vec3::ZERO, Vec3::Y), - camera: Camera { + commands.spawn(( + Camera3d::default(), + Camera { // renders after / on top of the main camera order: 1, clear_color: ClearColorConfig::None, ..default() }, - ..default() - }); + Transform::from_xyz(10.0, 10., -5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/update_gltf_scene.rs b/examples/3d/update_gltf_scene.rs index ac9df29e6d909..7c14ea0237e03 100644 --- a/examples/3d/update_gltf_scene.rs +++ b/examples/3d/update_gltf_scene.rs @@ -24,11 +24,8 @@ fn setup(mut commands: Commands, asset_server: Res) { }, )); commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(-0.5, 0.9, 1.5) - .looking_at(Vec3::new(-0.5, 0.3, 0.0), Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(-0.5, 0.9, 1.5).looking_at(Vec3::new(-0.5, 0.3, 0.0), Vec3::Y), EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/vertex_colors.rs b/examples/3d/vertex_colors.rs index 315d370a13694..90eb67abd7ce3 100644 --- a/examples/3d/vertex_colors.rs +++ b/examples/3d/vertex_colors.rs @@ -51,8 +51,8 @@ fn setup( )); // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } diff --git a/examples/3d/visibility_range.rs b/examples/3d/visibility_range.rs index b237d1301d24f..f8f90919575ee 100644 --- a/examples/3d/visibility_range.rs +++ b/examples/3d/visibility_range.rs @@ -137,10 +137,10 @@ fn setup( // Spawn a camera. commands - .spawn(Camera3dBundle { - transform: Transform::from_xyz(0.7, 0.7, 1.0).looking_at(CAMERA_FOCAL_POINT, Vec3::Y), - ..default() - }) + .spawn(( + Camera3d::default(), + Transform::from_xyz(0.7, 0.7, 1.0).looking_at(CAMERA_FOCAL_POINT, Vec3::Y), + )) .insert(EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), diff --git a/examples/3d/volumetric_fog.rs b/examples/3d/volumetric_fog.rs index b100ebc923484..8f710bb85cac9 100644 --- a/examples/3d/volumetric_fog.rs +++ b/examples/3d/volumetric_fog.rs @@ -63,17 +63,16 @@ fn setup(mut commands: Commands, asset_server: Res, app_settings: R // Spawn the camera. commands - .spawn(Camera3dBundle { - transform: Transform::from_xyz(-1.7, 1.5, 4.5) - .looking_at(vec3(-1.5, 1.7, 3.5), Vec3::Y), - camera: Camera { + .spawn(( + Camera3d::default(), + Camera { hdr: true, ..default() }, - ..default() - }) - .insert(Tonemapping::TonyMcMapface) - .insert(Bloom::default()) + Transform::from_xyz(-1.7, 1.5, 4.5).looking_at(vec3(-1.5, 1.7, 3.5), Vec3::Y), + Tonemapping::TonyMcMapface, + Bloom::default(), + )) .insert(Skybox { image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), brightness: 1000.0, diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index e424c5c58924d..9509c689dfe1b 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -93,10 +93,10 @@ fn setup( commands.spawn((PointLight::default(), Transform::from_xyz(2.0, 4.0, 2.0))); // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // Text used to show controls commands.spawn( diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index 73a662526e190..1cc0192b91489 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -52,11 +52,10 @@ fn setup( }); // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(100.0, 100.0, 150.0) - .looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(100.0, 100.0, 150.0).looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y), + )); // Plane commands.spawn(( diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index b6ca201cc5917..f5eecd3d8ddb2 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -26,10 +26,10 @@ fn setup( mut graphs: ResMut>, ) { // Camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // Light commands.spawn(( diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index 448f692e0962c..c04abb6a0a2db 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -144,7 +144,7 @@ fn setup( animation_player.play(animation_node_index).repeat(); // Add a camera. - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // Build the UI. We have a parent node that covers the whole screen and // contains the `AnimationPlayer`, as well as a child node that contains the diff --git a/examples/animation/animation_graph.rs b/examples/animation/animation_graph.rs index 4336151fefa64..ecc47389d2ce1 100644 --- a/examples/animation/animation_graph.rs +++ b/examples/animation/animation_graph.rs @@ -218,10 +218,10 @@ fn setup_scene( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-10.0, 5.0, 13.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-10.0, 5.0, 13.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), + )); commands.spawn(( PointLight { diff --git a/examples/animation/animation_masks.rs b/examples/animation/animation_masks.rs index 4a9177074dd06..9057ae9e8d01b 100644 --- a/examples/animation/animation_masks.rs +++ b/examples/animation/animation_masks.rs @@ -122,11 +122,10 @@ fn setup_scene( mut materials: ResMut>, ) { // Spawn the camera. - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-15.0, 10.0, 20.0) - .looking_at(Vec3::new(0., 1., 0.), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-15.0, 10.0, 20.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), + )); // Spawn the light. commands.spawn(( diff --git a/examples/animation/color_animation.rs b/examples/animation/color_animation.rs index e1b364e39b5e8..dff3175c4e9c3 100644 --- a/examples/animation/color_animation.rs +++ b/examples/animation/color_animation.rs @@ -35,7 +35,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); // The color spaces `Oklaba`, `Laba`, `LinearRgba`, `Srgba` and `Xyza` all are either perceptually or physically linear. // This property allows us to define curves, e.g. bezier curves through these spaces. diff --git a/examples/animation/cubic_curve.rs b/examples/animation/cubic_curve.rs index 2c2ed2486fe66..702346cdb2830 100644 --- a/examples/animation/cubic_curve.rs +++ b/examples/animation/cubic_curve.rs @@ -62,10 +62,10 @@ fn setup( )); // The camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0., 6., 12.).looking_at(Vec3::new(0., 3., 0.), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0., 6., 12.).looking_at(Vec3::new(0., 3., 0.), Vec3::Y), + )); } fn animate_cube(time: Res