Skip to content

Commit 7317473

Browse files
committed
use the default() method in examples instead of Default::default() (#4952)
# Objective - Use the `..default()` method in examples instead of `..Default::default()`
1 parent 649e30d commit 7317473

14 files changed

+52
-52
lines changed

examples/2d/transparency_2d.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
1717

1818
commands.spawn_bundle(SpriteBundle {
1919
texture: sprite_handle.clone(),
20-
..Default::default()
20+
..default()
2121
});
2222
commands.spawn_bundle(SpriteBundle {
2323
sprite: Sprite {
2424
// Alpha channel of the color controls transparency.
2525
color: Color::rgba(0.0, 0.0, 1.0, 0.7),
26-
..Default::default()
26+
..default()
2727
},
2828
texture: sprite_handle.clone(),
2929
transform: Transform::from_xyz(100.0, 0.0, 0.0),
30-
..Default::default()
30+
..default()
3131
});
3232
commands.spawn_bundle(SpriteBundle {
3333
sprite: Sprite {
3434
color: Color::rgba(0.0, 1.0, 0.0, 0.3),
35-
..Default::default()
35+
..default()
3636
},
3737
texture: sprite_handle,
3838
transform: Transform::from_xyz(200.0, 0.0, 0.0),
39-
..Default::default()
39+
..default()
4040
});
4141
}

examples/3d/shapes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn setup(
5555
),
5656
..default()
5757
},
58-
..Default::default()
58+
..default()
5959
})
6060
.insert(Shape);
6161
}
@@ -65,22 +65,22 @@ fn setup(
6565
intensity: 9000.0,
6666
range: 100.,
6767
shadows_enabled: true,
68-
..Default::default()
68+
..default()
6969
},
7070
transform: Transform::from_xyz(8.0, 16.0, 8.0),
71-
..Default::default()
71+
..default()
7272
});
7373

7474
// ground plane
7575
commands.spawn_bundle(PbrBundle {
7676
mesh: meshes.add(shape::Plane { size: 50. }.into()),
7777
material: materials.add(Color::SILVER.into()),
78-
..Default::default()
78+
..default()
7979
});
8080

8181
commands.spawn_bundle(Camera3dBundle {
8282
transform: Transform::from_xyz(0.0, 6., 12.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
83-
..Default::default()
83+
..default()
8484
});
8585
}
8686

examples/3d/transparency_3d.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn setup(
2525
commands.spawn_bundle(PbrBundle {
2626
mesh: meshes.add(Mesh::from(shape::Plane { size: 6.0 })),
2727
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
28-
..Default::default()
28+
..default()
2929
});
3030
// transparent sphere, using alpha_mode: Mask
3131
commands.spawn_bundle(PbrBundle {
@@ -45,7 +45,7 @@ fn setup(
4545
..default()
4646
}),
4747
transform: Transform::from_xyz(1.0, 0.5, -1.5),
48-
..Default::default()
48+
..default()
4949
});
5050
// transparent cube, using alpha_mode: Blend
5151
commands.spawn_bundle(PbrBundle {
@@ -55,7 +55,7 @@ fn setup(
5555
// automatically set to `Blend` if the alpha channel is anything lower than 1.0.
5656
material: materials.add(Color::rgba(0.5, 0.5, 1.0, 0.0).into()),
5757
transform: Transform::from_xyz(0.0, 0.5, 0.0),
58-
..Default::default()
58+
..default()
5959
});
6060
// sphere
6161
commands.spawn_bundle(PbrBundle {
@@ -65,22 +65,22 @@ fn setup(
6565
})),
6666
material: materials.add(Color::rgb(0.7, 0.2, 0.1).into()),
6767
transform: Transform::from_xyz(0.0, 0.5, -1.5),
68-
..Default::default()
68+
..default()
6969
});
7070
// light
7171
commands.spawn_bundle(PointLightBundle {
7272
point_light: PointLight {
7373
intensity: 1500.0,
7474
shadows_enabled: true,
75-
..Default::default()
75+
..default()
7676
},
7777
transform: Transform::from_xyz(4.0, 8.0, 4.0),
78-
..Default::default()
78+
..default()
7979
});
8080
// camera
8181
commands.spawn_bundle(Camera3dBundle {
8282
transform: Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
83-
..Default::default()
83+
..default()
8484
});
8585
}
8686

