Skip to content

Commit 4185311

Browse files
authored
fix: update component spawning to bevy 0.15 usage (#103)
1 parent 538421e commit 4185311

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

examples/might/src/main.rs

+19-28
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ fn setup(
6060
mut materials: ResMut<Assets<StandardMaterial>>,
6161
) {
6262
commands.spawn((
63-
Camera3dBundle {
64-
transform: Transform::from_xyz(2.0, 6.0, 6.0)
65-
.looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
66-
..default()
67-
},
63+
Camera3d::default(),
64+
Transform::from_xyz(2.0, 6.0, 6.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
6865
PanOrbitCamera::default(),
6966
EnvironmentMapLight {
7067
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
@@ -74,32 +71,29 @@ fn setup(
7471
},
7572
));
7673

77-
commands.spawn(DirectionalLightBundle {
78-
directional_light: DirectionalLight {
74+
commands.spawn((
75+
DirectionalLight {
7976
shadows_enabled: true,
8077
..default()
8178
},
82-
cascade_shadow_config: CascadeShadowConfigBuilder {
79+
CascadeShadowConfigBuilder {
8380
num_cascades: 1,
8481
maximum_distance: 1.6,
8582
..default()
86-
}
87-
.into(),
88-
..default()
89-
});
83+
}.build(),
84+
));
9085

9186
// ground plane
92-
commands.spawn(PbrBundle {
93-
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
94-
material: materials.add(StandardMaterial {
87+
commands.spawn((
88+
Mesh3d(meshes.add(Plane3d::default().mesh().size(50.0, 50.0))),
89+
MeshMaterial3d(materials.add(StandardMaterial {
9590
base_color: Color::BLACK,
9691
perceptual_roughness: 1.0,
9792
double_sided: false,
9893
unlit: true,
9994
..default()
100-
}),
101-
..default()
102-
});
95+
})),
96+
));
10397
}
10498

10599
// Loads our knight into the asset server, it isn't spawned.
@@ -128,16 +122,12 @@ fn spawn_knight(
128122
let as_custom_mat = AuraMaterial { inner: 0.0 };
129123

130124
commands
131-
.spawn(SceneBundle {
132-
scene: gltf.scenes[0].clone(),
133-
..Default::default()
134-
})
125+
.spawn(SceneRoot(gltf.scenes[0].clone()))
135126
.with_children(|parent| {
136-
parent.spawn(MaterialMeshBundle {
137-
mesh: meshes.add(disc),
138-
material: materials.add(as_custom_mat),
139-
..default()
140-
});
127+
parent.spawn((
128+
Mesh3d(meshes.add(disc)),
129+
MeshMaterial3d(materials.add(as_custom_mat)),
130+
));
141131
});
142132

143133
was_loaded.0 = true;
@@ -155,7 +145,7 @@ fn animate_light_direction(
155145
transform.rotation = Quat::from_euler(
156146
EulerRot::ZYX,
157147
0.0,
158-
time.elapsed_seconds() * PI / 5.0,
148+
time.elapsed_secs() * PI / 5.0,
159149
-FRAC_PI_4,
160150
);
161151
}
@@ -186,3 +176,4 @@ fn quit_listener(input: Res<ButtonInput<KeyCode>>) {
186176
std::process::exit(0)
187177
}
188178
}
179+

0 commit comments

Comments
 (0)