Skip to content

Commit fb77a38

Browse files
committed
fmt
1 parent 1c40fa6 commit fb77a38

12 files changed

+117
-121
lines changed

examples/2d_cam_move.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
2525

2626
let mut dolly = Sprite::from_image(asset_server.load("bevy_dolly.png"));
2727
dolly.custom_size = Some(Vec2::new(128., 128.));
28-
commands.spawn((dolly, offset_transform.with_translation(Vec3 { x: 0., y: 0., z: 1. })));
28+
commands.spawn((
29+
dolly,
30+
offset_transform.with_translation(Vec3 {
31+
x: 0.,
32+
y: 0.,
33+
z: 1.,
34+
}),
35+
));
2936

3037
commands.spawn((
3138
Camera2d::default(),

examples/2d_edge_snap.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,25 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
3131
let mut dolly = Sprite::from_image(asset_server.load("bevy_dolly.png"));
3232
dolly.custom_size = Some(Vec2::new(128., 128.));
3333
commands.spawn((
34-
dolly,
35-
offset_transform.with_translation(Vec3 { x: 0., y: 0., z: 1. }),
36-
Direction::Right
37-
)
38-
);
34+
dolly,
35+
offset_transform.with_translation(Vec3 {
36+
x: 0.,
37+
y: 0.,
38+
z: 1.,
39+
}),
40+
Direction::Right,
41+
));
3942

4043
let mut room = Sprite::from_image(asset_server.load("room.png"));
4144
room.custom_size = Some(Vec2::new(2.6 * 800., 800.));
42-
commands.spawn((room, offset_transform.with_translation(Vec3 { x: 0., y: 200., z: 0. })));
45+
commands.spawn((
46+
room,
47+
offset_transform.with_translation(Vec3 {
48+
x: 0.,
49+
y: 200.,
50+
z: 0.,
51+
}),
52+
));
4353

4454
let mut room_end = Sprite::from_image(asset_server.load("room_end.png"));
4555
commands.spawn((room_end.clone(), Transform::from_xyz(1016., -104.5, 2.0)));

examples/2d_fight_cam.rs

+23-13
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,44 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
3535
dolly.custom_size = Some(Vec2::new(128., 128.));
3636

3737
commands.spawn((
38-
dolly.clone(),
39-
offset_transform.with_translation(Vec3 { x: 0., y: 0., z: 1. }),
38+
dolly.clone(),
39+
offset_transform.with_translation(Vec3 {
40+
x: 0.,
41+
y: 0.,
42+
z: 1.,
43+
}),
4044
Direction::Right,
41-
PlayerOne
45+
PlayerOne,
4246
));
4347

4448
dolly.flip_x = true;
4549
commands.spawn((
46-
dolly,
47-
offset_transform.with_translation(Vec3 { x: 0., y: 0., z: 1. }),
48-
PlayerTwo
50+
dolly,
51+
offset_transform.with_translation(Vec3 {
52+
x: 0.,
53+
y: 0.,
54+
z: 1.,
55+
}),
56+
PlayerTwo,
4957
));
5058

5159
let mut room = Sprite::from_image(asset_server.load("room.png"));
5260
room.custom_size = Some(Vec2::new(2.6 * 800., 800.));
53-
commands.spawn((room, offset_transform.with_translation(Vec3 { x: 0., y: 200., z: 0. })));
61+
commands.spawn((
62+
room,
63+
offset_transform.with_translation(Vec3 {
64+
x: 0.,
65+
y: 200.,
66+
z: 0.,
67+
}),
68+
));
5469

5570
let mut room_end = Sprite::from_image(asset_server.load("room_end.png"));
5671
commands.spawn((room_end.clone(), Transform::from_xyz(1016., -104.5, 2.0)));
5772

5873
room_end.flip_x = true;
5974
commands.spawn((room_end, Transform::from_xyz(-1016., -104.5, 2.0)));
6075

