sevenx_engine 0.2.11

Engine de jogos 2D/3D completa com suporte Android, física, áudio, partículas, tilemap, UI, eventos e sistema 3D avançado com PBR.
Documentation
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
// Módulo 3D Experimental - Mesh e Vertex
use serde::{Deserialize, Serialize};
use crate::texture3d::Material3D;

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Vec3 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}

impl Vec3 {
    pub fn new(x: f32, y: f32, z: f32) -> Self {
        Self { x, y, z }
    }

    pub fn zero() -> Self {
        Self::new(0.0, 0.0, 0.0)
    }

    pub fn dot(&self, other: &Vec3) -> f32 {
        self.x * other.x + self.y * other.y + self.z * other.z
    }

    pub fn cross(&self, other: &Vec3) -> Vec3 {
        Vec3::new(
            self.y * other.z - self.z * other.y,
            self.z * other.x - self.x * other.z,
            self.x * other.y - self.y * other.x,
        )
    }

    pub fn length(&self) -> f32 {
        (self.x * self.x + self.y * self.y + self.z * self.z).sqrt()
    }

    pub fn normalize(&self) -> Vec3 {
        let len = self.length();
        if len > 0.0 {
            Vec3::new(self.x / len, self.y / len, self.z / len)
        } else {
            *self
        }
    }

    pub fn distance(&self, other: &Vec3) -> f32 {
        let dx = self.x - other.x;
        let dy = self.y - other.y;
        let dz = self.z - other.z;
        (dx * dx + dy * dy + dz * dz).sqrt()
    }

    pub fn lerp(&self, other: &Vec3, t: f32) -> Vec3 {
        Vec3::new(
            self.x + (other.x - self.x) * t,
            self.y + (other.y - self.y) * t,
            self.z + (other.z - self.z) * t,
        )
    }
}

// Operadores matemáticos para Vec3
impl std::ops::Add for Vec3 {
    type Output = Vec3;
    fn add(self, other: Vec3) -> Vec3 {
        Vec3::new(self.x + other.x, self.y + other.y, self.z + other.z)
    }
}

impl std::ops::Sub for Vec3 {
    type Output = Vec3;
    fn sub(self, other: Vec3) -> Vec3 {
        Vec3::new(self.x - other.x, self.y - other.y, self.z - other.z)
    }
}

impl std::ops::Mul<f32> for Vec3 {
    type Output = Vec3;
    fn mul(self, scalar: f32) -> Vec3 {
        Vec3::new(self.x * scalar, self.y * scalar, self.z * scalar)
    }
}

impl std::ops::Div<f32> for Vec3 {
    type Output = Vec3;
    fn div(self, scalar: f32) -> Vec3 {
        Vec3::new(self.x / scalar, self.y / scalar, self.z / scalar)
    }
}