examples/animation/animated_fox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn setup(
3535
commands.spawn_bundle(Camera3dBundle {
3636
transform: Transform::from_xyz(100.0, 100.0, 150.0)
3737
.looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y),
38-
..Default::default()
38+
..default()
3939
});
4040

4141
// Plane

examples/animation/custom_skinned_mesh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() {
1818
.add_plugins(DefaultPlugins)
1919
.insert_resource(AmbientLight {
2020
brightness: 1.0,
21-
..Default::default()
21+
..default()
2222
})
2323
.add_startup_system(setup)
2424
.add_system(joint_animation)
@@ -152,7 +152,7 @@ fn setup(
152152
)
153153
.into(),
154154
),
155-
..Default::default()
155+
..default()
156156
})
157157
.insert(SkinnedMesh {
158158
inverse_bindposes: inverse_bindposes.clone(),

examples/animation/gltf_skinned_mesh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
.add_plugins(DefaultPlugins)
1111
.insert_resource(AmbientLight {
1212
brightness: 1.0,
13-
..Default::default()
13+
..default()
1414
})
1515
.add_startup_system(setup)
1616
.add_system(joint_animation)

examples/stress_tests/many_foxes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn setup(
148148
commands.spawn_bundle(Camera3dBundle {
149149
transform: Transform::from_translation(translation)
150150
.looking_at(0.2 * Vec3::new(translation.x, 0.0, translation.z), Vec3::Y),
151-
..Default::default()
151+
..default()
152152
});
153153

154154
// Plane

examples/transforms/3d_rotation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ fn setup(
3131
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
3232
material: materials.add(Color::WHITE.into()),
3333
transform: Transform::from_translation(Vec3::ZERO),
34-
..Default::default()
34+
..default()
3535
})
3636
.insert(Rotatable { speed: 0.3 });
3737

3838
// Spawn a camera looking at the entities to show what's happening in this example.
3939
commands.spawn_bundle(Camera3dBundle {
4040
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
41-
..Default::default()
41+
..default()
4242
});
4343

4444
// Add a light source for better 3d visibility.
4545
commands.spawn_bundle(PointLightBundle {
4646
transform: Transform::from_translation(Vec3::ONE * 3.0),
47-
..Default::default()
47+
..default()
4848
});
4949
}
5050

examples/transforms/global_vs_local_translation.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn setup(
5555
.insert_bundle(PbrBundle {
5656
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
5757
material: materials.add(Color::YELLOW.into()),
58-
..Default::default()
58+
..default()
5959
})
6060
.insert(ChangeGlobal)
6161
.insert(Move)
@@ -71,7 +71,7 @@ fn setup(
7171
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
7272
material: materials.add(Color::RED.into()),
7373
transform: Transform::from_translation(Vec3::Y - Vec3::Z),
74-
..Default::default()
74+
..default()
7575
})
7676
.insert(ChangeGlobal)
7777
.insert(Move)
@@ -81,7 +81,7 @@ fn setup(
8181
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
8282
material: materials.add(Color::GREEN.into()),
8383
transform: Transform::from_translation(Vec3::Y + Vec3::Z),
84-
..Default::default()
84+
..default()
8585
})
8686
.insert(ChangeLocal)
8787
.insert(Move)
@@ -91,13 +91,13 @@ fn setup(
9191
// Spawn a camera looking at the entities to show what's happening in this example.
9292
commands.spawn_bundle(Camera3dBundle {
9393
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
94-
..Default::default()
94+
..default()
9595
});
9696

9797
// Add a light source for better 3d visibility.
9898
commands.spawn_bundle(PointLightBundle {
9999
transform: Transform::from_translation(Vec3::splat(3.0)),
100-
..Default::default()
100+
..default()
101101
});
102102

103103
// Add text to explain inputs and what is happening.
@@ -115,10 +115,10 @@ The red cube is moved through its GlobalTransform and thus is unaffected by the
115115
},
116116
TextAlignment {
117117
horizontal: HorizontalAlign::Left,
118-
..Default::default()
118+
..default()
119119
},
120120
),
121-
..Default::default()
121+
..default()
122122
});
123123
}
124124

