diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 7e9e8a4ab6cfa..9f36e73ec2a28 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -51,6 +51,20 @@ pub enum WindowOrigin { BottomLeft, } +#[derive(Debug, Clone, Reflect, Serialize, Deserialize)] +#[reflect_value(Serialize, Deserialize)] +pub enum ScalingMode { + /// Manually specify left/right/top/bottom values. + /// Ignore window resizing; the image will stretch. + None, + /// Match the window size. 1 world unit = 1 pixel. + WindowSize, + /// Keep vertical axis constant; resize horizontal with aspect ratio. + FixedVertical, + /// Keep horizontal axis constant; resize vertical with aspect ratio. + FixedHorizontal, +} + #[derive(Debug, Clone, Reflect)] #[reflect(Component)] pub struct OrthographicProjection { @@ -61,23 +75,25 @@ pub struct OrthographicProjection { pub near: f32, pub far: f32, pub window_origin: WindowOrigin, + pub scaling_mode: ScalingMode, + pub scale: f32, } impl CameraProjection for OrthographicProjection { fn get_projection_matrix(&self) -> Mat4 { Mat4::orthographic_rh( - self.left, - self.right, - self.bottom, - self.top, + self.left * self.scale, + self.right * self.scale, + self.bottom * self.scale, + self.top * self.scale, self.near, self.far, ) } fn update(&mut self, width: f32, height: f32) { - match self.window_origin { - WindowOrigin::Center => { + match (&self.scaling_mode, &self.window_origin) { + (ScalingMode::WindowSize, WindowOrigin::Center) => { let half_width = width / 2.0; let half_height = height / 2.0; self.left = -half_width; @@ -85,12 +101,41 @@ impl CameraProjection for OrthographicProjection { self.top = half_height; self.bottom = -half_height; } - WindowOrigin::BottomLeft => { + (ScalingMode::WindowSize, WindowOrigin::BottomLeft) => { self.left = 0.0; self.right = width; self.top = height; self.bottom = 0.0; } + (ScalingMode::FixedVertical, WindowOrigin::Center) => { + let aspect_ratio = width / height; + self.left = -aspect_ratio; + self.right = aspect_ratio; + self.top = 1.0; + self.bottom = -1.0; + } + (ScalingMode::FixedVertical, WindowOrigin::BottomLeft) => { + let aspect_ratio = width / height; + self.left = 0.0; + self.right = aspect_ratio; + self.top = 1.0; + self.bottom = 0.0; + } + (ScalingMode::FixedHorizontal, WindowOrigin::Center) => { + let aspect_ratio = height / width; + self.left = -1.0; + self.right = 1.0; + self.top = aspect_ratio; + self.bottom = -aspect_ratio; + } + (ScalingMode::FixedHorizontal, WindowOrigin::BottomLeft) => { + let aspect_ratio = height / width; + self.left = 0.0; + self.right = 1.0; + self.top = aspect_ratio; + self.bottom = 0.0; + } + (ScalingMode::None, _) => {} } } @@ -102,13 +147,15 @@ impl CameraProjection for OrthographicProjection { impl Default for OrthographicProjection { fn default() -> Self { OrthographicProjection { - left: 0.0, - right: 0.0, - bottom: 0.0, - top: 0.0, + left: -1.0, + right: 1.0, + bottom: -1.0, + top: 1.0, near: 0.0, far: 1000.0, window_origin: WindowOrigin::Center, + scaling_mode: ScalingMode::WindowSize, + scale: 1.0, } } } diff --git a/crates/bevy_render/src/entity.rs b/crates/bevy_render/src/entity.rs index a87aa88896044..72ebe7d4d1f83 100644 --- a/crates/bevy_render/src/entity.rs +++ b/crates/bevy_render/src/entity.rs @@ -22,9 +22,11 @@ pub struct MeshBundle { pub global_transform: GlobalTransform, } -/// A component bundle for "3d camera" entities +/// Component bundle for camera entities with perspective projection +/// +/// Use this for 3D rendering. #[derive(Bundle)] -pub struct Camera3dBundle { +pub struct PerspectiveCameraBundle { pub camera: Camera, pub perspective_projection: PerspectiveProjection, pub visible_entities: VisibleEntities, @@ -32,9 +34,28 @@ pub struct Camera3dBundle { pub global_transform: GlobalTransform, } -impl Default for Camera3dBundle { +impl PerspectiveCameraBundle { + pub fn new_3d() -> Self { + Default::default() + } + + pub fn with_name(name: &str) -> Self { + PerspectiveCameraBundle { + camera: Camera { + name: Some(name.to_string()), + ..Default::default() + }, + perspective_projection: Default::default(), + visible_entities: Default::default(), + transform: Default::default(), + global_transform: Default::default(), + } + } +} + +impl Default for PerspectiveCameraBundle { fn default() -> Self { - Camera3dBundle { + PerspectiveCameraBundle { camera: Camera { name: Some(base::camera::CAMERA_3D.to_string()), ..Default::default() @@ -47,9 +68,11 @@ impl Default for Camera3dBundle { } } -/// A component bundle for "2d camera" entities +/// Component bundle for camera entities with orthographic projection +/// +/// Use this for 2D games, isometric games, CAD-like 3D views. #[derive(Bundle)] -pub struct Camera2dBundle { +pub struct OrthographicCameraBundle { pub camera: Camera, pub orthographic_projection: OrthographicProjection, pub visible_entities: VisibleEntities, @@ -57,12 +80,12 @@ pub struct Camera2dBundle { pub global_transform: GlobalTransform, } -impl Default for Camera2dBundle { - fn default() -> Self { +impl OrthographicCameraBundle { + pub fn new_2d() -> Self { // we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset // the camera's translation by far and use a right handed coordinate system let far = 1000.0; - Camera2dBundle { + OrthographicCameraBundle { camera: Camera { name: Some(base::camera::CAMERA_2D.to_string()), ..Default::default() @@ -76,4 +99,30 @@ impl Default for Camera2dBundle { global_transform: Default::default(), } } + + pub fn new_3d() -> Self { + OrthographicCameraBundle { + camera: Camera { + name: Some(base::camera::CAMERA_3D.to_string()), + ..Default::default() + }, + orthographic_projection: Default::default(), + visible_entities: Default::default(), + transform: Default::default(), + global_transform: Default::default(), + } + } + + pub fn with_name(name: &str) -> Self { + OrthographicCameraBundle { + camera: Camera { + name: Some(name.to_string()), + ..Default::default() + }, + orthographic_projection: Default::default(), + visible_entities: Default::default(), + transform: Default::default(), + global_transform: Default::default(), + } + } } diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index 64fb748e175e0..28f0faf21ffad 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -164,7 +164,7 @@ impl Default for ButtonBundle { } #[derive(Bundle, Debug)] -pub struct CameraUiBundle { +pub struct UiCameraBundle { pub camera: Camera, pub orthographic_projection: OrthographicProjection, pub visible_entities: VisibleEntities, @@ -172,12 +172,12 @@ pub struct CameraUiBundle { pub global_transform: GlobalTransform, } -impl Default for CameraUiBundle { +impl Default for UiCameraBundle { fn default() -> Self { // we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset // the camera's translation by far and use a right handed coordinate system let far = 1000.0; - CameraUiBundle { + UiCameraBundle { camera: Camera { name: Some(crate::camera::CAMERA_UI.to_string()), ..Default::default() diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs index 851dac3d2b0e8..821196b9c1c8b 100644 --- a/examples/2d/contributors.rs +++ b/examples/2d/contributors.rs @@ -55,8 +55,8 @@ fn setup( let texture_handle = asset_server.load("branding/icon.png"); commands - .spawn(Camera2dBundle::default()) - .spawn(CameraUiBundle::default()); + .spawn(OrthographicCameraBundle::new_2d()) + .spawn(UiCameraBundle::default()); let mut sel = ContributorSelection { order: vec![], diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index 2d8f298c3e1da..6392ce606d69d 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -14,7 +14,7 @@ fn setup( ) { let texture_handle = asset_server.load("branding/icon.png"); commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(SpriteBundle { material: materials.add(texture_handle.into()), ..Default::default() diff --git a/examples/2d/sprite_sheet.rs b/examples/2d/sprite_sheet.rs index e8c92c45df346..155401cc120d7 100644 --- a/examples/2d/sprite_sheet.rs +++ b/examples/2d/sprite_sheet.rs @@ -31,7 +31,7 @@ fn setup( let texture_atlas = TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); let texture_atlas_handle = texture_atlases.add(texture_atlas); commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(SpriteSheetBundle { texture_atlas: texture_atlas_handle, transform: Transform::from_scale(Vec3::splat(6.0)), diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index 4b3b6ab4f64ac..f5d91c8a5172f 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -11,7 +11,7 @@ fn main() { fn setup(commands: &mut Commands, asset_server: Res) { commands // 2d camera - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(Text2dBundle { text: Text::with_section( "This text is in the 2D scene.", diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index c643d5e931615..f1267be1649e6 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -64,7 +64,7 @@ fn setup( // set up a scene to display our texture atlas commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) // draw a sprite from the atlas .spawn(SpriteSheetBundle { transform: Transform { diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index dadb559a86b83..a66db90191f52 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -35,7 +35,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index c3340c6e0d027..02005a727a9d7 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -15,7 +15,7 @@ fn setup(commands: &mut Commands, asset_server: Res) { transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(0.7, 0.7, 1.0) .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index 1fe5688fd03a1..ed5a920737fbf 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -31,7 +31,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(-3.0, 3.0, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index ff8c2e9c274b8..81e4b3d9d4330 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -57,7 +57,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(5.0, 10.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/spawner.rs b/examples/3d/spawner.rs index 09a88c7d55641..978aaec3663c5 100644 --- a/examples/3d/spawner.rs +++ b/examples/3d/spawner.rs @@ -43,7 +43,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(0.0, 15.0, 150.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index db47465500641..705979879b7e6 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -95,7 +95,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(3.0, 5.0, 8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/update_gltf_scene.rs b/examples/3d/update_gltf_scene.rs index a5140e8098b99..e5b2d5eedcbac 100644 --- a/examples/3d/update_gltf_scene.rs +++ b/examples/3d/update_gltf_scene.rs @@ -29,7 +29,7 @@ fn setup( transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(1.05, 0.9, 1.5) .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), ..Default::default() diff --git a/examples/3d/z_sort_debug.rs b/examples/3d/z_sort_debug.rs index d7a69e1b0f6ca..337608401c8da 100644 --- a/examples/3d/z_sort_debug.rs +++ b/examples/3d/z_sort_debug.rs @@ -82,7 +82,7 @@ fn setup( }); }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(5.0, 10.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/android/android.rs b/examples/android/android.rs index ce8a9d616c452..1a2f25116dc0c 100644 --- a/examples/android/android.rs +++ b/examples/android/android.rs @@ -37,7 +37,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index a471bc91e1022..bf4d17863ce90 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -70,7 +70,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(0.0, 3.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/asset/custom_asset_io.rs b/examples/asset/custom_asset_io.rs index 7e986644e4be4..f6694080543fa 100644 --- a/examples/asset/custom_asset_io.rs +++ b/examples/asset/custom_asset_io.rs @@ -96,7 +96,7 @@ fn setup( ) { let texture_handle = asset_server.load("branding/icon.png"); commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(SpriteBundle { material: materials.add(texture_handle.into()), ..Default::default() diff --git a/examples/asset/hot_asset_reloading.rs b/examples/asset/hot_asset_reloading.rs index 62578443e5d7f..b27ba6de82106 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -30,7 +30,7 @@ fn setup(commands: &mut Commands, asset_server: Res) { ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(2.0, 2.0, 6.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/ecs/hierarchy.rs b/examples/ecs/hierarchy.rs index 5d0f49a03388a..875bd7a9cd32d 100644 --- a/examples/ecs/hierarchy.rs +++ b/examples/ecs/hierarchy.rs @@ -13,7 +13,7 @@ fn setup( asset_server: Res, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(OrthographicCameraBundle::new_2d()); let texture = asset_server.load("branding/icon.png"); // Spawn a root entity with no parent diff --git a/examples/ecs/parallel_query.rs b/examples/ecs/parallel_query.rs index b590a2c0460a8..17296707cd871 100644 --- a/examples/ecs/parallel_query.rs +++ b/examples/ecs/parallel_query.rs @@ -8,7 +8,7 @@ fn spawn_system( asset_server: Res, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(OrthographicCameraBundle::new_2d()); let texture_handle = asset_server.load("branding/icon.png"); let material = materials.add(texture_handle.into()); for _ in 0..128 { diff --git a/examples/ecs/removal_detection.rs b/examples/ecs/removal_detection.rs index 6709f940477e3..80c430ff833d4 100644 --- a/examples/ecs/removal_detection.rs +++ b/examples/ecs/removal_detection.rs @@ -33,7 +33,7 @@ fn setup( let texture = asset_server.load("branding/icon.png"); commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(SpriteBundle { material: materials.add(texture.into()), ..Default::default() diff --git a/examples/ecs/state.rs b/examples/ecs/state.rs index 770157aa19ec2..95e8f82763138 100644 --- a/examples/ecs/state.rs +++ b/examples/ecs/state.rs @@ -35,7 +35,7 @@ fn setup_menu( ) { commands // ui camera - .spawn(CameraUiBundle::default()) + .spawn(UiCameraBundle::default()) .spawn(ButtonBundle { style: Style { size: Size::new(Val::Px(150.0), Val::Px(65.0)), @@ -104,7 +104,7 @@ fn setup_game( ) { let texture_handle = asset_server.load("branding/icon.png"); commands - .spawn(Camera2dBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) .spawn(SpriteBundle { material: materials.add(texture_handle.into()), ..Default::default() diff --git a/examples/game/alien_cake_addict.rs b/examples/game/alien_cake_addict.rs index 34ec530dc5ce8..bc0d7ac238075 100644 --- a/examples/game/alien_cake_addict.rs +++ b/examples/game/alien_cake_addict.rs @@ -83,7 +83,7 @@ fn setup_cameras(commands: &mut Commands, mut game: ResMut) { game.camera_should_focus = Vec3::from(RESET_FOCUS); game.camera_is_focus = game.camera_should_focus; commands - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz( -(BOARD_SIZE_I as f32 / 2.0), 2.0 * BOARD_SIZE_J as f32 / 3.0, @@ -92,7 +92,7 @@ fn setup_cameras(commands: &mut Commands, mut game: ResMut) { .looking_at(game.camera_is_focus, Vec3::unit_y()), ..Default::default() }) - .spawn(CameraUiBundle::default()); + .spawn(UiCameraBundle::default()); } fn setup(commands: &mut Commands, asset_server: Res, mut game: ResMut) { diff --git a/examples/game/breakout.rs b/examples/game/breakout.rs index 16ec1f67a0d42..750635024a07e 100644 --- a/examples/game/breakout.rs +++ b/examples/game/breakout.rs @@ -44,8 +44,8 @@ fn setup( // Add the game's entities to our world commands // cameras - .spawn(Camera2dBundle::default()) - .spawn(CameraUiBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) + .spawn(UiCameraBundle::default()) // paddle .spawn(SpriteBundle { material: materials.add(Color::rgb(0.5, 0.5, 1.0).into()), diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index 8ec9fa85cdebc..04a713a9826c1 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -52,7 +52,7 @@ fn setup( ..Default::default() }) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/scene/scene.rs b/examples/scene/scene.rs index 811a778c0d813..b242617f36493 100644 --- a/examples/scene/scene.rs +++ b/examples/scene/scene.rs @@ -97,7 +97,7 @@ fn save_scene_system(_world: &mut World, resources: &mut Resources) { // This is only necessary for the info message in the UI. See examples/ui/text.rs for a standalone text example. fn infotext_system(commands: &mut Commands, asset_server: Res) { - commands.spawn(CameraUiBundle::default()).spawn(TextBundle { + commands.spawn(UiCameraBundle::default()).spawn(TextBundle { style: Style { align_self: AlignSelf::FlexEnd, ..Default::default() diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index 368831f7d3ae9..43912ab0853fb 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -109,7 +109,7 @@ fn setup( .add_node_edge("my_array_texture", base::node::MAIN_PASS) .unwrap(); - commands.spawn(Camera3dBundle { + commands.spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/shader/hot_shader_reloading.rs b/examples/shader/hot_shader_reloading.rs index e64bfc0d00781..6f675224a4a9e 100644 --- a/examples/shader/hot_shader_reloading.rs +++ b/examples/shader/hot_shader_reloading.rs @@ -72,7 +72,7 @@ fn setup( }) .with(material) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/shader/mesh_custom_attribute.rs b/examples/shader/mesh_custom_attribute.rs index 03858f4a595e0..6d0d2ca09e295 100644 --- a/examples/shader/mesh_custom_attribute.rs +++ b/examples/shader/mesh_custom_attribute.rs @@ -137,7 +137,7 @@ fn setup( }) .with(material) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/shader/shader_custom_material.rs b/examples/shader/shader_custom_material.rs index ca74cdee0bfae..dc02029f37709 100644 --- a/examples/shader/shader_custom_material.rs +++ b/examples/shader/shader_custom_material.rs @@ -93,7 +93,7 @@ fn setup( }) .with(material) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index 487e5705201d7..552db2f9b9c54 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -124,7 +124,7 @@ fn setup( }) .with(blue_material) // camera - .spawn(Camera3dBundle { + .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() diff --git a/examples/tools/bevymark.rs b/examples/tools/bevymark.rs index 91054be6d4d99..a24203a211730 100644 --- a/examples/tools/bevymark.rs +++ b/examples/tools/bevymark.rs @@ -50,8 +50,8 @@ fn main() { fn setup(commands: &mut Commands, asset_server: Res) { commands - .spawn(Camera2dBundle::default()) - .spawn(CameraUiBundle::default()) + .spawn(OrthographicCameraBundle::new_2d()) + .spawn(UiCameraBundle::default()) .spawn(TextBundle { text: Text { sections: vec![ diff --git a/examples/ui/button.rs b/examples/ui/button.rs index dc831caed5abc..119234a5cf464 100644 --- a/examples/ui/button.rs +++ b/examples/ui/button.rs @@ -61,7 +61,7 @@ fn setup( ) { commands // ui camera - .spawn(CameraUiBundle::default()) + .spawn(UiCameraBundle::default()) .spawn(ButtonBundle { style: Style { size: Size::new(Val::Px(150.0), Val::Px(65.0)), diff --git a/examples/ui/font_atlas_debug.rs b/examples/ui/font_atlas_debug.rs index 3ef3a0c47428d..bbd3884305dab 100644 --- a/examples/ui/font_atlas_debug.rs +++ b/examples/ui/font_atlas_debug.rs @@ -79,7 +79,7 @@ fn text_update_system(mut state: ResMut, time: Res