From 9dab198cb25f06747ace8ba69ce0aabb681a4b48 Mon Sep 17 00:00:00 2001 From: Markus Ineichen Date: Tue, 10 Dec 2024 08:10:36 +0100 Subject: [PATCH] Add Camera3D to required-components of PanOrbitCamera (#91) --- Cargo.toml | 1 + README.md | 3 +-- examples/advanced.rs | 1 - examples/animate.rs | 1 - examples/basic.rs | 1 - examples/egui.rs | 1 - examples/egui_multiple_windows.rs | 2 -- examples/follow_target.rs | 1 - examples/keyboard_controls.rs | 1 - examples/multiple_viewports.rs | 2 -- examples/multiple_windows.rs | 2 -- examples/orthographic.rs | 1 - examples/render_to_texture.rs | 1 - src/lib.rs | 8 ++------ 14 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9cfa148..d580f01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ bevy_egui = ["dep:bevy_egui"] [dependencies] bevy = { version = "0.15", default-features = false, features = [ + "bevy_core_pipeline", "bevy_render", "bevy_window" ] } diff --git a/README.md b/README.md index c9896a1..9bd6248 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ Add `PanOrbitCamera` to a camera: ```rust ignore commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); @@ -68,7 +67,7 @@ all the possible configuration options. ## Version Compatibility | bevy | bevy_panorbit_camera | -|------|----------------------| +| ---- | -------------------- | | 0.15 | 0.21 | | 0.14 | 0.19-0.20 | | 0.13 | 0.14-0.18 | diff --git a/examples/advanced.rs b/examples/advanced.rs index 1dbf8a6..92c3738 100644 --- a/examples/advanced.rs +++ b/examples/advanced.rs @@ -47,7 +47,6 @@ fn setup( commands.spawn(( // Note we're setting the initial position below with yaw, pitch, and radius, hence // we don't set transform on the camera. - Camera3d::default(), PanOrbitCamera { // Set focal point (what the camera should look at) focus: Vec3::new(0.0, 1.0, 0.0), diff --git a/examples/animate.rs b/examples/animate.rs index e14b56c..ee02589 100644 --- a/examples/animate.rs +++ b/examples/animate.rs @@ -39,7 +39,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera { // Disable smoothing, since the animation takes care of that diff --git a/examples/basic.rs b/examples/basic.rs index e899ee5..66472ad 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -37,7 +37,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); diff --git a/examples/egui.rs b/examples/egui.rs index d911050..031e862 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -42,7 +42,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); diff --git a/examples/egui_multiple_windows.rs b/examples/egui_multiple_windows.rs index 0e32d8b..cde8cc9 100644 --- a/examples/egui_multiple_windows.rs +++ b/examples/egui_multiple_windows.rs @@ -45,7 +45,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); @@ -60,7 +59,6 @@ fn setup( // second window camera commands.spawn(( - Camera3d::default(), Camera { target: RenderTarget::Window(WindowRef::Entity(second_window)), ..default() diff --git a/examples/follow_target.rs b/examples/follow_target.rs index 519195c..e38f41c 100644 --- a/examples/follow_target.rs +++ b/examples/follow_target.rs @@ -44,7 +44,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera { // Panning the camera changes the focus, and so you most likely want to disable diff --git a/examples/keyboard_controls.rs b/examples/keyboard_controls.rs index 0b8c1c2..4f3863e 100644 --- a/examples/keyboard_controls.rs +++ b/examples/keyboard_controls.rs @@ -44,7 +44,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); diff --git a/examples/multiple_viewports.rs b/examples/multiple_viewports.rs index d51f457..86ebbf4 100644 --- a/examples/multiple_viewports.rs +++ b/examples/multiple_viewports.rs @@ -40,13 +40,11 @@ fn setup( )); // Main Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 0.5, 5.0)), PanOrbitCamera::default(), )); // Minimap Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(1.0, 1.5, 4.0)), Camera { // Renders the minimap camera after the main camera, so it is rendered on top diff --git a/examples/multiple_windows.rs b/examples/multiple_windows.rs index a2c275b..c510f96 100644 --- a/examples/multiple_windows.rs +++ b/examples/multiple_windows.rs @@ -39,7 +39,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), PanOrbitCamera::default(), )); @@ -54,7 +53,6 @@ fn setup( // second window camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(5.0, 1.5, 7.0)), Camera { target: RenderTarget::Window(WindowRef::Entity(second_window)), diff --git a/examples/orthographic.rs b/examples/orthographic.rs index 6f65080..9193198 100644 --- a/examples/orthographic.rs +++ b/examples/orthographic.rs @@ -41,7 +41,6 @@ fn setup( )); // Camera commands.spawn(( - Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 1.5, 6.0)), Projection::from(OrthographicProjection { scaling_mode: ScalingMode::FixedVertical { diff --git a/examples/render_to_texture.rs b/examples/render_to_texture.rs index 45a37f5..fa0d1b8 100644 --- a/examples/render_to_texture.rs +++ b/examples/render_to_texture.rs @@ -105,7 +105,6 @@ fn setup( // that is controlled by PanOrbitCamera. let pan_orbit_id = commands .spawn(( - Camera3d::default(), Camera { // render before the "main pass" camera clear_color: ClearColorConfig::Custom(Color::WHITE), diff --git a/src/lib.rs b/src/lib.rs index 63f68d2..68c791b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,8 +81,6 @@ pub struct PanOrbitCameraSystemSet; /// Tags an entity as capable of panning and orbiting, and provides a way to configure the /// camera's behaviour and controls. -/// The entity must have `Transform` and `Projection` components. Typically you would add a -/// `Camera3dBundle` which already contains these. /// # Example /// ```no_run /// # use bevy::prelude::*; @@ -97,15 +95,13 @@ pub struct PanOrbitCameraSystemSet; /// fn setup(mut commands: Commands) { /// commands /// .spawn(( -/// Camera3dBundle { -/// transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), -/// ..default() -/// }, +/// Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)), /// PanOrbitCamera::default(), /// )); /// } /// ``` #[derive(Component, Copy, Clone, Debug, PartialEq)] +#[require(Camera3d)] pub struct PanOrbitCamera { /// The point to orbit around, and what the camera looks at. Updated automatically. /// If you want to change the focus programmatically after initialization, set `target_focus`