//! Additional [`GizmoBuffer`] Functions -- Crosses1//!2//! Includes the implementation of [`GizmoBuffer::cross`] and [`GizmoBuffer::cross_2d`],3//! and assorted support items.45use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup};6use bevy_color::Color;7use bevy_math::{Isometry2d, Isometry3d, Vec2, Vec3};89impl<Config, Clear> GizmoBuffer<Config, Clear>10where11Config: GizmoConfigGroup,12Clear: 'static + Send + Sync,13{14/// Draw a cross in 3D with the given `isometry` applied.15///16/// If `isometry == Isometry3d::IDENTITY` then17///18/// - the center is at `Vec3::ZERO`19/// - the `half_size`s are aligned with the `Vec3::X`, `Vec3::Y` and `Vec3::Z` axes.20///21/// This should be called for each frame the cross needs to be rendered.22///23/// # Example24/// ```25/// # use bevy_gizmos::prelude::*;26/// # use bevy_math::prelude::*;27/// # use bevy_color::palettes::basic::WHITE;28/// fn system(mut gizmos: Gizmos) {29/// gizmos.cross(Isometry3d::IDENTITY, 0.5, WHITE);30/// }31/// # bevy_ecs::system::assert_is_system(system);32/// ```33pub fn cross(34&mut self,35isometry: impl Into<Isometry3d>,36half_size: f32,37color: impl Into<Color>,38) {39let isometry = isometry.into();40let color: Color = color.into();41[Vec3::X, Vec3::Y, Vec3::Z]42.map(|axis| axis * half_size)43.into_iter()44.for_each(|axis| {45self.line(isometry * axis, isometry * (-axis), color);46});47}4849/// Draw a cross in 2D with the given `isometry` applied.50///51/// If `isometry == Isometry2d::IDENTITY` then52///53/// - the center is at `Vec3::ZERO`54/// - the `half_size`s are aligned with the `Vec3::X` and `Vec3::Y` axes.55///56/// This should be called for each frame the cross needs to be rendered.57///58/// # Example59/// ```60/// # use bevy_gizmos::prelude::*;61/// # use bevy_math::prelude::*;62/// # use bevy_color::palettes::basic::WHITE;63/// fn system(mut gizmos: Gizmos) {64/// gizmos.cross_2d(Isometry2d::IDENTITY, 0.5, WHITE);65/// }66/// # bevy_ecs::system::assert_is_system(system);67/// ```68pub fn cross_2d(69&mut self,70isometry: impl Into<Isometry2d>,71half_size: f32,72color: impl Into<Color>,73) {74let isometry = isometry.into();75let color: Color = color.into();76[Vec2::X, Vec2::Y]77.map(|axis| axis * half_size)78.into_iter()79.for_each(|axis| {80self.line_2d(isometry * axis, isometry * (-axis), color);81});82}83}848586