Skip to content

Commit 613001b

Browse files
authored
feat: bevy 0.16 (#112)
1 parent 65f7f17 commit 613001b

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_panorbit_camera"
3-
version = "0.25.0"
3+
version = "0.26.0"
44
authors = ["Plonq"]
55
edition = "2021"
66
description = "A basic pan and orbit camera in Bevy"
@@ -15,17 +15,17 @@ readme = "README.md"
1515
bevy_egui = ["dep:bevy_egui"]
1616

1717
[dependencies]
18-
bevy = { version = "0.15", default-features = false, features = [
18+
bevy = { version = "0.16", default-features = false, features = [
1919
"bevy_core_pipeline",
2020
"bevy_render",
2121
"bevy_window",
2222
] }
23-
bevy_egui = { version = "0.33", optional = true, default-features = false }
23+
bevy_egui = { version = "0.34", optional = true, default-features = false }
2424

2525
[dev-dependencies]
26-
bevy = { version = "0.15" }
26+
bevy = { version = "0.16" }
2727
float-cmp = "0.10.0"
28-
bevy_egui = { version = "0.33", default-features = false, features = [
28+
bevy_egui = { version = "0.34", default-features = false, features = [
2929
"render",
3030
"default_fonts",
3131
] }

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ all the possible configuration options.
6868

6969
| bevy | bevy_panorbit_camera |
7070
|------|----------------------|
71+
| 0.16 | 0.26 |
7172
| 0.15 | 0.21-0.25 |
7273
| 0.14 | 0.19-0.20 |
7374
| 0.13 | 0.14-0.18 |

examples/follow_target.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn animate_cube(
6464
mut cube_q: Query<&mut Transform, With<Cube>>,
6565
mut angle: Local<f32>,
6666
) {
67-
if let Ok(mut cube_tfm) = cube_q.get_single_mut() {
67+
if let Ok(mut cube_tfm) = cube_q.single_mut() {
6868
// Rotate 20 degrees a second, wrapping around to 0 after a full rotation
6969
*angle += 20f32.to_radians() * time.delta_secs() % TAU;
7070
// Convert angle to position
@@ -75,8 +75,8 @@ fn animate_cube(
7575

7676
/// Set the camera's focus to the cube's position
7777
fn cam_follow(mut pan_orbit_q: Query<&mut PanOrbitCamera>, cube_q: Query<&Transform, With<Cube>>) {
78-
if let Ok(mut pan_orbit) = pan_orbit_q.get_single_mut() {
79-
if let Ok(cube_tfm) = cube_q.get_single() {
78+
if let Ok(mut pan_orbit) = pan_orbit_q.single_mut() {
79+
if let Ok(cube_tfm) = cube_q.single() {
8080
pan_orbit.target_focus = cube_tfm.translation;
8181
// Whenever changing properties manually like this, it's necessary to force
8282
// PanOrbitCamera to update this frame (by default it only updates when there are

examples/multiple_viewports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn set_camera_viewports(
6868
) {
6969
for resize_event in resize_events.read() {
7070
let window = windows.get(resize_event.window).unwrap();
71-
let mut right_camera = right_camera.single_mut();
71+
let mut right_camera = right_camera.single_mut().unwrap();
7272
let size = window.resolution.physical_width() / 5;
7373
right_camera.viewport = Some(Viewport {
7474
physical_position: UVec2::new(window.resolution.physical_width() - size, 0),

examples/orthographic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn switch_projection(
5858
mut camera_query: Query<(&mut PanOrbitCamera, &mut Projection)>,
5959
) {
6060
if key_input.just_pressed(KeyCode::KeyR) {
61-
let Ok((mut camera, mut projection)) = camera_query.get_single_mut() else {
61+
let Ok((mut camera, mut projection)) = camera_query.single_mut() else {
6262
return;
6363
};
6464
std::mem::swap(&mut *next_projection, &mut *projection);

examples/render_to_texture.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use bevy::window::PrimaryWindow;
1212
use bevy::{
1313
prelude::*,
1414
render::{
15-
camera::RenderTarget,
15+
camera::{ImageRenderTarget, RenderTarget},
1616
render_resource::{
1717
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
1818
},
@@ -109,7 +109,7 @@ fn setup(
109109
// render before the "main pass" camera
110110
clear_color: ClearColorConfig::Custom(Color::WHITE),
111111
order: -1,
112-
target: RenderTarget::Image(image_handle.clone()),
112+
target: RenderTarget::Image(ImageRenderTarget::from(image_handle.clone())),
113113
..default()
114114
},
115115
Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)).looking_at(Vec3::ZERO, Vec3::Y),
@@ -148,7 +148,7 @@ fn setup(
148148
// Note: you probably want to update the `viewport_size` and `window_size` whenever they change,
149149
// I haven't done this here for simplicity.
150150
let primary_window = windows
151-
.get_single()
151+
.single()
152152
.expect("There is only ever one primary window");
153153
active_cam.set_if_neq(ActiveCameraData {
154154
// Set the entity to the entity ID of the camera you want to control. In this case, it's

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ fn active_viewport_data(
429429
// First check if cursor is in the same window as this camera
430430
if let RenderTarget::Window(win_ref) = camera.target {
431431
let Some(window) = (match win_ref {
432-
WindowRef::Primary => primary_windows.get_single().ok(),
432+
WindowRef::Primary => primary_windows.single().ok(),
433433
WindowRef::Entity(entity) => other_windows.get(entity).ok(),
434434
}) else {
435435
// Window does not exist - maybe it was closed and the camera not cleaned up
@@ -665,6 +665,7 @@ fn pan_orbit_camera(
665665
Projection::Orthographic(ref p) => {
666666
pan *= Vec2::new(p.area.width(), p.area.height()) / vp_size;
667667
}
668+
Projection::Custom(_) => todo!(),
668669
}
669670
// Translate by local axes
670671
let right = transform.rotation * pan_orbit.axis[0] * -pan.x;

0 commit comments

Comments
 (0)