Skip to content

Commit

Permalink
use the default() method in examples instead of Default::default() (#…
Browse files Browse the repository at this point in the history
…4952)

# Objective

- Use the `..default()` method in examples instead of `..Default::default()`
  • Loading branch information
mockersf authored and james7132 committed Jun 7, 2022
1 parent 9f6c741 commit 56ac553
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 52 deletions.
10 changes: 5 additions & 5 deletions examples/2d/transparency_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {

commands.spawn_bundle(SpriteBundle {
texture: sprite_handle.clone(),
..Default::default()
..default()
});
commands.spawn_bundle(SpriteBundle {
sprite: Sprite {
// Alpha channel of the color controls transparency.
color: Color::rgba(0.0, 0.0, 1.0, 0.7),
..Default::default()
..default()
},
texture: sprite_handle.clone(),
transform: Transform::from_xyz(100.0, 0.0, 0.0),
..Default::default()
..default()
});
commands.spawn_bundle(SpriteBundle {
sprite: Sprite {
color: Color::rgba(0.0, 1.0, 0.0, 0.3),
..Default::default()
..default()
},
texture: sprite_handle,
transform: Transform::from_xyz(200.0, 0.0, 0.0),
..Default::default()
..default()
});
}
10 changes: 5 additions & 5 deletions examples/3d/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn setup(
),
..default()
},
..Default::default()
..default()
})
.insert(Shape);
}
Expand All @@ -65,22 +65,22 @@ fn setup(
intensity: 9000.0,
range: 100.,
shadows_enabled: true,
..Default::default()
..default()
},
transform: Transform::from_xyz(8.0, 16.0, 8.0),
..Default::default()
..default()
});

// ground plane
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(shape::Plane { size: 50. }.into()),
material: materials.add(Color::SILVER.into()),
..Default::default()
..default()
});

commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(0.0, 6., 12.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
..Default::default()
..default()
});
}

Expand Down
14 changes: 7 additions & 7 deletions examples/3d/transparency_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn setup(
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 6.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
..default()
});
// transparent sphere, using alpha_mode: Mask
commands.spawn_bundle(PbrBundle {
Expand All @@ -45,7 +45,7 @@ fn setup(
..default()
}),
transform: Transform::from_xyz(1.0, 0.5, -1.5),
..Default::default()
..default()
});
// transparent cube, using alpha_mode: Blend
commands.spawn_bundle(PbrBundle {
Expand All @@ -55,7 +55,7 @@ fn setup(
// automatically set to `Blend` if the alpha channel is anything lower than 1.0.
material: materials.add(Color::rgba(0.5, 0.5, 1.0, 0.0).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
..default()
});
// sphere
commands.spawn_bundle(PbrBundle {
Expand All @@ -65,22 +65,22 @@ fn setup(
})),
material: materials.add(Color::rgb(0.7, 0.2, 0.1).into()),
transform: Transform::from_xyz(0.0, 0.5, -1.5),
..Default::default()
..default()
});
// light
commands.spawn_bundle(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..Default::default()
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
..default()
});
// camera
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
..default()
});
}

Expand Down
2 changes: 1 addition & 1 deletion examples/animation/animated_fox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn setup(
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(100.0, 100.0, 150.0)
.looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y),
..Default::default()
..default()
});

// Plane
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/custom_skinned_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.insert_resource(AmbientLight {
brightness: 1.0,
..Default::default()
..default()
})
.add_startup_system(setup)
.add_system(joint_animation)
Expand Down Expand Up @@ -152,7 +152,7 @@ fn setup(
)
.into(),
),
..Default::default()
..default()
})
.insert(SkinnedMesh {
inverse_bindposes: inverse_bindposes.clone(),
Expand Down
2 changes: 1 addition & 1 deletion examples/animation/gltf_skinned_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.insert_resource(AmbientLight {
brightness: 1.0,
..Default::default()
..default()
})
.add_startup_system(setup)
.add_system(joint_animation)
Expand Down
2 changes: 1 addition & 1 deletion examples/stress_tests/many_foxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn setup(
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_translation(translation)
.looking_at(0.2 * Vec3::new(translation.x, 0.0, translation.z), Vec3::Y),
..Default::default()
..default()
});

// Plane
Expand Down
6 changes: 3 additions & 3 deletions examples/transforms/3d_rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::WHITE.into()),
transform: Transform::from_translation(Vec3::ZERO),
..Default::default()
..default()
})
.insert(Rotatable { speed: 0.3 });

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

