infinite_grid/
infinite_grid.rs1use bevy::{
8 camera_controller::free_camera::{FreeCamera, FreeCameraPlugin},
9 dev_tools::infinite_grid::{InfiniteGrid, InfiniteGridPlugin, InfiniteGridSettings},
10 prelude::*,
11};
12
13fn main() {
14 App::new()
15 .add_plugins((
16 DefaultPlugins,
17 FreeCameraPlugin,
18 InfiniteGridPlugin,
20 ))
21 .add_systems(Startup, setup_system)
22 .run();
23}
24
25fn setup_system(
26 mut commands: Commands,
27 mut meshes: ResMut<Assets<Mesh>>,
28 mut standard_materials: ResMut<Assets<StandardMaterial>>,
29) {
30 commands.spawn((
31 InfiniteGrid,
33 InfiniteGridSettings::default(),
35 ));
36
37 commands.spawn((
38 Camera3d::default(),
39 Transform::from_xyz(-12.5, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
40 FreeCamera::default(),
41 ));
42
43 commands.spawn((
44 DirectionalLight { ..default() },
45 Transform::from_translation(Vec3::X * 15. + Vec3::Y * 20.).looking_at(Vec3::ZERO, Vec3::Y),
46 ));
47
48 commands.spawn((
50 Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
51 MeshMaterial3d(
52 standard_materials.add(StandardMaterial::from_color(Color::srgba(
53 1.0, 1.0, 1.0, 0.5,
54 ))),
55 ),
56 Transform::from_xyz(0.0, 2.0, 0.0),
57 ));
58
59 commands.spawn((
60 Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
61 MeshMaterial3d(
62 standard_materials.add(StandardMaterial::from_color(Color::srgba(
63 1.0, 1.0, 1.0, 0.5,
64 ))),
65 ),
66 Transform::from_xyz(0.0, -2.0, 0.0),
67 ));
68}