Skip to content

Commit

Permalink
Slow down the many_cubes example (bevyengine#4117)
Browse files Browse the repository at this point in the history
# Objective

- After bevyengine#4015, the `many_cubes` example could introduce discomfort in some cases

## Solution

- Slow down the camera, add space between the cubes

https://user-images.githubusercontent.com/8672791/156898412-0fcd29b4-63b1-4e11-bf52-7ec40cb8f932.mp4
  • Loading branch information
mockersf authored and aevyrie committed Jun 7, 2022
1 parent 664c415 commit 141d057
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions examples/3d/many_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,37 @@ fn setup(
});
for x in 0..WIDTH {
for y in 0..HEIGHT {
// introduce spaces to break any kind of moiré pattern
if x % 10 == 0 || y % 10 == 0 {
continue;
}
// cube
commands.spawn_bundle(PbrBundle {
mesh: mesh.clone_weak(),
material: material.clone_weak(),
transform: Transform::from_xyz((x as f32) * 2.0, (y as f32) * 2.0, 0.0),
transform: Transform::from_xyz((x as f32) * 2.5, (y as f32) * 2.5, 0.0),
..default()
});
commands.spawn_bundle(PbrBundle {
mesh: mesh.clone_weak(),
material: material.clone_weak(),
transform: Transform::from_xyz(
(x as f32) * 2.0,
HEIGHT as f32 * 2.0,
(y as f32) * 2.0,
(x as f32) * 2.5,
HEIGHT as f32 * 2.5,
(y as f32) * 2.5,
),
..Default::default()
});
commands.spawn_bundle(PbrBundle {
mesh: mesh.clone_weak(),
material: material.clone_weak(),
transform: Transform::from_xyz((x as f32) * 2.0, 0.0, (y as f32) * 2.0),
transform: Transform::from_xyz((x as f32) * 2.5, 0.0, (y as f32) * 2.5),
..Default::default()
});
commands.spawn_bundle(PbrBundle {
mesh: mesh.clone_weak(),
material: material.clone_weak(),
transform: Transform::from_xyz(0.0, (x as f32) * 2.0, (y as f32) * 2.0),
transform: Transform::from_xyz(0.0, (x as f32) * 2.5, (y as f32) * 2.5),
..Default::default()
});
}
Expand All @@ -66,7 +70,7 @@ fn setup(
mesh,
material,
transform: Transform {
translation: Vec3::new(0.0, HEIGHT as f32 * 2.0, 0.0),
translation: Vec3::new(0.0, HEIGHT as f32 * 2.5, 0.0),
scale: Vec3::splat(5.0),
..Default::default()
},
Expand All @@ -87,8 +91,8 @@ fn setup(
// System for rotating the camera
fn move_camera(time: Res<Time>, mut camera_query: Query<&mut Transform, With<Camera>>) {
let mut camera_transform = camera_query.single_mut();
camera_transform.rotate(Quat::from_rotation_z(time.delta_seconds() * 0.5));
camera_transform.rotate(Quat::from_rotation_x(time.delta_seconds() * 0.5));
camera_transform.rotate(Quat::from_rotation_z(time.delta_seconds() * 0.15));
camera_transform.rotate(Quat::from_rotation_x(time.delta_seconds() * 0.15));
}

// System for printing the number of meshes on every tick of the timer
Expand Down

0 comments on commit 141d057

Please sign in to comment.