-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdepth_test.rs
40 lines (35 loc) · 1.08 KB
/
depth_test.rs
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
use bevy::prelude::*;
use bevy_prototype_debug_lines::{DebugLines, DebugLinesPlugin};
fn main() {
App::new()
.insert_resource(Msaa::default())
.add_plugins(DefaultPlugins)
.add_plugins(DebugLinesPlugin::with_depth_test(true))
.add_systems(Startup, setup)
.add_systems(Update, demo)
.run();
}
fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 0.0, 5.0),
..default()
});
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(StandardMaterial {
base_color: Color::RED,
..Default::default()
}),
transform: Transform::from_xyz(0.0, 0.0, -0.5),
..Default::default()
});
}
fn demo(mut lines: ResMut<DebugLines>) {
lines.line_gradient(
Vec3::new(-1.0, -1.0, -1.0),
Vec3::new(1.0, 1.0, 1.0),
0.0,
Color::BLUE,
Color::RED,
);
}