examples/transforms/scale.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ fn setup(
4646
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
4747
material: materials.add(Color::WHITE.into()),
4848
transform: Transform::from_rotation(Quat::from_rotation_y(PI / 4.0)),
49-
..Default::default()
49+
..default()
5050
})
5151
.insert(Scaling::new());
5252

5353
// Spawn a camera looking at the entities to show what's happening in this example.
5454
commands.spawn_bundle(Camera3dBundle {
5555
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
56-
..Default::default()
56+
..default()
5757
});
5858

5959
// Add a light source for better 3d visibility.
6060
commands.spawn_bundle(PointLightBundle {
6161
transform: Transform::from_translation(Vec3::ONE * 3.0),
62-
..Default::default()
62+
..default()
6363
});
6464
}
6565

examples/transforms/transform.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn setup(
4646
})),
4747
material: materials.add(Color::YELLOW.into()),
4848
transform: Transform::from_translation(Vec3::ZERO),
49-
..Default::default()
49+
..default()
5050
})
5151
.insert(Center {
5252
max_size: 1.0,
@@ -67,7 +67,7 @@ fn setup(
6767
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
6868
material: materials.add(Color::WHITE.into()),
6969
transform: cube_spawn,
70-
..Default::default()
70+
..default()
7171
})
7272
.insert(CubeState {
7373
start_pos: cube_spawn.translation,
@@ -78,13 +78,13 @@ fn setup(
7878
// Spawn a camera looking at the entities to show what's happening in this example.
7979
commands.spawn_bundle(Camera3dBundle {
8080
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
81-
..Default::default()
81+
..default()
8282
});
8383

8484
// Add a light source for better 3d visibility.
8585
commands.spawn_bundle(PointLightBundle {
8686
transform: Transform::from_translation(Vec3::ONE * 3.0),
87-
..Default::default()
87+
..default()
8888
});
8989
}
9090

examples/transforms/translation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ fn setup(
4343
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
4444
material: materials.add(Color::WHITE.into()),
4545
transform: Transform::from_translation(entity_spawn),
46-
..Default::default()
46+
..default()
4747
})
4848
.insert(Movable::new(entity_spawn));
4949

5050
// Spawn a camera looking at the entities to show what's happening in this example.
5151
commands.spawn_bundle(Camera3dBundle {
5252
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(entity_spawn, Vec3::Y),
53-
..Default::default()
53+
..default()
5454
});
5555

5656
// Add a light source for better 3d visibility.
5757
commands.spawn_bundle(PointLightBundle {
5858
transform: Transform::from_translation(Vec3::ONE * 3.0),
59-
..Default::default()
59+
..default()
6060
});
6161
}
6262

examples/ui/transparency_ui.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
2323
margin: UiRect::all(Val::Auto),
2424
justify_content: JustifyContent::Center,
2525
align_items: AlignItems::Center,
26-
..Default::default()
26+
..default()
2727
},
2828
color: Color::rgb(0.1, 0.5, 0.1).into(),
29-
..Default::default()
29+
..default()
3030
})
3131
.with_children(|parent| {
3232
parent.spawn_bundle(TextBundle {
@@ -40,7 +40,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
4040
},
4141
Default::default(),
4242
),
43-
..Default::default()
43+
..default()
4444
});
4545
});
4646

@@ -53,10 +53,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
5353
margin: UiRect::all(Val::Auto),
5454
justify_content: JustifyContent::Center,
5555
align_items: AlignItems::Center,
56-
..Default::default()
56+
..default()
5757
},
5858
color: Color::rgb(0.5, 0.1, 0.5).into(),
59-
..Default::default()
59+
..default()
6060
})
6161
.with_children(|parent| {
6262
parent.spawn_bundle(TextBundle {
@@ -70,7 +70,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
7070
},
7171
Default::default(),
7272
),
73-
..Default::default()
73+
..default()
7474
});
7575
});
7676
}

0 commit comments

Comments
 (0)