Skip to content

Commit 64232c2

Browse files
committed
Update to Bevy 0.15
1 parent 8a84314 commit 64232c2

File tree

5 files changed

+41
-34
lines changed

5 files changed

+41
-34
lines changed

Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_spectator"
33
description = "A spectator camera plugin for Bevy"
4-
version = "0.6.0"
4+
version = "0.7.0"
55
edition = "2021"
66
authors = ["JonahPlusPlus <[email protected]>"]
77
license = "MIT OR Apache-2.0"
@@ -11,15 +11,16 @@ repository = "https://github.com/JonahPlusPlus/bevy_spectator"
1111
exclude = ["/examples/"]
1212

1313
[dependencies]
14-
bevy = { version = "0.14", default-features = false }
14+
bevy = { version = "0.15", default-features = false, features = ["bevy_window"] }
1515

1616
[dev-dependencies]
17-
bevy = { version = "0.14", default-features = false, features = [
17+
bevy = { version = "0.15", default-features = false, features = [
1818
"bevy_asset",
1919
"bevy_core_pipeline",
2020
"bevy_pbr",
2121
"bevy_render",
2222
"bevy_sprite",
23+
"bevy_window",
2324
"x11",
2425
"ktx2",
2526
"zstd",
@@ -33,3 +34,7 @@ init = [] # Enables automatically choosing a camera
3334
[[example]]
3435
name = "3d_scene"
3536
path = "examples/3d_scene.rs"
37+
38+
[[example]]
39+
name = "2d_scene"
40+
path = "examples/2d_scene.rs"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn setup(mut commands: Commands) {
4747

4848
| bevy | bevy_spectator |
4949
|------|----------------|
50+
| 0.15 | 0.7 |
5051
| 0.14 | 0.6 |
5152
| 0.13 | 0.5 |
5253
| 0.12 | 0.4 |

examples/2d_scene.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ fn main() {
1717
}
1818

1919
fn setup(mut commands: Commands) {
20-
commands.spawn((Camera2dBundle::default(), Spectator));
21-
commands.spawn(SpriteBundle {
22-
transform: Transform {
23-
scale: Vec3::new(10.0, 10.0, 1.0),
24-
..default()
25-
},
26-
..default()
27-
});
20+
// Sprite
21+
commands.spawn((
22+
Sprite::default(),
23+
Transform::default().with_scale(Vec3::new(10.0, 10.0, 1.0)),
24+
));
25+
26+
// Camera
27+
commands.spawn((
28+
Camera2d::default(),
29+
Spectator,
30+
));
2831
}

examples/3d_scene.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,31 @@ fn setup(
2222
mut materials: ResMut<Assets<StandardMaterial>>,
2323
) {
2424
// plane
25-
commands.spawn(PbrBundle {
26-
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
27-
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
28-
..default()
29-
});
25+
commands.spawn((
26+
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
27+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
28+
));
29+
3030
// cube
31-
commands.spawn(PbrBundle {
32-
mesh: meshes.add(Cuboid::default()),
33-
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
34-
transform: Transform::from_xyz(0.0, 0.5, 0.0),
35-
..default()
36-
});
31+
commands.spawn((
32+
Mesh3d(meshes.add(Cuboid::default())),
33+
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
34+
Transform::from_xyz(0.0, 0.5, 0.0),
35+
));
36+
3737
// light
38-
commands.spawn(PointLightBundle {
39-
point_light: PointLight {
38+
commands.spawn((
39+
PointLight {
4040
shadows_enabled: true,
4141
..default()
4242
},
43-
transform: Transform::from_xyz(4.0, 8.0, 4.0),
44-
..default()
45-
});
43+
Transform::from_xyz(4.0, 8.0, 4.0),
44+
));
45+
4646
// camera
4747
commands.spawn((
48-
Camera3dBundle {
49-
transform: Transform::from_xyz(-3.0, 1.5, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
50-
..default()
51-
},
48+
Camera3d::default(),
49+
Transform::from_xyz(-3.0, 1.5, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
5250
Spectator,
5351
));
5452
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ fn spectator_update(
108108
true => CursorGrabMode::Confined,
109109
false => CursorGrabMode::None,
110110
};
111-
window.cursor.grab_mode = grab_mode;
112-
window.cursor.visible = !focused;
111+
window.cursor_options.grab_mode = grab_mode;
112+
window.cursor_options.visible = !focused;
113113
}
114114
};
115115

@@ -208,7 +208,7 @@ fn spectator_update(
208208

209209
let result = forward * delta_axial + right * delta_lateral + up * delta_vertical;
210210

211-
camera_transform.translation += result * time.delta_seconds();
211+
camera_transform.translation += result * time.delta_secs();
212212
}
213213
}
214214

0 commit comments

Comments
 (0)