61-
6276
commands.spawn((
6377
MainCamera,
6478
Rig::builder()
@@ -71,11 +85,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
7185

7286
fn draw_gizmo(mut gizmos: Gizmos, q0: Query<&Transform, With<MainCamera>>) {
7387
for a in &q0 {
74-
gizmos.rect_2d(
75-
a.translation.truncate(),
76-
Vec2::splat(300.),
77-
Color::BLACK,
78-
);
88+
gizmos.rect_2d(a.translation.truncate(), Vec2::splat(300.), Color::BLACK);
7989
}
8090
}
8191

examples/custom.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn setup(
3131
// plane
3232
commands.spawn((
3333
Mesh3d(meshes.add(Plane3d::default().mesh().size(5., 5.))),
34-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
34+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
3535
));
3636

3737
let start_pos = Vec3::new(0., 0., 0.);
@@ -41,7 +41,7 @@ fn setup(
4141
commands.spawn((
4242
SceneRoot(poly_dolly),
4343
Transform::from_xyz(0., 0.2, 0.),
44-
Rotates
44+
Rotates,
4545
));
4646

4747
commands.spawn((
@@ -50,14 +50,11 @@ fn setup(
5050
.with(MovableLookAt::from_position_target(start_pos))
5151
.build(),
5252
Camera3d::default(),
53-
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y)
53+
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y),
5454
));
5555

5656
// light
57-
commands.spawn((
58-
PointLight::default(),
59-
Transform::from_xyz(4.0, 8.0, 4.0)
60-
));
57+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
6158
}
6259

6360
fn update_camera(q0: Query<&Transform, With<Rotates>>, mut q1: Query<&mut Rig>) {
@@ -73,8 +70,8 @@ struct Rotates;
7370

7471
fn rotator_system(time: Res<Time>, mut query: Query<&mut Transform, With<Rotates>>) {
7572
for mut transform in query.iter_mut() {
76-
*transform = Transform::from_rotation(Quat::from_rotation_y(
77-
(4.0 * PI / 20.0) * time.delta_secs(),
78-
)) * *transform;
73+
*transform =
74+
Transform::from_rotation(Quat::from_rotation_y((4.0 * PI / 20.0) * time.delta_secs()))
75+
* *transform;
7976
}
8077
}

examples/follow.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn setup(
3131
// plane
3232
commands.spawn((
3333
Mesh3d(meshes.add(Plane3d::default().mesh().size(5., 5.))),
34-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
34+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
3535
));
3636

3737
let start_pos = Vec3::new(0., 0., 0.);
@@ -41,7 +41,7 @@ fn setup(
4141
commands.spawn((
4242
SceneRoot(poly_dolly),
4343
Transform::from_xyz(0., 0.2, 0.),
44-
Rotates
44+
Rotates,
4545
));
4646

4747
commands.spawn((
@@ -50,14 +50,11 @@ fn setup(
5050
.with(MovableLookAt::from_position_target(start_pos))
5151
.build(),
5252
Camera3d::default(),
53-
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y)
53+
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y),
5454
));
5555

5656
// light
57-
commands.spawn((
58-
PointLight::default(),
59-
Transform::from_xyz(4.0, 8.0, 4.0)
60-
));
57+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
6158
}
6259

6360
fn update_camera(q0: Query<&Transform, With<Rotates>>, mut q1: Query<&mut Rig>) {
@@ -73,8 +70,8 @@ struct Rotates;
7370

7471
fn rotator_system(time: Res<Time>, mut query: Query<&mut Transform, With<Rotates>>) {
7572
for mut transform in query.iter_mut() {
76-
*transform = Transform::from_rotation(Quat::from_rotation_y(
77-
(4.0 * PI / 20.0) * time.delta_secs(),
78-
)) * *transform;
73+
*transform =
74+
Transform::from_rotation(Quat::from_rotation_y((4.0 * PI / 20.0) * time.delta_secs()))
75+
* *transform;
7976
}
8077
}

examples/fpv.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ fn setup(
3737
// plane
3838
commands.spawn((
3939
Mesh3d(meshes.add(Plane3d::default().mesh().size(5., 5.))),
40-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
40+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
4141
));
4242

4343
let poly_dolly = asset_server.load(GltfAssetLabel::Scene(0).from_asset("poly_dolly.gltf"));
4444

45-
commands.spawn((
46-
SceneRoot(poly_dolly),
47-
Transform::from_xyz(0., 0.2, 0.),
48-
));
45+
commands.spawn((SceneRoot(poly_dolly), Transform::from_xyz(0., 0.2, 0.)));
4946

5047
let translation = [2.0f32, 2.0f32, 5.0f32];
5148
let transform =
@@ -57,14 +54,11 @@ fn setup(
5754
.with(Fpv::from_position_target(transform))
5855
.build(),
5956
Camera3d::default(),
60-
transform
57+
transform,
6158
));
6259

6360
// light
64-
commands.spawn((
65-
PointLight::default(),
66-
Transform::from_xyz(4.0, 8.0, 4.0)
67-
));
61+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
6862

6963
info!("Use W, A, S, D for movement");
7064
info!("Use Space/E and Ctrl/Q for going up and down");

examples/inspector_egui.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,21 @@ fn setup(
2222
// plane
2323
commands.spawn((
2424
Mesh3d(meshes.add(Plane3d::default().mesh().size(20., 20.))),
25-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
25+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
2626
));
2727

2828
commands.spawn((
2929
MainCamera,
3030
Rig::builder()
31-
.with(Position::new(Vec3::Y * 3.0))
32-
.with(LookAt::new(Vec3::new(0., -2., 2.)))
31+
.with(Position::new(Vec3::Y * 3.0))
32+
.with(LookAt::new(Vec3::new(0., -2., 2.)))
3333
.build(),
3434
Camera3d::default(),
35-
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y)
35+
Transform::from_xyz(-2.0, 1., 5.0).looking_at(Vec3::ZERO, Vec3::Y),
3636
));
3737

3838
// light
39-
commands.spawn((
40-
PointLight::default(),
41-
Transform::from_xyz(4.0, 8.0, 4.0)
42-
));
39+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
4340

4441
info!("Use W, A, S, D for movement");
4542
info!("Use Space and Shift for going up and down");

examples/minimal.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn setup(
2626
// plane
2727
commands.spawn((
2828
Mesh3d(meshes.add(Plane3d::default().mesh().size(20., 20.))),
29-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
29+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
3030
));
3131

3232
commands.spawn((
@@ -39,14 +39,11 @@ fn setup(
3939
))
4040
.build(),
4141
Camera3d::default(),
42-
Transform::from_xyz(-2.0, 2., 5.0).looking_at(Vec3::ZERO, Vec3::Y)
42+
Transform::from_xyz(-2.0, 2., 5.0).looking_at(Vec3::ZERO, Vec3::Y),
4343
));
4444

4545
// light
46-
commands.spawn((
47-
PointLight::default(),
48-
Transform::from_xyz(4.0, 8.0, 4.0)
49-
));
46+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
5047

5148
info!("Use W, A, S, D for movement");
5249
info!("Use Space and Shift for going up and down");

examples/orbit.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ fn setup(
6464
// plane
6565
commands.spawn((
6666
Mesh3d(meshes.add(Plane3d::default().mesh().size(5., 5.))),
67-
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3)))
67+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
6868
));
6969

7070
let poly_dolly = asset_server.load(GltfAssetLabel::Scene(0).from_asset("poly_dolly.gltf"));
7171

7272
commands.spawn((
7373
SceneRoot(poly_dolly),
7474
Transform::from_xyz(0., 0.2, 0.),
75-
DollyPosCtrlMove
75+
DollyPosCtrlMove,
7676
));
7777

7878
commands.spawn((
@@ -89,26 +89,25 @@ fn setup(
8989
let start_transform = Transform::from_xyz(10.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y);
9090

9191
let orth = Projection::from(OrthographicProjection {
92-
scaling_mode: ScalingMode::FixedVertical { viewport_height: 2.0 },
92+
scaling_mode: ScalingMode::FixedVertical {
93+
viewport_height: 2.0,
94+
},
9395
scale: 3.,
9496
..OrthographicProjection::default_3d()
9597
});
9698

9799
let pers = Projection::from(PerspectiveProjection::default());
98100

99101
if *startup_perspective == ProjectionType::Orthographic {
100-
commands.spawn((MainCamera, orth,start_transform));
101-
commands.spawn((SecondCamera, pers,start_transform));
102+
commands.spawn((MainCamera, orth, start_transform));
103+
commands.spawn((SecondCamera, pers, start_transform));
102104
} else {
103-
commands.spawn((MainCamera, pers,start_transform));
104-
commands.spawn((SecondCamera, orth,start_transform));
105+
commands.spawn((MainCamera, pers, start_transform));
106+
commands.spawn((SecondCamera, orth, start_transform));
105107
}
106108

107109
// light
108-
commands.spawn((
109-
PointLight::default(),
110-
Transform::from_xyz(4.0, 8.0, 4.0)
111-
));
110+
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
112111

113112
info!("Use W, A, S, D for movement");
114113
info!("Use Space and Shift for going up and down");

0 commit comments

Comments
 (0)