Skip to content

Commit f6500f5

Browse files
committed
Allow wiresphere to be rotated
1 parent 5654d3c commit f6500f5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

crates/bevy_gizmos/src/gizmos.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,17 @@ impl GizmoBuffer {
118118

119119
/// Draw a sphere.
120120
#[inline]
121-
pub fn sphere(&mut self, position: Vec3, radius: f32, color: Color) -> SphereBuilder {
121+
pub fn sphere(
122+
&mut self,
123+
position: Vec3,
124+
rotation: Quat,
125+
radius: f32,
126+
color: Color,
127+
) -> SphereBuilder {
122128
SphereBuilder {
123129
buffer: self,
124130
position,
131+
rotation,
125132
radius,
126133
color,
127134
circle_segments: DEFAULT_CIRCLE_SEGMENTS,
@@ -280,6 +287,7 @@ impl<'a> Drop for CircleBuilder<'a> {
280287
pub struct SphereBuilder<'a> {
281288
buffer: &'a mut GizmoBuffer,
282289
position: Vec3,
290+
rotation: Quat,
283291
radius: f32,
284292
color: Color,
285293
circle_segments: usize,
@@ -296,7 +304,7 @@ impl Drop for SphereBuilder<'_> {
296304
fn drop(&mut self) {
297305
for axis in Vec3::AXES {
298306
self.buffer
299-
.circle(self.position, axis, self.radius, self.color)
307+
.circle(self.position, self.rotation * axis, self.radius, self.color)
300308
.segments(self.circle_segments);
301309
}
302310
}

examples/3d/3d_gizmos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn system(mut gizmos: Gizmos, time: Res<Time>) {
6262
Color::GREEN,
6363
);
6464

65-
gizmos.sphere(Vec3::new(1., 0.5, 0.), 0.5, Color::RED);
65+
gizmos.sphere(Vec3::new(1., 0.5, 0.), Quat::IDENTITY, 0.5, Color::RED);
6666

6767
for y in [0., 0.5, 1.] {
6868
gizmos.ray(
@@ -79,7 +79,7 @@ fn system(mut gizmos: Gizmos, time: Res<Time>) {
7979
.circle(Vec3::ZERO, Vec3::Y, 3.1, Color::NAVY)
8080
.segments(64);
8181
gizmos
82-
.sphere(Vec3::ZERO, 3.2, Color::BLACK)
82+
.sphere(Vec3::ZERO, Quat::IDENTITY, 3.2, Color::BLACK)
8383
.circle_segments(64);
8484
}
8585

0 commit comments

Comments
 (0)