Skip to main content

3d_scene/
3d_scene.rs

1//! A simple 3D scene with light shining over a cube sitting on a plane.
2
3use bevy::prelude::*;
4
5fn main() {
6    App::new()
7        .add_plugins(DefaultPlugins)
8        .add_systems(Startup, scene.spawn())
9        .run();
10}
11
12/// set up a simple 3D scene
13fn scene() -> impl SceneList {
14    bsn_list! [
15        (
16            #CircularBase
17            Mesh3d(asset_value(Circle::new(4.0)))
18            MeshMaterial3d::<StandardMaterial>(asset_value(Color::WHITE))
19            Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2))
20        ),
21        (
22            #Cube
23            Mesh3d(asset_value(Cuboid::new(1.0, 1.0, 1.0)))
24            MeshMaterial3d::<StandardMaterial>(asset_value(Color::srgb_u8(124, 144, 255)))
25            Transform::from_xyz(0.0, 0.5, 0.0)
26        ),
27        (
28            PointLight {
29                shadow_maps_enabled: true,
30            }
31            Transform::from_xyz(4.0, 8.0, 4.0)
32        ),
33        (
34            Camera3d
35            template_value(Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y))
36        )
37    ]
38}