From e728570872f566dea80cee397a84bb4cda09daea Mon Sep 17 00:00:00 2001 From: krunchington Date: Tue, 11 Mar 2025 20:39:32 -0700 Subject: [PATCH 1/3] Update shader_prepass example to use children! macro --- examples/shader/shader_prepass.rs | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/examples/shader/shader_prepass.rs b/examples/shader/shader_prepass.rs index b53f9fe941729..00059a35e084b 100644 --- a/examples/shader/shader_prepass.rs +++ b/examples/shader/shader_prepass.rs @@ -123,23 +123,22 @@ fn setup( Transform::from_xyz(4.0, 8.0, 4.0), )); - commands - .spawn(( - Text::default(), - Node { - position_type: PositionType::Absolute, - top: Val::Px(12.0), - left: Val::Px(12.0), - ..default() - }, - )) - .with_children(|p| { - p.spawn(TextSpan::new("Prepass Output: transparent\n")); - p.spawn(TextSpan::new("\n\n")); - p.spawn(TextSpan::new("Controls\n")); - p.spawn(TextSpan::new("---------------\n")); - p.spawn(TextSpan::new("Space - Change output\n")); - }); + commands.spawn(( + Text::default(), + Node { + position_type: PositionType::Absolute, + top: Val::Px(12.0), + left: Val::Px(12.0), + ..default() + }, + children![ + TextSpan::new("Prepass Output: transparent\n"), + TextSpan::new("\n\n"), + TextSpan::new("Controls\n"), + TextSpan::new("---------------\n"), + TextSpan::new("Space - Change output\n"), + ], + )); } // This is the struct that will be passed to your shader From 5f6dd91f9ae1178b1d44d6210d3812f7effb884b Mon Sep 17 00:00:00 2001 From: krunchington Date: Tue, 11 Mar 2025 20:45:31 -0700 Subject: [PATCH 2/3] Update testbed_2d example to use children! macro --- examples/testbed/2d.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/testbed/2d.rs b/examples/testbed/2d.rs index d3e7d46217e3e..2e7ef52546b13 100644 --- a/examples/testbed/2d.rs +++ b/examples/testbed/2d.rs @@ -226,20 +226,19 @@ mod text { Transform::from_translation(dest + Vec3::Z), anchor, StateScoped(super::Scene::Text), + children![ + ( + TextSpan::new(format!("{}, {}\n", anchor.x, anchor.y)), + TextFont::from_font_size(14.0), + TextColor(palettes::tailwind::BLUE_400.into()), + ), + ( + TextSpan::new(format!("{justify:?}")), + TextFont::from_font_size(14.0), + TextColor(palettes::tailwind::GREEN_400.into()), + ), + ], )); - text.with_children(|parent| { - parent.spawn(( - TextSpan::new(format!("{}, {}\n", anchor.x, anchor.y)), - TextFont::from_font_size(14.0), - TextColor(palettes::tailwind::BLUE_400.into()), - )); - parent.spawn(( - TextSpan::new(format!("{justify:?}")), - TextFont::from_font_size(14.0), - TextColor(palettes::tailwind::GREEN_400.into()), - )); - }); - if let Some(bounds) = bounds { text.insert(bounds); From bf367c54b056e5cad5a386be30b695a91da220ed Mon Sep 17 00:00:00 2001 From: krunchington Date: Tue, 11 Mar 2025 20:55:03 -0700 Subject: [PATCH 3/3] Update first_person_view_model example to use children! macro --- examples/camera/first_person_view_model.rs | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/camera/first_person_view_model.rs b/examples/camera/first_person_view_model.rs index 56a24e9119330..09ff0d17bf1a6 100644 --- a/examples/camera/first_person_view_model.rs +++ b/examples/camera/first_person_view_model.rs @@ -104,25 +104,22 @@ fn spawn_view_model( let arm = meshes.add(Cuboid::new(0.1, 0.1, 0.5)); let arm_material = materials.add(Color::from(tailwind::TEAL_200)); - commands - .spawn(( - Player, - CameraSensitivity::default(), - Transform::from_xyz(0.0, 1.0, 0.0), - Visibility::default(), - )) - .with_children(|parent| { - parent.spawn(( + commands.spawn(( + Player, + CameraSensitivity::default(), + Transform::from_xyz(0.0, 1.0, 0.0), + Visibility::default(), + children![ + ( WorldModelCamera, Camera3d::default(), Projection::from(PerspectiveProjection { fov: 90.0_f32.to_radians(), ..default() }), - )); - + ), // Spawn view model camera. - parent.spawn(( + ( Camera3d::default(), Camera { // Bump the order to render on top of the world model. @@ -135,10 +132,9 @@ fn spawn_view_model( }), // Only render objects belonging to the view model. RenderLayers::layer(VIEW_MODEL_RENDER_LAYER), - )); - + ), // Spawn the player's right arm. - parent.spawn(( + ( Mesh3d(arm), MeshMaterial3d(arm_material), Transform::from_xyz(0.2, -0.1, -0.25), @@ -146,8 +142,9 @@ fn spawn_view_model( RenderLayers::layer(VIEW_MODEL_RENDER_LAYER), // The arm is free-floating, so shadows would look weird. NotShadowCaster, - )); - }); + ), + ], + )); } fn spawn_world_model(