orthographic/
orthographic.rs1use bevy::{camera::ScalingMode, prelude::*};
4
5fn main() {
6 App::new()
7 .add_plugins(DefaultPlugins)
8 .add_systems(Startup, setup)
9 .run();
10}
11
12fn setup(
14 mut commands: Commands,
15 mut meshes: ResMut<Assets<Mesh>>,
16 mut materials: ResMut<Assets<StandardMaterial>>,
17) {
18 commands.spawn((
20 Camera3d::default(),
21 Projection::from(OrthographicProjection {
22 scaling_mode: ScalingMode::FixedVertical {
24 viewport_height: 6.0,
25 },
26 ..OrthographicProjection::default_3d()
27 }),
28 Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
29 ));
30
31 commands.spawn((
33 Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
34 MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
35 ));
36 commands.spawn((
38 Mesh3d(meshes.add(Cuboid::default())),
39 MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
40 Transform::from_xyz(1.5, 0.5, 1.5),
41 ));
42 commands.spawn((
43 Mesh3d(meshes.add(Cuboid::default())),
44 MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
45 Transform::from_xyz(1.5, 0.5, -1.5),
46 ));
47 commands.spawn((
48 Mesh3d(meshes.add(Cuboid::default())),
49 MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
50 Transform::from_xyz(-1.5, 0.5, 1.5),
51 ));
52 commands.spawn((
53 Mesh3d(meshes.add(Cuboid::default())),
54 MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
55 Transform::from_xyz(-1.5, 0.5, -1.5),
56 ));
57 commands.spawn((PointLight::default(), Transform::from_xyz(3.0, 8.0, 5.0)));
59}