Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to bevy 0.15 #87

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
dmlukichev marked this conversation as resolved.
Show resolved Hide resolved
/target
/Cargo.lock
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.21

- Update to Bevy 0.15

## 0.20

- Change `zoom_lower_limit` from `Option<f32>` to `f32`, defaulting to `0.05`, and remove the hard coded lower zoom limit of `0.05`.
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_panorbit_camera"
version = "0.20.0"
version = "0.21.0-rc.3"
authors = ["Plonq"]
edition = "2021"
description = "A basic pan and orbit camera in Bevy"
Expand All @@ -15,13 +15,13 @@ readme = "README.md"
bevy_egui = ["dep:bevy_egui"]

[dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15.0-rc.3", default-features = false, features = [
"bevy_render",
] }
bevy_egui = { version = "0.30", optional = true, default-features = false }

[dev-dependencies]
bevy = { version = "0.14" }
bevy = { version = "0.15.0-rc.3" }
float-cmp = "0.9.0"
bevy_egui = { version = "0.30", default-features = false, features = [
"render",
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ Add `PanOrbitCamera` to a camera:

```rust ignore
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
..default()
},
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
```
Expand All @@ -71,6 +69,7 @@ all the possible configuration options.

| bevy | bevy_panorbit_camera |
|------|----------------------|
| 0.15 | 0.21 |
| 0.14 | 0.19-0.20 |
| 0.13 | 0.14-0.18 |
| 0.12 | 0.9-0.13 |
Expand Down
31 changes: 14 additions & 17 deletions examples/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,29 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Ground
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
// Cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
// Camera
commands.spawn((
// Note we're setting the initial position below with yaw, pitch, and radius, hence
// we don't set transform on the camera.
Camera3dBundle::default(),
Camera3d::default(),
PanOrbitCamera {
// Set focal point (what the camera should look at)
focus: Vec3::new(0.0, 1.0, 0.0),
Expand Down
41 changes: 18 additions & 23 deletions examples/animate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,28 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Ground
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
// Cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
..default()
},
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera {
// Disable smoothing, since the animation takes care of that
orbit_smoothness: 0.0,
Expand All @@ -60,10 +55,10 @@ fn setup(
fn animate(time: Res<Time>, mut pan_orbit_query: Query<&mut PanOrbitCamera>) {
for mut pan_orbit in pan_orbit_query.iter_mut() {
// Must set target values, not yaw/pitch directly
pan_orbit.target_yaw += 15f32.to_radians() * time.delta_seconds();
pan_orbit.target_pitch = time.elapsed_seconds_wrapped().sin() * TAU * 0.1;
pan_orbit.target_yaw += 15f32.to_radians() * time.delta_secs();
pan_orbit.target_pitch = time.elapsed_secs_wrapped().sin() * TAU * 0.1;
pan_orbit.radius =
Some((((time.elapsed_seconds_wrapped() * 2.0).cos() + 1.0) * 0.5) * 2.0 + 4.0);
Some((((time.elapsed_secs_wrapped() * 2.0).cos() + 1.0) * 0.5) * 2.0 + 4.0);

// Force camera to update its transform
pan_orbit.force_update = true;
Expand Down
35 changes: 15 additions & 20 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,28 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Ground
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
// Cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
..default()
},
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
}
35 changes: 15 additions & 20 deletions examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,28 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Ground
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
// Cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
..default()
},
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
PanOrbitCamera::default(),
));
}
Expand Down
37 changes: 16 additions & 21 deletions examples/follow_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,30 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Ground
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
// Cube
commands
.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
})
.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
))
.insert(Cube);
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
..default()
},
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
// panning when setting the focus manually
Expand All @@ -72,7 +67,7 @@ fn animate_cube(
) {
if let Ok(mut cube_tfm) = cube_q.get_single_mut() {
// Rotate 20 degrees a second, wrapping around to 0 after a full rotation
*angle += 20f32.to_radians() * time.delta_seconds() % TAU;
*angle += 20f32.to_radians() * time.delta_secs() % TAU;
// Convert angle to position
let pos = Vec3::new(angle.sin() * 1.5, 0.5, angle.cos() * 1.5);
cube_tfm.translation = pos;
Expand Down
Loading
Loading