Struct bevy_gizmos::gizmos::Gizmos
source · pub struct Gizmos<'w, 's, Config = DefaultGizmoConfigGroup, Clear = ()>{
pub config: &'w GizmoConfig,
pub config_ext: &'w Config,
/* 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, or ticks when in FixedMain
, in which
they are spawned.
A system in Main
will be cleared each rendering
frame, while a system in FixedMain
will be
cleared each time the RunFixedMainLoop
schedule is run.
Gizmos should be spawned before the Last
schedule
to ensure they are drawn.
To set up your own clearing context (useful for custom scheduling similar
to FixedMain
):
use bevy_gizmos::{prelude::*, *, gizmos::GizmoStorage};
struct ClearContextSetup;
impl Plugin for ClearContextSetup {
fn build(&self, app: &mut App) {
app.init_resource::<GizmoStorage<DefaultGizmoConfigGroup, MyContext>>()
// Make sure this context starts/ends cleanly if inside another context. E.g. it
// should start after the parent context starts and end after the parent context ends.
.add_systems(StartOfMyContext, start_gizmo_context::<DefaultGizmoConfigGroup, MyContext>)
// If not running multiple times, put this with [`start_gizmo_context`].
.add_systems(StartOfRun, clear_gizmo_context::<DefaultGizmoConfigGroup, MyContext>)
// If not running multiple times, put this with [`end_gizmo_context`].
.add_systems(EndOfRun, collect_requested_gizmos::<DefaultGizmoConfigGroup, MyContext>)
.add_systems(EndOfMyContext, end_gizmo_context::<DefaultGizmoConfigGroup, MyContext>)
.add_systems(
Last,
propagate_gizmos::<DefaultGizmoConfigGroup, MyContext>.before(UpdateGizmoMeshes),
);
}
}
Fields§
§config: &'w GizmoConfig
The currently used GizmoConfig
config_ext: &'w Config
The currently used GizmoConfigGroup
Implementations§
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn arc_2d(
&mut self,
position: Vec2,
direction_angle: f32,
arc_angle: f32,
radius: f32,
color: impl Into<Color>
) -> Arc2dBuilder<'_, 'w, 's, Config, Clear>
pub fn arc_2d( &mut self, position: Vec2, direction_angle: f32, arc_angle: f32, radius: f32, color: impl Into<Color> ) -> Arc2dBuilder<'_, 'w, 's, Config, Clear>
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.direction_angle
sets the counter-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.radius
controls the distance fromposition
to this arc, and thus its curvature.color
sets the color to draw the arc.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., 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., RED)
.resolution(64);
}
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn arc_3d(
&mut self,
angle: f32,
radius: f32,
position: Vec3,
rotation: Quat,
color: impl Into<Color>
) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
pub fn arc_3d( &mut self, angle: f32, radius: f32, position: Vec3, rotation: Quat, color: impl Into<Color> ) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
Draw an arc, which is a part of the circumference of a circle, in 3D. For default values this is drawing a standard arc. A standard arc is defined as
- an arc with a center at
Vec3::ZERO
- starting at
Vec3::X
- embedded in the XZ plane
- rotates counterclockwise
This should be called for each frame the arc needs to be rendered.
§Arguments
angle
: sets how much of a circle circumference is passed, e.g. PI is half a circle. This value should be in the range (-2 * PI..=2 * PI)radius
: distance between the arc and its center pointposition
: position of the arcs center pointrotation
: defines orientation of the arc, by default we assume the arc is contained in a plane parallel to the XZ plane and the default starting point is (position + Vec3::X
)color
: color of the arc
§Builder methods
The resolution of the arc (i.e. the level of detail) can be adjusted with the
.resolution(...)
method.
§Example
fn system(mut gizmos: Gizmos) {
// rotation rotates normal to point in the direction of `Vec3::NEG_ONE`
let rotation = Quat::from_rotation_arc(Vec3::Y, Vec3::NEG_ONE.normalize());
gizmos
.arc_3d(
270.0_f32.to_radians(),
0.25,
Vec3::ONE,
rotation,
ORANGE
)
.resolution(100);
}
sourcepub fn short_arc_3d_between(
&mut self,
center: Vec3,
from: Vec3,
to: Vec3,
color: impl Into<Color>
) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
pub fn short_arc_3d_between( &mut self, center: Vec3, from: Vec3, to: Vec3, color: impl Into<Color> ) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
Draws the shortest arc between two points (from
and to
) relative to a specified center
point.
§Arguments
center
: The center point around which the arc is drawn.from
: The starting point of the arc.to
: The ending point of the arc.color
: color of the arc
§Builder methods
The resolution of the arc (i.e. the level of detail) can be adjusted with the
.resolution(...)
method.
§Examples
fn system(mut gizmos: Gizmos) {
gizmos.short_arc_3d_between(
Vec3::ONE,
Vec3::ONE + Vec3::NEG_ONE,
Vec3::ZERO,
ORANGE
)
.resolution(100);
}
§Notes
- This method assumes that the points
from
andto
are distinct fromcenter
. If one of the points is coincident withcenter
, nothing is rendered. - The arc is drawn as a portion of a circle with a radius equal to the distance from the
center
tofrom
. If the distance fromcenter
toto
is not equal to the radius, then the results will behave as if this were the case
sourcepub fn long_arc_3d_between(
&mut self,
center: Vec3,
from: Vec3,
to: Vec3,
color: impl Into<Color>
) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
pub fn long_arc_3d_between( &mut self, center: Vec3, from: Vec3, to: Vec3, color: impl Into<Color> ) -> Arc3dBuilder<'_, 'w, 's, Config, Clear>
Draws the longest arc between two points (from
and to
) relative to a specified center
point.
§Arguments
center
: The center point around which the arc is drawn.from
: The starting point of the arc.to
: The ending point of the arc.color
: color of the arc
§Builder methods
The resolution of the arc (i.e. the level of detail) can be adjusted with the
.resolution(...)
method.
§Examples
fn system(mut gizmos: Gizmos) {
gizmos.long_arc_3d_between(
Vec3::ONE,
Vec3::ONE + Vec3::NEG_ONE,
Vec3::ZERO,
ORANGE
)
.resolution(100);
}
§Notes
- This method assumes that the points
from
andto
are distinct fromcenter
. If one of the points is coincident withcenter
, nothing is rendered. - The arc is drawn as a portion of a circle with a radius equal to the distance from the
center
tofrom
. If the distance fromcenter
toto
is not equal to the radius, then the results will behave as if this were the case.
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn arrow(
&mut self,
start: Vec3,
end: Vec3,
color: impl Into<Color>
) -> ArrowBuilder<'_, 'w, 's, Config, Clear>
pub fn arrow( &mut self, start: Vec3, end: Vec3, color: impl Into<Color> ) -> ArrowBuilder<'_, 'w, 's, Config, Clear>
Draw an arrow in 3D, from start
to end
. Has four tips for convenient 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, GREEN);
}
sourcepub fn arrow_2d(
&mut self,
start: Vec2,
end: Vec2,
color: impl Into<Color>
) -> ArrowBuilder<'_, 'w, 's, Config, Clear>
pub fn arrow_2d( &mut self, start: Vec2, end: Vec2, color: impl Into<Color> ) -> ArrowBuilder<'_, 'w, 's, Config, Clear>
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, GREEN);
}
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn axes(&mut self, transform: impl TransformPoint, base_length: f32)
pub fn axes(&mut self, transform: impl TransformPoint, base_length: f32)
Draw a set of axes local to the given transform (transform
), with length scaled by a factor
of base_length
.
This should be called for each frame the axes need to be rendered.
§Example
fn draw_axes(
mut gizmos: Gizmos,
query: Query<&Transform, With<MyComponent>>,
) {
for &transform in &query {
gizmos.axes(transform, 1.);
}
}
sourcepub fn axes_2d(&mut self, transform: impl TransformPoint, base_length: f32)
pub fn axes_2d(&mut self, transform: impl TransformPoint, base_length: f32)
Draw a set of axes local to the given transform (transform
), with length scaled by a factor
of base_length
.
This should be called for each frame the axes need to be rendered.
§Example
fn draw_axes_2d(
mut gizmos: Gizmos,
query: Query<&Transform, With<AxesComponent>>,
) {
for &transform in &query {
gizmos.axes_2d(transform, 1.);
}
}
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn ellipse(
&mut self,
position: Vec3,
rotation: Quat,
half_size: Vec2,
color: impl Into<Color>
) -> EllipseBuilder<'_, 'w, 's, Config, Clear>
pub fn ellipse( &mut self, position: Vec3, rotation: Quat, half_size: Vec2, color: impl Into<Color> ) -> EllipseBuilder<'_, 'w, 's, Config, Clear>
Draw an ellipse in 3D at position
with the flat side facing normal
.
This should be called for each frame the ellipse needs to be rendered.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(1., 2.), GREEN);
// Ellipses have 32 line-segments by default.
// You may want to increase this for larger ellipses.
gizmos
.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(5., 1.), RED)
.resolution(64);
}
sourcepub fn ellipse_2d(
&mut self,
position: Vec2,
angle: f32,
half_size: Vec2,
color: impl Into<Color>
) -> Ellipse2dBuilder<'_, 'w, 's, Config, Clear>
pub fn ellipse_2d( &mut self, position: Vec2, angle: f32, half_size: Vec2, color: impl Into<Color> ) -> Ellipse2dBuilder<'_, 'w, 's, Config, Clear>
Draw an ellipse in 2D.
This should be called for each frame the ellipse needs to be rendered.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(2., 1.), GREEN);
// Ellipses have 32 line-segments by default.
// You may want to increase this for larger ellipses.
gizmos
.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(5., 1.), RED)
.resolution(64);
}
sourcepub fn circle(
&mut self,
position: Vec3,
normal: Dir3,
radius: f32,
color: impl Into<Color>
) -> EllipseBuilder<'_, 'w, 's, Config, Clear>
pub fn circle( &mut self, position: Vec3, normal: Dir3, radius: f32, color: impl Into<Color> ) -> EllipseBuilder<'_, 'w, 's, Config, Clear>
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, Dir3::Z, 1., GREEN);
// Circles have 32 line-segments by default.
// You may want to increase this for larger circles.
gizmos
.circle(Vec3::ZERO, Dir3::Z, 5., RED)
.resolution(64);
}
sourcepub fn circle_2d(
&mut self,
position: Vec2,
radius: f32,
color: impl Into<Color>
) -> Ellipse2dBuilder<'_, 'w, 's, Config, Clear>
pub fn circle_2d( &mut self, position: Vec2, radius: f32, color: impl Into<Color> ) -> Ellipse2dBuilder<'_, 'w, 's, Config, Clear>
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., GREEN);
// Circles have 32 line-segments by default.
// You may want to increase this for larger circles.
gizmos
.circle_2d(Vec2::ZERO, 5., RED)
.resolution(64);
}
sourcepub fn sphere(
&mut self,
position: Vec3,
rotation: Quat,
radius: f32,
color: impl Into<Color>
) -> SphereBuilder<'_, 'w, 's, Config, Clear>
pub fn sphere( &mut self, position: Vec3, rotation: Quat, radius: f32, color: impl Into<Color> ) -> SphereBuilder<'_, 'w, 's, Config, Clear>
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)
.resolution(64);
}
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn line(&mut self, start: Vec3, end: Vec3, color: impl Into<Color>)
pub fn line(&mut self, start: Vec3, end: Vec3, color: impl Into<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, GREEN);
}
sourcepub fn line_gradient<C: Into<Color>>(
&mut self,
start: Vec3,
end: Vec3,
start_color: C,
end_color: C
)
pub fn line_gradient<C: Into<Color>>( &mut self, start: Vec3, end: Vec3, start_color: C, end_color: C )
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, GREEN, RED);
}
sourcepub fn ray(&mut self, start: Vec3, vector: Vec3, color: impl Into<Color>)
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: impl Into<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, GREEN);
}
sourcepub fn ray_gradient<C: Into<Color>>(
&mut self,
start: Vec3,
vector: Vec3,
start_color: C,
end_color: C
)
pub fn ray_gradient<C: Into<Color>>( &mut self, start: Vec3, vector: Vec3, start_color: C, end_color: C )
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, GREEN, RED);
}
sourcepub fn linestrip(
&mut self,
positions: impl IntoIterator<Item = Vec3>,
color: impl Into<Color>
)
pub fn linestrip( &mut self, positions: impl IntoIterator<Item = Vec3>, color: impl Into<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], GREEN);
}
sourcepub fn linestrip_gradient<C: Into<Color>>(
&mut self,
points: impl IntoIterator<Item = (Vec3, C)>
)
pub fn linestrip_gradient<C: Into<Color>>( &mut self, points: impl IntoIterator<Item = (Vec3, C)> )
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, GREEN),
(Vec3::X, RED),
(Vec3::Y, BLUE)
]);
}
sourcepub fn rect(
&mut self,
position: Vec3,
rotation: Quat,
size: Vec2,
color: impl Into<Color>
)
pub fn rect( &mut self, position: Vec3, rotation: Quat, size: Vec2, color: impl Into<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, GREEN);
}
sourcepub fn cuboid(
&mut self,
transform: impl TransformPoint,
color: impl Into<Color>
)
pub fn cuboid( &mut self, transform: impl TransformPoint, color: impl Into<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, GREEN);
}
sourcepub fn line_2d(&mut self, start: Vec2, end: Vec2, color: impl Into<Color>)
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: impl Into<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, GREEN);
}
sourcepub fn line_gradient_2d<C: Into<Color>>(
&mut self,
start: Vec2,
end: Vec2,
start_color: C,
end_color: C
)
pub fn line_gradient_2d<C: Into<Color>>( &mut self, start: Vec2, end: Vec2, start_color: C, end_color: C )
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, GREEN, RED);
}
sourcepub fn linestrip_2d(
&mut self,
positions: impl IntoIterator<Item = Vec2>,
color: impl Into<Color>
)
pub fn linestrip_2d( &mut self, positions: impl IntoIterator<Item = Vec2>, color: impl Into<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], GREEN);
}
sourcepub fn linestrip_gradient_2d<C: Into<Color>>(
&mut self,
positions: impl IntoIterator<Item = (Vec2, C)>
)
pub fn linestrip_gradient_2d<C: Into<Color>>( &mut self, positions: impl IntoIterator<Item = (Vec2, C)> )
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, GREEN),
(Vec2::X, RED),
(Vec2::Y, BLUE)
]);
}
sourcepub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: impl Into<Color>)
pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: impl Into<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, GREEN);
}
sourcepub fn ray_gradient_2d<C: Into<Color>>(
&mut self,
start: Vec2,
vector: Vec2,
start_color: C,
end_color: C
)
pub fn ray_gradient_2d<C: Into<Color>>( &mut self, start: Vec2, vector: Vec2, start_color: C, end_color: C )
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, GREEN, RED);
}
sourcepub fn rect_2d(
&mut self,
position: Vec2,
rotation: impl Into<Rot2>,
size: Vec2,
color: impl Into<Color>
)
pub fn rect_2d( &mut self, position: Vec2, rotation: impl Into<Rot2>, size: Vec2, color: impl Into<Color> )
Draw a wireframe rectangle in 2D.
This should be called for each frame the rectangle needs to be rendered.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.rect_2d(Vec2::ZERO, 0., Vec2::ONE, GREEN);
}
source§impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Gizmos<'w, 's, Config, Clear>
sourcepub fn grid(
&mut self,
position: Vec3,
rotation: Quat,
cell_count: UVec2,
spacing: Vec2,
color: impl Into<LinearRgba>
) -> GridBuilder2d<'_, 'w, 's, Config, Clear>
pub fn grid( &mut self, position: Vec3, rotation: Quat, cell_count: UVec2, spacing: Vec2, color: impl Into<LinearRgba> ) -> GridBuilder2d<'_, 'w, 's, Config, Clear>
Draw a 2D grid in 3D.
This should be called for each frame the grid needs to be rendered.
§Arguments
position
: The center point of the grid.rotation
: defines the orientation of the grid, by default we assume the grid is contained in a plane parallel to the XY plane.cell_count
: defines the amount of cells in the x and y axesspacing
: defines the distance between cells along the x and y axescolor
: color of the grid
§Builder methods
- The skew of the grid can be adjusted using the
.skew(...)
,.skew_x(...)
or.skew_y(...)
methods. They behave very similar to their CSS equivalents. - All outer edges can be toggled on or off using
.outer_edges(...)
. Alternatively you can use.outer_edges_x(...)
or.outer_edges_y(...)
to toggle the outer edges along an axis.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.grid(
Vec3::ZERO,
Quat::IDENTITY,
UVec2::new(10, 10),
Vec2::splat(2.),
GREEN
)
.skew_x(0.25)
.outer_edges();
}
sourcepub fn grid_3d(
&mut self,
position: Vec3,
rotation: Quat,
cell_count: UVec3,
spacing: Vec3,
color: impl Into<LinearRgba>
) -> GridBuilder3d<'_, 'w, 's, Config, Clear>
pub fn grid_3d( &mut self, position: Vec3, rotation: Quat, cell_count: UVec3, spacing: Vec3, color: impl Into<LinearRgba> ) -> GridBuilder3d<'_, 'w, 's, Config, Clear>
Draw a 3D grid of voxel-like cells.
This should be called for each frame the grid needs to be rendered.
§Arguments
position
: The center point of the grid.rotation
: defines the orientation of the grid, by default we assume the grid is contained in a plane parallel to the XY plane.cell_count
: defines the amount of cells in the x, y and z axesspacing
: defines the distance between cells along the x, y and z axescolor
: color of the grid
§Builder methods
- The skew of the grid can be adjusted using the
.skew(...)
,.skew_x(...)
,.skew_y(...)
or.skew_z(...)
methods. They behave very similar to their CSS equivalents. - All outer edges can be toggled on or off using
.outer_edges(...)
. Alternatively you can use.outer_edges_x(...)
,.outer_edges_y(...)
or.outer_edges_z(...)
to toggle the outer edges along an axis.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.grid_3d(
Vec3::ZERO,
Quat::IDENTITY,
UVec3::new(10, 2, 10),
Vec3::splat(2.),
GREEN
)
.skew_x(0.25)
.outer_edges();
}
sourcepub fn grid_2d(
&mut self,
position: Vec2,
rotation: f32,
cell_count: UVec2,
spacing: Vec2,
color: impl Into<LinearRgba>
) -> GridBuilder2d<'_, 'w, 's, Config, Clear>
pub fn grid_2d( &mut self, position: Vec2, rotation: f32, cell_count: UVec2, spacing: Vec2, color: impl Into<LinearRgba> ) -> GridBuilder2d<'_, 'w, 's, Config, Clear>
Draw a grid in 2D.
This should be called for each frame the grid needs to be rendered.
§Arguments
position
: The center point of the grid.rotation
: defines the orientation of the grid.cell_count
: defines the amount of cells in the x and y axesspacing
: defines the distance between cells along the x and y axescolor
: color of the grid
§Builder methods
- The skew of the grid can be adjusted using the
.skew(...)
,.skew_x(...)
or.skew_y(...)
methods. They behave very similar to their CSS equivalents. - All outer edges can be toggled on or off using
.outer_edges(...)
. Alternatively you can use.outer_edges_x(...)
or.outer_edges_y(...)
to toggle the outer edges along an axis.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.grid_2d(
Vec2::ZERO,
0.0,
UVec2::new(10, 10),
Vec2::splat(1.),
GREEN
)
.skew_x(0.25)
.outer_edges();
}
source§impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T>
impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T>
sourcepub fn rounded_rect(
&mut self,
position: Vec3,
rotation: Quat,
size: Vec2,
color: impl Into<Color>
) -> RoundedRectBuilder<'_, 'w, 's, T>
pub fn rounded_rect( &mut self, position: Vec3, rotation: Quat, size: Vec2, color: impl Into<Color> ) -> RoundedRectBuilder<'_, 'w, 's, T>
Draw a wireframe rectangle with rounded corners in 3D.
This should be called for each frame the rectangle needs to be rendered.
§Arguments
position
: The center point of the rectangle.rotation
: defines orientation of the rectangle, by default we assume the rectangle is contained in a plane parallel to the XY plane.size
: defines the size of the rectangle. This refers to the ‘outer size’, similar to a bounding box.color
: color of the rectangle
§Builder methods
- The corner radius can be adjusted with the
.corner_radius(...)
method. - The resolution of the arcs at each corner (i.e. the level of detail) can be adjusted with the
.arc_resolution(...)
method.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.rounded_rect(
Vec3::ZERO,
Quat::IDENTITY,
Vec2::ONE,
GREEN
)
.corner_radius(0.25)
.arc_resolution(10);
}
sourcepub fn rounded_rect_2d(
&mut self,
position: Vec2,
rotation: f32,
size: Vec2,
color: impl Into<Color>
) -> RoundedRectBuilder<'_, 'w, 's, T>
pub fn rounded_rect_2d( &mut self, position: Vec2, rotation: f32, size: Vec2, color: impl Into<Color> ) -> RoundedRectBuilder<'_, 'w, 's, T>
Draw a wireframe rectangle with rounded corners in 2D.
This should be called for each frame the rectangle needs to be rendered.
§Arguments
position
: The center point of the rectangle.rotation
: defines orientation of the rectangle.size
: defines the size of the rectangle. This refers to the ‘outer size’, similar to a bounding box.color
: color of the rectangle
§Builder methods
- The corner radius can be adjusted with the
.corner_radius(...)
method. - The resolution of the arcs at each corner (i.e. the level of detail) can be adjusted with the
.arc_resolution(...)
method.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.rounded_rect_2d(
Vec2::ZERO,
0.,
Vec2::ONE,
GREEN
)
.corner_radius(0.25)
.arc_resolution(10);
}
sourcepub fn rounded_cuboid(
&mut self,
position: Vec3,
rotation: Quat,
size: Vec3,
color: impl Into<Color>
) -> RoundedCuboidBuilder<'_, 'w, 's, T>
pub fn rounded_cuboid( &mut self, position: Vec3, rotation: Quat, size: Vec3, color: impl Into<Color> ) -> RoundedCuboidBuilder<'_, 'w, 's, T>
Draw a wireframe cuboid with rounded corners in 3D.
This should be called for each frame the cuboid needs to be rendered.
§Arguments
position
: The center point of the cuboid.rotation
: defines orientation of the cuboid.size
: defines the size of the cuboid. This refers to the ‘outer size’, similar to a bounding box.color
: color of the cuboid
§Builder methods
- The edge radius can be adjusted with the
.edge_radius(...)
method. - The resolution of the arcs at each edge (i.e. the level of detail) can be adjusted with the
.arc_resolution(...)
method.
§Example
fn system(mut gizmos: Gizmos) {
gizmos.rounded_cuboid(
Vec3::ZERO,
Quat::IDENTITY,
Vec3::ONE,
GREEN
)
.edge_radius(0.25)
.arc_resolution(10);
}
Trait Implementations§
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Annulus> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Annulus> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Annulus2dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Annulus2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_2d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Arc2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Arc2d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<BoxedPolygon> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<BoxedPolygon> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<BoxedPolyline2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<BoxedPolyline2d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Capsule2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Capsule2d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Circle> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Circle> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Ellipse2dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Ellipse2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_2d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<CircularSector> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<CircularSector> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<CircularSegment> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<CircularSegment> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Dir2> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Dir2> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Ellipse> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Ellipse> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Ellipse2dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Ellipse2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_2d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Line2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Line2d> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Line2dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Line2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_2d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Plane2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Plane2d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive2d<Polygon<N>> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive2d<Polygon<N>> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive2d<Polyline2d<N>> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive2d<Polyline2d<N>> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Rectangle> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Rectangle> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<RegularPolygon> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<RegularPolygon> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Rhombus> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Rhombus> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Segment2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Segment2d> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Segment2dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Segment2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_2d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive2d<Triangle2d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive2d<Triangle2d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<BoxedPolyline3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<BoxedPolyline3d> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = ()
where
Self: 'a
type Output<'a> = () where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§fn primitive_3d(
&mut self,
primitive: &BoxedPolyline3d,
position: Vec3,
rotation: Quat,
color: impl Into<Color>
) -> Self::Output<'_>
fn primitive_3d( &mut self, primitive: &BoxedPolyline3d, position: Vec3, rotation: Quat, color: impl Into<Color> ) -> Self::Output<'_>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Capsule3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Capsule3d> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Capsule3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Capsule3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cone> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cone> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Cone3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Cone3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<ConicalFrustum> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<ConicalFrustum> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = ConicalFrustum3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = ConicalFrustum3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§fn primitive_3d(
&mut self,
primitive: &ConicalFrustum,
position: Vec3,
rotation: Quat,
color: impl Into<Color>
) -> Self::Output<'_>
fn primitive_3d( &mut self, primitive: &ConicalFrustum, position: Vec3, rotation: Quat, color: impl Into<Color> ) -> Self::Output<'_>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cuboid> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cuboid> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cylinder> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Cylinder> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Cylinder3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Cylinder3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Dir3> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Dir3> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Line3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Line3d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Plane3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Plane3d> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Plane3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Plane3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive3d<Polyline3d<N>> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, const N: usize, Config, Clear> GizmoPrimitive3d<Polyline3d<N>> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Segment3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Segment3d> for Gizmos<'w, 's, Config, Clear>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Sphere> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Sphere> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = SphereBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = SphereBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Tetrahedron> for Gizmos<'w, 's, T>
impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Tetrahedron> for Gizmos<'w, 's, T>
source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Torus> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Torus> for Gizmos<'w, 's, Config, Clear>
§type Output<'a> = Torus3dBuilder<'a, 'w, 's, Config, Clear>
where
Self: 'a
type Output<'a> = Torus3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a
primitive_3d
. This is a builder to set non-default values.source§impl<'w, 's, Config, Clear> GizmoPrimitive3d<Triangle3d> for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> GizmoPrimitive3d<Triangle3d> for Gizmos<'w, 's, Config, Clear>
source§impl<Config, Clear> SystemParam for Gizmos<'_, '_, Config, Clear>
impl<Config, Clear> SystemParam for Gizmos<'_, '_, Config, Clear>
§type State = GizmosFetchState<Config, Clear>
type State = GizmosFetchState<Config, Clear>
§type Item<'w, 's> = Gizmos<'w, 's, Config, Clear>
type Item<'w, 's> = Gizmos<'w, 's, Config, Clear>
Self
, instantiated with new lifetimes. Read moresource§fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
World
access used by this SystemParam
and creates a new instance of this param’s State
.source§unsafe fn new_archetype(
state: &mut Self::State,
archetype: &Archetype,
system_meta: &mut SystemMeta
)
unsafe fn new_archetype( state: &mut Self::State, archetype: &Archetype, system_meta: &mut SystemMeta )
Archetype
, registers the components accessed by this SystemParam
(if applicable).a Read moresource§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
SystemParam
’s state.
This is used to apply Commands
during apply_deferred
.source§unsafe fn get_param<'w, 's>(
state: &'s mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick
) -> Self::Item<'w, 's>
unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick ) -> Self::Item<'w, 's>
SystemParamFunction
. Read moresource§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_> )
apply_deferred
.impl<'w, 's, Config, Clear> ReadOnlySystemParam for Gizmos<'w, 's, Config, Clear>where
Config: GizmoConfigGroup,
Clear: 'static + Send + Sync,
Deferred<'s, GizmoBuffer<Config, Clear>>: ReadOnlySystemParam,
Res<'w, GizmoConfigStore>: ReadOnlySystemParam,
Auto Trait Implementations§
impl<'w, 's, Config, Clear> Freeze for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> RefUnwindSafe for Gizmos<'w, 's, Config, Clear>where
Config: RefUnwindSafe,
Clear: RefUnwindSafe,
impl<'w, 's, Config, Clear> Send for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Sync for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config, Clear> Unpin for Gizmos<'w, 's, Config, Clear>
impl<'w, 's, Config = DefaultGizmoConfigGroup, Clear = ()> !UnwindSafe for Gizmos<'w, 's, Config, Clear>
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> 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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.source§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
.source§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.source§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.