Struct bevy::prelude::Gizmos

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>

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 )

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)

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 )

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 )

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)> )

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 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 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)

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)

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)

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 )

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 )

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)> )

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)

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 )

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);
}

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);
}

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 from position to this arc, and thus its curvature.
  • direction_angle sets the clockwise angle in radians between Vec2::Y and the vector from position 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);
}

pub fn rect_2d( &mut self, position: Vec2, rotation: f32, size: Vec2, color: 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, Color::GREEN);
}

Trait Implementations§

§

impl SystemParam for Gizmos<'_>

§

type State = FetchState

Used to store data which persists across invocations of a system.
§

type Item<'w, 's> = Gizmos<'s>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
§

fn init_state( world: &mut World, system_meta: &mut SystemMeta ) -> <Gizmos<'_> as SystemParam>::State

Registers any 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 )

For the specified Archetype, registers the components accessed by this SystemParam (if applicable).
§

fn apply( state: &mut <Gizmos<'_> as SystemParam>::State, system_meta: &SystemMeta, world: &mut World )

Applies any deferred mutations stored in this 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>

Creates a parameter to be passed into a SystemParamFunction. Read more
§

impl<'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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,

§

impl<T> Settings for Twhere T: 'static + Send + Sync,

§

impl<T> WasmNotSend for Twhere T: Send,

§

impl<T> WasmNotSync for Twhere T: Sync,