//! This module is for 'retained' alternatives to the 'immediate mode' [`Gizmos`](crate::gizmos::Gizmos) system parameter.12use core::ops::{Deref, DerefMut};34use bevy_asset::Handle;5use bevy_ecs::{component::Component, reflect::ReflectComponent};6use bevy_reflect::{std_traits::ReflectDefault, Reflect};7use bevy_transform::components::Transform;89use crate::{10config::{ErasedGizmoConfigGroup, GizmoLineConfig},11gizmos::GizmoBuffer,12GizmoAsset,13};1415impl Deref for GizmoAsset {16type Target = GizmoBuffer<ErasedGizmoConfigGroup, ()>;1718fn deref(&self) -> &Self::Target {19&self.buffer20}21}2223impl DerefMut for GizmoAsset {24fn deref_mut(&mut self) -> &mut Self::Target {25&mut self.buffer26}27}2829/// A component that draws the gizmos of a [`GizmoAsset`].30///31/// When drawing a greater number of static lines a [`Gizmo`] component can32/// have far better performance than the [`Gizmos`] system parameter,33/// but the system parameter will perform better for smaller lines that update often.34///35/// ## Example36/// ```37/// # use bevy_ecs::prelude::*;38/// # use bevy_gizmos::prelude::*;39/// # use bevy_asset::prelude::*;40/// # use bevy_color::palettes::css::*;41/// # use bevy_utils::default;42/// # use bevy_math::prelude::*;43/// fn system(44/// mut commands: Commands,45/// mut gizmo_assets: ResMut<Assets<GizmoAsset>>,46/// ) {47/// let mut gizmo = GizmoAsset::default();48///49/// gizmo.sphere(Vec3::ZERO, 1., RED);50///51/// commands.spawn(Gizmo {52/// handle: gizmo_assets.add(gizmo),53/// line_config: GizmoLineConfig {54/// width: 4.,55/// ..default()56/// },57/// ..default()58/// });59/// }60/// ```61///62/// [`Gizmos`]: crate::gizmos::Gizmos63#[derive(Component, Clone, Debug, Default, Reflect)]64#[reflect(Component, Clone, Default)]65#[require(Transform)]66pub struct Gizmo {67/// The handle to the gizmo to draw.68pub handle: Handle<GizmoAsset>,69/// The line specific configuration for this gizmo.70pub line_config: GizmoLineConfig,71/// How closer to the camera than real geometry the gizmo should be.72///73/// In 2D this setting has no effect and is effectively always -1.74///75/// Value between -1 and 1 (inclusive).76/// * 0 means that there is no change to the gizmo position when rendering77/// * 1 means it is furthest away from camera as possible78/// * -1 means that it will always render in front of other things.79///80/// This is typically useful if you are drawing wireframes on top of polygons81/// and your wireframe is z-fighting (flickering on/off) with your main model.82/// You would set this value to a negative number close to 0.83pub depth_bias: f32,84}858687