Skip to content

Commit

Permalink
Add Camera3D to required-components of PanOrbitCamera (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
mineichen authored Dec 10, 2024
1 parent 672ef73 commit 9dab198
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 22 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
] }
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
));
Expand All @@ -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 |
Expand Down
1 change: 0 additions & 1 deletion examples/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion examples/animate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fn setup(
));
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
Expand Down
1 change: 0 additions & 1 deletion examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn setup(
));
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
Expand Down
2 changes: 0 additions & 2 deletions examples/egui_multiple_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fn setup(
));
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
Expand All @@ -60,7 +59,6 @@ fn setup(

// second window camera
commands.spawn((
Camera3d::default(),
Camera {
target: RenderTarget::Window(WindowRef::Entity(second_window)),
..default()
Expand Down
1 change: 0 additions & 1 deletion examples/follow_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion examples/keyboard_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ fn setup(
));
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
Expand Down
2 changes: 0 additions & 2 deletions examples/multiple_viewports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions examples/multiple_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ fn setup(
));
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
Expand All @@ -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)),
Expand Down
1 change: 0 additions & 1 deletion examples/orthographic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion examples/render_to_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -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`
Expand Down

0 comments on commit 9dab198

Please sign in to comment.