-
-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy path3d.rs
More file actions
46 lines (34 loc) · 1.31 KB
/
Copy path3d.rs
File metadata and controls
46 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use macroquad::prelude::*;
#[macroquad::main("3D")]
async fn main() {
let rust_logo = load_texture("examples/rust.png").await.unwrap();
let ferris = load_texture("examples/ferris.png").await.unwrap();
loop {
clear_background(LIGHTGRAY);
// Going 3d!
set_camera(&Camera3D {
position: vec3(-20., 15., 0.),
up: vec3(0., 1., 0.),
target: vec3(0., 0., 0.),
..Default::default()
});
draw_grid(20, 1., BLACK, GRAY);
draw_cube_wires(vec3(0., 1., -6.), vec3(2., 2., 2.), DARKGREEN);
draw_cube_wires(vec3(0., 1., 6.), vec3(2., 2., 2.), DARKBLUE);
draw_cube_wires(vec3(2., 1., 2.), vec3(2., 2., 2.), YELLOW);
draw_plane(vec3(-8., 0., -8.), vec2(5., 5.), Some(&ferris), WHITE);
draw_cube(
vec3(-5., 1., -2.),
vec3(2., 2., 2.),
Some(&rust_logo),
WHITE,
);
draw_cube(vec3(-5., 1., 2.), vec3(2., 2., 2.), Some(&ferris), WHITE);
draw_cube(vec3(2., 0., -2.), vec3(0.4, 0.4, 0.4), None, BLACK);
draw_sphere(vec3(-8., 0., 0.), 1., None, BLUE);
// Back to screen space, render some text
set_default_camera();
draw_text("WELCOME TO 3D WORLD", 10.0, 20.0, 30.0, BLACK);
next_frame().await
}
}