pub struct Gizmos<'s> { /* private fields */ }
Expand description
A SystemParam
for drawing gizmos.
They are drawn in immediate mode, which means they will be rendered only for
the frames in which they are spawned.
Gizmos should be spawned before the Last
schedule to ensure they are drawn.
Implementations§
§impl<'s> Gizmos<'s>
impl<'s> Gizmos<'s>
pub fn arc_2d(
&mut self,
position: Vec2,
direction_angle: f32,
arc_angle: f32,
radius: f32,
color: Color
) -> Arc2dBuilder<'_, 's>
pub fn arc_2d( &mut self, position: Vec2, direction_angle: f32, arc_angle: f32, radius: f32, color: Color ) -> Arc2dBuilder<'_, 's>
Draw an arc, which is a part of the circumference of a circle, in 2D.
This should be called for each frame the arc needs to be rendered.
Arguments
position
sets the center of this circle.radius
controls the distance fromposition
to this arc, and thus its curvature.direction_angle
sets the clockwise angle in radians betweenVec2::Y
and the vector fromposition
to the midpoint of the arc.arc_angle
sets the length of this arc, in radians.
Example
fn system(mut gizmos: Gizmos) {
gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., Color::GREEN);
// Arcs have 32 line-segments by default.
// You may want to increase this for larger arcs.
gizmos
.arc_2d(Vec2::ZERO, 0., PI / 4., 5., Color::RED)
.segments(64);
}
§impl<'s> Gizmos<'s>
impl<'s> Gizmos<'s>
pub fn arrow(
&mut self,
start: Vec3,
end: Vec3,
color: Color
) -> ArrowBuilder<'_, 's>
pub fn arrow( &mut self, start: Vec3, end: Vec3, color: Color ) -> ArrowBuilder<'_, 's>
Draw an arrow in 3D, from start
to end
. Has four tips for convienent viewing from any direction.
This should be called for each frame the arrow needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.arrow(Vec3::ZERO, Vec3::ONE, Color::GREEN);
}
pub fn arrow_2d(
&mut self,
start: Vec2,
end: Vec2,
color: Color
) -> ArrowBuilder<'_, 's>
pub fn arrow_2d( &mut self, start: Vec2, end: Vec2, color: Color ) -> ArrowBuilder<'_, 's>
Draw an arrow in 2D (on the xy plane), from start
to end
.
This should be called for each frame the arrow needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.arrow_2d(Vec2::ZERO, Vec2::X, Color::GREEN);
}
§impl<'s> Gizmos<'s>
impl<'s> Gizmos<'s>
pub fn circle(
&mut self,
position: Vec3,
normal: Vec3,
radius: f32,
color: Color
) -> CircleBuilder<'_, 's>
pub fn circle( &mut self, position: Vec3, normal: Vec3, radius: f32, color: Color ) -> CircleBuilder<'_, 's>
Draw a circle in 3D at position
with the flat side facing normal
.
This should be called for each frame the circle needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.circle(Vec3::ZERO, Vec3::Z, 1., Color::GREEN);
// Circles have 32 line-segments by default.
// You may want to increase this for larger circles.
gizmos
.circle(Vec3::ZERO, Vec3::Z, 5., Color::RED)
.segments(64);
}
pub fn circle_2d(
&mut self,
position: Vec2,
radius: f32,
color: Color
) -> Circle2dBuilder<'_, 's>
pub fn circle_2d( &mut self, position: Vec2, radius: f32, color: Color ) -> Circle2dBuilder<'_, 's>
Draw a circle in 2D.
This should be called for each frame the circle needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.circle_2d(Vec2::ZERO, 1., Color::GREEN);
// Circles have 32 line-segments by default.
// You may want to increase this for larger circles.
gizmos
.circle_2d(Vec2::ZERO, 5., Color::RED)
.segments(64);
}
§impl<'s> Gizmos<'s>
impl<'s> Gizmos<'s>
pub fn line(&mut self, start: Vec3, end: Vec3, color: Color)
pub fn line(&mut self, start: Vec3, end: Vec3, color: Color)
Draw a line in 3D from start
to end
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN);
}
pub fn line_gradient(
&mut self,
start: Vec3,
end: Vec3,
start_color: Color,
end_color: Color
)
pub fn line_gradient( &mut self, start: Vec3, end: Vec3, start_color: Color, end_color: Color )
Draw a line in 3D with a color gradient from start
to end
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line_gradient(Vec3::ZERO, Vec3::X, Color::GREEN, Color::RED);
}
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: Color)
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: Color)
Draw a line in 3D from start
to start + vector
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.ray(Vec3::Y, Vec3::X, Color::GREEN);
}
pub fn ray_gradient(
&mut self,
start: Vec3,
vector: Vec3,
start_color: Color,
end_color: Color
)
pub fn ray_gradient( &mut self, start: Vec3, vector: Vec3, start_color: Color, end_color: Color )
Draw a line in 3D with a color gradient from start
to start + vector
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.ray_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED);
}
pub fn linestrip(
&mut self,
positions: impl IntoIterator<Item = Vec3>,
color: Color
)
pub fn linestrip( &mut self, positions: impl IntoIterator<Item = Vec3>, color: Color )
Draw a line in 3D made of straight segments between the points.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.linestrip([Vec3::ZERO, Vec3::X, Vec3::Y], Color::GREEN);
}
pub fn linestrip_gradient(
&mut self,
points: impl IntoIterator<Item = (Vec3, Color)>
)
pub fn linestrip_gradient( &mut self, points: impl IntoIterator<Item = (Vec3, Color)> )
Draw a line in 3D made of straight segments between the points, with a color gradient.
This should be called for each frame the lines need to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.linestrip_gradient([
(Vec3::ZERO, Color::GREEN),
(Vec3::X, Color::RED),
(Vec3::Y, Color::BLUE)
]);
}
pub fn sphere(
&mut self,
position: Vec3,
rotation: Quat,
radius: f32,
color: Color
) -> SphereBuilder<'_, 's>
pub fn sphere( &mut self, position: Vec3, rotation: Quat, radius: f32, color: Color ) -> SphereBuilder<'_, 's>
Draw a wireframe sphere in 3D made out of 3 circles around the axes.
This should be called for each frame the sphere needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.sphere(Vec3::ZERO, Quat::IDENTITY, 1., Color::BLACK);
// Each circle has 32 line-segments by default.
// You may want to increase this for larger spheres.
gizmos
.sphere(Vec3::ZERO, Quat::IDENTITY, 5., Color::BLACK)
.circle_segments(64);
}
pub fn rect(&mut self, position: Vec3, rotation: Quat, size: Vec2, color: Color)
pub fn rect(&mut self, position: Vec3, rotation: Quat, size: Vec2, color: Color)
Draw a wireframe rectangle in 3D.
This should be called for each frame the rectangle needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.rect(Vec3::ZERO, Quat::IDENTITY, Vec2::ONE, Color::GREEN);
}
pub fn cuboid(&mut self, transform: impl TransformPoint, color: Color)
pub fn cuboid(&mut self, transform: impl TransformPoint, color: Color)
Draw a wireframe cube in 3D.
This should be called for each frame the cube needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.cuboid(Transform::IDENTITY, Color::GREEN);
}
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color)
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color)
Draw a line in 2D from start
to end
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line_2d(Vec2::ZERO, Vec2::X, Color::GREEN);
}
pub fn line_gradient_2d(
&mut self,
start: Vec2,
end: Vec2,
start_color: Color,
end_color: Color
)
pub fn line_gradient_2d( &mut self, start: Vec2, end: Vec2, start_color: Color, end_color: Color )
Draw a line in 2D with a color gradient from start
to end
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line_gradient_2d(Vec2::ZERO, Vec2::X, Color::GREEN, Color::RED);
}
pub fn linestrip_2d(
&mut self,
positions: impl IntoIterator<Item = Vec2>,
color: Color
)
pub fn linestrip_2d( &mut self, positions: impl IntoIterator<Item = Vec2>, color: Color )
Draw a line in 2D made of straight segments between the points.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.linestrip_2d([Vec2::ZERO, Vec2::X, Vec2::Y], Color::GREEN);
}
pub fn linestrip_gradient_2d(
&mut self,
positions: impl IntoIterator<Item = (Vec2, Color)>
)
pub fn linestrip_gradient_2d( &mut self, positions: impl IntoIterator<Item = (Vec2, Color)> )
Draw a line in 2D made of straight segments between the points, with a color gradient.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.linestrip_gradient_2d([
(Vec2::ZERO, Color::GREEN),
(Vec2::X, Color::RED),
(Vec2::Y, Color::BLUE)
]);
}
pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: Color)
pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: Color)
Draw a line in 2D from start
to start + vector
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.ray_2d(Vec2::Y, Vec2::X, Color::GREEN);
}
pub fn ray_gradient_2d(
&mut self,
start: Vec2,
vector: Vec2,
start_color: Color,
end_color: Color
)
pub fn ray_gradient_2d( &mut self, start: Vec2, vector: Vec2, start_color: Color, end_color: Color )
Draw a line in 2D with a color gradient from start
to start + vector
.
This should be called for each frame the line needs to be rendered.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED);
}
Trait Implementations§
§impl SystemParam for Gizmos<'_>
impl SystemParam for Gizmos<'_>
§type Item<'w, 's> = Gizmos<'s>
type Item<'w, 's> = Gizmos<'s>
Self
, instantiated with new lifetimes. Read more§fn init_state(
world: &mut World,
system_meta: &mut SystemMeta
) -> <Gizmos<'_> as SystemParam>::State
fn init_state( world: &mut World, system_meta: &mut SystemMeta ) -> <Gizmos<'_> as SystemParam>::State
World
access used by this SystemParam
and creates a new instance of this param’s State
.§fn new_archetype(
state: &mut <Gizmos<'_> as SystemParam>::State,
archetype: &Archetype,
system_meta: &mut SystemMeta
)
fn new_archetype( state: &mut <Gizmos<'_> as SystemParam>::State, archetype: &Archetype, system_meta: &mut SystemMeta )
Archetype
, registers the components accessed by this SystemParam
(if applicable).§fn apply(
state: &mut <Gizmos<'_> as SystemParam>::State,
system_meta: &SystemMeta,
world: &mut World
)
fn apply( state: &mut <Gizmos<'_> as SystemParam>::State, system_meta: &SystemMeta, world: &mut World )
SystemParam
’s state.
This is used to apply Commands
during apply_deferred
.§unsafe fn get_param<'w, 's>(
state: &'s mut <Gizmos<'_> as SystemParam>::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick
) -> <Gizmos<'_> as SystemParam>::Item<'w, 's>
unsafe fn get_param<'w, 's>( state: &'s mut <Gizmos<'_> as SystemParam>::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick ) -> <Gizmos<'_> as SystemParam>::Item<'w, 's>
SystemParamFunction
. Read moreimpl<'w, 's> ReadOnlySystemParam for Gizmos<'s>where Deferred<'s, GizmoBuffer>: ReadOnlySystemParam,
Auto Trait Implementations§
impl<'s> RefUnwindSafe for Gizmos<'s>
impl<'s> Send for Gizmos<'s>
impl<'s> Sync for Gizmos<'s>
impl<'s> Unpin for Gizmos<'s>
impl<'s> !UnwindSafe for Gizmos<'s>
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.