Skip to content

Commit 234fdfa

Browse files
committed
Update first_person_view_model example to use children! macro
1 parent 61c6bd9 commit 234fdfa

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

examples/camera/first_person_view_model.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,22 @@ fn spawn_view_model(
104104
let arm = meshes.add(Cuboid::new(0.1, 0.1, 0.5));
105105
let arm_material = materials.add(Color::from(tailwind::TEAL_200));
106106

107-
commands
108-
.spawn((
109-
Player,
110-
CameraSensitivity::default(),
111-
Transform::from_xyz(0.0, 1.0, 0.0),
112-
Visibility::default(),
113-
))
114-
.with_children(|parent| {
115-
parent.spawn((
107+
commands.spawn((
108+
Player,
109+
CameraSensitivity::default(),
110+
Transform::from_xyz(0.0, 1.0, 0.0),
111+
Visibility::default(),
112+
children![
113+
(
116114
WorldModelCamera,
117115
Camera3d::default(),
118116
Projection::from(PerspectiveProjection {
119117
fov: 90.0_f32.to_radians(),
120118
..default()
121119
}),
122-
));
123-
120+
),
124121
// Spawn view model camera.
125-
parent.spawn((
122+
(
126123
Camera3d::default(),
127124
Camera {
128125
// Bump the order to render on top of the world model.
@@ -135,19 +132,19 @@ fn spawn_view_model(
135132
}),
136133
// Only render objects belonging to the view model.
137134
RenderLayers::layer(VIEW_MODEL_RENDER_LAYER),
138-
));
139-
135+
),
140136
// Spawn the player's right arm.
141-
parent.spawn((
137+
(
142138
Mesh3d(arm),
143139
MeshMaterial3d(arm_material),
144140
Transform::from_xyz(0.2, -0.1, -0.25),
145141
// Ensure the arm is only rendered by the view model camera.
146142
RenderLayers::layer(VIEW_MODEL_RENDER_LAYER),
147143
// The arm is free-floating, so shadows would look weird.
148144
NotShadowCaster,
149-
));
150-
});
145+
),
146+
],
147+
));
151148
}
152149

153150
fn spawn_world_model(

0 commit comments

Comments
 (0)