Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Use SpatialBundle/TransformBundle in examples #6002

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions examples/2d/mesh2d_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ fn star(
ColoredMesh2d::default(),
// The `Handle<Mesh>` needs to be wrapped in a `Mesh2dHandle` to use 2d rendering instead of 3d
Mesh2dHandle(meshes.add(star)),
// These other components are needed for 2d meshes to be rendered
Transform::default(),
GlobalTransform::default(),
Visibility::default(),
ComputedVisibility::default(),
// This bundle's components are needed for something to be rendered
SpatialBundle::VISIBLE_IDENTITY,
));
commands
// And use an orthographic projection
.spawn(Camera2dBundle::default());

// Spawn the camera
commands.spawn(Camera2dBundle::default());
}

/// A marker component for colored 2d meshes
Expand Down
15 changes: 6 additions & 9 deletions examples/animation/custom_skinned_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,14 @@ fn setup(
for i in -5..5 {
// Create joint entities
let joint_0 = commands
.spawn((
Transform::from_xyz(i as f32 * 1.5, 0.0, 0.0),
GlobalTransform::IDENTITY,
))
.spawn(TransformBundle::from(Transform::from_xyz(
i as f32 * 1.5,
0.0,
0.0,
)))
.id();
let joint_1 = commands
.spawn((
AnimatedJoint,
Transform::IDENTITY,
GlobalTransform::IDENTITY,
))
.spawn((AnimatedJoint, TransformBundle::IDENTITY))
.id();

// Set joint_1 as a child of joint_0.
Expand Down
5 changes: 1 addition & 4 deletions examples/shader/shader_instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ fn main() {
fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
commands.spawn((
meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
Transform::from_xyz(0.0, 0.0, 0.0),
GlobalTransform::default(),
SpatialBundle::VISIBLE_IDENTITY,
InstanceMaterialData(
(1..=10)
.flat_map(|x| (1..=10).map(move |y| (x as f32 / 10.0, y as f32 / 10.0)))
Expand All @@ -44,8 +43,6 @@ fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
})
.collect(),
),
Visibility::default(),
ComputedVisibility::default(),
// NOTE: Frustum culling is done based on the Aabb of the Mesh and the GlobalTransform.
// As the cube is at the origin, if its Aabb moves outside the view frustum, all the
// instanced cubes will be culled.
Expand Down
5 changes: 1 addition & 4 deletions examples/stress_tests/many_foxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ fn setup(
let (base_rotation, ring_direction) = ring_directions[ring_index % 2];
let ring_parent = commands
.spawn((
Transform::default(),
GlobalTransform::default(),
Visibility::default(),
ComputedVisibility::default(),
SpatialBundle::VISIBLE_IDENTITY,
ring_direction,
Ring { radius },
))
Expand Down
8 changes: 2 additions & 6 deletions examples/stress_tests/transform_hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,7 @@ fn spawn_tree(
}

// insert root
ents.push(
commands
.spawn((root_transform, GlobalTransform::default()))
.id(),
);
ents.push(commands.spawn(TransformBundle::from(root_transform)).id());

let mut result = InsertResult::default();
let mut rng = rand::thread_rng();
Expand Down Expand Up @@ -417,7 +413,7 @@ fn spawn_tree(
};

// only insert the components necessary for the transform propagation
cmd.insert((transform, GlobalTransform::default()));
cmd.insert(TransformBundle::from(transform));

cmd.id()
};
Expand Down