mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Add tetrahedron gizmos (#12914)
# Objective - Adds tetrahedron gizmos, suggestion of #9400 ## Solution - Implement tetrahedron gizmos as a `gizmos.primitive_3d` ## Additional info Here is a short video of the default tetrahedron :) https://github.com/bevyengine/bevy/assets/62256001/a6f31b6f-78bc-4dc2-8f46-2ebd04ed8a0e --------- Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
parent
78c922509b
commit
597799a979
1 changed files with 30 additions and 1 deletions
|
@ -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<T: GizmoConfigGroup> Drop for Torus3dBuilder<'_, '_, '_, T> {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// tetrahedron
|
||||
|
||||
impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Tetrahedron> 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<Color>,
|
||||
) -> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue