diff --git a/crates/bevy_gizmos/src/primitives/dim3.rs b/crates/bevy_gizmos/src/primitives/dim3.rs index c34d9ba234..9f1f38890a 100644 --- a/crates/bevy_gizmos/src/primitives/dim3.rs +++ b/crates/bevy_gizmos/src/primitives/dim3.rs @@ -6,7 +6,7 @@ use std::f32::consts::TAU; use bevy_color::Color; use bevy_math::primitives::{ BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, - Polyline3d, Primitive3d, Segment3d, Sphere, Torus, + Polyline3d, Primitive3d, Segment3d, Sphere, Tetrahedron, Torus, }; use bevy_math::{Dir3, Quat, Vec3}; @@ -943,3 +943,32 @@ impl Drop for Torus3dBuilder<'_, '_, '_, T> { }); } } + +// tetrahedron + +impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> { + type Output<'a> = () where Self: 'a; + + fn primitive_3d( + &mut self, + primitive: Tetrahedron, + position: Vec3, + rotation: Quat, + color: impl Into, + ) -> Self::Output<'_> { + if !self.enabled { + return; + } + + let [a, b, c, d] = primitive + .vertices + .map(rotate_then_translate_3d(rotation, position)); + + let lines = [(a, b), (a, c), (a, d), (b, c), (b, d), (c, d)]; + + let color = color.into(); + for (a, b) in lines.into_iter() { + self.line(a, b, color); + } + } +}