impl std::ops::Neg for Vec3 {
    type Output = Vec3;
    fn neg(self) -> Vec3 {
        Vec3::new(-self.x, -self.y, -self.z)
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Vertex {
    pub position: Vec3,
    pub normal: Vec3,
    pub uv: (f32, f32),
    pub color: [u8; 4],
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Mesh3D {
    pub vertices: Vec<Vertex>,
    pub indices: Vec<u32>,
    pub position: Vec3,
    pub rotation: Vec3,
    pub scale: Vec3,
    #[serde(default)]
    pub material: Option<Material3D>,
    #[serde(default = "default_true")]
    pub cast_shadow: bool,
    #[serde(default = "default_true")]
    pub receive_shadow: bool,
}

fn default_true() -> bool {
    true
}

impl Mesh3D {
    pub fn new() -> Self {
        Self {
            vertices: Vec::new(),
            indices: Vec::new(),
            position: Vec3::zero(),
            rotation: Vec3::zero(),
            scale: Vec3::new(1.0, 1.0, 1.0),
            material: None,
            cast_shadow: true,
            receive_shadow: true,
        }
    }
    
    pub fn with_material(mut self, material: Material3D) -> Self {
        self.material = Some(material);
        self
    }
    
    pub fn set_material(&mut self, material: Material3D) {
        self.material = Some(material);
    }
    
    pub fn finalize(vertices: Vec<Vertex>, indices: Vec<u32>) -> Self {
        Self {
            vertices,
            indices,
            position: Vec3::zero(),
            rotation: Vec3::zero(),
            scale: Vec3::new(1.0, 1.0, 1.0),
            material: None,
            cast_shadow: true,
            receive_shadow: true,
        }
    }

    // Cria um cubo
    pub fn cube(size: f32) -> Self {
        let s = size / 2.0;
        let vertices = vec![
            // Front
            Vertex { position: Vec3::new(-s, -s, s), normal: Vec3::new(0.0, 0.0, 1.0), uv: (0.0, 0.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(s, -s, s), normal: Vec3::new(0.0, 0.0, 1.0), uv: (1.0, 0.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(s, s, s), normal: Vec3::new(0.0, 0.0, 1.0), uv: (1.0, 1.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(-s, s, s), normal: Vec3::new(0.0, 0.0, 1.0), uv: (0.0, 1.0), color: [255, 255, 255, 255] },
            // Back
            Vertex { position: Vec3::new(s, -s, -s), normal: Vec3::new(0.0, 0.0, -1.0), uv: (0.0, 0.0), color: [200, 200, 200, 255] },
            Vertex { position: Vec3::new(-s, -s, -s), normal: Vec3::new(0.0, 0.0, -1.0), uv: (1.0, 0.0), color: [200, 200, 200, 255] },
            Vertex { position: Vec3::new(-s, s, -s), normal: Vec3::new(0.0, 0.0, -1.0), uv: (1.0, 1.0), color: [200, 200, 200, 255] },
            Vertex { position: Vec3::new(s, s, -s), normal: Vec3::new(0.0, 0.0, -1.0), uv: (0.0, 1.0), color: [200, 200, 200, 255] },
        ];

        let indices = vec![
            0, 1, 2, 2, 3, 0, // Front
            4, 5, 6, 6, 7, 4, // Back
            5, 0, 3, 3, 6, 5, // Left
            1, 4, 7, 7, 2, 1, // Right
            3, 2, 7, 7, 6, 3, // Top
            5, 4, 1, 1, 0, 5, // Bottom
        ];

        Self {
            vertices,
            indices,
            position: Vec3::zero(),
            rotation: Vec3::zero(),
            scale: Vec3::new(1.0, 1.0, 1.0),
            material: None,
            cast_shadow: true,
            receive_shadow: true,
        }
    }

    // Cria uma esfera (simplificada)
    pub fn sphere(radius: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        for lat in 0..=segments {
            let theta = lat as f32 * std::f32::consts::PI / segments as f32;
            let sin_theta = theta.sin();
            let cos_theta = theta.cos();

            for lon in 0..=segments {
                let phi = lon as f32 * 2.0 * std::f32::consts::PI / segments as f32;
                let sin_phi = phi.sin();
                let cos_phi = phi.cos();

                let x = cos_phi * sin_theta;
                let y = cos_theta;
                let z = sin_phi * sin_theta;

                vertices.push(Vertex {
                    position: Vec3::new(x * radius, y * radius, z * radius),
                    normal: Vec3::new(x, y, z),
                    uv: (lon as f32 / segments as f32, lat as f32 / segments as f32),
                    color: [255, 255, 255, 255],
                });
            }
        }

        for lat in 0..segments {
            for lon in 0..segments {
                let first = lat * (segments + 1) + lon;
                let second = first + segments + 1;

                indices.push(first);
                indices.push(second);
                indices.push(first + 1);

                indices.push(second);
                indices.push(second + 1);
                indices.push(first + 1);
            }
        }

        Self::finalize(vertices, indices)
    }

    // Cria um plano (útil para chão, paredes)
    pub fn plane(width: f32, height: f32) -> Self {
        let hw = width / 2.0;
        let hh = height / 2.0;
        
        let vertices = vec![
            Vertex {
                position: Vec3::new(-hw, 0.0, -hh),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (0.0, 0.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(hw, 0.0, -hh),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (1.0, 0.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(hw, 0.0, hh),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (1.0, 1.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(-hw, 0.0, hh),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (0.0, 1.0),
                color: [255, 255, 255, 255],
            },
        ];

        let indices = vec![0, 1, 2, 2, 3, 0];

        Self::finalize(vertices, indices)
    }

    // Cria um cilindro
    pub fn cylinder(radius: f32, height: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();
        let half_height = height / 2.0;

        // Vértices do topo e base
        for i in 0..=segments {
            let angle = i as f32 * 2.0 * std::f32::consts::PI / segments as f32;
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            // Topo
            vertices.push(Vertex {
                position: Vec3::new(x, half_height, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 0.0),
                color: [255, 255, 255, 255],
            });

            // Base
            vertices.push(Vertex {
                position: Vec3::new(x, -half_height, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 1.0),
                color: [255, 255, 255, 255],
            });
        }

        // Índices das faces laterais
        for i in 0..segments {
            let top1 = i * 2;
            let bottom1 = i * 2 + 1;
            let top2 = (i + 1) * 2;
            let bottom2 = (i + 1) * 2 + 1;

            indices.push(top1);
            indices.push(bottom1);
            indices.push(top2);

            indices.push(bottom1);
            indices.push(bottom2);
            indices.push(top2);
        }

        Self::finalize(vertices, indices)
    }

    // Cria uma pirâmide
    pub fn pyramid(size: f32) -> Self {
        let s = size / 2.0;
        let h = size;

        let vertices = vec![
            // Base
            Vertex { position: Vec3::new(-s, 0.0, -s), normal: Vec3::new(0.0, -1.0, 0.0), uv: (0.0, 0.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(s, 0.0, -s), normal: Vec3::new(0.0, -1.0, 0.0), uv: (1.0, 0.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(s, 0.0, s), normal: Vec3::new(0.0, -1.0, 0.0), uv: (1.0, 1.0), color: [255, 255, 255, 255] },
            Vertex { position: Vec3::new(-s, 0.0, s), normal: Vec3::new(0.0, -1.0, 0.0), uv: (0.0, 1.0), color: [255, 255, 255, 255] },
            // Topo
            Vertex { position: Vec3::new(0.0, h, 0.0), normal: Vec3::new(0.0, 1.0, 0.0), uv: (0.5, 0.5), color: [255, 255, 255, 255] },
        ];

        let indices = vec![
            0, 1, 2, 2, 3, 0,  // Base
            0, 4, 1,            // Face 1
            1, 4, 2,            // Face 2
            2, 4, 3,            // Face 3
            3, 4, 0,            // Face 4
        ];

        Self::finalize(vertices, indices)
    }

    // Cria um cone (útil para árvores, foguetes)
    pub fn cone(radius: f32, height: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        // Centro da base
        vertices.push(Vertex {
            position: Vec3::new(0.0, 0.0, 0.0),
            normal: Vec3::new(0.0, -1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Vértices da base
        for i in 0..=segments {
            let angle = i as f32 * 2.0 * std::f32::consts::PI / segments as f32;
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            vertices.push(Vertex {
                position: Vec3::new(x, 0.0, z),
                normal: Vec3::new(0.0, -1.0, 0.0),
                uv: (angle.cos() * 0.5 + 0.5, angle.sin() * 0.5 + 0.5),
                color: [255, 255, 255, 255],
            });
        }

        // Topo do cone
        let apex_index = vertices.len() as u32;
        vertices.push(Vertex {
            position: Vec3::new(0.0, height, 0.0),
            normal: Vec3::new(0.0, 1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Índices da base
        for i in 1..=segments {
            indices.push(0);
            indices.push(i + 1);
            indices.push(i);
        }

        // Índices das faces laterais
        for i in 1..=segments {
            indices.push(i);
            indices.push(i + 1);
            indices.push(apex_index);
        }

        Self::finalize(vertices, indices)
    }

    // Cria uma cápsula (cilindro com hemisférios nas pontas)
    pub fn capsule(radius: f32, height: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();
        let half_height = height / 2.0;

        // Cilindro central
        for i in 0..=segments {
            let angle = i as f32 * 2.0 * std::f32::consts::PI / segments as f32;
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            vertices.push(Vertex {
                position: Vec3::new(x, half_height, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 0.0),
                color: [255, 255, 255, 255],
            });

            vertices.push(Vertex {
                position: Vec3::new(x, -half_height, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 1.0),
                color: [255, 255, 255, 255],
            });
        }

        // Índices do cilindro
        for i in 0..segments {
            let top1 = i * 2;
            let bottom1 = i * 2 + 1;
            let top2 = (i + 1) * 2;
            let bottom2 = (i + 1) * 2 + 1;

            indices.push(top1);
            indices.push(bottom1);
            indices.push(top2);

            indices.push(bottom1);
            indices.push(bottom2);
            indices.push(top2);
        }

        Self::finalize(vertices, indices)
    }

    // Cria um quad (plano vertical, útil para billboards e sprites 3D)
    pub fn quad(width: f32, height: f32) -> Self {
        let hw = width / 2.0;
        let hh = height / 2.0;

        let vertices = vec![
            Vertex {
                position: Vec3::new(-hw, -hh, 0.0),
                normal: Vec3::new(0.0, 0.0, 1.0),
                uv: (0.0, 1.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(hw, -hh, 0.0),
                normal: Vec3::new(0.0, 0.0, 1.0),
                uv: (1.0, 1.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(hw, hh, 0.0),
                normal: Vec3::new(0.0, 0.0, 1.0),
                uv: (1.0, 0.0),
                color: [255, 255, 255, 255],
            },
            Vertex {
                position: Vec3::new(-hw, hh, 0.0),
                normal: Vec3::new(0.0, 0.0, 1.0),
                uv: (0.0, 0.0),
                color: [255, 255, 255, 255],
            },
        ];

        let indices = vec![0, 1, 2, 2, 3, 0];

        Self::finalize(vertices, indices)
    }

    // Cria um torus (rosquinha)
    pub fn torus(major_radius: f32, minor_radius: f32, major_segments: u32, minor_segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        for i in 0..=major_segments {
            let u = i as f32 * 2.0 * std::f32::consts::PI / major_segments as f32;
            let cos_u = u.cos();
            let sin_u = u.sin();

            for j in 0..=minor_segments {
                let v = j as f32 * 2.0 * std::f32::consts::PI / minor_segments as f32;
                let cos_v = v.cos();
                let sin_v = v.sin();

                let x = (major_radius + minor_radius * cos_v) * cos_u;
                let y = minor_radius * sin_v;
                let z = (major_radius + minor_radius * cos_v) * sin_u;

                let nx = cos_v * cos_u;
                let ny = sin_v;
                let nz = cos_v * sin_u;

                vertices.push(Vertex {
                    position: Vec3::new(x, y, z),
                    normal: Vec3::new(nx, ny, nz),
                    uv: (i as f32 / major_segments as f32, j as f32 / minor_segments as f32),
                    color: [255, 255, 255, 255],
                });
            }
        }

        for i in 0..major_segments {
            for j in 0..minor_segments {
                let a = i * (minor_segments + 1) + j;
                let b = a + minor_segments + 1;

                indices.push(a);
                indices.push(b);
                indices.push(a + 1);

                indices.push(b);
                indices.push(b + 1);
                indices.push(a + 1);
            }
        }

        Self::finalize(vertices, indices)
    }

    // Cria um grid (útil para terreno e debug)
    pub fn grid(width: f32, depth: f32, width_segments: u32, depth_segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        let hw = width / 2.0;
        let hd = depth / 2.0;

        for z in 0..=depth_segments {
            for x in 0..=width_segments {
                let px = (x as f32 / width_segments as f32) * width - hw;
                let pz = (z as f32 / depth_segments as f32) * depth - hd;

                vertices.push(Vertex {
                    position: Vec3::new(px, 0.0, pz),
                    normal: Vec3::new(0.0, 1.0, 0.0),
                    uv: (x as f32 / width_segments as f32, z as f32 / depth_segments as f32),
                    color: [255, 255, 255, 255],
                });
            }
        }

        for z in 0..depth_segments {
            for x in 0..width_segments {
                let a = z * (width_segments + 1) + x;
                let b = a + width_segments + 1;

                indices.push(a);
                indices.push(b);
                indices.push(a + 1);

                indices.push(b);
                indices.push(b + 1);
                indices.push(a + 1);
            }
        }

        Self::finalize(vertices, indices)
    }

    // Cria uma icosphere (esfera mais uniforme que a esfera UV)
    pub fn icosphere(radius: f32, subdivisions: u32) -> Self {
        let t = (1.0 + 5.0_f32.sqrt()) / 2.0;

        let mut vertices = vec![
            Vec3::new(-1.0, t, 0.0).normalize(),
            Vec3::new(1.0, t, 0.0).normalize(),
            Vec3::new(-1.0, -t, 0.0).normalize(),
            Vec3::new(1.0, -t, 0.0).normalize(),
            Vec3::new(0.0, -1.0, t).normalize(),
            Vec3::new(0.0, 1.0, t).normalize(),
            Vec3::new(0.0, -1.0, -t).normalize(),
            Vec3::new(0.0, 1.0, -t).normalize(),
            Vec3::new(t, 0.0, -1.0).normalize(),
            Vec3::new(t, 0.0, 1.0).normalize(),
            Vec3::new(-t, 0.0, -1.0).normalize(),
            Vec3::new(-t, 0.0, 1.0).normalize(),
        ];

        let mut indices = vec![
            0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11,
            1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8,
            3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9,
            4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1,
        ];

        // Subdivisão (simplificada para performance)
        for _ in 0..subdivisions.min(2) {
            let mut new_indices = Vec::new();
            for i in (0..indices.len()).step_by(3) {
                let v1 = vertices[indices[i] as usize];
                let v2 = vertices[indices[i + 1] as usize];
                let v3 = vertices[indices[i + 2] as usize];

                let a = Vec3::new(
                    (v1.x + v2.x) / 2.0,
                    (v1.y + v2.y) / 2.0,
                    (v1.z + v2.z) / 2.0,
                ).normalize();
                let b = Vec3::new(
                    (v2.x + v3.x) / 2.0,
                    (v2.y + v3.y) / 2.0,
                    (v2.z + v3.z) / 2.0,
                ).normalize();
                let c = Vec3::new(
                    (v3.x + v1.x) / 2.0,
                    (v3.y + v1.y) / 2.0,
                    (v3.z + v1.z) / 2.0,
                ).normalize();

                let ai = vertices.len() as u32;
                vertices.push(a);
                let bi = vertices.len() as u32;
                vertices.push(b);
                let ci = vertices.len() as u32;
                vertices.push(c);

                new_indices.extend_from_slice(&[
                    indices[i], ai, ci,
                    indices[i + 1], bi, ai,
                    indices[i + 2], ci, bi,
                    ai, bi, ci,
                ]);
            }
            indices = new_indices;
        }

        let mesh_vertices: Vec<Vertex> = vertices
            .iter()
            .map(|v| Vertex {
                position: Vec3::new(v.x * radius, v.y * radius, v.z * radius),
                normal: *v,
                uv: (
                    0.5 + v.x.atan2(v.z) / (2.0 * std::f32::consts::PI),
                    0.5 - v.y.asin() / std::f32::consts::PI,
                ),
                color: [255, 255, 255, 255],
            })
            .collect();

        Self::finalize(mesh_vertices, indices)
    }

    // Cria um prisma hexagonal (útil para arquitetura)
    pub fn prism(radius: f32, height: f32, sides: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();
        let half_height = height / 2.0;

        // Centro do topo
        vertices.push(Vertex {
            position: Vec3::new(0.0, half_height, 0.0),
            normal: Vec3::new(0.0, 1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Centro da base
        vertices.push(Vertex {
            position: Vec3::new(0.0, -half_height, 0.0),
            normal: Vec3::new(0.0, -1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Vértices do topo e base
        for i in 0..=sides {
            let angle = i as f32 * 2.0 * std::f32::consts::PI / sides as f32;
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            // Topo
            vertices.push(Vertex {
                position: Vec3::new(x, half_height, z),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (angle.cos() * 0.5 + 0.5, angle.sin() * 0.5 + 0.5),
                color: [255, 255, 255, 255],
            });

            // Base
            vertices.push(Vertex {
                position: Vec3::new(x, -half_height, z),
                normal: Vec3::new(0.0, -1.0, 0.0),
                uv: (angle.cos() * 0.5 + 0.5, angle.sin() * 0.5 + 0.5),
                color: [255, 255, 255, 255],
            });
        }

        // Índices do topo
        for i in 0..sides {
            indices.push(0);
            indices.push(2 + i * 2);
            indices.push(2 + (i + 1) * 2);
        }

        // Índices da base
        for i in 0..sides {
            indices.push(1);
            indices.push(3 + (i + 1) * 2);
            indices.push(3 + i * 2);
        }

        // Índices das faces laterais
        for i in 0..sides {
            let top1 = 2 + i * 2;
            let bottom1 = 3 + i * 2;
            let top2 = 2 + (i + 1) * 2;
            let bottom2 = 3 + (i + 1) * 2;

            indices.push(top1);
            indices.push(bottom1);
            indices.push(top2);

            indices.push(bottom1);
            indices.push(bottom2);
            indices.push(top2);
        }

        Self::finalize(vertices, indices)
    }

    // Métodos auxiliares para manipulação de mesh

    // Define a cor de todos os vértices
    pub fn set_color(&mut self, color: [u8; 4]) {
        for vertex in &mut self.vertices {
            vertex.color = color;
        }
    }

    // Calcula normais automaticamente (flat shading)
    pub fn calculate_normals(&mut self) {
        for i in (0..self.indices.len()).step_by(3) {
            let i0 = self.indices[i] as usize;
            let i1 = self.indices[i + 1] as usize;
            let i2 = self.indices[i + 2] as usize;

            let v0 = &self.vertices[i0].position;
            let v1 = &self.vertices[i1].position;
            let v2 = &self.vertices[i2].position;

            let edge1 = Vec3::new(v1.x - v0.x, v1.y - v0.y, v1.z - v0.z);
            let edge2 = Vec3::new(v2.x - v0.x, v2.y - v0.y, v2.z - v0.z);
            let normal = edge1.cross(&edge2).normalize();

            self.vertices[i0].normal = normal;
            self.vertices[i1].normal = normal;
            self.vertices[i2].normal = normal;
        }
    }

    // Combina múltiplas meshes em uma só
    pub fn merge(&mut self, other: &Mesh3D) {
        let offset = self.vertices.len() as u32;
        self.vertices.extend_from_slice(&other.vertices);
        self.indices.extend(other.indices.iter().map(|i| i + offset));
    }

    // Inverte as normais (útil para objetos internos)
    pub fn flip_normals(&mut self) {
        for vertex in &mut self.vertices {
            vertex.normal.x = -vertex.normal.x;
            vertex.normal.y = -vertex.normal.y;
            vertex.normal.z = -vertex.normal.z;
        }
    }

    // 🆕 v0.1.1 - Novos métodos

    // Translada a mesh
    pub fn translate(&mut self, offset: Vec3) {
        for vertex in &mut self.vertices {
            vertex.position.x += offset.x;
            vertex.position.y += offset.y;
            vertex.position.z += offset.z;
        }
    }

    // Escala a mesh
    pub fn scale(&mut self, scale: Vec3) {
        for vertex in &mut self.vertices {
            vertex.position.x *= scale.x;
            vertex.position.y *= scale.y;
            vertex.position.z *= scale.z;
        }
    }

    // Rotaciona a mesh em torno do eixo Y
    pub fn rotate_y(&mut self, angle: f32) {
        let cos = angle.cos();
        let sin = angle.sin();
        for vertex in &mut self.vertices {
            let x = vertex.position.x;
            let z = vertex.position.z;
            vertex.position.x = x * cos - z * sin;
            vertex.position.z = x * sin + z * cos;
        }
    }

    // Cria uma caixa com dimensões específicas (v0.1.1)
    pub fn box_sized(width: f32, height: f32, depth: f32) -> Self {
        let mut mesh = Self::cube(1.0);
        mesh.scale(Vec3::new(width, height, depth));
        mesh
    }

    // Cria um cilindro com altura e raio específicos (v0.1.1)
    pub fn cylinder_sized(radius: f32, height: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        // Tampa inferior
        vertices.push(Vertex {
            position: Vec3::new(0.0, -height / 2.0, 0.0),
            normal: Vec3::new(0.0, -1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Tampa superior
        vertices.push(Vertex {
            position: Vec3::new(0.0, height / 2.0, 0.0),
            normal: Vec3::new(0.0, 1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Vértices do corpo
        for i in 0..=segments {
            let angle = (i as f32 / segments as f32) * std::f32::consts::PI * 2.0;
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            // Inferior
            vertices.push(Vertex {
                position: Vec3::new(x, -height / 2.0, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 1.0),
                color: [255, 255, 255, 255],
            });

            // Superior
            vertices.push(Vertex {
                position: Vec3::new(x, height / 2.0, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / segments as f32, 0.0),
                color: [255, 255, 255, 255],
            });
        }

        // Índices do corpo
        for i in 0..segments {
            let base = 2 + i * 2;
            indices.extend_from_slice(&[
                base, base + 2, base + 1,
                base + 1, base + 2, base + 3,
            ]);

            // Tampa inferior
            indices.extend_from_slice(&[0, base + 2, base]);

            // Tampa superior
            indices.extend_from_slice(&[1, base + 1, base + 3]);
        }

        Self::finalize(vertices, indices)
    }

    // Cria uma esfera com raio específico (v0.1.1)
    pub fn sphere_sized(radius: f32, segments: u32) -> Self {
        let mut mesh = Self::sphere(1.0, segments);
        mesh.scale(Vec3::new(radius, radius, radius));
        mesh
    }

    // Cria um anel/torus (v0.1.1)
    pub fn ring(outer_radius: f32, inner_radius: f32, segments: u32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        for i in 0..=segments {
            let angle = (i as f32 / segments as f32) * std::f32::consts::PI * 2.0;
            let cos = angle.cos();
            let sin = angle.sin();

            // Vértice externo
            vertices.push(Vertex {
                position: Vec3::new(cos * outer_radius, 0.0, sin * outer_radius),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (i as f32 / segments as f32, 0.0),
                color: [255, 255, 255, 255],
            });

            // Vértice interno
            vertices.push(Vertex {
                position: Vec3::new(cos * inner_radius, 0.0, sin * inner_radius),
                normal: Vec3::new(0.0, 1.0, 0.0),
                uv: (i as f32 / segments as f32, 1.0),
                color: [255, 255, 255, 255],
            });
        }

        for i in 0..segments {
            let base = i * 2;
            indices.extend_from_slice(&[
                base, base + 2, base + 1,
                base + 1, base + 2, base + 3,
            ]);
        }

        Self::finalize(vertices, indices)
    }

    // Cria uma estrela 3D (v0.1.1)
    pub fn star(outer_radius: f32, inner_radius: f32, points: u32, height: f32) -> Self {
        let mut vertices = Vec::new();
        let mut indices = Vec::new();

        // Centro superior e inferior
        vertices.push(Vertex {
            position: Vec3::new(0.0, height / 2.0, 0.0),
            normal: Vec3::new(0.0, 1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });
        vertices.push(Vertex {
            position: Vec3::new(0.0, -height / 2.0, 0.0),
            normal: Vec3::new(0.0, -1.0, 0.0),
            uv: (0.5, 0.5),
            color: [255, 255, 255, 255],
        });

        // Pontas da estrela
        for i in 0..(points * 2) {
            let angle = (i as f32 / (points * 2) as f32) * std::f32::consts::PI * 2.0;
            let radius = if i % 2 == 0 { outer_radius } else { inner_radius };
            let x = angle.cos() * radius;
            let z = angle.sin() * radius;

            // Superior
            vertices.push(Vertex {
                position: Vec3::new(x, height / 2.0, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / (points * 2) as f32, 0.0),
                color: [255, 255, 255, 255],
            });

            // Inferior
            vertices.push(Vertex {
                position: Vec3::new(x, -height / 2.0, z),
                normal: Vec3::new(x, 0.0, z).normalize(),
                uv: (i as f32 / (points * 2) as f32, 1.0),
                color: [255, 255, 255, 255],
            });
        }

        // Índices
        for i in 0..(points * 2) {
            let base = 2 + i * 2;
            let next = 2 + ((i + 1) % (points * 2)) * 2;

            // Tampa superior
            indices.extend_from_slice(&[0, base, next]);

            // Tampa inferior
            indices.extend_from_slice(&[1, next + 1, base + 1]);

            // Lateral
            indices.extend_from_slice(&[
                base, next, base + 1,
                base + 1, next, next + 1,
            ]);
        }

        Self::finalize(vertices, indices)
    }

    // Obtém o centro (bounding box center) da mesh
    pub fn get_center(&self) -> Vec3 {
        if self.vertices.is_empty() {
            return Vec3::zero();
        }

        let mut min = self.vertices[0].position;
        let mut max = self.vertices[0].position;

        for vertex in &self.vertices {
            min.x = min.x.min(vertex.position.x);
            min.y = min.y.min(vertex.position.y);
            min.z = min.z.min(vertex.position.z);
            max.x = max.x.max(vertex.position.x);
            max.y = max.y.max(vertex.position.y);
            max.z = max.z.max(vertex.position.z);
        }

        Vec3::new(
            (min.x + max.x) / 2.0,
            (min.y + max.y) / 2.0,
            (min.z + max.z) / 2.0,
        )
    }

    // Obtém o tamanho (bounding box size) da mesh
    pub fn get_size(&self) -> Vec3 {
        if self.vertices.is_empty() {
            return Vec3::zero();
        }

        let mut min = self.vertices[0].position;
        let mut max = self.vertices[0].position;

        for vertex in &self.vertices {
            min.x = min.x.min(vertex.position.x);
            min.y = min.y.min(vertex.position.y);
            min.z = min.z.min(vertex.position.z);
            max.x = max.x.max(vertex.position.x);
            max.y = max.y.max(vertex.position.y);
            max.z = max.z.max(vertex.position.z);
        }

        Vec3::new(max.x - min.x, max.y - min.y, max.z - min.z)
    }

    // 🆕 v0.2.8 - Métodos avançados de manipulação

    // Subdivide a mesh para mais detalhes
    pub fn subdivide(&mut self) {
        let mut new_vertices = self.vertices.clone();
        let mut new_indices = Vec::new();

        for i in (0..self.indices.len()).step_by(3) {
            let i0 = self.indices[i] as usize;
            let i1 = self.indices[i + 1] as usize;
            let i2 = self.indices[i + 2] as usize;

            let v0 = &self.vertices[i0];
            let v1 = &self.vertices[i1];
            let v2 = &self.vertices[i2];

            // Cria vértices no meio das arestas
            let mid01 = Vertex {
                position: Vec3::new(
                    (v0.position.x + v1.position.x) / 2.0,
                    (v0.position.y + v1.position.y) / 2.0,
                    (v0.position.z + v1.position.z) / 2.0,
                ),
                normal: Vec3::new(
                    (v0.normal.x + v1.normal.x) / 2.0,
                    (v0.normal.y + v1.normal.y) / 2.0,
                    (v0.normal.z + v1.normal.z) / 2.0,
                ).normalize(),
                uv: ((v0.uv.0 + v1.uv.0) / 2.0, (v0.uv.1 + v1.uv.1) / 2.0),
                color: v0.color,
            };

            let mid12 = Vertex {
                position: Vec3::new(
                    (v1.position.x + v2.position.x) / 2.0,
                    (v1.position.y + v2.position.y) / 2.0,
                    (v1.position.z + v2.position.z) / 2.0,
                ),
                normal: Vec3::new(
                    (v1.normal.x + v2.normal.x) / 2.0,
                    (v1.normal.y + v2.normal.y) / 2.0,
                    (v1.normal.z + v2.normal.z) / 2.0,
                ).normalize(),
                uv: ((v1.uv.0 + v2.uv.0) / 2.0, (v1.uv.1 + v2.uv.1) / 2.0),
                color: v1.color,
            };

            let mid20 = Vertex {
                position: Vec3::new(
                    (v2.position.x + v0.position.x) / 2.0,
                    (v2.position.y + v0.position.y) / 2.0,
                    (v2.position.z + v0.position.z) / 2.0,
                ),
                normal: Vec3::new(
                    (v2.normal.x + v0.normal.x) / 2.0,
                    (v2.normal.y + v0.normal.y) / 2.0,
                    (v2.normal.z + v0.normal.z) / 2.0,
                ).normalize(),
                uv: ((v2.uv.0 + v0.uv.0) / 2.0, (v2.uv.1 + v0.uv.1) / 2.0),
                color: v2.color,
            };

            let idx_mid01 = new_vertices.len() as u32;
            new_vertices.push(mid01);
            let idx_mid12 = new_vertices.len() as u32;
            new_vertices.push(mid12);
            let idx_mid20 = new_vertices.len() as u32;
            new_vertices.push(mid20);

            // Cria 4 novos triângulos
            new_indices.extend_from_slice(&[
                self.indices[i], idx_mid01, idx_mid20,
                idx_mid01, self.indices[i + 1], idx_mid12,
                idx_mid20, idx_mid12, self.indices[i + 2],
                idx_mid01, idx_mid12, idx_mid20,
            ]);
        }

        self.vertices = new_vertices;
        self.indices = new_indices;
    }

    // Suaviza a mesh (smooth shading)
    pub fn smooth(&mut self) {
        let mut normals = vec![Vec3::zero(); self.vertices.len()];
        let mut counts = vec![0; self.vertices.len()];

        // Acumula normais de faces adjacentes
        for i in (0..self.indices.len()).step_by(3) {
            let i0 = self.indices[i] as usize;
            let i1 = self.indices[i + 1] as usize;
            let i2 = self.indices[i + 2] as usize;

            let v0 = &self.vertices[i0].position;
            let v1 = &self.vertices[i1].position;
            let v2 = &self.vertices[i2].position;

            let edge1 = Vec3::new(v1.x - v0.x, v1.y - v0.y, v1.z - v0.z);
            let edge2 = Vec3::new(v2.x - v0.x, v2.y - v0.y, v2.z - v0.z);
            let normal = edge1.cross(&edge2);

            normals[i0] = normals[i0] + normal;
            normals[i1] = normals[i1] + normal;
            normals[i2] = normals[i2] + normal;
            counts[i0] += 1;
            counts[i1] += 1;
            counts[i2] += 1;
        }

        // Média e normaliza
        for i in 0..self.vertices.len() {
            if counts[i] > 0 {
                self.vertices[i].normal = (normals[i] / counts[i] as f32).normalize();
            }
        }
    }

    // Cria uma cópia espelhada da mesh
    pub fn mirror(&self, axis: MirrorAxis) -> Self {
        let mut mirrored = self.clone();
        
        for vertex in &mut mirrored.vertices {
            match axis {
                MirrorAxis::X => vertex.position.x = -vertex.position.x,
                MirrorAxis::Y => vertex.position.y = -vertex.position.y,
                MirrorAxis::Z => vertex.position.z = -vertex.position.z,
            }
        }

        // Inverte ordem dos índices para manter winding correto
        for i in (0..mirrored.indices.len()).step_by(3) {
            mirrored.indices.swap(i + 1, i + 2);
        }

        mirrored
    }

    // Extrude faces ao longo das normais
    pub fn extrude(&mut self, distance: f32) {
        let original_vertices = self.vertices.clone();
        
        for vertex in &mut self.vertices {
            vertex.position = vertex.position + vertex.normal * distance;
        }

        // Adiciona faces laterais
        let offset = original_vertices.len() as u32;
        self.vertices.extend(original_vertices);

        let original_indices = self.indices.clone();
        for i in (0..original_indices.len()).step_by(3) {
            let i0 = original_indices[i];
            let i1 = original_indices[i + 1];
            let i2 = original_indices[i + 2];

            // Conecta vértices originais com extrudados
            self.indices.extend_from_slice(&[
                i0, i1, i0 + offset,
                i1, i1 + offset, i0 + offset,
                i1, i2, i1 + offset,
                i2, i2 + offset, i1 + offset,
                i2, i0, i2 + offset,
                i0, i0 + offset, i2 + offset,
            ]);
        }
    }

    // Aplica ruído para terrenos procedurais
    pub fn apply_noise(&mut self, amplitude: f32, frequency: f32) {
        use rand::Rng;
        let mut rng = rand::thread_rng();

        for vertex in &mut self.vertices {
            let noise = rng.gen_range(-1.0..1.0) * amplitude;
            let offset = vertex.normal * noise * frequency;
            vertex.position = vertex.position + offset;
        }
    }

    // Otimiza removendo vértices duplicados
    pub fn optimize(&mut self) {
        let mut unique_vertices = Vec::new();
        let mut index_map = Vec::new();

        for vertex in &self.vertices {
            if let Some(idx) = unique_vertices.iter().position(|v: &Vertex| {
                (v.position.x - vertex.position.x).abs() < 0.001
                    && (v.position.y - vertex.position.y).abs() < 0.001
                    && (v.position.z - vertex.position.z).abs() < 0.001
            }) {
                index_map.push(idx as u32);
            } else {
                index_map.push(unique_vertices.len() as u32);
                unique_vertices.push(vertex.clone());
            }
        }

        // Remapeia índices
        for index in &mut self.indices {
            *index = index_map[*index as usize];
        }

        self.vertices = unique_vertices;
    }

    // Calcula área de superfície total
    pub fn surface_area(&self) -> f32 {
        let mut area = 0.0;

        for i in (0..self.indices.len()).step_by(3) {
            let v0 = &self.vertices[self.indices[i] as usize].position;
            let v1 = &self.vertices[self.indices[i + 1] as usize].position;
            let v2 = &self.vertices[self.indices[i + 2] as usize].position;

            let edge1 = *v1 - *v0;
            let edge2 = *v2 - *v0;
            let cross = edge1.cross(&edge2);
            area += cross.length() / 2.0;
        }

        area
    }

    // Calcula volume (para meshes fechadas)
    pub fn volume(&self) -> f32 {
        let mut volume = 0.0;

        for i in (0..self.indices.len()).step_by(3) {
            let v0 = &self.vertices[self.indices[i] as usize].position;
            let v1 = &self.vertices[self.indices[i + 1] as usize].position;
            let v2 = &self.vertices[self.indices[i + 2] as usize].position;

            volume += v0.dot(&v1.cross(v2)) / 6.0;
        }

        volume.abs()
    }
}

#[derive(Debug, Clone, Copy)]
pub enum MirrorAxis {
    X,
    Y,
    Z,
}