pub struct Gizmos<'s> { /* private fields */ }
Expand description
A SystemParam
for drawing gizmos.
Implementations§
§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 from start
to end
.
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 with a color gradient from start
to end
.
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 from start
to start + vector
.
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 with a color gradient from start
to start + vector
.
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 lines between a list of points.
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 lines between a list of points with a color gradient.
Example
fn system(mut gizmos: Gizmos) {
gizmos.linestrip_gradient([
(Vec3::ZERO, Color::GREEN),
(Vec3::X, Color::RED),
(Vec3::Y, Color::BLUE)
]);
}
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 at position
with the flat side facing normal
.
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 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 made out of 3 circles.
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.
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.
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 from start
to end
.
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 with a color gradient from start
to end
.
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 lines between a list of points.
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 lines between a list of points with a color gradient.
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 from start
to start + vector
.
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 with a color gradient from start
to start + vector
.
Example
fn system(mut gizmos: Gizmos) {
gizmos.line_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED);
}
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.
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);
}
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.
Arguments
position
sets the center of this circle.radius
controls the distance fromposition
to this arc, and thus its curvature.direction_angle
sets the angle in radians betweenposition
and 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);
}
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>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.