// Add a light source for better 3d visibility.
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::ONE * 3.0),
..Default::default()
..default()
});
}

Expand Down
14 changes: 7 additions & 7 deletions examples/transforms/global_vs_local_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn setup(
.insert_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::YELLOW.into()),
..Default::default()
..default()
})
.insert(ChangeGlobal)
.insert(Move)
Expand All @@ -71,7 +71,7 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
material: materials.add(Color::RED.into()),
transform: Transform::from_translation(Vec3::Y - Vec3::Z),
..Default::default()
..default()
})
.insert(ChangeGlobal)
.insert(Move)
Expand All @@ -81,7 +81,7 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
material: materials.add(Color::GREEN.into()),
transform: Transform::from_translation(Vec3::Y + Vec3::Z),
..Default::default()
..default()
})
.insert(ChangeLocal)
.insert(Move)
Expand All @@ -91,13 +91,13 @@ fn setup(
// Spawn a camera looking at the entities to show what's happening in this example.
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
..default()
});

// Add a light source for better 3d visibility.
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::splat(3.0)),
..Default::default()
..default()
});

// Add text to explain inputs and what is happening.
Expand All @@ -115,10 +115,10 @@ The red cube is moved through its GlobalTransform and thus is unaffected by the
},
TextAlignment {
horizontal: HorizontalAlign::Left,
..Default::default()
..default()
},
),
..Default::default()
..default()
});
}

Expand Down
6 changes: 3 additions & 3 deletions examples/transforms/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::WHITE.into()),
transform: Transform::from_rotation(Quat::from_rotation_y(PI / 4.0)),
..Default::default()
..default()
})
.insert(Scaling::new());

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

// Add a light source for better 3d visibility.
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::ONE * 3.0),
..Default::default()
..default()
});
}

Expand Down
8 changes: 4 additions & 4 deletions examples/transforms/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn setup(
})),
material: materials.add(Color::YELLOW.into()),
transform: Transform::from_translation(Vec3::ZERO),
..Default::default()
..default()
})
.insert(Center {
max_size: 1.0,
Expand All @@ -67,7 +67,7 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::WHITE.into()),
transform: cube_spawn,
..Default::default()
..default()
})
.insert(CubeState {
start_pos: cube_spawn.translation,
Expand All @@ -78,13 +78,13 @@ fn setup(
// Spawn a camera looking at the entities to show what's happening in this example.
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
..default()
});

// Add a light source for better 3d visibility.
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::ONE * 3.0),
..Default::default()
..default()
});
}

Expand Down
6 changes: 3 additions & 3 deletions examples/transforms/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ fn setup(
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::WHITE.into()),
transform: Transform::from_translation(entity_spawn),
..Default::default()
..default()
})
.insert(Movable::new(entity_spawn));

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

// Add a light source for better 3d visibility.
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::ONE * 3.0),
..Default::default()
..default()
});
}

Expand Down
12 changes: 6 additions & 6 deletions examples/ui/transparency_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
margin: UiRect::all(Val::Auto),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..Default::default()
..default()
},
color: Color::rgb(0.1, 0.5, 0.1).into(),
..Default::default()
..default()
})
.with_children(|parent| {
parent.spawn_bundle(TextBundle {
Expand All @@ -40,7 +40,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
Default::default(),
),
..Default::default()
..default()
});
});

Expand All @@ -53,10 +53,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
margin: UiRect::all(Val::Auto),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..Default::default()
..default()
},
color: Color::rgb(0.5, 0.1, 0.5).into(),
..Default::default()
..default()
})
.with_children(|parent| {
parent.spawn_bundle(TextBundle {
Expand All @@ -70,7 +70,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
Default::default(),
),
..Default::default()
..default()
});
});
}
Loading

0 comments on commit 56ac553

Please sign in to comment.