1use super::*;
2
3pub const fn lines3d_vertex_index_counts() -> (u32, u32) {
5 (8, 24)
7}
8
9impl Lines3d {
10 pub fn cube (index_offset : u32) -> Self {
11 let vertex = |x, y, z| vertex::Vert3dInstanced { inst_position: [x, y, z] };
12 let vertices = vec![
13 vertex (-1.0, -1.0, -1.0),
15 vertex (-1.0, 1.0, -1.0),
16 vertex ( 1.0, 1.0, -1.0),
17 vertex ( 1.0, -1.0, -1.0),
18 vertex (-1.0, -1.0, 1.0),
20 vertex (-1.0, 1.0, 1.0),
21 vertex ( 1.0, 1.0, 1.0),
22 vertex ( 1.0, -1.0, 1.0)
23 ];
24
25 let indices = [
26 0, 1,
28 1, 2,
29 2, 3,
30 3, 0,
31 4, 5,
33 5, 6,
34 6, 7,
35 7, 4,
36 0, 4,
38 1, 5,
39 2, 6,
40 3, 7
41 ].map (|i| i + index_offset).into_iter().collect::<Vec<_>>();
42
43 if cfg!(debug_assertions) {
44 let (num_vertices, num_indices) = lines3d_vertex_index_counts();
45 debug_assert_eq!(vertices.len(), num_vertices as usize);
46 debug_assert_eq!(indices.len(), num_indices as usize);
47 }
48
49 Lines3d { vertices, indices }
50 }
51}