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        #CircularBase
16        Mesh3d(asset_value(Circle::new(4.0)))
17        MeshMaterial3d::<StandardMaterial>(asset_value(Color::WHITE))
18        Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2))
19        --
20        #Cube
21        Mesh3d(asset_value(Cuboid::new(1.0, 1.0, 1.0)))
22        MeshMaterial3d::<StandardMaterial>(asset_value(Color::srgb_u8(124, 144, 255)))
23        Transform::from_xyz(0.0, 0.5, 0.0)
24        --
25        PointLight {
26            shadow_maps_enabled: true,
27        }
28        Transform::from_xyz(4.0, 8.0, 4.0)
29        --
30        Camera3d
31        Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y)
32    }
33}