Skip to main content

gallery/
gallery.rs

1use nightshade_api::prelude::*;
2
3fn main() {
4    let mut app = open();
5    set_background(&mut app.world, Background::Color([0.02, 0.02, 0.04, 1.0]));
6    show_grid(&mut app.world, false);
7    set_bloom(&mut app.world, true);
8    spawn_floor(&mut app.world, 12.0);
9
10    for row in 0..5 {
11        for column in 0..5 {
12            let sphere = spawn_sphere(
13                &mut app.world,
14                vec3(column as f32 * 1.5 - 3.0, 0.5, row as f32 * 1.5 - 3.0),
15            );
16            set_color(&mut app.world, sphere, RED);
17            set_metallic_roughness(
18                &mut app.world,
19                sphere,
20                row as f32 / 4.0,
21                column as f32 / 4.0,
22            );
23        }
24    }
25
26    let lineup = [
27        spawn_cube(&mut app.world, vec3(-5.5, 0.5, 4.5)),
28        spawn_cylinder(&mut app.world, vec3(-4.0, 0.5, 4.5)),
29        spawn_cone(&mut app.world, vec3(-2.5, 0.5, 4.5)),
30    ];
31    for (index, entity) in lineup.into_iter().enumerate() {
32        set_color(&mut app.world, entity, [GOLD, TEAL, PURPLE][index]);
33    }
34    let checkered = spawn_cube(&mut app.world, vec3(-5.5, 0.5, 2.5));
35    set_texture(&mut app.world, checkered, "checkerboard");
36
37    let torus = spawn_torus(&mut app.world, vec3(0.0, 2.5, 0.0));
38    set_emissive(&mut app.world, torus, [1.0, 0.6, 0.1], 6.0);
39
40    orbit_camera(&mut app.world, vec3(0.0, 1.0, 0.0), 12.0);
41    while frame(&mut app) {}
42}