mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Rename bevy_render::Color
to LegacyColor
(#12069)
# Objective The migration process for `bevy_color` (#12013) will be fairly involved: there will be hundreds of affected files, and a large number of APIs. ## Solution To allow us to proceed granularly, we're going to keep both `bevy_color::Color` (new) and `bevy_render::Color` (old) around until the migration is complete. However, simply doing this directly is confusing! They're both called `Color`, making it very hard to tell when a portion of the code has been ported. As discussed in #12056, by renaming the old `Color` type, we can make it easier to gradually migrate over, one API at a time. ## Migration Guide THIS MIGRATION GUIDE INTENTIONALLY LEFT BLANK. This change should not be shipped to end users: delete this section in the final migration guide! --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
This commit is contained in:
parent
10aef141f3
commit
de004da8d5
171 changed files with 1209 additions and 1165 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Alpha, Hsla, Lcha, LinearRgba, Oklaba, Srgba, StandardColor, Xyza};
|
use crate::{Alpha, Hsla, Lcha, LinearRgba, Oklaba, Srgba, StandardColor, Xyza};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||||
use bevy_render::color::Color as LegacyColor;
|
use bevy_render::color::LegacyColor;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// An enumerated type that can represent any of the color types in this crate.
|
/// An enumerated type that can represent any of the color types in this crate.
|
||||||
|
|
|
@ -136,9 +136,9 @@ impl From<Srgba> for Hsla {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Hsla> for bevy_render::color::Color {
|
impl From<Hsla> for bevy_render::color::LegacyColor {
|
||||||
fn from(value: Hsla) -> Self {
|
fn from(value: Hsla) -> Self {
|
||||||
bevy_render::color::Color::Hsla {
|
bevy_render::color::LegacyColor::Hsla {
|
||||||
hue: value.hue,
|
hue: value.hue,
|
||||||
saturation: value.saturation,
|
saturation: value.saturation,
|
||||||
lightness: value.lightness,
|
lightness: value.lightness,
|
||||||
|
@ -147,10 +147,10 @@ impl From<Hsla> for bevy_render::color::Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bevy_render::color::Color> for Hsla {
|
impl From<bevy_render::color::LegacyColor> for Hsla {
|
||||||
fn from(value: bevy_render::color::Color) -> Self {
|
fn from(value: bevy_render::color::LegacyColor) -> Self {
|
||||||
match value.as_hsla() {
|
match value.as_hsla() {
|
||||||
bevy_render::color::Color::Hsla {
|
bevy_render::color::LegacyColor::Hsla {
|
||||||
hue,
|
hue,
|
||||||
saturation,
|
saturation,
|
||||||
lightness,
|
lightness,
|
||||||
|
|
|
@ -157,9 +157,9 @@ impl From<Lcha> for LinearRgba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Lcha> for bevy_render::color::Color {
|
impl From<Lcha> for bevy_render::color::LegacyColor {
|
||||||
fn from(value: Lcha) -> Self {
|
fn from(value: Lcha) -> Self {
|
||||||
bevy_render::color::Color::Lcha {
|
bevy_render::color::LegacyColor::Lcha {
|
||||||
hue: value.hue,
|
hue: value.hue,
|
||||||
chroma: value.chroma,
|
chroma: value.chroma,
|
||||||
lightness: value.lightness,
|
lightness: value.lightness,
|
||||||
|
@ -168,10 +168,10 @@ impl From<Lcha> for bevy_render::color::Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bevy_render::color::Color> for Lcha {
|
impl From<bevy_render::color::LegacyColor> for Lcha {
|
||||||
fn from(value: bevy_render::color::Color) -> Self {
|
fn from(value: bevy_render::color::LegacyColor) -> Self {
|
||||||
match value.as_lcha() {
|
match value.as_lcha() {
|
||||||
bevy_render::color::Color::Lcha {
|
bevy_render::color::LegacyColor::Lcha {
|
||||||
hue,
|
hue,
|
||||||
chroma,
|
chroma,
|
||||||
lightness,
|
lightness,
|
||||||
|
|
|
@ -95,7 +95,7 @@ pub use oklaba::*;
|
||||||
pub use srgba::*;
|
pub use srgba::*;
|
||||||
pub use xyza::*;
|
pub use xyza::*;
|
||||||
|
|
||||||
use bevy_render::color::Color as LegacyColor;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
/// Describes the traits that a color should implement for consistency.
|
/// Describes the traits that a color should implement for consistency.
|
||||||
pub(crate) trait StandardColor
|
pub(crate) trait StandardColor
|
||||||
|
|
|
@ -172,9 +172,9 @@ impl From<Srgba> for LinearRgba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<LinearRgba> for bevy_render::color::Color {
|
impl From<LinearRgba> for bevy_render::color::LegacyColor {
|
||||||
fn from(value: LinearRgba) -> Self {
|
fn from(value: LinearRgba) -> Self {
|
||||||
bevy_render::color::Color::RgbaLinear {
|
bevy_render::color::LegacyColor::RgbaLinear {
|
||||||
red: value.red,
|
red: value.red,
|
||||||
green: value.green,
|
green: value.green,
|
||||||
blue: value.blue,
|
blue: value.blue,
|
||||||
|
@ -183,10 +183,10 @@ impl From<LinearRgba> for bevy_render::color::Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bevy_render::color::Color> for LinearRgba {
|
impl From<bevy_render::color::LegacyColor> for LinearRgba {
|
||||||
fn from(value: bevy_render::color::Color) -> Self {
|
fn from(value: bevy_render::color::LegacyColor) -> Self {
|
||||||
match value.as_rgba_linear() {
|
match value.as_rgba_linear() {
|
||||||
bevy_render::color::Color::RgbaLinear {
|
bevy_render::color::LegacyColor::RgbaLinear {
|
||||||
red,
|
red,
|
||||||
green,
|
green,
|
||||||
blue,
|
blue,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
StandardColor,
|
StandardColor,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||||
use bevy_render::color::Color as LegacyColor;
|
use bevy_render::color::LegacyColor;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Oklaba color space, with alpha
|
/// Color in Oklaba color space, with alpha
|
||||||
|
|
|
@ -267,9 +267,9 @@ impl From<Oklaba> for Srgba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Srgba> for bevy_render::color::Color {
|
impl From<Srgba> for bevy_render::color::LegacyColor {
|
||||||
fn from(value: Srgba) -> Self {
|
fn from(value: Srgba) -> Self {
|
||||||
bevy_render::color::Color::Rgba {
|
bevy_render::color::LegacyColor::Rgba {
|
||||||
red: value.red,
|
red: value.red,
|
||||||
green: value.green,
|
green: value.green,
|
||||||
blue: value.blue,
|
blue: value.blue,
|
||||||
|
@ -278,10 +278,10 @@ impl From<Srgba> for bevy_render::color::Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bevy_render::color::Color> for Srgba {
|
impl From<bevy_render::color::LegacyColor> for Srgba {
|
||||||
fn from(value: bevy_render::color::Color) -> Self {
|
fn from(value: bevy_render::color::LegacyColor) -> Self {
|
||||||
match value.as_rgba() {
|
match value.as_rgba() {
|
||||||
bevy_render::color::Color::Rgba {
|
bevy_render::color::LegacyColor::Rgba {
|
||||||
red,
|
red,
|
||||||
green,
|
green,
|
||||||
blue,
|
blue,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Alpha, Hsla, Lcha, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor};
|
use crate::{Alpha, Hsla, Lcha, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// [CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel.
|
/// [CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel.
|
||||||
|
@ -208,13 +208,13 @@ impl From<Xyza> for Oklaba {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for Xyza {
|
impl From<LegacyColor> for Xyza {
|
||||||
fn from(value: Color) -> Self {
|
fn from(value: LegacyColor) -> Self {
|
||||||
LinearRgba::from(value).into()
|
LinearRgba::from(value).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Xyza> for Color {
|
impl From<Xyza> for LegacyColor {
|
||||||
fn from(value: Xyza) -> Self {
|
fn from(value: Xyza) -> Self {
|
||||||
LinearRgba::from(value).into()
|
LinearRgba::from(value).into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ use bevy_render::{
|
||||||
extract_component::{
|
extract_component::{
|
||||||
ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin,
|
ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin,
|
||||||
},
|
},
|
||||||
prelude::Color,
|
prelude::LegacyColor,
|
||||||
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner},
|
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner},
|
||||||
render_resource::*,
|
render_resource::*,
|
||||||
renderer::{RenderContext, RenderDevice},
|
renderer::{RenderContext, RenderDevice},
|
||||||
|
@ -240,7 +240,7 @@ impl ViewNode for BloomNode {
|
||||||
mip as f32,
|
mip as f32,
|
||||||
(bloom_texture.mip_count - 1) as f32,
|
(bloom_texture.mip_count - 1) as f32,
|
||||||
);
|
);
|
||||||
upsampling_pass.set_blend_constant(Color::rgb_linear(blend, blend, blend));
|
upsampling_pass.set_blend_constant(LegacyColor::rgb_linear(blend, blend, blend));
|
||||||
upsampling_pass.draw(0..3, 0..1);
|
upsampling_pass.draw(0..3, 0..1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ impl ViewNode for BloomNode {
|
||||||
}
|
}
|
||||||
let blend =
|
let blend =
|
||||||
compute_blend_factor(bloom_settings, 0.0, (bloom_texture.mip_count - 1) as f32);
|
compute_blend_factor(bloom_settings, 0.0, (bloom_texture.mip_count - 1) as f32);
|
||||||
upsampling_final_pass.set_blend_constant(Color::rgb_linear(blend, blend, blend));
|
upsampling_final_pass.set_blend_constant(LegacyColor::rgb_linear(blend, blend, blend));
|
||||||
upsampling_final_pass.draw(0..3, 0..1);
|
upsampling_final_pass.draw(0..3, 0..1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ use bevy_app::{App, Plugin, PostUpdate};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{Camera, ExtractedCamera},
|
camera::{Camera, ExtractedCamera},
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
extract_component::ExtractComponentPlugin,
|
extract_component::ExtractComponentPlugin,
|
||||||
mesh::Mesh,
|
mesh::Mesh,
|
||||||
prelude::Msaa,
|
prelude::Msaa,
|
||||||
|
@ -836,18 +836,19 @@ pub fn prepare_prepass_textures(
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.entity(entity).insert(ViewPrepassTextures {
|
commands.entity(entity).insert(ViewPrepassTextures {
|
||||||
depth: cached_depth_texture.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))),
|
depth: cached_depth_texture
|
||||||
|
.map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))),
|
||||||
normal: cached_normals_texture
|
normal: cached_normals_texture
|
||||||
.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))),
|
.map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))),
|
||||||
// Red and Green channels are X and Y components of the motion vectors
|
// Red and Green channels are X and Y components of the motion vectors
|
||||||
// Blue channel doesn't matter, but set to 0.0 for possible faster clear
|
// Blue channel doesn't matter, but set to 0.0 for possible faster clear
|
||||||
// https://gpuopen.com/performance/#clears
|
// https://gpuopen.com/performance/#clears
|
||||||
motion_vectors: cached_motion_vectors_texture
|
motion_vectors: cached_motion_vectors_texture
|
||||||
.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))),
|
.map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))),
|
||||||
deferred: cached_deferred_texture
|
deferred: cached_deferred_texture
|
||||||
.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))),
|
.map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))),
|
||||||
deferred_lighting_pass_id: cached_deferred_lighting_pass_id_texture
|
deferred_lighting_pass_id: cached_deferred_lighting_pass_id_texture
|
||||||
.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))),
|
.map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))),
|
||||||
size,
|
size,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use bevy_app::{App, Plugin};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::ExtractedCamera,
|
camera::ExtractedCamera,
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext},
|
render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext},
|
||||||
render_resource::BindGroupEntries,
|
render_resource::BindGroupEntries,
|
||||||
renderer::RenderContext,
|
renderer::RenderContext,
|
||||||
|
@ -93,7 +93,7 @@ impl Node for MsaaWritebackNode {
|
||||||
view: target.sampled_main_texture_view().unwrap(),
|
view: target.sampled_main_texture_view().unwrap(),
|
||||||
resolve_target: Some(post_process.destination),
|
resolve_target: Some(post_process.destination),
|
||||||
ops: Operations {
|
ops: Operations {
|
||||||
load: LoadOp::Clear(Color::BLACK.into()),
|
load: LoadOp::Clear(LegacyColor::BLACK.into()),
|
||||||
store: StoreOp::Store,
|
store: StoreOp::Store,
|
||||||
},
|
},
|
||||||
})],
|
})],
|
||||||
|
|
|
@ -12,7 +12,7 @@ use bevy_ecs::{
|
||||||
system::{Query, Res},
|
system::{Query, Res},
|
||||||
};
|
};
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
use bevy_render::{color::Color, primitives::Aabb};
|
use bevy_render::{color::LegacyColor, primitives::Aabb};
|
||||||
use bevy_transform::{
|
use bevy_transform::{
|
||||||
components::{GlobalTransform, Transform},
|
components::{GlobalTransform, Transform},
|
||||||
TransformSystem,
|
TransformSystem,
|
||||||
|
@ -57,7 +57,7 @@ pub struct AabbGizmoConfigGroup {
|
||||||
/// A random color is chosen per box if `None`.
|
/// A random color is chosen per box if `None`.
|
||||||
///
|
///
|
||||||
/// Defaults to `None`.
|
/// Defaults to `None`.
|
||||||
pub default_color: Option<Color>,
|
pub default_color: Option<LegacyColor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add this [`Component`] to an entity to draw its [`Aabb`] component.
|
/// Add this [`Component`] to an entity to draw its [`Aabb`] component.
|
||||||
|
@ -67,7 +67,7 @@ pub struct ShowAabbGizmo {
|
||||||
/// The color of the box.
|
/// The color of the box.
|
||||||
///
|
///
|
||||||
/// The default color from the [`AabbGizmoConfigGroup`] config is used if `None`,
|
/// The default color from the [`AabbGizmoConfigGroup`] config is used if `None`,
|
||||||
pub color: Option<Color>,
|
pub color: Option<LegacyColor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_aabbs(
|
fn draw_aabbs(
|
||||||
|
@ -96,7 +96,7 @@ fn draw_all_aabbs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn color_from_entity(entity: Entity) -> Color {
|
fn color_from_entity(entity: Entity) -> LegacyColor {
|
||||||
let index = entity.index();
|
let index = entity.index();
|
||||||
|
|
||||||
// from https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
// from https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
||||||
|
@ -108,7 +108,7 @@ fn color_from_entity(entity: Entity) -> Color {
|
||||||
const RATIO_360: f32 = 360.0 / u32::MAX as f32;
|
const RATIO_360: f32 = 360.0 / u32::MAX as f32;
|
||||||
let hue = index.wrapping_mul(FRAC_U32MAX_GOLDEN_RATIO) as f32 * RATIO_360;
|
let hue = index.wrapping_mul(FRAC_U32MAX_GOLDEN_RATIO) as f32 * RATIO_360;
|
||||||
|
|
||||||
Color::hsl(hue, 1., 0.5)
|
LegacyColor::hsl(hue, 1., 0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aabb_transform(aabb: Aabb, transform: GlobalTransform) -> GlobalTransform {
|
fn aabb_transform(aabb: Aabb, transform: GlobalTransform) -> GlobalTransform {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use crate::circles::DEFAULT_CIRCLE_SEGMENTS;
|
use crate::circles::DEFAULT_CIRCLE_SEGMENTS;
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
use bevy_math::{Quat, Vec2, Vec3};
|
use bevy_math::{Quat, Vec2, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
use std::f32::consts::TAU;
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
// === 2D ===
|
// === 2D ===
|
||||||
|
@ -30,12 +30,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// # use std::f32::consts::PI;
|
/// # use std::f32::consts::PI;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., Color::GREEN);
|
/// gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., LegacyColor::GREEN);
|
||||||
///
|
///
|
||||||
/// // Arcs have 32 line-segments by default.
|
/// // Arcs have 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger arcs.
|
/// // You may want to increase this for larger arcs.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .arc_2d(Vec2::ZERO, 0., PI / 4., 5., Color::RED)
|
/// .arc_2d(Vec2::ZERO, 0., PI / 4., 5., LegacyColor::RED)
|
||||||
/// .segments(64);
|
/// .segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -47,7 +47,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
direction_angle: f32,
|
direction_angle: f32,
|
||||||
arc_angle: f32,
|
arc_angle: f32,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Arc2dBuilder<'_, 'w, 's, T> {
|
) -> Arc2dBuilder<'_, 'w, 's, T> {
|
||||||
Arc2dBuilder {
|
Arc2dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -68,7 +68,7 @@ pub struct Arc2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
direction_angle: f32,
|
direction_angle: f32,
|
||||||
arc_angle: f32,
|
arc_angle: f32,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
segments: Option<usize>,
|
segments: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// 0.25,
|
/// 0.25,
|
||||||
/// Vec3::ONE,
|
/// Vec3::ONE,
|
||||||
/// rotation,
|
/// rotation,
|
||||||
/// Color::ORANGE
|
/// LegacyColor::ORANGE
|
||||||
/// )
|
/// )
|
||||||
/// .segments(100);
|
/// .segments(100);
|
||||||
/// }
|
/// }
|
||||||
|
@ -165,7 +165,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
radius: f32,
|
radius: f32,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
||||||
Arc3dBuilder {
|
Arc3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -202,7 +202,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// Vec3::ONE,
|
/// Vec3::ONE,
|
||||||
/// Vec3::ONE + Vec3::NEG_ONE,
|
/// Vec3::ONE + Vec3::NEG_ONE,
|
||||||
/// Vec3::ZERO,
|
/// Vec3::ZERO,
|
||||||
/// Color::ORANGE
|
/// LegacyColor::ORANGE
|
||||||
/// )
|
/// )
|
||||||
/// .segments(100);
|
/// .segments(100);
|
||||||
/// }
|
/// }
|
||||||
|
@ -221,7 +221,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
center: Vec3,
|
center: Vec3,
|
||||||
from: Vec3,
|
from: Vec3,
|
||||||
to: Vec3,
|
to: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
||||||
self.arc_from_to(center, from, to, color, |x| x)
|
self.arc_from_to(center, from, to, color, |x| x)
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// Vec3::ONE,
|
/// Vec3::ONE,
|
||||||
/// Vec3::ONE + Vec3::NEG_ONE,
|
/// Vec3::ONE + Vec3::NEG_ONE,
|
||||||
/// Vec3::ZERO,
|
/// Vec3::ZERO,
|
||||||
/// Color::ORANGE
|
/// LegacyColor::ORANGE
|
||||||
/// )
|
/// )
|
||||||
/// .segments(100);
|
/// .segments(100);
|
||||||
/// }
|
/// }
|
||||||
|
@ -267,7 +267,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
center: Vec3,
|
center: Vec3,
|
||||||
from: Vec3,
|
from: Vec3,
|
||||||
to: Vec3,
|
to: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
||||||
self.arc_from_to(center, from, to, color, |angle| {
|
self.arc_from_to(center, from, to, color, |angle| {
|
||||||
if angle > 0.0 {
|
if angle > 0.0 {
|
||||||
|
@ -286,7 +286,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
center: Vec3,
|
center: Vec3,
|
||||||
from: Vec3,
|
from: Vec3,
|
||||||
to: Vec3,
|
to: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
angle_fn: impl Fn(f32) -> f32,
|
angle_fn: impl Fn(f32) -> f32,
|
||||||
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
) -> Arc3dBuilder<'_, 'w, 's, T> {
|
||||||
// `from` and `to` can be the same here since in either case nothing gets rendered and the
|
// `from` and `to` can be the same here since in either case nothing gets rendered and the
|
||||||
|
@ -331,7 +331,7 @@ pub struct Arc3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
segments: Option<usize>,
|
segments: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
use bevy_math::{Quat, Vec2, Vec3};
|
use bevy_math::{Quat, Vec2, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
/// A builder returned by [`Gizmos::arrow`] and [`Gizmos::arrow_2d`]
|
/// A builder returned by [`Gizmos::arrow`] and [`Gizmos::arrow_2d`]
|
||||||
pub struct ArrowBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
pub struct ArrowBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
gizmos: &'a mut Gizmos<'w, 's, T>,
|
gizmos: &'a mut Gizmos<'w, 's, T>,
|
||||||
start: Vec3,
|
start: Vec3,
|
||||||
end: Vec3,
|
end: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
tip_length: f32,
|
tip_length: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ impl<T: GizmoConfigGroup> ArrowBuilder<'_, '_, '_, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.arrow(Vec3::ZERO, Vec3::ONE, Color::GREEN)
|
/// gizmos.arrow(Vec3::ZERO, Vec3::ONE, LegacyColor::GREEN)
|
||||||
/// .with_tip_length(3.);
|
/// .with_tip_length(3.);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -77,11 +77,16 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.arrow(Vec3::ZERO, Vec3::ONE, Color::GREEN);
|
/// gizmos.arrow(Vec3::ZERO, Vec3::ONE, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn arrow(&mut self, start: Vec3, end: Vec3, color: Color) -> ArrowBuilder<'_, 'w, 's, T> {
|
pub fn arrow(
|
||||||
|
&mut self,
|
||||||
|
start: Vec3,
|
||||||
|
end: Vec3,
|
||||||
|
color: LegacyColor,
|
||||||
|
) -> ArrowBuilder<'_, 'w, 's, T> {
|
||||||
let length = (end - start).length();
|
let length = (end - start).length();
|
||||||
ArrowBuilder {
|
ArrowBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -102,7 +107,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.arrow_2d(Vec2::ZERO, Vec2::X, Color::GREEN);
|
/// gizmos.arrow_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -110,7 +115,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
&mut self,
|
&mut self,
|
||||||
start: Vec2,
|
start: Vec2,
|
||||||
end: Vec2,
|
end: Vec2,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> ArrowBuilder<'_, 'w, 's, T> {
|
) -> ArrowBuilder<'_, 'w, 's, T> {
|
||||||
self.arrow(start.extend(0.), end.extend(0.), color)
|
self.arrow(start.extend(0.), end.extend(0.), color)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
use bevy_math::Mat2;
|
use bevy_math::Mat2;
|
||||||
use bevy_math::{primitives::Direction3d, Quat, Vec2, Vec3};
|
use bevy_math::{primitives::Direction3d, Quat, Vec2, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
use std::f32::consts::TAU;
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
pub(crate) const DEFAULT_CIRCLE_SEGMENTS: usize = 32;
|
pub(crate) const DEFAULT_CIRCLE_SEGMENTS: usize = 32;
|
||||||
|
@ -30,12 +30,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(1., 2.), Color::GREEN);
|
/// gizmos.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(1., 2.), LegacyColor::GREEN);
|
||||||
///
|
///
|
||||||
/// // Ellipses have 32 line-segments by default.
|
/// // Ellipses have 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger ellipses.
|
/// // You may want to increase this for larger ellipses.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(5., 1.), Color::RED)
|
/// .ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(5., 1.), LegacyColor::RED)
|
||||||
/// .segments(64);
|
/// .segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -46,7 +46,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
half_size: Vec2,
|
half_size: Vec2,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> EllipseBuilder<'_, 'w, 's, T> {
|
) -> EllipseBuilder<'_, 'w, 's, T> {
|
||||||
EllipseBuilder {
|
EllipseBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -68,12 +68,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(2., 1.), Color::GREEN);
|
/// gizmos.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(2., 1.), LegacyColor::GREEN);
|
||||||
///
|
///
|
||||||
/// // Ellipses have 32 line-segments by default.
|
/// // Ellipses have 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger ellipses.
|
/// // You may want to increase this for larger ellipses.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(5., 1.), Color::RED)
|
/// .ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(5., 1.), LegacyColor::RED)
|
||||||
/// .segments(64);
|
/// .segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -84,7 +84,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
half_size: Vec2,
|
half_size: Vec2,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Ellipse2dBuilder<'_, 'w, 's, T> {
|
) -> Ellipse2dBuilder<'_, 'w, 's, T> {
|
||||||
Ellipse2dBuilder {
|
Ellipse2dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -106,12 +106,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.circle(Vec3::ZERO, Direction3d::Z, 1., Color::GREEN);
|
/// gizmos.circle(Vec3::ZERO, Direction3d::Z, 1., LegacyColor::GREEN);
|
||||||
///
|
///
|
||||||
/// // Circles have 32 line-segments by default.
|
/// // Circles have 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger circles.
|
/// // You may want to increase this for larger circles.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .circle(Vec3::ZERO, Direction3d::Z, 5., Color::RED)
|
/// .circle(Vec3::ZERO, Direction3d::Z, 5., LegacyColor::RED)
|
||||||
/// .segments(64);
|
/// .segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -122,7 +122,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
normal: Direction3d,
|
normal: Direction3d,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> EllipseBuilder<'_, 'w, 's, T> {
|
) -> EllipseBuilder<'_, 'w, 's, T> {
|
||||||
EllipseBuilder {
|
EllipseBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -144,12 +144,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.circle_2d(Vec2::ZERO, 1., Color::GREEN);
|
/// gizmos.circle_2d(Vec2::ZERO, 1., LegacyColor::GREEN);
|
||||||
///
|
///
|
||||||
/// // Circles have 32 line-segments by default.
|
/// // Circles have 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger circles.
|
/// // You may want to increase this for larger circles.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .circle_2d(Vec2::ZERO, 5., Color::RED)
|
/// .circle_2d(Vec2::ZERO, 5., LegacyColor::RED)
|
||||||
/// .segments(64);
|
/// .segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -159,7 +159,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
&mut self,
|
&mut self,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Ellipse2dBuilder<'_, 'w, 's, T> {
|
) -> Ellipse2dBuilder<'_, 'w, 's, T> {
|
||||||
Ellipse2dBuilder {
|
Ellipse2dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -178,7 +178,7 @@ pub struct EllipseBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
half_size: Vec2,
|
half_size: Vec2,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
segments: usize,
|
segments: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ pub struct Ellipse2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
rotation: Mat2,
|
rotation: Mat2,
|
||||||
half_size: Vec2,
|
half_size: Vec2,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
segments: usize,
|
segments: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use bevy_ecs::{
|
||||||
world::{unsafe_world_cell::UnsafeWorldCell, World},
|
world::{unsafe_world_cell::UnsafeWorldCell, World},
|
||||||
};
|
};
|
||||||
use bevy_math::{primitives::Direction3d, Mat2, Quat, Vec2, Vec3};
|
use bevy_math::{primitives::Direction3d, Mat2, Quat, Vec2, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
use bevy_transform::TransformPoint;
|
use bevy_transform::TransformPoint;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -131,12 +131,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN);
|
/// gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn line(&mut self, start: Vec3, end: Vec3, color: Color) {
|
pub fn line(&mut self, start: Vec3, end: Vec3, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -154,12 +154,18 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.line_gradient(Vec3::ZERO, Vec3::X, Color::GREEN, Color::RED);
|
/// gizmos.line_gradient(Vec3::ZERO, Vec3::X, LegacyColor::GREEN, LegacyColor::RED);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
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: LegacyColor,
|
||||||
|
end_color: LegacyColor,
|
||||||
|
) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,12 +183,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.ray(Vec3::Y, Vec3::X, Color::GREEN);
|
/// gizmos.ray(Vec3::Y, Vec3::X, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: Color) {
|
pub fn ray(&mut self, start: Vec3, vector: Vec3, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +205,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.ray_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED);
|
/// gizmos.ray_gradient(Vec3::Y, Vec3::X, LegacyColor::GREEN, LegacyColor::RED);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -208,8 +214,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
&mut self,
|
&mut self,
|
||||||
start: Vec3,
|
start: Vec3,
|
||||||
vector: Vec3,
|
vector: Vec3,
|
||||||
start_color: Color,
|
start_color: LegacyColor,
|
||||||
end_color: Color,
|
end_color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -227,12 +233,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.linestrip([Vec3::ZERO, Vec3::X, Vec3::Y], Color::GREEN);
|
/// gizmos.linestrip([Vec3::ZERO, Vec3::X, Vec3::Y], LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn linestrip(&mut self, positions: impl IntoIterator<Item = Vec3>, color: Color) {
|
pub fn linestrip(&mut self, positions: impl IntoIterator<Item = Vec3>, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -255,15 +261,15 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.linestrip_gradient([
|
/// gizmos.linestrip_gradient([
|
||||||
/// (Vec3::ZERO, Color::GREEN),
|
/// (Vec3::ZERO, LegacyColor::GREEN),
|
||||||
/// (Vec3::X, Color::RED),
|
/// (Vec3::X, LegacyColor::RED),
|
||||||
/// (Vec3::Y, Color::BLUE)
|
/// (Vec3::Y, LegacyColor::BLUE)
|
||||||
/// ]);
|
/// ]);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn linestrip_gradient(&mut self, points: impl IntoIterator<Item = (Vec3, Color)>) {
|
pub fn linestrip_gradient(&mut self, points: impl IntoIterator<Item = (Vec3, LegacyColor)>) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -298,12 +304,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.sphere(Vec3::ZERO, Quat::IDENTITY, 1., Color::BLACK);
|
/// gizmos.sphere(Vec3::ZERO, Quat::IDENTITY, 1., LegacyColor::BLACK);
|
||||||
///
|
///
|
||||||
/// // Each circle has 32 line-segments by default.
|
/// // Each circle has 32 line-segments by default.
|
||||||
/// // You may want to increase this for larger spheres.
|
/// // You may want to increase this for larger spheres.
|
||||||
/// gizmos
|
/// gizmos
|
||||||
/// .sphere(Vec3::ZERO, Quat::IDENTITY, 5., Color::BLACK)
|
/// .sphere(Vec3::ZERO, Quat::IDENTITY, 5., LegacyColor::BLACK)
|
||||||
/// .circle_segments(64);
|
/// .circle_segments(64);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
|
@ -314,7 +320,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> SphereBuilder<'_, 'w, 's, T> {
|
) -> SphereBuilder<'_, 'w, 's, T> {
|
||||||
SphereBuilder {
|
SphereBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -336,12 +342,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.rect(Vec3::ZERO, Quat::IDENTITY, Vec2::ONE, Color::GREEN);
|
/// gizmos.rect(Vec3::ZERO, Quat::IDENTITY, Vec2::ONE, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
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: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -359,12 +365,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_transform::prelude::*;
|
/// # use bevy_transform::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.cuboid(Transform::IDENTITY, Color::GREEN);
|
/// gizmos.cuboid(Transform::IDENTITY, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cuboid(&mut self, transform: impl TransformPoint, color: Color) {
|
pub fn cuboid(&mut self, transform: impl TransformPoint, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -397,12 +403,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.line_2d(Vec2::ZERO, Vec2::X, Color::GREEN);
|
/// gizmos.line_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color) {
|
pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +425,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.line_gradient_2d(Vec2::ZERO, Vec2::X, Color::GREEN, Color::RED);
|
/// gizmos.line_gradient_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN, LegacyColor::RED);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -428,8 +434,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
&mut self,
|
&mut self,
|
||||||
start: Vec2,
|
start: Vec2,
|
||||||
end: Vec2,
|
end: Vec2,
|
||||||
start_color: Color,
|
start_color: LegacyColor,
|
||||||
end_color: Color,
|
end_color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -447,12 +453,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.linestrip_2d([Vec2::ZERO, Vec2::X, Vec2::Y], Color::GREEN);
|
/// gizmos.linestrip_2d([Vec2::ZERO, Vec2::X, Vec2::Y], LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
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: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -470,15 +476,18 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.linestrip_gradient_2d([
|
/// gizmos.linestrip_gradient_2d([
|
||||||
/// (Vec2::ZERO, Color::GREEN),
|
/// (Vec2::ZERO, LegacyColor::GREEN),
|
||||||
/// (Vec2::X, Color::RED),
|
/// (Vec2::X, LegacyColor::RED),
|
||||||
/// (Vec2::Y, Color::BLUE)
|
/// (Vec2::Y, LegacyColor::BLUE)
|
||||||
/// ]);
|
/// ]);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
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, LegacyColor)>,
|
||||||
|
) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -499,12 +508,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.ray_2d(Vec2::Y, Vec2::X, Color::GREEN);
|
/// gizmos.ray_2d(Vec2::Y, Vec2::X, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: Color) {
|
pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -521,7 +530,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.line_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED);
|
/// gizmos.line_gradient(Vec3::Y, Vec3::X, LegacyColor::GREEN, LegacyColor::RED);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -530,8 +539,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
&mut self,
|
&mut self,
|
||||||
start: Vec2,
|
start: Vec2,
|
||||||
vector: Vec2,
|
vector: Vec2,
|
||||||
start_color: Color,
|
start_color: LegacyColor,
|
||||||
end_color: Color,
|
end_color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -549,12 +558,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
/// # use bevy_render::prelude::*;
|
/// # use bevy_render::prelude::*;
|
||||||
/// # use bevy_math::prelude::*;
|
/// # use bevy_math::prelude::*;
|
||||||
/// fn system(mut gizmos: Gizmos) {
|
/// fn system(mut gizmos: Gizmos) {
|
||||||
/// gizmos.rect_2d(Vec2::ZERO, 0., Vec2::ONE, Color::GREEN);
|
/// gizmos.rect_2d(Vec2::ZERO, 0., Vec2::ONE, LegacyColor::GREEN);
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(system);
|
/// # bevy_ecs::system::assert_is_system(system);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn rect_2d(&mut self, position: Vec2, rotation: f32, size: Vec2, color: Color) {
|
pub fn rect_2d(&mut self, position: Vec2, rotation: f32, size: Vec2, color: LegacyColor) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -571,14 +580,14 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn extend_list_colors(&mut self, colors: impl IntoIterator<Item = Color>) {
|
fn extend_list_colors(&mut self, colors: impl IntoIterator<Item = LegacyColor>) {
|
||||||
self.buffer
|
self.buffer
|
||||||
.list_colors
|
.list_colors
|
||||||
.extend(colors.into_iter().map(|color| color.as_linear_rgba_f32()));
|
.extend(colors.into_iter().map(|color| color.as_linear_rgba_f32()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_list_color(&mut self, color: Color, count: usize) {
|
fn add_list_color(&mut self, color: LegacyColor, count: usize) {
|
||||||
self.buffer
|
self.buffer
|
||||||
.list_colors
|
.list_colors
|
||||||
.extend(iter::repeat(color.as_linear_rgba_f32()).take(count));
|
.extend(iter::repeat(color.as_linear_rgba_f32()).take(count));
|
||||||
|
@ -601,7 +610,7 @@ pub struct SphereBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
circle_segments: usize,
|
circle_segments: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! # use bevy_render::prelude::*;
|
//! # use bevy_render::prelude::*;
|
||||||
//! # use bevy_math::prelude::*;
|
//! # use bevy_math::prelude::*;
|
||||||
//! fn system(mut gizmos: Gizmos) {
|
//! fn system(mut gizmos: Gizmos) {
|
||||||
//! gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN);
|
//! gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN);
|
||||||
//! }
|
//! }
|
||||||
//! # bevy_ecs::system::assert_is_system(system);
|
//! # bevy_ecs::system::assert_is_system(system);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
|
@ -9,7 +9,7 @@ use bevy_math::primitives::{
|
||||||
Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
|
Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
|
||||||
};
|
};
|
||||||
use bevy_math::{Mat2, Vec2};
|
use bevy_math::{Mat2, Vec2};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ pub trait GizmoPrimitive2d<P: Primitive2d> {
|
||||||
primitive: P,
|
primitive: P,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_>;
|
) -> Self::Output<'_>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Direction2d> for Gizmos<'w, '
|
||||||
primitive: Direction2d,
|
primitive: Direction2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -70,7 +70,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Circle> for Gizmos<'w, 's, T>
|
||||||
primitive: Circle,
|
primitive: Circle,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
_angle: f32,
|
_angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -90,7 +90,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Ellipse> for Gizmos<'w, 's, T
|
||||||
primitive: Ellipse,
|
primitive: Ellipse,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -110,7 +110,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Capsule2d> for Gizmos<'w, 's,
|
||||||
primitive: Capsule2d,
|
primitive: Capsule2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -167,7 +167,7 @@ pub struct Line2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
|
|
||||||
position: Vec2, // position of the center of the line
|
position: Vec2, // position of the center of the line
|
||||||
rotation: Mat2, // rotation of the line
|
rotation: Mat2, // rotation of the line
|
||||||
color: Color, // color of the line
|
color: LegacyColor, // color of the line
|
||||||
|
|
||||||
draw_arrow: bool, // decides whether to indicate the direction of the line with an arrow
|
draw_arrow: bool, // decides whether to indicate the direction of the line with an arrow
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Line2d> for Gizmos<'w, 's, T>
|
||||||
primitive: Line2d,
|
primitive: Line2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Line2dBuilder {
|
Line2dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -239,7 +239,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Plane2d> for Gizmos<'w, 's, T
|
||||||
primitive: Plane2d,
|
primitive: Plane2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -287,7 +287,7 @@ pub struct Segment2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
|
|
||||||
position: Vec2, // position of the center of the line segment
|
position: Vec2, // position of the center of the line segment
|
||||||
rotation: Mat2, // rotation of the line segment
|
rotation: Mat2, // rotation of the line segment
|
||||||
color: Color, // color of the line segment
|
color: LegacyColor, // color of the line segment
|
||||||
|
|
||||||
draw_arrow: bool, // decides whether to draw just a line or an arrow
|
draw_arrow: bool, // decides whether to draw just a line or an arrow
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Segment2d> for Gizmos<'w, 's,
|
||||||
primitive: Segment2d,
|
primitive: Segment2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Segment2dBuilder {
|
Segment2dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -354,7 +354,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d<Polyline2d<N>
|
||||||
primitive: Polyline2d<N>,
|
primitive: Polyline2d<N>,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -381,7 +381,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolyline2d> for Gizmos<'
|
||||||
primitive: BoxedPolyline2d,
|
primitive: BoxedPolyline2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -408,7 +408,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Triangle2d> for Gizmos<'w, 's
|
||||||
primitive: Triangle2d,
|
primitive: Triangle2d,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -429,7 +429,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Rectangle> for Gizmos<'w, 's,
|
||||||
primitive: Rectangle,
|
primitive: Rectangle,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -459,7 +459,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d<Polygon<N>>
|
||||||
primitive: Polygon<N>,
|
primitive: Polygon<N>,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -496,7 +496,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolygon> for Gizmos<'w,
|
||||||
primitive: BoxedPolygon,
|
primitive: BoxedPolygon,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -531,7 +531,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<RegularPolygon> for Gizmos<'w
|
||||||
primitive: RegularPolygon,
|
primitive: RegularPolygon,
|
||||||
position: Vec2,
|
position: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use bevy_math::primitives::{
|
||||||
Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Torus,
|
Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Torus,
|
||||||
};
|
};
|
||||||
use bevy_math::{Quat, Vec3};
|
use bevy_math::{Quat, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ pub trait GizmoPrimitive3d<P: Primitive3d> {
|
||||||
primitive: P,
|
primitive: P,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_>;
|
) -> Self::Output<'_>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Direction3d> for Gizmos<'w, '
|
||||||
primitive: Direction3d,
|
primitive: Direction3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
self.arrow(position, position + (rotation * *primitive), color);
|
self.arrow(position, position + (rotation * *primitive), color);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ pub struct SphereBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// Center position of the sphere in 3D space
|
// Center position of the sphere in 3D space
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
// Color of the sphere
|
// Color of the sphere
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments used to approximate the sphere geometry
|
// Number of segments used to approximate the sphere geometry
|
||||||
segments: usize,
|
segments: usize,
|
||||||
|
@ -85,7 +85,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Sphere> for Gizmos<'w, 's, T>
|
||||||
primitive: Sphere,
|
primitive: Sphere,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
SphereBuilder {
|
SphereBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -146,7 +146,7 @@ pub struct Plane3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// Center position of the sphere in 3D space
|
// Center position of the sphere in 3D space
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
// Color of the sphere
|
// Color of the sphere
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of axis to hint the plane
|
// Number of axis to hint the plane
|
||||||
axis_count: usize,
|
axis_count: usize,
|
||||||
|
@ -184,7 +184,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Plane3d> for Gizmos<'w, 's, T
|
||||||
primitive: Plane3d,
|
primitive: Plane3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Plane3dBuilder {
|
Plane3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -251,7 +251,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Line3d> for Gizmos<'w, 's, T>
|
||||||
primitive: Line3d,
|
primitive: Line3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -278,7 +278,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Segment3d> for Gizmos<'w, 's,
|
||||||
primitive: Segment3d,
|
primitive: Segment3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -303,7 +303,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive3d<Polyline3d<N>
|
||||||
primitive: Polyline3d<N>,
|
primitive: Polyline3d<N>,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -328,7 +328,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<BoxedPolyline3d> for Gizmos<'
|
||||||
primitive: BoxedPolyline3d,
|
primitive: BoxedPolyline3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -355,7 +355,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cuboid> for Gizmos<'w, 's, T>
|
||||||
primitive: Cuboid,
|
primitive: Cuboid,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
|
@ -417,7 +417,7 @@ pub struct Cylinder3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// default orientation is: the cylinder is aligned with `Vec3::Y` axis
|
// default orientation is: the cylinder is aligned with `Vec3::Y` axis
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
// Color of the cylinder
|
// Color of the cylinder
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments used to approximate the cylinder geometry
|
// Number of segments used to approximate the cylinder geometry
|
||||||
segments: usize,
|
segments: usize,
|
||||||
|
@ -439,7 +439,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cylinder> for Gizmos<'w, 's,
|
||||||
primitive: Cylinder,
|
primitive: Cylinder,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Cylinder3dBuilder {
|
Cylinder3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -514,7 +514,7 @@ pub struct Capsule3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// default orientation is: the capsule is aligned with `Vec3::Y` axis
|
// default orientation is: the capsule is aligned with `Vec3::Y` axis
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
// Color of the capsule
|
// Color of the capsule
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments used to approximate the capsule geometry
|
// Number of segments used to approximate the capsule geometry
|
||||||
segments: usize,
|
segments: usize,
|
||||||
|
@ -536,7 +536,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Capsule3d> for Gizmos<'w, 's,
|
||||||
primitive: Capsule3d,
|
primitive: Capsule3d,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Capsule3dBuilder {
|
Capsule3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -607,7 +607,7 @@ pub struct Cone3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// default orientation is: cone base normal is aligned with the `Vec3::Y` axis
|
// default orientation is: cone base normal is aligned with the `Vec3::Y` axis
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
// Color of the cone
|
// Color of the cone
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments used to approximate the cone geometry
|
// Number of segments used to approximate the cone geometry
|
||||||
segments: usize,
|
segments: usize,
|
||||||
|
@ -629,7 +629,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Cone> for Gizmos<'w, 's, T> {
|
||||||
primitive: Cone,
|
primitive: Cone,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Cone3dBuilder {
|
Cone3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -703,7 +703,7 @@ pub struct ConicalFrustum3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// default orientation is: conical frustum base shape normals are aligned with `Vec3::Y` axis
|
// default orientation is: conical frustum base shape normals are aligned with `Vec3::Y` axis
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
// Color of the conical frustum
|
// Color of the conical frustum
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments used to approximate the curved surfaces
|
// Number of segments used to approximate the curved surfaces
|
||||||
segments: usize,
|
segments: usize,
|
||||||
|
@ -725,7 +725,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<ConicalFrustum> for Gizmos<'w
|
||||||
primitive: ConicalFrustum,
|
primitive: ConicalFrustum,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
ConicalFrustum3dBuilder {
|
ConicalFrustum3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
@ -807,7 +807,7 @@ pub struct Torus3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> {
|
||||||
// default orientation is: major circle normal is aligned with `Vec3::Y` axis
|
// default orientation is: major circle normal is aligned with `Vec3::Y` axis
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
// Color of the torus
|
// Color of the torus
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
|
|
||||||
// Number of segments in the minor (tube) direction
|
// Number of segments in the minor (tube) direction
|
||||||
minor_segments: usize,
|
minor_segments: usize,
|
||||||
|
@ -837,7 +837,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Torus> for Gizmos<'w, 's, T>
|
||||||
primitive: Torus,
|
primitive: Torus,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) -> Self::Output<'_> {
|
) -> Self::Output<'_> {
|
||||||
Torus3dBuilder {
|
Torus3dBuilder {
|
||||||
gizmos: self,
|
gizmos: self,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::f32::consts::TAU;
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
use bevy_math::{Mat2, Quat, Vec2, Vec3};
|
use bevy_math::{Mat2, Quat, Vec2, Vec3};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
use crate::prelude::{GizmoConfigGroup, Gizmos};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ pub(crate) fn draw_semi_sphere<T: GizmoConfigGroup>(
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
center: Vec3,
|
center: Vec3,
|
||||||
top: Vec3,
|
top: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
circle_coordinates(radius, segments)
|
circle_coordinates(radius, segments)
|
||||||
.map(|p| Vec3::new(p.x, 0.0, p.y))
|
.map(|p| Vec3::new(p.x, 0.0, p.y))
|
||||||
|
@ -81,7 +81,7 @@ pub(crate) fn draw_circle_3d<T: GizmoConfigGroup>(
|
||||||
segments: usize,
|
segments: usize,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
translation: Vec3,
|
translation: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
let positions = (0..=segments)
|
let positions = (0..=segments)
|
||||||
.map(|frac| frac as f32 / segments as f32)
|
.map(|frac| frac as f32 / segments as f32)
|
||||||
|
@ -100,7 +100,7 @@ pub(crate) fn draw_cylinder_vertical_lines<T: GizmoConfigGroup>(
|
||||||
half_height: f32,
|
half_height: f32,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
center: Vec3,
|
center: Vec3,
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
) {
|
) {
|
||||||
circle_coordinates(radius, segments)
|
circle_coordinates(radius, segments)
|
||||||
.map(move |point_2d| {
|
.map(move |point_2d| {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use bevy_pbr::{
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
alpha::AlphaMode,
|
alpha::AlphaMode,
|
||||||
camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode},
|
camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode},
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
mesh::{
|
mesh::{
|
||||||
morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights},
|
morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights},
|
||||||
skinning::{SkinnedMesh, SkinnedMeshInverseBindposes},
|
skinning::{SkinnedMesh, SkinnedMeshInverseBindposes},
|
||||||
|
@ -918,7 +918,7 @@ fn load_material(
|
||||||
let ior = material.ior().unwrap_or(1.5);
|
let ior = material.ior().unwrap_or(1.5);
|
||||||
|
|
||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
base_color: Color::rgba_linear(color[0], color[1], color[2], color[3]),
|
base_color: LegacyColor::rgba_linear(color[0], color[1], color[2], color[3]),
|
||||||
base_color_texture,
|
base_color_texture,
|
||||||
perceptual_roughness: pbr.roughness_factor(),
|
perceptual_roughness: pbr.roughness_factor(),
|
||||||
metallic: pbr.metallic_factor(),
|
metallic: pbr.metallic_factor(),
|
||||||
|
@ -933,7 +933,7 @@ fn load_material(
|
||||||
Some(Face::Back)
|
Some(Face::Back)
|
||||||
},
|
},
|
||||||
occlusion_texture,
|
occlusion_texture,
|
||||||
emissive: Color::rgb_linear(emissive[0], emissive[1], emissive[2])
|
emissive: LegacyColor::rgb_linear(emissive[0], emissive[1], emissive[2])
|
||||||
* material.emissive_strength().unwrap_or(1.0),
|
* material.emissive_strength().unwrap_or(1.0),
|
||||||
emissive_texture,
|
emissive_texture,
|
||||||
specular_transmission,
|
specular_transmission,
|
||||||
|
@ -944,7 +944,7 @@ fn load_material(
|
||||||
thickness_texture,
|
thickness_texture,
|
||||||
ior,
|
ior,
|
||||||
attenuation_distance,
|
attenuation_distance,
|
||||||
attenuation_color: Color::rgb_linear(
|
attenuation_color: LegacyColor::rgb_linear(
|
||||||
attenuation_color[0],
|
attenuation_color[0],
|
||||||
attenuation_color[1],
|
attenuation_color[1],
|
||||||
attenuation_color[2],
|
attenuation_color[2],
|
||||||
|
@ -1173,7 +1173,7 @@ fn load_node(
|
||||||
gltf::khr_lights_punctual::Kind::Directional => {
|
gltf::khr_lights_punctual::Kind::Directional => {
|
||||||
let mut entity = parent.spawn(DirectionalLightBundle {
|
let mut entity = parent.spawn(DirectionalLightBundle {
|
||||||
directional_light: DirectionalLight {
|
directional_light: DirectionalLight {
|
||||||
color: Color::rgb_from_array(light.color()),
|
color: LegacyColor::rgb_from_array(light.color()),
|
||||||
// NOTE: KHR_punctual_lights defines the intensity units for directional
|
// NOTE: KHR_punctual_lights defines the intensity units for directional
|
||||||
// lights in lux (lm/m^2) which is what we need.
|
// lights in lux (lm/m^2) which is what we need.
|
||||||
illuminance: light.intensity(),
|
illuminance: light.intensity(),
|
||||||
|
@ -1193,7 +1193,7 @@ fn load_node(
|
||||||
gltf::khr_lights_punctual::Kind::Point => {
|
gltf::khr_lights_punctual::Kind::Point => {
|
||||||
let mut entity = parent.spawn(PointLightBundle {
|
let mut entity = parent.spawn(PointLightBundle {
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
color: Color::rgb_from_array(light.color()),
|
color: LegacyColor::rgb_from_array(light.color()),
|
||||||
// NOTE: KHR_punctual_lights defines the intensity units for point lights in
|
// NOTE: KHR_punctual_lights defines the intensity units for point lights in
|
||||||
// candela (lm/sr) which is luminous intensity and we need luminous power.
|
// candela (lm/sr) which is luminous intensity and we need luminous power.
|
||||||
// For a point light, luminous power = 4 * pi * luminous intensity
|
// For a point light, luminous power = 4 * pi * luminous intensity
|
||||||
|
@ -1219,7 +1219,7 @@ fn load_node(
|
||||||
} => {
|
} => {
|
||||||
let mut entity = parent.spawn(SpotLightBundle {
|
let mut entity = parent.spawn(SpotLightBundle {
|
||||||
spot_light: SpotLight {
|
spot_light: SpotLight {
|
||||||
color: Color::rgb_from_array(light.color()),
|
color: LegacyColor::rgb_from_array(light.color()),
|
||||||
// NOTE: KHR_punctual_lights defines the intensity units for spot lights in
|
// NOTE: KHR_punctual_lights defines the intensity units for spot lights in
|
||||||
// candela (lm/sr) which is luminous intensity and we need luminous power.
|
// candela (lm/sr) which is luminous intensity and we need luminous power.
|
||||||
// For a spot light, we map luminous power = 4 * pi * luminous intensity
|
// For a spot light, we map luminous power = 4 * pi * luminous intensity
|
||||||
|
|
|
@ -178,7 +178,7 @@ pub mod gizmos {
|
||||||
//! # use bevy_render::prelude::*;
|
//! # use bevy_render::prelude::*;
|
||||||
//! # use bevy_math::prelude::*;
|
//! # use bevy_math::prelude::*;
|
||||||
//! fn system(mut gizmos: Gizmos) {
|
//! fn system(mut gizmos: Gizmos) {
|
||||||
//! gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN);
|
//! gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN);
|
||||||
//! }
|
//! }
|
||||||
//! # bevy_ecs::system::assert_is_system(system);
|
//! # bevy_ecs::system::assert_is_system(system);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::ReflectComponent;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_math::Vec3;
|
use bevy_math::Vec3;
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Camera};
|
use bevy_render::{color::LegacyColor, extract_component::ExtractComponent, prelude::Camera};
|
||||||
|
|
||||||
/// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect,
|
/// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect,
|
||||||
/// in which objects appear progressively more covered in atmospheric haze the further away they are from the camera.
|
/// in which objects appear progressively more covered in atmospheric haze the further away they are from the camera.
|
||||||
|
@ -34,7 +34,7 @@ use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Ca
|
||||||
/// },
|
/// },
|
||||||
/// // Add fog to the same entity
|
/// // Add fog to the same entity
|
||||||
/// FogSettings {
|
/// FogSettings {
|
||||||
/// color: Color::WHITE,
|
/// color: LegacyColor::WHITE,
|
||||||
/// falloff: FogFalloff::Exponential { density: 1e-3 },
|
/// falloff: FogFalloff::Exponential { density: 1e-3 },
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// },
|
/// },
|
||||||
|
@ -55,14 +55,14 @@ pub struct FogSettings {
|
||||||
///
|
///
|
||||||
/// **Tip:** The alpha channel of the color can be used to “modulate” the fog effect without
|
/// **Tip:** The alpha channel of the color can be used to “modulate” the fog effect without
|
||||||
/// changing the fog falloff mode or parameters.
|
/// changing the fog falloff mode or parameters.
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
|
|
||||||
/// Color used to modulate the influence of directional light colors on the
|
/// Color used to modulate the influence of directional light colors on the
|
||||||
/// fog, where the view direction aligns with each directional light direction,
|
/// fog, where the view direction aligns with each directional light direction,
|
||||||
/// producing a “glow” or light dispersion effect. (e.g. around the sun)
|
/// producing a “glow” or light dispersion effect. (e.g. around the sun)
|
||||||
///
|
///
|
||||||
/// Use [`Color::NONE`] to disable the effect.
|
/// Use [`LegacyColor::NONE`] to disable the effect.
|
||||||
pub directional_light_color: Color,
|
pub directional_light_color: LegacyColor,
|
||||||
|
|
||||||
/// The exponent applied to the directional light alignment calculation.
|
/// The exponent applied to the directional light alignment calculation.
|
||||||
/// A higher value means a more concentrated “glow”.
|
/// A higher value means a more concentrated “glow”.
|
||||||
|
@ -346,7 +346,7 @@ impl FogFalloff {
|
||||||
/// [`FogFalloff::REVISED_KOSCHMIEDER_CONTRAST_THRESHOLD`].
|
/// [`FogFalloff::REVISED_KOSCHMIEDER_CONTRAST_THRESHOLD`].
|
||||||
pub fn from_visibility_color(
|
pub fn from_visibility_color(
|
||||||
visibility: f32,
|
visibility: f32,
|
||||||
extinction_inscattering_color: Color,
|
extinction_inscattering_color: LegacyColor,
|
||||||
) -> FogFalloff {
|
) -> FogFalloff {
|
||||||
FogFalloff::from_visibility_contrast_colors(
|
FogFalloff::from_visibility_contrast_colors(
|
||||||
visibility,
|
visibility,
|
||||||
|
@ -362,12 +362,12 @@ impl FogFalloff {
|
||||||
///
|
///
|
||||||
/// ## Tips
|
/// ## Tips
|
||||||
/// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects;
|
/// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects;
|
||||||
/// - Using an `extinction_color` of [`Color::WHITE`] or [`Color::NONE`] disables the extinction effect;
|
/// - Using an `extinction_color` of [`LegacyColor::WHITE`] or [`LegacyColor::NONE`] disables the extinction effect;
|
||||||
/// - Using an `inscattering_color` of [`Color::BLACK`] or [`Color::NONE`] disables the inscattering effect.
|
/// - Using an `inscattering_color` of [`LegacyColor::BLACK`] or [`LegacyColor::NONE`] disables the inscattering effect.
|
||||||
pub fn from_visibility_colors(
|
pub fn from_visibility_colors(
|
||||||
visibility: f32,
|
visibility: f32,
|
||||||
extinction_color: Color,
|
extinction_color: LegacyColor,
|
||||||
inscattering_color: Color,
|
inscattering_color: LegacyColor,
|
||||||
) -> FogFalloff {
|
) -> FogFalloff {
|
||||||
FogFalloff::from_visibility_contrast_colors(
|
FogFalloff::from_visibility_contrast_colors(
|
||||||
visibility,
|
visibility,
|
||||||
|
@ -382,7 +382,7 @@ impl FogFalloff {
|
||||||
pub fn from_visibility_contrast_color(
|
pub fn from_visibility_contrast_color(
|
||||||
visibility: f32,
|
visibility: f32,
|
||||||
contrast_threshold: f32,
|
contrast_threshold: f32,
|
||||||
extinction_inscattering_color: Color,
|
extinction_inscattering_color: LegacyColor,
|
||||||
) -> FogFalloff {
|
) -> FogFalloff {
|
||||||
FogFalloff::from_visibility_contrast_colors(
|
FogFalloff::from_visibility_contrast_colors(
|
||||||
visibility,
|
visibility,
|
||||||
|
@ -397,13 +397,13 @@ impl FogFalloff {
|
||||||
///
|
///
|
||||||
/// ## Tips
|
/// ## Tips
|
||||||
/// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects;
|
/// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects;
|
||||||
/// - Using an `extinction_color` of [`Color::WHITE`] or [`Color::NONE`] disables the extinction effect;
|
/// - Using an `extinction_color` of [`LegacyColor::WHITE`] or [`LegacyColor::NONE`] disables the extinction effect;
|
||||||
/// - Using an `inscattering_color` of [`Color::BLACK`] or [`Color::NONE`] disables the inscattering effect.
|
/// - Using an `inscattering_color` of [`LegacyColor::BLACK`] or [`LegacyColor::NONE`] disables the inscattering effect.
|
||||||
pub fn from_visibility_contrast_colors(
|
pub fn from_visibility_contrast_colors(
|
||||||
visibility: f32,
|
visibility: f32,
|
||||||
contrast_threshold: f32,
|
contrast_threshold: f32,
|
||||||
extinction_color: Color,
|
extinction_color: LegacyColor,
|
||||||
inscattering_color: Color,
|
inscattering_color: LegacyColor,
|
||||||
) -> FogFalloff {
|
) -> FogFalloff {
|
||||||
use std::f32::consts::E;
|
use std::f32::consts::E;
|
||||||
|
|
||||||
|
@ -465,12 +465,12 @@ impl FogFalloff {
|
||||||
impl Default for FogSettings {
|
impl Default for FogSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba(1.0, 1.0, 1.0, 1.0),
|
color: LegacyColor::rgba(1.0, 1.0, 1.0, 1.0),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
start: 0.0,
|
start: 0.0,
|
||||||
end: 100.0,
|
end: 100.0,
|
||||||
},
|
},
|
||||||
directional_light_color: Color::NONE,
|
directional_light_color: LegacyColor::NONE,
|
||||||
directional_light_exponent: 8.0,
|
directional_light_exponent: 8.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ use bevy_render::{
|
||||||
camera::{CameraUpdateSystem, Projection},
|
camera::{CameraUpdateSystem, Projection},
|
||||||
extract_component::ExtractComponentPlugin,
|
extract_component::ExtractComponentPlugin,
|
||||||
extract_resource::ExtractResourcePlugin,
|
extract_resource::ExtractResourcePlugin,
|
||||||
prelude::Color,
|
prelude::LegacyColor,
|
||||||
render_asset::prepare_assets,
|
render_asset::prepare_assets,
|
||||||
render_graph::RenderGraph,
|
render_graph::RenderGraph,
|
||||||
render_phase::sort_phase_system,
|
render_phase::sort_phase_system,
|
||||||
|
@ -336,7 +336,7 @@ impl Plugin for PbrPlugin {
|
||||||
app.world.resource_mut::<Assets<StandardMaterial>>().insert(
|
app.world.resource_mut::<Assets<StandardMaterial>>().insert(
|
||||||
Handle::<StandardMaterial>::default(),
|
Handle::<StandardMaterial>::default(),
|
||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
base_color: Color::rgb(1.0, 0.0, 0.5),
|
base_color: LegacyColor::rgb(1.0, 0.0, 0.5),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ use bevy_math::{
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{Camera, CameraProjection},
|
camera::{Camera, CameraProjection},
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
extract_component::ExtractComponent,
|
extract_component::ExtractComponent,
|
||||||
extract_resource::ExtractResource,
|
extract_resource::ExtractResource,
|
||||||
primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, HalfSpace, Sphere},
|
primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, HalfSpace, Sphere},
|
||||||
|
@ -98,7 +98,7 @@ pub mod light_consts {
|
||||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
pub struct PointLight {
|
pub struct PointLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
|
/// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
|
||||||
pub intensity: f32,
|
pub intensity: f32,
|
||||||
pub range: f32,
|
pub range: f32,
|
||||||
|
@ -114,7 +114,7 @@ pub struct PointLight {
|
||||||
impl Default for PointLight {
|
impl Default for PointLight {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
PointLight {
|
PointLight {
|
||||||
color: Color::rgb(1.0, 1.0, 1.0),
|
color: LegacyColor::rgb(1.0, 1.0, 1.0),
|
||||||
// 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
|
// 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
|
||||||
// default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
|
// default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
|
||||||
// this would be way too bright.
|
// this would be way too bright.
|
||||||
|
@ -152,7 +152,7 @@ impl Default for PointLightShadowMap {
|
||||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
pub struct SpotLight {
|
pub struct SpotLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
|
/// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
|
||||||
pub intensity: f32,
|
pub intensity: f32,
|
||||||
pub range: f32,
|
pub range: f32,
|
||||||
|
@ -185,7 +185,7 @@ impl Default for SpotLight {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// a quarter arc attenuating from the center
|
// a quarter arc attenuating from the center
|
||||||
Self {
|
Self {
|
||||||
color: Color::rgb(1.0, 1.0, 1.0),
|
color: LegacyColor::rgb(1.0, 1.0, 1.0),
|
||||||
// 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
|
// 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
|
||||||
// default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
|
// default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
|
||||||
// this would be way too bright.
|
// this would be way too bright.
|
||||||
|
@ -251,7 +251,7 @@ impl Default for SpotLight {
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
pub struct DirectionalLight {
|
pub struct DirectionalLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// Illuminance in lux (lumens per square meter), representing the amount of
|
/// Illuminance in lux (lumens per square meter), representing the amount of
|
||||||
/// light projected onto surfaces by this light source. Lux is used here
|
/// light projected onto surfaces by this light source. Lux is used here
|
||||||
/// instead of lumens because a directional light illuminates all surfaces
|
/// instead of lumens because a directional light illuminates all surfaces
|
||||||
|
@ -269,7 +269,7 @@ pub struct DirectionalLight {
|
||||||
impl Default for DirectionalLight {
|
impl Default for DirectionalLight {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
DirectionalLight {
|
DirectionalLight {
|
||||||
color: Color::rgb(1.0, 1.0, 1.0),
|
color: LegacyColor::rgb(1.0, 1.0, 1.0),
|
||||||
illuminance: light_consts::lux::AMBIENT_DAYLIGHT,
|
illuminance: light_consts::lux::AMBIENT_DAYLIGHT,
|
||||||
shadows_enabled: false,
|
shadows_enabled: false,
|
||||||
shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
|
shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
|
||||||
|
@ -636,7 +636,7 @@ fn calculate_cascade(
|
||||||
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
|
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource)]
|
||||||
pub struct AmbientLight {
|
pub struct AmbientLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// A direct scale factor multiplied with `color` before being passed to the shader.
|
/// A direct scale factor multiplied with `color` before being passed to the shader.
|
||||||
pub brightness: f32,
|
pub brightness: f32,
|
||||||
}
|
}
|
||||||
|
@ -644,14 +644,14 @@ pub struct AmbientLight {
|
||||||
impl Default for AmbientLight {
|
impl Default for AmbientLight {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 80.0,
|
brightness: 80.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AmbientLight {
|
impl AmbientLight {
|
||||||
pub const NONE: AmbientLight = AmbientLight {
|
pub const NONE: AmbientLight = AmbientLight {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 0.0,
|
brightness: 0.0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight};
|
||||||
/// # use bevy_pbr::{Material, MaterialMeshBundle};
|
/// # use bevy_pbr::{Material, MaterialMeshBundle};
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # use bevy_reflect::TypePath;
|
/// # use bevy_reflect::TypePath;
|
||||||
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
|
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor};
|
||||||
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
||||||
///
|
///
|
||||||
/// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)]
|
/// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)]
|
||||||
|
@ -60,7 +60,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight};
|
||||||
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
||||||
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
||||||
/// // add the sampler attribute with a different binding index.
|
/// // add the sampler attribute with a different binding index.
|
||||||
/// #[texture(1)]
|
/// #[texture(1)]
|
||||||
|
@ -80,7 +80,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight};
|
||||||
/// fn setup(mut commands: Commands, mut materials: ResMut<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
|
/// fn setup(mut commands: Commands, mut materials: ResMut<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
|
||||||
/// commands.spawn(MaterialMeshBundle {
|
/// commands.spawn(MaterialMeshBundle {
|
||||||
/// material: materials.add(CustomMaterial {
|
/// material: materials.add(CustomMaterial {
|
||||||
/// color: Color::RED,
|
/// color: LegacyColor::RED,
|
||||||
/// color_texture: asset_server.load("some_image.png"),
|
/// color_texture: asset_server.load("some_image.png"),
|
||||||
/// }),
|
/// }),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
|
|
|
@ -2,8 +2,8 @@ use bevy_asset::{Asset, Handle};
|
||||||
use bevy_math::{Affine2, Vec2, Vec4};
|
use bevy_math::{Affine2, Vec2, Vec4};
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*,
|
color::LegacyColor, mesh::MeshVertexBufferLayout, render_asset::RenderAssets,
|
||||||
texture::Image,
|
render_resource::*, texture::Image,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID;
|
use crate::deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID;
|
||||||
|
@ -13,7 +13,7 @@ use crate::*;
|
||||||
/// Standard property values with pictures here
|
/// Standard property values with pictures here
|
||||||
/// <https://google.github.io/filament/Material%20Properties.pdf>.
|
/// <https://google.github.io/filament/Material%20Properties.pdf>.
|
||||||
///
|
///
|
||||||
/// May be created directly from a [`Color`] or an [`Image`].
|
/// May be created directly from a [`LegacyColor`] or an [`Image`].
|
||||||
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone)]
|
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone)]
|
||||||
#[bind_group_data(StandardMaterialKey)]
|
#[bind_group_data(StandardMaterialKey)]
|
||||||
#[uniform(0, StandardMaterialUniform)]
|
#[uniform(0, StandardMaterialUniform)]
|
||||||
|
@ -25,15 +25,15 @@ pub struct StandardMaterial {
|
||||||
/// in between. If used together with a `base_color_texture`, this is factored into the final
|
/// in between. If used together with a `base_color_texture`, this is factored into the final
|
||||||
/// base color as `base_color * base_color_texture_value`
|
/// base color as `base_color * base_color_texture_value`
|
||||||
///
|
///
|
||||||
/// Defaults to [`Color::WHITE`].
|
/// Defaults to [`LegacyColor::WHITE`].
|
||||||
pub base_color: Color,
|
pub base_color: LegacyColor,
|
||||||
|
|
||||||
/// The texture component of the material's color before lighting.
|
/// The texture component of the material's color before lighting.
|
||||||
/// The actual pre-lighting color is `base_color * this_texture`.
|
/// The actual pre-lighting color is `base_color * this_texture`.
|
||||||
///
|
///
|
||||||
/// See [`base_color`] for details.
|
/// See [`base_color`] for details.
|
||||||
///
|
///
|
||||||
/// You should set `base_color` to [`Color::WHITE`] (the default)
|
/// You should set `base_color` to [`LegacyColor::WHITE`] (the default)
|
||||||
/// if you want the texture to show as-is.
|
/// if you want the texture to show as-is.
|
||||||
///
|
///
|
||||||
/// Setting `base_color` to something else than white will tint
|
/// Setting `base_color` to something else than white will tint
|
||||||
|
@ -61,13 +61,13 @@ pub struct StandardMaterial {
|
||||||
///
|
///
|
||||||
/// Note that **an emissive material won't light up surrounding areas like a light source**,
|
/// Note that **an emissive material won't light up surrounding areas like a light source**,
|
||||||
/// it just adds a value to the color seen on screen.
|
/// it just adds a value to the color seen on screen.
|
||||||
pub emissive: Color,
|
pub emissive: LegacyColor,
|
||||||
|
|
||||||
/// The emissive map, multiplies pixels with [`emissive`]
|
/// The emissive map, multiplies pixels with [`emissive`]
|
||||||
/// to get the final "emitting" color of a surface.
|
/// to get the final "emitting" color of a surface.
|
||||||
///
|
///
|
||||||
/// This color is multiplied by [`emissive`] to get the final emitted color.
|
/// This color is multiplied by [`emissive`] to get the final emitted color.
|
||||||
/// Meaning that you should set [`emissive`] to [`Color::WHITE`]
|
/// Meaning that you should set [`emissive`] to [`LegacyColor::WHITE`]
|
||||||
/// if you want to use the full range of color of the emissive texture.
|
/// if you want to use the full range of color of the emissive texture.
|
||||||
///
|
///
|
||||||
/// [`emissive`]: StandardMaterial::emissive
|
/// [`emissive`]: StandardMaterial::emissive
|
||||||
|
@ -274,7 +274,7 @@ pub struct StandardMaterial {
|
||||||
|
|
||||||
/// The resulting (non-absorbed) color after white light travels through the attenuation distance.
|
/// The resulting (non-absorbed) color after white light travels through the attenuation distance.
|
||||||
///
|
///
|
||||||
/// Defaults to [`Color::WHITE`], i.e. no change.
|
/// Defaults to [`LegacyColor::WHITE`], i.e. no change.
|
||||||
///
|
///
|
||||||
/// **Note:** To have any effect, must be used in conjunction with:
|
/// **Note:** To have any effect, must be used in conjunction with:
|
||||||
/// - [`StandardMaterial::attenuation_distance`];
|
/// - [`StandardMaterial::attenuation_distance`];
|
||||||
|
@ -282,7 +282,7 @@ pub struct StandardMaterial {
|
||||||
/// - [`StandardMaterial::diffuse_transmission`] or [`StandardMaterial::specular_transmission`].
|
/// - [`StandardMaterial::diffuse_transmission`] or [`StandardMaterial::specular_transmission`].
|
||||||
#[doc(alias = "absorption_color")]
|
#[doc(alias = "absorption_color")]
|
||||||
#[doc(alias = "extinction_color")]
|
#[doc(alias = "extinction_color")]
|
||||||
pub attenuation_color: Color,
|
pub attenuation_color: LegacyColor,
|
||||||
|
|
||||||
/// Used to fake the lighting of bumps and dents on a material.
|
/// Used to fake the lighting of bumps and dents on a material.
|
||||||
///
|
///
|
||||||
|
@ -482,9 +482,9 @@ impl Default for StandardMaterial {
|
||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
// White because it gets multiplied with texture values if someone uses
|
// White because it gets multiplied with texture values if someone uses
|
||||||
// a texture.
|
// a texture.
|
||||||
base_color: Color::rgb(1.0, 1.0, 1.0),
|
base_color: LegacyColor::rgb(1.0, 1.0, 1.0),
|
||||||
base_color_texture: None,
|
base_color_texture: None,
|
||||||
emissive: Color::BLACK,
|
emissive: LegacyColor::BLACK,
|
||||||
emissive_texture: None,
|
emissive_texture: None,
|
||||||
// Matches Blender's default roughness.
|
// Matches Blender's default roughness.
|
||||||
perceptual_roughness: 0.5,
|
perceptual_roughness: 0.5,
|
||||||
|
@ -505,7 +505,7 @@ impl Default for StandardMaterial {
|
||||||
#[cfg(feature = "pbr_transmission_textures")]
|
#[cfg(feature = "pbr_transmission_textures")]
|
||||||
thickness_texture: None,
|
thickness_texture: None,
|
||||||
ior: 1.5,
|
ior: 1.5,
|
||||||
attenuation_color: Color::WHITE,
|
attenuation_color: LegacyColor::WHITE,
|
||||||
attenuation_distance: f32::INFINITY,
|
attenuation_distance: f32::INFINITY,
|
||||||
occlusion_texture: None,
|
occlusion_texture: None,
|
||||||
normal_map_texture: None,
|
normal_map_texture: None,
|
||||||
|
@ -528,8 +528,8 @@ impl Default for StandardMaterial {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for StandardMaterial {
|
impl From<LegacyColor> for StandardMaterial {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: LegacyColor) -> Self {
|
||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
base_color: color,
|
base_color: color,
|
||||||
alpha_mode: if color.a() < 1.0 {
|
alpha_mode: if color.a() < 1.0 {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy_ecs::prelude::*;
|
||||||
use bevy_math::{Mat4, UVec3, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles};
|
use bevy_math::{Mat4, UVec3, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::Camera,
|
camera::Camera,
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
mesh::Mesh,
|
mesh::Mesh,
|
||||||
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
|
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
|
||||||
render_asset::RenderAssets,
|
render_asset::RenderAssets,
|
||||||
|
@ -29,7 +29,7 @@ use crate::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ExtractedPointLight {
|
pub struct ExtractedPointLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// luminous intensity in lumens per steradian
|
/// luminous intensity in lumens per steradian
|
||||||
pub intensity: f32,
|
pub intensity: f32,
|
||||||
pub range: f32,
|
pub range: f32,
|
||||||
|
@ -43,7 +43,7 @@ pub struct ExtractedPointLight {
|
||||||
|
|
||||||
#[derive(Component, Debug)]
|
#[derive(Component, Debug)]
|
||||||
pub struct ExtractedDirectionalLight {
|
pub struct ExtractedDirectionalLight {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
pub illuminance: f32,
|
pub illuminance: f32,
|
||||||
pub transform: GlobalTransform,
|
pub transform: GlobalTransform,
|
||||||
pub shadows_enabled: bool,
|
pub shadows_enabled: bool,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy_asset::{load_internal_asset, Asset, Assets, Handle};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
extract_resource::ExtractResource,
|
extract_resource::ExtractResource,
|
||||||
mesh::{Mesh, MeshVertexBufferLayout},
|
mesh::{Mesh, MeshVertexBufferLayout},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
@ -69,7 +69,7 @@ pub struct Wireframe;
|
||||||
#[derive(Component, Debug, Clone, Default, Reflect)]
|
#[derive(Component, Debug, Clone, Default, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
pub struct WireframeColor {
|
pub struct WireframeColor {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disables wireframe rendering for any entity it is attached to.
|
/// Disables wireframe rendering for any entity it is attached to.
|
||||||
|
@ -89,7 +89,7 @@ pub struct WireframeConfig {
|
||||||
/// If [`Self::global`] is set, any [`Entity`] that does not have a [`Wireframe`] component attached to it will have
|
/// If [`Self::global`] is set, any [`Entity`] that does not have a [`Wireframe`] component attached to it will have
|
||||||
/// wireframes using this color. Otherwise, this will be the fallback color for any entity that has a [`Wireframe`],
|
/// wireframes using this color. Otherwise, this will be the fallback color for any entity that has a [`Wireframe`],
|
||||||
/// but no [`WireframeColor`].
|
/// but no [`WireframeColor`].
|
||||||
pub default_color: Color,
|
pub default_color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
|
@ -200,7 +200,7 @@ fn apply_global_wireframe_material(
|
||||||
#[derive(Default, AsBindGroup, TypePath, Debug, Clone, Asset)]
|
#[derive(Default, AsBindGroup, TypePath, Debug, Clone, Asset)]
|
||||||
pub struct WireframeMaterial {
|
pub struct WireframeMaterial {
|
||||||
#[uniform(0)]
|
#[uniform(0)]
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Material for WireframeMaterial {
|
impl Material for WireframeMaterial {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{color::Color, extract_resource::ExtractResource};
|
use crate::{color::LegacyColor, extract_resource::ExtractResource};
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||||
|
@ -12,15 +12,15 @@ pub enum ClearColorConfig {
|
||||||
#[default]
|
#[default]
|
||||||
Default,
|
Default,
|
||||||
/// The given clear color is used, overriding the [`ClearColor`] resource defined in the world.
|
/// The given clear color is used, overriding the [`ClearColor`] resource defined in the world.
|
||||||
Custom(Color),
|
Custom(LegacyColor),
|
||||||
/// No clear color is used: the camera will simply draw on top of anything already in the viewport.
|
/// No clear color is used: the camera will simply draw on top of anything already in the viewport.
|
||||||
///
|
///
|
||||||
/// This can be useful when multiple cameras are rendering to the same viewport.
|
/// This can be useful when multiple cameras are rendering to the same viewport.
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for ClearColorConfig {
|
impl From<LegacyColor> for ClearColorConfig {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: LegacyColor) -> Self {
|
||||||
Self::Custom(color)
|
Self::Custom(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ impl From<Color> for ClearColorConfig {
|
||||||
/// when there are portions of the screen with nothing rendered.
|
/// when there are portions of the screen with nothing rendered.
|
||||||
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
|
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource)]
|
||||||
pub struct ClearColor(pub Color);
|
pub struct ClearColor(pub LegacyColor);
|
||||||
|
|
||||||
/// Match the dark gray bevy website code block color by default.
|
/// Match the dark gray bevy website code block color by default.
|
||||||
impl Default for ClearColor {
|
impl Default for ClearColor {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self(Color::rgb_u8(43, 44, 47))
|
Self(LegacyColor::rgb_u8(43, 44, 47))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,7 +38,7 @@ pub mod prelude {
|
||||||
Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection,
|
Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection,
|
||||||
Projection,
|
Projection,
|
||||||
},
|
},
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
mesh::{morph::MorphWeights, primitives::Meshable, Mesh},
|
mesh::{morph::MorphWeights, primitives::Meshable, Mesh},
|
||||||
render_resource::Shader,
|
render_resource::Shader,
|
||||||
spatial_bundle::SpatialBundle,
|
spatial_bundle::SpatialBundle,
|
||||||
|
@ -330,7 +330,7 @@ impl Plugin for RenderPlugin {
|
||||||
));
|
));
|
||||||
|
|
||||||
app.register_type::<alpha::AlphaMode>()
|
app.register_type::<alpha::AlphaMode>()
|
||||||
.register_type::<color::Color>()
|
.register_type::<color::LegacyColor>()
|
||||||
.register_type::<primitives::Aabb>()
|
.register_type::<primitives::Aabb>()
|
||||||
.register_type::<primitives::CascadesFrusta>()
|
.register_type::<primitives::CascadesFrusta>()
|
||||||
.register_type::<primitives::CubemapFrusta>()
|
.register_type::<primitives::CubemapFrusta>()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
camera::Viewport,
|
camera::Viewport,
|
||||||
prelude::Color,
|
prelude::LegacyColor,
|
||||||
render_resource::{
|
render_resource::{
|
||||||
BindGroup, BindGroupId, Buffer, BufferId, BufferSlice, RenderPipeline, RenderPipelineId,
|
BindGroup, BindGroupId, Buffer, BufferId, BufferSlice, RenderPipeline, RenderPipelineId,
|
||||||
ShaderStages,
|
ShaderStages,
|
||||||
|
@ -598,7 +598,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||||
/// Sets the blend color as used by some of the blending modes.
|
/// Sets the blend color as used by some of the blending modes.
|
||||||
///
|
///
|
||||||
/// Subsequent blending tests will test against this value.
|
/// Subsequent blending tests will test against this value.
|
||||||
pub fn set_blend_constant(&mut self, color: Color) {
|
pub fn set_blend_constant(&mut self, color: LegacyColor) {
|
||||||
detailed_trace!("set blend constant: {:?}", color);
|
detailed_trace!("set blend constant: {:?}", color);
|
||||||
self.pass.set_blend_constant(wgpu::Color::from(color));
|
self.pass.set_blend_constant(wgpu::Color::from(color));
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,12 @@ impl Deref for BindGroup {
|
||||||
/// what their binding type is, and what index they should be bound at:
|
/// what their binding type is, and what index they should be bound at:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::*, texture::Image};
|
/// # use bevy_render::{color::LegacyColor, render_resource::*, texture::Image};
|
||||||
/// # use bevy_asset::Handle;
|
/// # use bevy_asset::Handle;
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// #[texture(1)]
|
/// #[texture(1)]
|
||||||
/// #[sampler(2)]
|
/// #[sampler(2)]
|
||||||
/// color_texture: Handle<Image>,
|
/// color_texture: Handle<Image>,
|
||||||
|
@ -109,7 +109,7 @@ impl Deref for BindGroup {
|
||||||
/// * `uniform(BINDING_INDEX)`
|
/// * `uniform(BINDING_INDEX)`
|
||||||
/// * The field will be converted to a shader-compatible type using the [`ShaderType`] trait, written to a [`Buffer`], and bound as a uniform.
|
/// * The field will be converted to a shader-compatible type using the [`ShaderType`] trait, written to a [`Buffer`], and bound as a uniform.
|
||||||
/// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and
|
/// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and
|
||||||
/// [`Color`](crate::color::Color). It can also be derived for custom structs.
|
/// [`LegacyColor`](crate::color::LegacyColor). It can also be derived for custom structs.
|
||||||
///
|
///
|
||||||
/// * `texture(BINDING_INDEX, arguments)`
|
/// * `texture(BINDING_INDEX, arguments)`
|
||||||
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
|
/// * This field's [`Handle<Image>`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture)
|
||||||
|
@ -162,24 +162,24 @@ impl Deref for BindGroup {
|
||||||
///
|
///
|
||||||
/// Note that fields without field-level binding attributes will be ignored.
|
/// Note that fields without field-level binding attributes will be ignored.
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::AsBindGroup};
|
/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup};
|
||||||
/// # use bevy_asset::Handle;
|
/// # use bevy_asset::Handle;
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// this_field_is_ignored: String,
|
/// this_field_is_ignored: String,
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// As mentioned above, [`Option<Handle<Image>>`] is also supported:
|
/// As mentioned above, [`Option<Handle<Image>>`] is also supported:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::AsBindGroup, texture::Image};
|
/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup, texture::Image};
|
||||||
/// # use bevy_asset::Handle;
|
/// # use bevy_asset::Handle;
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// #[texture(1)]
|
/// #[texture(1)]
|
||||||
/// #[sampler(2)]
|
/// #[sampler(2)]
|
||||||
/// color_texture: Option<Handle<Image>>,
|
/// color_texture: Option<Handle<Image>>,
|
||||||
|
@ -190,11 +190,11 @@ impl Deref for BindGroup {
|
||||||
///
|
///
|
||||||
/// Field uniforms with the same index will be combined into a single binding:
|
/// Field uniforms with the same index will be combined into a single binding:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::AsBindGroup};
|
/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup};
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// roughness: f32,
|
/// roughness: f32,
|
||||||
/// }
|
/// }
|
||||||
|
@ -227,17 +227,17 @@ impl Deref for BindGroup {
|
||||||
/// The previous `CoolMaterial` example illustrating "combining multiple field-level uniform attributes with the same binding index" can
|
/// The previous `CoolMaterial` example illustrating "combining multiple field-level uniform attributes with the same binding index" can
|
||||||
/// also be equivalently represented with a single struct-level uniform attribute:
|
/// also be equivalently represented with a single struct-level uniform attribute:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::{AsBindGroup, ShaderType}};
|
/// # use bevy_render::{color::LegacyColor, render_resource::{AsBindGroup, ShaderType}};
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// #[uniform(0, CoolMaterialUniform)]
|
/// #[uniform(0, CoolMaterialUniform)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// roughness: f32,
|
/// roughness: f32,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[derive(ShaderType)]
|
/// #[derive(ShaderType)]
|
||||||
/// struct CoolMaterialUniform {
|
/// struct CoolMaterialUniform {
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// roughness: f32,
|
/// roughness: f32,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -253,12 +253,12 @@ impl Deref for BindGroup {
|
||||||
///
|
///
|
||||||
/// Setting `bind_group_data` looks like this:
|
/// Setting `bind_group_data` looks like this:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_render::{color::Color, render_resource::AsBindGroup};
|
/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup};
|
||||||
/// #[derive(AsBindGroup)]
|
/// #[derive(AsBindGroup)]
|
||||||
/// #[bind_group_data(CoolMaterialKey)]
|
/// #[bind_group_data(CoolMaterialKey)]
|
||||||
/// struct CoolMaterial {
|
/// struct CoolMaterial {
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// is_shaded: bool,
|
/// is_shaded: bool,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::CachedTexture;
|
use super::CachedTexture;
|
||||||
use crate::{prelude::Color, render_resource::TextureView};
|
use crate::{prelude::LegacyColor, render_resource::TextureView};
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
|
@ -13,7 +13,7 @@ use wgpu::{
|
||||||
pub struct ColorAttachment {
|
pub struct ColorAttachment {
|
||||||
pub texture: CachedTexture,
|
pub texture: CachedTexture,
|
||||||
pub resolve_target: Option<CachedTexture>,
|
pub resolve_target: Option<CachedTexture>,
|
||||||
clear_color: Option<Color>,
|
clear_color: Option<LegacyColor>,
|
||||||
is_first_call: Arc<AtomicBool>,
|
is_first_call: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ impl ColorAttachment {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
texture: CachedTexture,
|
texture: CachedTexture,
|
||||||
resolve_target: Option<CachedTexture>,
|
resolve_target: Option<CachedTexture>,
|
||||||
clear_color: Option<Color>,
|
clear_color: Option<LegacyColor>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
texture,
|
texture,
|
||||||
|
|
|
@ -4,7 +4,8 @@ use bevy_asset::{load_internal_asset, Asset, AssetApp, Assets, Handle};
|
||||||
use bevy_math::Vec4;
|
use bevy_math::Vec4;
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
color::Color, prelude::Shader, render_asset::RenderAssets, render_resource::*, texture::Image,
|
color::LegacyColor, prelude::Shader, render_asset::RenderAssets, render_resource::*,
|
||||||
|
texture::Image,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const COLOR_MATERIAL_SHADER_HANDLE: Handle<Shader> =
|
pub const COLOR_MATERIAL_SHADER_HANDLE: Handle<Shader> =
|
||||||
|
@ -28,7 +29,7 @@ impl Plugin for ColorMaterialPlugin {
|
||||||
app.world.resource_mut::<Assets<ColorMaterial>>().insert(
|
app.world.resource_mut::<Assets<ColorMaterial>>().insert(
|
||||||
Handle::<ColorMaterial>::default(),
|
Handle::<ColorMaterial>::default(),
|
||||||
ColorMaterial {
|
ColorMaterial {
|
||||||
color: Color::rgb(1.0, 0.0, 1.0),
|
color: LegacyColor::rgb(1.0, 0.0, 1.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -40,7 +41,7 @@ impl Plugin for ColorMaterialPlugin {
|
||||||
#[reflect(Default, Debug)]
|
#[reflect(Default, Debug)]
|
||||||
#[uniform(0, ColorMaterialUniform)]
|
#[uniform(0, ColorMaterialUniform)]
|
||||||
pub struct ColorMaterial {
|
pub struct ColorMaterial {
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
#[texture(1)]
|
#[texture(1)]
|
||||||
#[sampler(2)]
|
#[sampler(2)]
|
||||||
pub texture: Option<Handle<Image>>,
|
pub texture: Option<Handle<Image>>,
|
||||||
|
@ -49,14 +50,14 @@ pub struct ColorMaterial {
|
||||||
impl Default for ColorMaterial {
|
impl Default for ColorMaterial {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ColorMaterial {
|
ColorMaterial {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
texture: None,
|
texture: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for ColorMaterial {
|
impl From<LegacyColor> for ColorMaterial {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: LegacyColor) -> Self {
|
||||||
ColorMaterial {
|
ColorMaterial {
|
||||||
color,
|
color,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -54,7 +54,7 @@ use crate::{
|
||||||
/// # use bevy_sprite::{Material2d, MaterialMesh2dBundle};
|
/// # use bevy_sprite::{Material2d, MaterialMesh2dBundle};
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # use bevy_reflect::TypePath;
|
/// # use bevy_reflect::TypePath;
|
||||||
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
|
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor};
|
||||||
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
||||||
///
|
///
|
||||||
/// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)]
|
/// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)]
|
||||||
|
@ -62,7 +62,7 @@ use crate::{
|
||||||
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
||||||
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
||||||
/// // add the sampler attribute with a different binding index.
|
/// // add the sampler attribute with a different binding index.
|
||||||
/// #[texture(1)]
|
/// #[texture(1)]
|
||||||
|
@ -82,7 +82,7 @@ use crate::{
|
||||||
/// fn setup(mut commands: Commands, mut materials: ResMut<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
|
/// fn setup(mut commands: Commands, mut materials: ResMut<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
|
||||||
/// commands.spawn(MaterialMesh2dBundle {
|
/// commands.spawn(MaterialMesh2dBundle {
|
||||||
/// material: materials.add(CustomMaterial {
|
/// material: materials.add(CustomMaterial {
|
||||||
/// color: Color::RED,
|
/// color: LegacyColor::RED,
|
||||||
/// color_texture: asset_server.load("some_image.png"),
|
/// color_texture: asset_server.load("some_image.png"),
|
||||||
/// }),
|
/// }),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
|
|
|
@ -16,7 +16,7 @@ use bevy_ecs::{
|
||||||
};
|
};
|
||||||
use bevy_math::{Affine3A, Quat, Rect, Vec2, Vec4};
|
use bevy_math::{Affine3A, Quat, Rect, Vec2, Vec4};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
render_asset::RenderAssets,
|
render_asset::RenderAssets,
|
||||||
render_phase::{
|
render_phase::{
|
||||||
DrawFunctions, PhaseItem, RenderCommand, RenderCommandResult, RenderPhase, SetItemPipeline,
|
DrawFunctions, PhaseItem, RenderCommand, RenderCommandResult, RenderPhase, SetItemPipeline,
|
||||||
|
@ -295,7 +295,7 @@ impl SpecializedRenderPipeline for SpritePipeline {
|
||||||
|
|
||||||
pub struct ExtractedSprite {
|
pub struct ExtractedSprite {
|
||||||
pub transform: GlobalTransform,
|
pub transform: GlobalTransform,
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// Select an area of the texture
|
/// Select an area of the texture
|
||||||
pub rect: Option<Rect>,
|
pub rect: Option<Rect>,
|
||||||
/// Change the on-screen size of the sprite
|
/// Change the on-screen size of the sprite
|
||||||
|
@ -406,7 +406,7 @@ struct SpriteInstance {
|
||||||
|
|
||||||
impl SpriteInstance {
|
impl SpriteInstance {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(transform: &Affine3A, color: &Color, uv_offset_scale: &Vec4) -> Self {
|
fn from(transform: &Affine3A, color: &LegacyColor, uv_offset_scale: &Vec4) -> Self {
|
||||||
let transpose_model_3x3 = transform.matrix3.transpose();
|
let transpose_model_3x3 = transform.matrix3.transpose();
|
||||||
Self {
|
Self {
|
||||||
i_model_transpose: [
|
i_model_transpose: [
|
||||||
|
@ -524,7 +524,7 @@ pub fn queue_sprites(
|
||||||
let sort_key = FloatOrd(extracted_sprite.transform.translation().z);
|
let sort_key = FloatOrd(extracted_sprite.transform.translation().z);
|
||||||
|
|
||||||
// Add the item to the render phase
|
// Add the item to the render phase
|
||||||
if extracted_sprite.color != Color::WHITE {
|
if extracted_sprite.color != LegacyColor::WHITE {
|
||||||
transparent_phase.add(Transparent2d {
|
transparent_phase.add(Transparent2d {
|
||||||
draw_function: draw_sprite_function,
|
draw_function: draw_sprite_function,
|
||||||
pipeline: colored_pipeline,
|
pipeline: colored_pipeline,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
||||||
use bevy_math::{Rect, Vec2};
|
use bevy_math::{Rect, Vec2};
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
|
|
||||||
use crate::TextureSlicer;
|
use crate::TextureSlicer;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use crate::TextureSlicer;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Sprite {
|
pub struct Sprite {
|
||||||
/// The sprite's color tint
|
/// The sprite's color tint
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
/// Flip the sprite along the `X` axis
|
/// Flip the sprite along the `X` axis
|
||||||
pub flip_x: bool,
|
pub flip_x: bool,
|
||||||
/// Flip the sprite along the `Y` axis
|
/// Flip the sprite along the `Y` axis
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy_asset::Handle;
|
use bevy_asset::Handle;
|
||||||
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
|
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render::color::Color;
|
use bevy_render::color::LegacyColor;
|
||||||
use bevy_utils::default;
|
use bevy_utils::default;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ impl Text {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_asset::Handle;
|
/// # use bevy_asset::Handle;
|
||||||
/// # use bevy_render::color::Color;
|
/// # use bevy_render::color::LegacyColor;
|
||||||
/// # use bevy_text::{Font, Text, TextStyle, JustifyText};
|
/// # use bevy_text::{Font, Text, TextStyle, JustifyText};
|
||||||
/// #
|
/// #
|
||||||
/// # let font_handle: Handle<Font> = Default::default();
|
/// # let font_handle: Handle<Font> = Default::default();
|
||||||
|
@ -45,7 +45,7 @@ impl Text {
|
||||||
/// TextStyle {
|
/// TextStyle {
|
||||||
/// font: font_handle.clone(),
|
/// font: font_handle.clone(),
|
||||||
/// font_size: 60.0,
|
/// font_size: 60.0,
|
||||||
/// color: Color::WHITE,
|
/// color: LegacyColor::WHITE,
|
||||||
/// },
|
/// },
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
|
@ -54,7 +54,7 @@ impl Text {
|
||||||
/// TextStyle {
|
/// TextStyle {
|
||||||
/// font: font_handle,
|
/// font: font_handle,
|
||||||
/// font_size: 60.0,
|
/// font_size: 60.0,
|
||||||
/// color: Color::WHITE,
|
/// color: LegacyColor::WHITE,
|
||||||
/// },
|
/// },
|
||||||
/// ) // You can still add text justifaction.
|
/// ) // You can still add text justifaction.
|
||||||
/// .with_justify(JustifyText::Center);
|
/// .with_justify(JustifyText::Center);
|
||||||
|
@ -70,7 +70,7 @@ impl Text {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_asset::Handle;
|
/// # use bevy_asset::Handle;
|
||||||
/// # use bevy_render::color::Color;
|
/// # use bevy_render::color::LegacyColor;
|
||||||
/// # use bevy_text::{Font, Text, TextStyle, TextSection};
|
/// # use bevy_text::{Font, Text, TextStyle, TextSection};
|
||||||
/// #
|
/// #
|
||||||
/// # let font_handle: Handle<Font> = Default::default();
|
/// # let font_handle: Handle<Font> = Default::default();
|
||||||
|
@ -81,7 +81,7 @@ impl Text {
|
||||||
/// TextStyle {
|
/// TextStyle {
|
||||||
/// font: font_handle.clone(),
|
/// font: font_handle.clone(),
|
||||||
/// font_size: 60.0,
|
/// font_size: 60.0,
|
||||||
/// color: Color::BLUE,
|
/// color: LegacyColor::BLUE,
|
||||||
/// },
|
/// },
|
||||||
/// ),
|
/// ),
|
||||||
/// TextSection::new(
|
/// TextSection::new(
|
||||||
|
@ -89,7 +89,7 @@ impl Text {
|
||||||
/// TextStyle {
|
/// TextStyle {
|
||||||
/// font: font_handle,
|
/// font: font_handle,
|
||||||
/// font_size: 60.0,
|
/// font_size: 60.0,
|
||||||
/// color: Color::RED,
|
/// color: LegacyColor::RED,
|
||||||
/// },
|
/// },
|
||||||
/// ),
|
/// ),
|
||||||
/// ]);
|
/// ]);
|
||||||
|
@ -204,7 +204,7 @@ pub struct TextStyle {
|
||||||
/// A new font atlas is generated for every combination of font handle and scaled font size
|
/// A new font atlas is generated for every combination of font handle and scaled font size
|
||||||
/// which can have a strong performance impact.
|
/// which can have a strong performance impact.
|
||||||
pub font_size: f32,
|
pub font_size: f32,
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TextStyle {
|
impl Default for TextStyle {
|
||||||
|
@ -212,7 +212,7 @@ impl Default for TextStyle {
|
||||||
Self {
|
Self {
|
||||||
font: Default::default(),
|
font: Default::default(),
|
||||||
font_size: 12.0,
|
font_size: 12.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use bevy_ecs::{
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
prelude::Color,
|
prelude::LegacyColor,
|
||||||
texture::Image,
|
texture::Image,
|
||||||
view::{InheritedVisibility, ViewVisibility, Visibility},
|
view::{InheritedVisibility, ViewVisibility, Visibility},
|
||||||
Extract,
|
Extract,
|
||||||
|
@ -115,7 +115,7 @@ pub fn extract_text2d_sprite(
|
||||||
let transform = *global_transform
|
let transform = *global_transform
|
||||||
* GlobalTransform::from_translation(alignment_translation.extend(0.))
|
* GlobalTransform::from_translation(alignment_translation.extend(0.))
|
||||||
* scaling;
|
* scaling;
|
||||||
let mut color = Color::WHITE;
|
let mut color = LegacyColor::WHITE;
|
||||||
let mut current_section = usize::MAX;
|
let mut current_section = usize::MAX;
|
||||||
for PositionedGlyph {
|
for PositionedGlyph {
|
||||||
position,
|
position,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
use bevy_asset::Handle;
|
use bevy_asset::Handle;
|
||||||
use bevy_ecs::bundle::Bundle;
|
use bevy_ecs::bundle::Bundle;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
prelude::Color,
|
prelude::LegacyColor,
|
||||||
view::{InheritedVisibility, ViewVisibility, Visibility},
|
view::{InheritedVisibility, ViewVisibility, Visibility},
|
||||||
};
|
};
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
|
@ -60,8 +60,8 @@ impl Default for NodeBundle {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NodeBundle {
|
NodeBundle {
|
||||||
// Transparent background
|
// Transparent background
|
||||||
background_color: Color::NONE.into(),
|
background_color: LegacyColor::NONE.into(),
|
||||||
border_color: Color::NONE.into(),
|
border_color: LegacyColor::NONE.into(),
|
||||||
node: Default::default(),
|
node: Default::default(),
|
||||||
style: Default::default(),
|
style: Default::default(),
|
||||||
focus_policy: Default::default(),
|
focus_policy: Default::default(),
|
||||||
|
@ -227,7 +227,7 @@ impl Default for TextBundle {
|
||||||
view_visibility: Default::default(),
|
view_visibility: Default::default(),
|
||||||
z_index: Default::default(),
|
z_index: Default::default(),
|
||||||
// Transparent background
|
// Transparent background
|
||||||
background_color: BackgroundColor(Color::NONE),
|
background_color: BackgroundColor(LegacyColor::NONE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ impl TextBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns this [`TextBundle`] with a new [`BackgroundColor`].
|
/// Returns this [`TextBundle`] with a new [`BackgroundColor`].
|
||||||
pub const fn with_background_color(mut self, color: Color) -> Self {
|
pub const fn with_background_color(mut self, color: LegacyColor) -> Self {
|
||||||
self.background_color = BackgroundColor(color);
|
self.background_color = BackgroundColor(color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ impl Default for ButtonBundle {
|
||||||
node: Default::default(),
|
node: Default::default(),
|
||||||
button: Default::default(),
|
button: Default::default(),
|
||||||
style: Default::default(),
|
style: Default::default(),
|
||||||
border_color: BorderColor(Color::NONE),
|
border_color: BorderColor(LegacyColor::NONE),
|
||||||
interaction: Default::default(),
|
interaction: Default::default(),
|
||||||
background_color: Default::default(),
|
background_color: Default::default(),
|
||||||
image: Default::default(),
|
image: Default::default(),
|
||||||
|
|
|
@ -28,7 +28,7 @@ use bevy_ecs::prelude::*;
|
||||||
use bevy_math::{Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec4Swizzles};
|
use bevy_math::{Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec4Swizzles};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::Camera,
|
camera::Camera,
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
render_asset::RenderAssets,
|
render_asset::RenderAssets,
|
||||||
render_graph::{RenderGraph, RunGraphOnViewNode},
|
render_graph::{RenderGraph, RunGraphOnViewNode},
|
||||||
render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions, RenderPhase},
|
render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions, RenderPhase},
|
||||||
|
@ -133,7 +133,7 @@ fn get_ui_graph(render_app: &mut App) -> RenderGraph {
|
||||||
pub struct ExtractedUiNode {
|
pub struct ExtractedUiNode {
|
||||||
pub stack_index: u32,
|
pub stack_index: u32,
|
||||||
pub transform: Mat4,
|
pub transform: Mat4,
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
pub rect: Rect,
|
pub rect: Rect,
|
||||||
pub image: AssetId<Image>,
|
pub image: AssetId<Image>,
|
||||||
pub atlas_size: Option<Vec2>,
|
pub atlas_size: Option<Vec2>,
|
||||||
|
@ -601,7 +601,7 @@ pub fn extract_text_uinodes(
|
||||||
let transform = Mat4::from(global_transform.affine())
|
let transform = Mat4::from(global_transform.affine())
|
||||||
* Mat4::from_translation(logical_top_left_nearest_pixel.extend(0.));
|
* Mat4::from_translation(logical_top_left_nearest_pixel.extend(0.));
|
||||||
|
|
||||||
let mut color = Color::WHITE;
|
let mut color = LegacyColor::WHITE;
|
||||||
let mut current_section = usize::MAX;
|
let mut current_section = usize::MAX;
|
||||||
for PositionedGlyph {
|
for PositionedGlyph {
|
||||||
position,
|
position,
|
||||||
|
|
|
@ -24,7 +24,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader
|
||||||
/// # use bevy_ui::prelude::*;
|
/// # use bevy_ui::prelude::*;
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # use bevy_reflect::TypePath;
|
/// # use bevy_reflect::TypePath;
|
||||||
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
|
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor};
|
||||||
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
|
||||||
///
|
///
|
||||||
/// #[derive(AsBindGroup, Asset, TypePath, Debug, Clone)]
|
/// #[derive(AsBindGroup, Asset, TypePath, Debug, Clone)]
|
||||||
|
@ -32,7 +32,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader
|
||||||
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
|
||||||
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
/// // its shader-compatible equivalent. Most core math types already implement `ShaderType`.
|
||||||
/// #[uniform(0)]
|
/// #[uniform(0)]
|
||||||
/// color: Color,
|
/// color: LegacyColor,
|
||||||
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
/// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just
|
||||||
/// // add the sampler attribute with a different binding index.
|
/// // add the sampler attribute with a different binding index.
|
||||||
/// #[texture(1)]
|
/// #[texture(1)]
|
||||||
|
@ -56,7 +56,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// },
|
/// },
|
||||||
/// material: materials.add(CustomMaterial {
|
/// material: materials.add(CustomMaterial {
|
||||||
/// color: Color::RED,
|
/// color: LegacyColor::RED,
|
||||||
/// color_texture: asset_server.load("some_image.png"),
|
/// color_texture: asset_server.load("some_image.png"),
|
||||||
/// }),
|
/// }),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
|
|
|
@ -5,7 +5,7 @@ use bevy_math::{Rect, Vec2};
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{Camera, RenderTarget},
|
camera::{Camera, RenderTarget},
|
||||||
color::Color,
|
color::LegacyColor,
|
||||||
texture::Image,
|
texture::Image,
|
||||||
};
|
};
|
||||||
use bevy_transform::prelude::GlobalTransform;
|
use bevy_transform::prelude::GlobalTransform;
|
||||||
|
@ -1597,10 +1597,10 @@ pub enum GridPlacementError {
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
pub struct BackgroundColor(pub Color);
|
pub struct BackgroundColor(pub LegacyColor);
|
||||||
|
|
||||||
impl BackgroundColor {
|
impl BackgroundColor {
|
||||||
pub const DEFAULT: Self = Self(Color::WHITE);
|
pub const DEFAULT: Self = Self(LegacyColor::WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BackgroundColor {
|
impl Default for BackgroundColor {
|
||||||
|
@ -1609,8 +1609,8 @@ impl Default for BackgroundColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Color> for BackgroundColor {
|
impl From<LegacyColor> for BackgroundColor {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: LegacyColor) -> Self {
|
||||||
Self(color)
|
Self(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1623,16 +1623,16 @@ impl From<Color> for BackgroundColor {
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
pub struct BorderColor(pub Color);
|
pub struct BorderColor(pub LegacyColor);
|
||||||
|
|
||||||
impl From<Color> for BorderColor {
|
impl From<LegacyColor> for BorderColor {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: LegacyColor) -> Self {
|
||||||
Self(color)
|
Self(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BorderColor {
|
impl BorderColor {
|
||||||
pub const DEFAULT: Self = BorderColor(Color::WHITE);
|
pub const DEFAULT: Self = BorderColor(LegacyColor::WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BorderColor {
|
impl Default for BorderColor {
|
||||||
|
@ -1655,7 +1655,7 @@ impl Default for BorderColor {
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # use bevy_ui::prelude::*;
|
/// # use bevy_ui::prelude::*;
|
||||||
/// # use bevy_render::prelude::Color;
|
/// # use bevy_render::prelude::LegacyColor;
|
||||||
/// fn setup_ui(mut commands: Commands) {
|
/// fn setup_ui(mut commands: Commands) {
|
||||||
/// commands.spawn((
|
/// commands.spawn((
|
||||||
/// NodeBundle {
|
/// NodeBundle {
|
||||||
|
@ -1664,10 +1664,10 @@ impl Default for BorderColor {
|
||||||
/// height: Val::Px(100.),
|
/// height: Val::Px(100.),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// },
|
/// },
|
||||||
/// background_color: Color::BLUE.into(),
|
/// background_color: LegacyColor::BLUE.into(),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// },
|
/// },
|
||||||
/// Outline::new(Val::Px(10.), Val::ZERO, Color::RED)
|
/// Outline::new(Val::Px(10.), Val::ZERO, LegacyColor::RED)
|
||||||
/// ));
|
/// ));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1676,7 +1676,7 @@ impl Default for BorderColor {
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # use bevy_ui::prelude::*;
|
/// # use bevy_ui::prelude::*;
|
||||||
/// # use bevy_render::prelude::Color;
|
/// # use bevy_render::prelude::LegacyColor;
|
||||||
/// fn outline_hovered_button_system(
|
/// fn outline_hovered_button_system(
|
||||||
/// mut commands: Commands,
|
/// mut commands: Commands,
|
||||||
/// mut node_query: Query<(Entity, &Interaction, Option<&mut Outline>), Changed<Interaction>>,
|
/// mut node_query: Query<(Entity, &Interaction, Option<&mut Outline>), Changed<Interaction>>,
|
||||||
|
@ -1684,9 +1684,9 @@ impl Default for BorderColor {
|
||||||
/// for (entity, interaction, mut maybe_outline) in node_query.iter_mut() {
|
/// for (entity, interaction, mut maybe_outline) in node_query.iter_mut() {
|
||||||
/// let outline_color =
|
/// let outline_color =
|
||||||
/// if matches!(*interaction, Interaction::Hovered) {
|
/// if matches!(*interaction, Interaction::Hovered) {
|
||||||
/// Color::WHITE
|
/// LegacyColor::WHITE
|
||||||
/// } else {
|
/// } else {
|
||||||
/// Color::NONE
|
/// LegacyColor::NONE
|
||||||
/// };
|
/// };
|
||||||
/// if let Some(mut outline) = maybe_outline {
|
/// if let Some(mut outline) = maybe_outline {
|
||||||
/// outline.color = outline_color;
|
/// outline.color = outline_color;
|
||||||
|
@ -1697,7 +1697,7 @@ impl Default for BorderColor {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// Inserting and removing an [`Outline`] component repeatedly will result in table moves, so it is generally preferable to
|
/// Inserting and removing an [`Outline`] component repeatedly will result in table moves, so it is generally preferable to
|
||||||
/// set `Outline::color` to `Color::NONE` to hide an outline.
|
/// set `Outline::color` to `LegacyColor::NONE` to hide an outline.
|
||||||
pub struct Outline {
|
pub struct Outline {
|
||||||
/// The width of the outline.
|
/// The width of the outline.
|
||||||
///
|
///
|
||||||
|
@ -1709,14 +1709,14 @@ pub struct Outline {
|
||||||
pub offset: Val,
|
pub offset: Val,
|
||||||
/// The color of the outline.
|
/// The color of the outline.
|
||||||
///
|
///
|
||||||
/// If you are frequently toggling outlines for a UI node on and off it is recommended to set `Color::None` to hide the outline.
|
/// If you are frequently toggling outlines for a UI node on and off it is recommended to set `LegacyColor::NONE` to hide the outline.
|
||||||
/// This avoids the table moves that would occur from the repeated insertion and removal of the `Outline` component.
|
/// This avoids the table moves that would occur from the repeated insertion and removal of the `Outline` component.
|
||||||
pub color: Color,
|
pub color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Outline {
|
impl Outline {
|
||||||
/// Create a new outline
|
/// Create a new outline
|
||||||
pub const fn new(width: Val, offset: Val, color: Color) -> Self {
|
pub const fn new(width: Val, offset: Val, color: LegacyColor) -> Self {
|
||||||
Self {
|
Self {
|
||||||
width,
|
width,
|
||||||
offset,
|
offset,
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn setup_cube(
|
||||||
// cube
|
// cube
|
||||||
parent.spawn(PbrBundle {
|
parent.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -81,7 +81,7 @@ fn setup_cube(
|
||||||
// cube
|
// cube
|
||||||
parent.spawn(PbrBundle {
|
parent.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,7 @@ fn setup(
|
||||||
|
|
||||||
for (i, shape) in shapes.into_iter().enumerate() {
|
for (i, shape) in shapes.into_iter().enumerate() {
|
||||||
// Distribute colors evenly across the rainbow.
|
// Distribute colors evenly across the rainbow.
|
||||||
let color = Color::hsl(360. * i as f32 / num_shapes as f32, 0.95, 0.7);
|
let color = LegacyColor::hsl(360. * i as f32 / num_shapes as f32, 0.95, 0.7);
|
||||||
|
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: shape,
|
mesh: shape,
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn draw_cursor(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
gizmos.circle_2d(point, 10., Color::WHITE);
|
gizmos.circle_2d(point, 10., LegacyColor::WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn setup(
|
||||||
commands.spawn(SpriteBundle {
|
commands.spawn(SpriteBundle {
|
||||||
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
color: Color::rgb(5.0, 5.0, 5.0), // 4. Put something bright in a dark environment to see the effect
|
color: LegacyColor::rgb(5.0, 5.0, 5.0), // 4. Put something bright in a dark environment to see the effect
|
||||||
custom_size: Some(Vec2::splat(160.0)),
|
custom_size: Some(Vec2::splat(160.0)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -50,7 +50,7 @@ fn setup(
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: meshes.add(Circle::new(100.)).into(),
|
mesh: meshes.add(Circle::new(100.)).into(),
|
||||||
// 4. Put something bright in a dark environment to see the effect
|
// 4. Put something bright in a dark environment to see the effect
|
||||||
material: materials.add(Color::rgb(7.5, 0.0, 7.5)),
|
material: materials.add(LegacyColor::rgb(7.5, 0.0, 7.5)),
|
||||||
transform: Transform::from_translation(Vec3::new(-200., 0., 0.)),
|
transform: Transform::from_translation(Vec3::new(-200., 0., 0.)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ fn setup(
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: meshes.add(RegularPolygon::new(100., 6)).into(),
|
mesh: meshes.add(RegularPolygon::new(100., 6)).into(),
|
||||||
// 4. Put something bright in a dark environment to see the effect
|
// 4. Put something bright in a dark environment to see the effect
|
||||||
material: materials.add(Color::rgb(6.25, 9.4, 9.1)),
|
material: materials.add(LegacyColor::rgb(6.25, 9.4, 9.1)),
|
||||||
transform: Transform::from_translation(Vec3::new(200., 0., 0.)),
|
transform: Transform::from_translation(Vec3::new(200., 0., 0.)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -70,7 +70,7 @@ fn setup(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 18.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -97,7 +97,7 @@ enum Shape {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) {
|
fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) {
|
||||||
let color = Color::GRAY;
|
let color = LegacyColor::GRAY;
|
||||||
for (shape, transform) in query.iter() {
|
for (shape, transform) in query.iter() {
|
||||||
let translation = transform.translation.xy();
|
let translation = transform.translation.xy();
|
||||||
let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
|
let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
|
||||||
|
@ -178,9 +178,9 @@ fn update_volumes(
|
||||||
fn render_volumes(mut gizmos: Gizmos, query: Query<(&CurrentVolume, &Intersects)>) {
|
fn render_volumes(mut gizmos: Gizmos, query: Query<(&CurrentVolume, &Intersects)>) {
|
||||||
for (volume, intersects) in query.iter() {
|
for (volume, intersects) in query.iter() {
|
||||||
let color = if **intersects {
|
let color = if **intersects {
|
||||||
Color::CYAN
|
LegacyColor::CYAN
|
||||||
} else {
|
} else {
|
||||||
Color::ORANGE_RED
|
LegacyColor::ORANGE_RED
|
||||||
};
|
};
|
||||||
match volume {
|
match volume {
|
||||||
CurrentVolume::Aabb(a) => {
|
CurrentVolume::Aabb(a) => {
|
||||||
|
@ -292,10 +292,10 @@ fn draw_ray(gizmos: &mut Gizmos, ray: &RayCast2d) {
|
||||||
gizmos.line_2d(
|
gizmos.line_2d(
|
||||||
ray.ray.origin,
|
ray.ray.origin,
|
||||||
ray.ray.origin + *ray.ray.direction * ray.max,
|
ray.ray.origin + *ray.ray.direction * ray.max,
|
||||||
Color::WHITE,
|
LegacyColor::WHITE,
|
||||||
);
|
);
|
||||||
for r in [1., 2., 3.] {
|
for r in [1., 2., 3.] {
|
||||||
gizmos.circle_2d(ray.ray.origin, r, Color::FUCHSIA);
|
gizmos.circle_2d(ray.ray.origin, r, LegacyColor::FUCHSIA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ fn ray_cast_system(
|
||||||
gizmos.circle_2d(
|
gizmos.circle_2d(
|
||||||
ray_cast.ray.origin + *ray_cast.ray.direction * toi,
|
ray_cast.ray.origin + *ray_cast.ray.direction * toi,
|
||||||
r,
|
r,
|
||||||
Color::GREEN,
|
LegacyColor::GREEN,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ fn aabb_cast_system(
|
||||||
+ aabb_cast.aabb.center(),
|
+ aabb_cast.aabb.center(),
|
||||||
0.,
|
0.,
|
||||||
aabb_cast.aabb.half_size() * 2.,
|
aabb_cast.aabb.half_size() * 2.,
|
||||||
Color::GREEN,
|
LegacyColor::GREEN,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ fn bounding_circle_cast_system(
|
||||||
+ *circle_cast.ray.ray.direction * toi
|
+ *circle_cast.ray.ray.direction * toi
|
||||||
+ circle_cast.circle.center(),
|
+ circle_cast.circle.center(),
|
||||||
circle_cast.circle.radius(),
|
circle_cast.circle.radius(),
|
||||||
Color::GREEN,
|
LegacyColor::GREEN,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ fn aabb_intersection_system(
|
||||||
) {
|
) {
|
||||||
let center = get_intersection_position(&time);
|
let center = get_intersection_position(&time);
|
||||||
let aabb = Aabb2d::new(center, Vec2::splat(50.));
|
let aabb = Aabb2d::new(center, Vec2::splat(50.));
|
||||||
gizmos.rect_2d(center, 0., aabb.half_size() * 2., Color::YELLOW);
|
gizmos.rect_2d(center, 0., aabb.half_size() * 2., LegacyColor::YELLOW);
|
||||||
|
|
||||||
for (volume, mut intersects) in volumes.iter_mut() {
|
for (volume, mut intersects) in volumes.iter_mut() {
|
||||||
let hit = match volume {
|
let hit = match volume {
|
||||||
|
@ -431,7 +431,7 @@ fn circle_intersection_system(
|
||||||
) {
|
) {
|
||||||
let center = get_intersection_position(&time);
|
let center = get_intersection_position(&time);
|
||||||
let circle = BoundingCircle::new(center, 50.);
|
let circle = BoundingCircle::new(center, 50.);
|
||||||
gizmos.circle_2d(center, circle.radius(), Color::YELLOW);
|
gizmos.circle_2d(center, circle.radius(), LegacyColor::YELLOW);
|
||||||
|
|
||||||
for (volume, mut intersects) in volumes.iter_mut() {
|
for (volume, mut intersects) in volumes.iter_mut() {
|
||||||
let hit = match volume {
|
let hit = match volume {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const ATTRIBUTE_BARYCENTRIC: MeshVertexAttribute =
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 1.0 / 5.0f32,
|
brightness: 1.0 / 5.0f32,
|
||||||
})
|
})
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn setup(
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: meshes.add(Rectangle::default()).into(),
|
mesh: meshes.add(Rectangle::default()).into(),
|
||||||
transform: Transform::default().with_scale(Vec3::splat(128.)),
|
transform: Transform::default().with_scale(Vec3::splat(128.)),
|
||||||
material: materials.add(Color::PURPLE),
|
material: materials.add(LegacyColor::PURPLE),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ fn star(
|
||||||
// Set the position attribute
|
// Set the position attribute
|
||||||
star.insert_attribute(Mesh::ATTRIBUTE_POSITION, v_pos);
|
star.insert_attribute(Mesh::ATTRIBUTE_POSITION, v_pos);
|
||||||
// And a RGB color attribute as well
|
// And a RGB color attribute as well
|
||||||
let mut v_color: Vec<u32> = vec![Color::BLACK.as_linear_rgba_u32()];
|
let mut v_color: Vec<u32> = vec![LegacyColor::BLACK.as_linear_rgba_u32()];
|
||||||
v_color.extend_from_slice(&[Color::YELLOW.as_linear_rgba_u32(); 10]);
|
v_color.extend_from_slice(&[LegacyColor::YELLOW.as_linear_rgba_u32(); 10]);
|
||||||
star.insert_attribute(
|
star.insert_attribute(
|
||||||
MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32),
|
MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32),
|
||||||
v_color,
|
v_color,
|
||||||
|
|
|
@ -27,10 +27,10 @@ fn setup(
|
||||||
let mut mesh = Mesh::from(Rectangle::default());
|
let mut mesh = Mesh::from(Rectangle::default());
|
||||||
// Build vertex colors for the quad. One entry per vertex (the corners of the quad)
|
// Build vertex colors for the quad. One entry per vertex (the corners of the quad)
|
||||||
let vertex_colors: Vec<[f32; 4]> = vec![
|
let vertex_colors: Vec<[f32; 4]> = vec![
|
||||||
Color::RED.as_rgba_f32(),
|
LegacyColor::RED.as_rgba_f32(),
|
||||||
Color::GREEN.as_rgba_f32(),
|
LegacyColor::GREEN.as_rgba_f32(),
|
||||||
Color::BLUE.as_rgba_f32(),
|
LegacyColor::BLUE.as_rgba_f32(),
|
||||||
Color::WHITE.as_rgba_f32(),
|
LegacyColor::WHITE.as_rgba_f32(),
|
||||||
];
|
];
|
||||||
// Insert the vertex colors as an attribute
|
// Insert the vertex colors as an attribute
|
||||||
mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, vertex_colors);
|
mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, vertex_colors);
|
||||||
|
|
|
@ -85,7 +85,7 @@ fn setup_mesh(
|
||||||
MaterialMesh2dBundle {
|
MaterialMesh2dBundle {
|
||||||
mesh: meshes.add(Capsule2d::default()).into(),
|
mesh: meshes.add(Capsule2d::default()).into(),
|
||||||
transform: Transform::from_xyz(40., 0., 2.).with_scale(Vec3::splat(32.)),
|
transform: Transform::from_xyz(40., 0., 2.).with_scale(Vec3::splat(32.)),
|
||||||
material: materials.add(Color::BLACK),
|
material: materials.add(LegacyColor::BLACK),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Rotate,
|
Rotate,
|
||||||
|
|
|
@ -114,7 +114,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let style = TextStyle {
|
let style = TextStyle {
|
||||||
font: font.clone(),
|
font: font.clone(),
|
||||||
font_size: 16.0,
|
font_size: 16.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font: font.clone(),
|
font: font.clone(),
|
||||||
font_size: 60.0,
|
font_size: 60.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
};
|
};
|
||||||
let text_justification = JustifyText::Center;
|
let text_justification = JustifyText::Center;
|
||||||
// 2d camera
|
// 2d camera
|
||||||
|
@ -72,14 +72,14 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let slightly_smaller_text_style = TextStyle {
|
let slightly_smaller_text_style = TextStyle {
|
||||||
font,
|
font,
|
||||||
font_size: 42.0,
|
font_size: 42.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
};
|
};
|
||||||
let box_size = Vec2::new(300.0, 200.0);
|
let box_size = Vec2::new(300.0, 200.0);
|
||||||
let box_position = Vec2::new(0.0, -250.0);
|
let box_position = Vec2::new(0.0, -250.0);
|
||||||
commands
|
commands
|
||||||
.spawn(SpriteBundle {
|
.spawn(SpriteBundle {
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
color: Color::rgb(0.25, 0.25, 0.75),
|
color: LegacyColor::rgb(0.25, 0.25, 0.75),
|
||||||
custom_size: Some(Vec2::new(box_size.x, box_size.y)),
|
custom_size: Some(Vec2::new(box_size.x, box_size.y)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -111,7 +111,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands
|
commands
|
||||||
.spawn(SpriteBundle {
|
.spawn(SpriteBundle {
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
color: Color::rgb(0.20, 0.3, 0.70),
|
color: LegacyColor::rgb(0.20, 0.3, 0.70),
|
||||||
custom_size: Some(Vec2::new(other_box_size.x, other_box_size.y)),
|
custom_size: Some(Vec2::new(other_box_size.x, other_box_size.y)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -139,10 +139,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (text_anchor, color) in [
|
for (text_anchor, color) in [
|
||||||
(Anchor::TopLeft, Color::RED),
|
(Anchor::TopLeft, LegacyColor::RED),
|
||||||
(Anchor::TopRight, Color::GREEN),
|
(Anchor::TopRight, LegacyColor::GREEN),
|
||||||
(Anchor::BottomRight, Color::BLUE),
|
(Anchor::BottomRight, LegacyColor::BLUE),
|
||||||
(Anchor::BottomLeft, Color::YELLOW),
|
(Anchor::BottomLeft, LegacyColor::YELLOW),
|
||||||
] {
|
] {
|
||||||
commands.spawn(Text2dBundle {
|
commands.spawn(Text2dBundle {
|
||||||
text: Text {
|
text: Text {
|
||||||
|
|
|
@ -124,7 +124,7 @@ fn setup(
|
||||||
let text_style: TextStyle = TextStyle {
|
let text_style: TextStyle = TextStyle {
|
||||||
font: font.clone(),
|
font: font.clone(),
|
||||||
font_size: 50.0,
|
font_size: 50.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
// labels to indicate padding
|
// labels to indicate padding
|
||||||
|
@ -173,7 +173,7 @@ fn setup(
|
||||||
let sampling_label_style = TextStyle {
|
let sampling_label_style = TextStyle {
|
||||||
font,
|
font,
|
||||||
font_size: 30.0,
|
font_size: 30.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
let base_y = 170.0; // y position of the sprites
|
let base_y = 170.0; // y position of the sprites
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(SpriteBundle {
|
commands.spawn(SpriteBundle {
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
// Alpha channel of the color controls transparency.
|
// Alpha channel of the color controls transparency.
|
||||||
color: Color::rgba(0.0, 0.0, 1.0, 0.7),
|
color: LegacyColor::rgba(0.0, 0.0, 1.0, 0.7),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
texture: sprite_handle.clone(),
|
texture: sprite_handle.clone(),
|
||||||
|
@ -31,7 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
});
|
});
|
||||||
commands.spawn(SpriteBundle {
|
commands.spawn(SpriteBundle {
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
color: Color::rgba(0.0, 1.0, 0.0, 0.3),
|
color: LegacyColor::rgba(0.0, 1.0, 0.0, 0.3),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
texture: sprite_handle,
|
texture: sprite_handle,
|
||||||
|
|
|
@ -18,14 +18,14 @@ fn setup(
|
||||||
// circular base
|
// circular base
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Circle::new(4.0)),
|
mesh: meshes.add(Circle::new(4.0)),
|
||||||
material: materials.add(Color::WHITE),
|
material: materials.add(LegacyColor::WHITE),
|
||||||
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
|
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cube
|
// cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
material: materials.add(LegacyColor::rgb_u8(124, 144, 255)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ fn setup(
|
||||||
// ground plane
|
// ground plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
||||||
material: materials.add(Color::SILVER),
|
material: materials.add(LegacyColor::SILVER),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn draw_cursor(
|
||||||
point + ground.up() * 0.01,
|
point + ground.up() * 0.01,
|
||||||
Direction3d::new_unchecked(ground.up()), // Up vector is already normalized.
|
Direction3d::new_unchecked(ground.up()), // Up vector is already normalized.
|
||||||
0.2,
|
0.2,
|
||||||
Color::WHITE,
|
LegacyColor::WHITE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(20., 20.)),
|
mesh: meshes.add(Plane3d::default().mesh().size(20., 20.)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Ground,
|
Ground,
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn setup(
|
||||||
for z in -1..2 {
|
for z in -1..2 {
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: cube.clone(),
|
mesh: cube.clone(),
|
||||||
material: materials.add(Color::WHITE),
|
material: materials.add(LegacyColor::WHITE),
|
||||||
transform: Transform::from_translation(Vec3::new(x as f32, 0.0, z as f32)),
|
transform: Transform::from_translation(Vec3::new(x as f32, 0.0, z as f32)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@ fn animate_materials(
|
||||||
) {
|
) {
|
||||||
for (i, material_handle) in material_handles.iter().enumerate() {
|
for (i, material_handle) in material_handles.iter().enumerate() {
|
||||||
if let Some(material) = materials.get_mut(material_handle) {
|
if let Some(material) = materials.get_mut(material_handle) {
|
||||||
let color = Color::hsl(
|
let color = LegacyColor::hsl(
|
||||||
((i as f32 * 2.345 + time.elapsed_seconds_wrapped()) * 100.0) % 360.0,
|
((i as f32 * 2.345 + time.elapsed_seconds_wrapped()) * 100.0) % 360.0,
|
||||||
1.0,
|
1.0,
|
||||||
0.5,
|
0.5,
|
||||||
|
|
|
@ -261,7 +261,7 @@ fn setup(
|
||||||
// Plane
|
// Plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
||||||
material: materials.add(Color::rgb(0.1, 0.2, 0.1)),
|
material: materials.add(LegacyColor::rgb(0.1, 0.2, 0.1)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ fn setup(
|
||||||
intensity: 150.0,
|
intensity: 150.0,
|
||||||
},
|
},
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba_u8(43, 44, 47, 255),
|
color: LegacyColor::rgba_u8(43, 44, 47, 255),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
start: 1.0,
|
start: 1.0,
|
||||||
end: 4.0,
|
end: 4.0,
|
||||||
|
|
|
@ -31,13 +31,13 @@ fn setup_camera_fog(mut commands: Commands) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba(0.35, 0.48, 0.66, 1.0),
|
color: LegacyColor::rgba(0.35, 0.48, 0.66, 1.0),
|
||||||
directional_light_color: Color::rgba(1.0, 0.95, 0.85, 0.5),
|
directional_light_color: LegacyColor::rgba(1.0, 0.95, 0.85, 0.5),
|
||||||
directional_light_exponent: 30.0,
|
directional_light_exponent: 30.0,
|
||||||
falloff: FogFalloff::from_visibility_colors(
|
falloff: FogFalloff::from_visibility_colors(
|
||||||
15.0, // distance in world units up to which objects retain visibility (>= 5% contrast)
|
15.0, // distance in world units up to which objects retain visibility (>= 5% contrast)
|
||||||
Color::rgb(0.35, 0.5, 0.66), // atmospheric extinction color (after light is lost due to absorption by atmospheric particles)
|
LegacyColor::rgb(0.35, 0.5, 0.66), // atmospheric extinction color (after light is lost due to absorption by atmospheric particles)
|
||||||
Color::rgb(0.8, 0.844, 1.0), // atmospheric inscattering color (light gained due to scattering from the sun)
|
LegacyColor::rgb(0.8, 0.844, 1.0), // atmospheric inscattering color (light gained due to scattering from the sun)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
@ -60,7 +60,7 @@ fn setup_terrain_scene(
|
||||||
// Sun
|
// Sun
|
||||||
commands.spawn(DirectionalLightBundle {
|
commands.spawn(DirectionalLightBundle {
|
||||||
directional_light: DirectionalLight {
|
directional_light: DirectionalLight {
|
||||||
color: Color::rgb(0.98, 0.95, 0.82),
|
color: LegacyColor::rgb(0.98, 0.95, 0.82),
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -81,7 +81,7 @@ fn setup_terrain_scene(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("888888").unwrap(),
|
base_color: LegacyColor::hex("888888").unwrap(),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
cull_mode: None,
|
cull_mode: None,
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn setup(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
let base_color = Color::rgba(0.9, 0.2, 0.3, 1.0);
|
let base_color = LegacyColor::rgba(0.9, 0.2, 0.3, 1.0);
|
||||||
let icosphere_mesh = meshes.add(Sphere::new(0.9).mesh().ico(7).unwrap());
|
let icosphere_mesh = meshes.add(Sphere::new(0.9).mesh().ico(7).unwrap());
|
||||||
|
|
||||||
// Opaque
|
// Opaque
|
||||||
|
@ -140,8 +140,8 @@ fn setup(
|
||||||
.id();
|
.id();
|
||||||
|
|
||||||
// Chessboard Plane
|
// Chessboard Plane
|
||||||
let black_material = materials.add(Color::BLACK);
|
let black_material = materials.add(LegacyColor::BLACK);
|
||||||
let white_material = materials.add(Color::WHITE);
|
let white_material = materials.add(LegacyColor::WHITE);
|
||||||
|
|
||||||
let plane_mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0));
|
let plane_mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0));
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ fn setup(
|
||||||
let label_text_style = TextStyle {
|
let label_text_style = TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
||||||
font_size: 25.0,
|
font_size: 25.0,
|
||||||
color: Color::ORANGE,
|
color: LegacyColor::ORANGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
|
|
|
@ -39,19 +39,19 @@ fn setup_scene(
|
||||||
));
|
));
|
||||||
|
|
||||||
let material_emissive1 = materials.add(StandardMaterial {
|
let material_emissive1 = materials.add(StandardMaterial {
|
||||||
emissive: Color::rgb_linear(2300.0, 900.0, 300.0), // 4. Put something bright in a dark environment to see the effect
|
emissive: LegacyColor::rgb_linear(2300.0, 900.0, 300.0), // 4. Put something bright in a dark environment to see the effect
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let material_emissive2 = materials.add(StandardMaterial {
|
let material_emissive2 = materials.add(StandardMaterial {
|
||||||
emissive: Color::rgb_linear(300.0, 2300.0, 900.0),
|
emissive: LegacyColor::rgb_linear(300.0, 2300.0, 900.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let material_emissive3 = materials.add(StandardMaterial {
|
let material_emissive3 = materials.add(StandardMaterial {
|
||||||
emissive: Color::rgb_linear(900.0, 300.0, 2300.0),
|
emissive: LegacyColor::rgb_linear(900.0, 300.0, 2300.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let material_non_emissive = materials.add(StandardMaterial {
|
let material_non_emissive = materials.add(StandardMaterial {
|
||||||
base_color: Color::GRAY,
|
base_color: LegacyColor::GRAY,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ fn setup_scene(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 20.0,
|
font_size: 20.0,
|
||||||
color: Color::BLACK,
|
color: LegacyColor::BLACK,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba_u8(43, 44, 47, 255),
|
color: LegacyColor::rgba_u8(43, 44, 47, 255),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
start: 1.0,
|
start: 1.0,
|
||||||
end: 8.0,
|
end: 8.0,
|
||||||
|
@ -95,7 +95,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut forward_mat: StandardMaterial = Color::rgb(0.1, 0.2, 0.1).into();
|
let mut forward_mat: StandardMaterial = LegacyColor::rgb(0.1, 0.2, 0.1).into();
|
||||||
forward_mat.opaque_render_method = OpaqueRendererMethod::Forward;
|
forward_mat.opaque_render_method = OpaqueRendererMethod::Forward;
|
||||||
let forward_mat_h = materials.add(forward_mat);
|
let forward_mat_h = materials.add(forward_mat);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let sphere_color = Color::rgb(10.0, 4.0, 1.0);
|
let sphere_color = LegacyColor::rgb(10.0, 4.0, 1.0);
|
||||||
let sphere_pos = Transform::from_xyz(0.4, 0.5, -0.8);
|
let sphere_pos = Transform::from_xyz(0.4, 0.5, -0.8);
|
||||||
// Emissive sphere
|
// Emissive sphere
|
||||||
let mut unlit_mat: StandardMaterial = sphere_color.into();
|
let mut unlit_mat: StandardMaterial = sphere_color.into();
|
||||||
|
@ -156,21 +156,21 @@ fn setup(
|
||||||
let s_val = if i < 3 { 0.0 } else { 0.2 };
|
let s_val = if i < 3 { 0.0 } else { 0.2 };
|
||||||
let material = if j == 0 {
|
let material = if j == 0 {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(s_val, s_val, 1.0),
|
base_color: LegacyColor::rgb(s_val, s_val, 1.0),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
} else if j == 1 {
|
} else if j == 1 {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(s_val, 1.0, s_val),
|
base_color: LegacyColor::rgb(s_val, 1.0, s_val),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(1.0, s_val, s_val),
|
base_color: LegacyColor::rgb(1.0, s_val, s_val),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
|
@ -193,7 +193,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("888888").unwrap(),
|
base_color: LegacyColor::hex("888888").unwrap(),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
cull_mode: None,
|
cull_mode: None,
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn setup(
|
||||||
let mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0));
|
let mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0));
|
||||||
let nb_plane = 10;
|
let nb_plane = 10;
|
||||||
for i in 0..nb_plane {
|
for i in 0..nb_plane {
|
||||||
let color = Color::hsl(i as f32 * 360.0 / nb_plane as f32, 1.0, 0.5);
|
let color = LegacyColor::hsl(i as f32 * 360.0 / nb_plane as f32, 1.0, 0.5);
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: mesh.clone(),
|
mesh: mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn setup_camera_fog(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle::default(),
|
Camera3dBundle::default(),
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba(0.25, 0.25, 0.25, 1.0),
|
color: LegacyColor::rgba(0.25, 0.25, 0.25, 1.0),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
start: 5.0,
|
start: 5.0,
|
||||||
end: 20.0,
|
end: 20.0,
|
||||||
|
@ -51,7 +51,7 @@ fn setup_pyramid_scene(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
let stone = materials.add(StandardMaterial {
|
let stone = materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("28221B").unwrap(),
|
base_color: LegacyColor::hex("28221B").unwrap(),
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -71,7 +71,7 @@ fn setup_pyramid_scene(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Sphere::default()),
|
mesh: meshes.add(Sphere::default()),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("126212CC").unwrap(),
|
base_color: LegacyColor::hex("126212CC").unwrap(),
|
||||||
reflectance: 1.0,
|
reflectance: 1.0,
|
||||||
perceptual_roughness: 0.0,
|
perceptual_roughness: 0.0,
|
||||||
metallic: 0.5,
|
metallic: 0.5,
|
||||||
|
@ -102,7 +102,7 @@ fn setup_pyramid_scene(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("888888").unwrap(),
|
base_color: LegacyColor::hex("888888").unwrap(),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
cull_mode: None,
|
cull_mode: None,
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -47,7 +47,7 @@ static SWITCH_TO_SPHERE_HELP_TEXT: &str = "Tab: Switch to a plain sphere mesh";
|
||||||
|
|
||||||
static CLICK_TO_MOVE_HELP_TEXT: &str = "Left click: Move the object";
|
static CLICK_TO_MOVE_HELP_TEXT: &str = "Left click: Move the object";
|
||||||
|
|
||||||
static GIZMO_COLOR: Color = Color::YELLOW;
|
static GIZMO_COLOR: LegacyColor = LegacyColor::YELLOW;
|
||||||
|
|
||||||
static VOXEL_TRANSFORM: Mat4 = Mat4::from_cols_array_2d(&[
|
static VOXEL_TRANSFORM: Mat4 = Mat4::from_cols_array_2d(&[
|
||||||
[-42.317566, 0.0, 0.0, 0.0],
|
[-42.317566, 0.0, 0.0, 0.0],
|
||||||
|
@ -148,7 +148,7 @@ fn main() {
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.init_resource::<ExampleAssets>()
|
.init_resource::<ExampleAssets>()
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 0.0,
|
brightness: 0.0,
|
||||||
})
|
})
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
|
@ -362,7 +362,7 @@ impl AppStatus {
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
||||||
font_size: 24.0,
|
font_size: 24.0,
|
||||||
color: Color::ANTIQUE_WHITE,
|
color: LegacyColor::ANTIQUE_WHITE,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ impl FromWorld for ExampleAssets {
|
||||||
let voxel_cube = mesh_assets.add(Cuboid::default());
|
let voxel_cube = mesh_assets.add(Cuboid::default());
|
||||||
|
|
||||||
let mut standard_material_assets = world.resource_mut::<Assets<StandardMaterial>>();
|
let mut standard_material_assets = world.resource_mut::<Assets<StandardMaterial>>();
|
||||||
let main_material = standard_material_assets.add(Color::SILVER);
|
let main_material = standard_material_assets.add(LegacyColor::SILVER);
|
||||||
|
|
||||||
ExampleAssets {
|
ExampleAssets {
|
||||||
main_sphere,
|
main_sphere,
|
||||||
|
@ -580,7 +580,7 @@ fn create_cubes(
|
||||||
let resolution = image.texture_descriptor.size;
|
let resolution = image.texture_descriptor.size;
|
||||||
|
|
||||||
let voxel_cube_material = voxel_visualization_material_assets.add(ExtendedMaterial {
|
let voxel_cube_material = voxel_visualization_material_assets.add(ExtendedMaterial {
|
||||||
base: StandardMaterial::from(Color::RED),
|
base: StandardMaterial::from(LegacyColor::RED),
|
||||||
extension: VoxelVisualizationExtension {
|
extension: VoxelVisualizationExtension {
|
||||||
irradiance_volume_info: VoxelVisualizationIrradianceVolumeInfo {
|
irradiance_volume_info: VoxelVisualizationIrradianceVolumeInfo {
|
||||||
transform: VOXEL_TRANSFORM.inverse(),
|
transform: VOXEL_TRANSFORM.inverse(),
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn setup(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(10.0, 10.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(10.0, 10.0)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -54,7 +54,7 @@ fn setup(
|
||||||
mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)),
|
mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)),
|
||||||
transform,
|
transform,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::INDIGO,
|
base_color: LegacyColor::INDIGO,
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -67,7 +67,7 @@ fn setup(
|
||||||
mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)),
|
mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)),
|
||||||
transform,
|
transform,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::INDIGO,
|
base_color: LegacyColor::INDIGO,
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -98,7 +98,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::PINK,
|
base_color: LegacyColor::PINK,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
|
@ -111,7 +111,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.5).mesh().uv(32, 18)),
|
mesh: meshes.add(Sphere::new(0.5).mesh().uv(32, 18)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::LIME_GREEN,
|
base_color: LegacyColor::LIME_GREEN,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(1.5, 1.0, 1.5),
|
transform: Transform::from_xyz(1.5, 1.0, 1.5),
|
||||||
|
@ -122,7 +122,7 @@ fn setup(
|
||||||
|
|
||||||
// ambient light
|
// ambient light
|
||||||
commands.insert_resource(AmbientLight {
|
commands.insert_resource(AmbientLight {
|
||||||
color: Color::ORANGE_RED,
|
color: LegacyColor::ORANGE_RED,
|
||||||
brightness: 0.02,
|
brightness: 0.02,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ fn setup(
|
||||||
transform: Transform::from_xyz(1.0, 2.0, 0.0),
|
transform: Transform::from_xyz(1.0, 2.0, 0.0),
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
||||||
color: Color::RED,
|
color: LegacyColor::RED,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -143,8 +143,8 @@ fn setup(
|
||||||
builder.spawn(PbrBundle {
|
builder.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
|
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::RED,
|
base_color: LegacyColor::RED,
|
||||||
emissive: Color::rgba_linear(7.13, 0.0, 0.0, 0.0),
|
emissive: LegacyColor::rgba_linear(7.13, 0.0, 0.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
|
@ -158,7 +158,7 @@ fn setup(
|
||||||
.looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z),
|
.looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z),
|
||||||
spot_light: SpotLight {
|
spot_light: SpotLight {
|
||||||
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
||||||
color: Color::GREEN,
|
color: LegacyColor::GREEN,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
inner_angle: 0.6,
|
inner_angle: 0.6,
|
||||||
outer_angle: 0.8,
|
outer_angle: 0.8,
|
||||||
|
@ -171,8 +171,8 @@ fn setup(
|
||||||
transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)),
|
transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)),
|
||||||
mesh: meshes.add(Capsule3d::new(0.1, 0.125)),
|
mesh: meshes.add(Capsule3d::new(0.1, 0.125)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::GREEN,
|
base_color: LegacyColor::GREEN,
|
||||||
emissive: Color::rgba_linear(0.0, 7.13, 0.0, 0.0),
|
emissive: LegacyColor::rgba_linear(0.0, 7.13, 0.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
|
@ -186,7 +186,7 @@ fn setup(
|
||||||
transform: Transform::from_xyz(0.0, 4.0, 0.0),
|
transform: Transform::from_xyz(0.0, 4.0, 0.0),
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb
|
||||||
color: Color::BLUE,
|
color: LegacyColor::BLUE,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -196,8 +196,8 @@ fn setup(
|
||||||
builder.spawn(PbrBundle {
|
builder.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
|
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::BLUE,
|
base_color: LegacyColor::BLUE,
|
||||||
emissive: Color::rgba_linear(0.0, 0.0, 7.13, 0.0),
|
emissive: LegacyColor::rgba_linear(0.0, 0.0, 7.13, 0.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn add_lightmaps_to_meshes(
|
||||||
let exposure = 250.0;
|
let exposure = 250.0;
|
||||||
for (entity, name, material) in meshes.iter() {
|
for (entity, name, material) in meshes.iter() {
|
||||||
if &**name == "Light" {
|
if &**name == "Light" {
|
||||||
materials.get_mut(material).unwrap().emissive = Color::WHITE * exposure;
|
materials.get_mut(material).unwrap().emissive = LegacyColor::WHITE * exposure;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn setup(
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(-1.5, 0.0, 0.0),
|
transform: Transform::from_xyz(-1.5, 0.0, 0.0),
|
||||||
material: materials.add(LineMaterial {
|
material: materials.add(LineMaterial {
|
||||||
color: Color::GREEN,
|
color: LegacyColor::GREEN,
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,9 @@ fn setup(
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(0.5, 0.0, 0.0),
|
transform: Transform::from_xyz(0.5, 0.0, 0.0),
|
||||||
material: materials.add(LineMaterial { color: Color::BLUE }),
|
material: materials.add(LineMaterial {
|
||||||
|
color: LegacyColor::BLUE,
|
||||||
|
}),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ fn setup(
|
||||||
#[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)]
|
#[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)]
|
||||||
struct LineMaterial {
|
struct LineMaterial {
|
||||||
#[uniform(0)]
|
#[uniform(0)]
|
||||||
color: Color,
|
color: LegacyColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Material for LineMaterial {
|
impl Material for LineMaterial {
|
||||||
|
|
|
@ -30,31 +30,31 @@ fn setup(
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cubes
|
// cubes
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(1.5, 0.5, 1.5),
|
transform: Transform::from_xyz(1.5, 0.5, 1.5),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(1.5, 0.5, -1.5),
|
transform: Transform::from_xyz(1.5, 0.5, -1.5),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(-1.5, 0.5, 1.5),
|
transform: Transform::from_xyz(-1.5, 0.5, 1.5),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(-1.5, 0.5, -1.5),
|
transform: Transform::from_xyz(-1.5, 0.5, -1.5),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -243,7 +243,7 @@ fn setup(
|
||||||
// with roughness and reflectance set.
|
// with roughness and reflectance set.
|
||||||
perceptual_roughness: 0.45,
|
perceptual_roughness: 0.45,
|
||||||
reflectance: 0.18,
|
reflectance: 0.18,
|
||||||
..Color::rgb_u8(0, 80, 0).into()
|
..LegacyColor::rgb_u8(0, 80, 0).into()
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(0.0, -1.0, 0.0),
|
transform: Transform::from_xyz(0.0, -1.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -30,7 +30,7 @@ fn setup(
|
||||||
) {
|
) {
|
||||||
let cube_handle = meshes.add(Cuboid::new(2.0, 2.0, 2.0));
|
let cube_handle = meshes.add(Cuboid::new(2.0, 2.0, 2.0));
|
||||||
let cube_material_handle = materials.add(StandardMaterial {
|
let cube_material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.8, 0.7, 0.6),
|
base_color: LegacyColor::rgb(0.8, 0.7, 0.6),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn setup(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: sphere_mesh.clone(),
|
mesh: sphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("#ffd891").unwrap(),
|
base_color: LegacyColor::hex("#ffd891").unwrap(),
|
||||||
// vary key PBR parameters on a grid of spheres to show the effect
|
// vary key PBR parameters on a grid of spheres to show the effect
|
||||||
metallic: y01,
|
metallic: y01,
|
||||||
perceptual_roughness: x01,
|
perceptual_roughness: x01,
|
||||||
|
@ -42,7 +42,7 @@ fn setup(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: sphere_mesh,
|
mesh: sphere_mesh,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("#ffd891").unwrap(),
|
base_color: LegacyColor::hex("#ffd891").unwrap(),
|
||||||
// vary key PBR parameters on a grid of spheres to show the effect
|
// vary key PBR parameters on a grid of spheres to show the effect
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..default()
|
||||||
|
@ -103,7 +103,7 @@ fn setup(
|
||||||
"Loading Environment Map...",
|
"Loading Environment Map...",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 36.0,
|
font_size: 36.0,
|
||||||
color: Color::RED,
|
color: LegacyColor::RED,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -128,7 +128,7 @@ fn spawn_sphere(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: sphere_mesh.clone(),
|
mesh: sphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::hex("#ffd891").unwrap(),
|
base_color: LegacyColor::hex("#ffd891").unwrap(),
|
||||||
metallic: 1.0,
|
metallic: 1.0,
|
||||||
perceptual_roughness: 0.0,
|
perceptual_roughness: 0.0,
|
||||||
..StandardMaterial::default()
|
..StandardMaterial::default()
|
||||||
|
@ -293,7 +293,7 @@ impl AppStatus {
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
||||||
font_size: 24.0,
|
font_size: 24.0,
|
||||||
color: Color::ANTIQUE_WHITE,
|
color: LegacyColor::ANTIQUE_WHITE,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ fn setup(
|
||||||
|
|
||||||
let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0));
|
let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0));
|
||||||
let cube_material_handle = materials.add(StandardMaterial {
|
let cube_material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.8, 0.7, 0.6),
|
base_color: LegacyColor::rgb(0.8, 0.7, 0.6),
|
||||||
reflectance: 0.02,
|
reflectance: 0.02,
|
||||||
unlit: false,
|
unlit: false,
|
||||||
..default()
|
..default()
|
||||||
|
@ -103,7 +103,7 @@ fn setup(
|
||||||
// render before the "main pass" camera
|
// render before the "main pass" camera
|
||||||
order: -1,
|
order: -1,
|
||||||
target: image_handle.clone().into(),
|
target: image_handle.clone().into(),
|
||||||
clear_color: Color::WHITE.into(),
|
clear_color: LegacyColor::WHITE.into(),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
|
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn setup(
|
||||||
let sphere_radius = 0.25;
|
let sphere_radius = 0.25;
|
||||||
|
|
||||||
let white_handle = materials.add(StandardMaterial {
|
let white_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -58,7 +58,7 @@ fn setup(
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
intensity: 0.0,
|
intensity: 0.0,
|
||||||
range: spawn_plane_depth,
|
range: spawn_plane_depth,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
shadow_depth_bias: 0.0,
|
shadow_depth_bias: 0.0,
|
||||||
shadow_normal_bias: 0.0,
|
shadow_normal_bias: 0.0,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
|
@ -125,7 +125,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
z_index: ZIndex::Global(i32::MAX),
|
z_index: ZIndex::Global(i32::MAX),
|
||||||
background_color: Color::BLACK.with_a(0.75).into(),
|
background_color: LegacyColor::BLACK.with_a(0.75).into(),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.with_children(|c| {
|
.with_children(|c| {
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn setup(
|
||||||
let sphere_radius = 0.25;
|
let sphere_radius = 0.25;
|
||||||
|
|
||||||
let white_handle = materials.add(StandardMaterial {
|
let white_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ fn setup(
|
||||||
// sphere - initially a caster
|
// sphere - initially a caster
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: sphere_handle.clone(),
|
mesh: sphere_handle.clone(),
|
||||||
material: materials.add(Color::RED),
|
material: materials.add(LegacyColor::RED),
|
||||||
transform: Transform::from_xyz(-1.0, spawn_height, 0.0),
|
transform: Transform::from_xyz(-1.0, spawn_height, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: sphere_handle,
|
mesh: sphere_handle,
|
||||||
material: materials.add(Color::BLUE),
|
material: materials.add(LegacyColor::BLUE),
|
||||||
transform: Transform::from_xyz(1.0, spawn_height, 0.0),
|
transform: Transform::from_xyz(1.0, spawn_height, 0.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(20.0, 20.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(20.0, 20.0)),
|
||||||
material: materials.add(Color::GREEN),
|
material: materials.add(LegacyColor::GREEN),
|
||||||
transform: Transform::from_xyz(0.0, 1.0, -10.0),
|
transform: Transform::from_xyz(0.0, 1.0, -10.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -83,7 +83,7 @@ fn setup(
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
intensity: 0.0,
|
intensity: 0.0,
|
||||||
range: spawn_plane_depth,
|
range: spawn_plane_depth,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
|
|
@ -88,7 +88,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
// NOTE: The ambient light is used to scale how bright the environment map is so with a bright
|
// NOTE: The ambient light is used to scale how bright the environment map is so with a bright
|
||||||
// environment map, use an appropriate color and brightness to match
|
// environment map, use an appropriate color and brightness to match
|
||||||
commands.insert_resource(AmbientLight {
|
commands.insert_resource(AmbientLight {
|
||||||
color: Color::rgb_u8(210, 220, 240),
|
color: LegacyColor::rgb_u8(210, 220, 240),
|
||||||
brightness: 1.0,
|
brightness: 1.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn setup(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.2, 0.2, 0.2),
|
base_color: LegacyColor::rgb(0.2, 0.2, 0.2),
|
||||||
perceptual_roughness: 0.08,
|
perceptual_roughness: 0.08,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -51,7 +51,7 @@ fn setup(
|
||||||
.spawn(PbrBundle {
|
.spawn(PbrBundle {
|
||||||
mesh: mesh.clone(),
|
mesh: mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.5, 0.5, 1.0),
|
base_color: LegacyColor::rgb(0.5, 0.5, 1.0),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -63,7 +63,7 @@ fn setup(
|
||||||
children.spawn(PointLightBundle {
|
children.spawn(PointLightBundle {
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
radius,
|
radius,
|
||||||
color: Color::rgb(0.2, 0.2, 1.0),
|
color: LegacyColor::rgb(0.2, 0.2, 1.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn setup(
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ fn setup(
|
||||||
align_items: AlignItems::Center,
|
align_items: AlignItems::Center,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
border_color: Color::WHITE.into(),
|
border_color: LegacyColor::WHITE.into(),
|
||||||
background_color: Color::DARK_GRAY.into(),
|
background_color: LegacyColor::DARK_GRAY.into(),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
|
@ -29,14 +29,14 @@ fn setup(
|
||||||
// ground plane
|
// ground plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
|
||||||
material: materials.add(Color::WHITE),
|
material: materials.add(LegacyColor::WHITE),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
// cubes
|
// cubes
|
||||||
let mut rng = StdRng::seed_from_u64(19878367467713);
|
let mut rng = StdRng::seed_from_u64(19878367467713);
|
||||||
let cube_mesh = meshes.add(Cuboid::new(0.5, 0.5, 0.5));
|
let cube_mesh = meshes.add(Cuboid::new(0.5, 0.5, 0.5));
|
||||||
let blue = materials.add(Color::rgb_u8(124, 144, 255));
|
let blue = materials.add(LegacyColor::rgb_u8(124, 144, 255));
|
||||||
for _ in 0..40 {
|
for _ in 0..40 {
|
||||||
let x = rng.gen_range(-5.0..5.0);
|
let x = rng.gen_range(-5.0..5.0);
|
||||||
let y = rng.gen_range(0.0..3.0);
|
let y = rng.gen_range(0.0..3.0);
|
||||||
|
@ -55,13 +55,13 @@ fn setup(
|
||||||
let sphere_mesh = meshes.add(Sphere::new(0.05).mesh().uv(32, 18));
|
let sphere_mesh = meshes.add(Sphere::new(0.05).mesh().uv(32, 18));
|
||||||
let sphere_mesh_direction = meshes.add(Sphere::new(0.1).mesh().uv(32, 18));
|
let sphere_mesh_direction = meshes.add(Sphere::new(0.1).mesh().uv(32, 18));
|
||||||
let red_emissive = materials.add(StandardMaterial {
|
let red_emissive = materials.add(StandardMaterial {
|
||||||
base_color: Color::RED,
|
base_color: LegacyColor::RED,
|
||||||
emissive: Color::rgba_linear(100.0, 0.0, 0.0, 0.0),
|
emissive: LegacyColor::rgba_linear(100.0, 0.0, 0.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let maroon_emissive = materials.add(StandardMaterial {
|
let maroon_emissive = materials.add(StandardMaterial {
|
||||||
base_color: Color::MAROON,
|
base_color: LegacyColor::MAROON,
|
||||||
emissive: Color::rgba_linear(50.0, 0.0, 0.0, 0.0),
|
emissive: LegacyColor::rgba_linear(50.0, 0.0, 0.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
for x in 0..4 {
|
for x in 0..4 {
|
||||||
|
@ -75,7 +75,7 @@ fn setup(
|
||||||
.looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
|
.looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
|
||||||
spot_light: SpotLight {
|
spot_light: SpotLight {
|
||||||
intensity: 4000.0, // lumens
|
intensity: 4000.0, // lumens
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
inner_angle: PI / 4.0 * 0.85,
|
inner_angle: PI / 4.0 * 0.85,
|
||||||
outer_angle: PI / 4.0,
|
outer_angle: PI / 4.0,
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn setup(
|
||||||
.insert(TemporalAntiAliasBundle::default());
|
.insert(TemporalAntiAliasBundle::default());
|
||||||
|
|
||||||
let material = materials.add(StandardMaterial {
|
let material = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.5, 0.5, 0.5),
|
base_color: LegacyColor::rgb(0.5, 0.5, 0.5),
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
reflectance: 0.0,
|
reflectance: 0.0,
|
||||||
..default()
|
..default()
|
||||||
|
@ -69,7 +69,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.4).mesh().uv(72, 36)),
|
mesh: meshes.add(Sphere::new(0.4).mesh().uv(72, 36)),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.4, 0.4, 0.4),
|
base_color: LegacyColor::rgb(0.4, 0.4, 0.4),
|
||||||
perceptual_roughness: 1.0,
|
perceptual_roughness: 1.0,
|
||||||
reflectance: 0.0,
|
reflectance: 0.0,
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn setup(
|
||||||
|
|
||||||
// this material modulates the texture to make it red (and slightly transparent)
|
// this material modulates the texture to make it red (and slightly transparent)
|
||||||
let red_material_handle = materials.add(StandardMaterial {
|
let red_material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgba(1.0, 0.0, 0.0, 0.5),
|
base_color: LegacyColor::rgba(1.0, 0.0, 0.0, 0.5),
|
||||||
base_color_texture: Some(texture_handle.clone()),
|
base_color_texture: Some(texture_handle.clone()),
|
||||||
alpha_mode: AlphaMode::Blend,
|
alpha_mode: AlphaMode::Blend,
|
||||||
unlit: true,
|
unlit: true,
|
||||||
|
@ -45,7 +45,7 @@ fn setup(
|
||||||
|
|
||||||
// and lets make this one blue! (and also slightly transparent)
|
// and lets make this one blue! (and also slightly transparent)
|
||||||
let blue_material_handle = materials.add(StandardMaterial {
|
let blue_material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgba(0.0, 0.0, 1.0, 0.5),
|
base_color: LegacyColor::rgba(0.0, 0.0, 1.0, 0.5),
|
||||||
base_color_texture: Some(texture_handle),
|
base_color_texture: Some(texture_handle),
|
||||||
alpha_mode: AlphaMode::Blend,
|
alpha_mode: AlphaMode::Blend,
|
||||||
unlit: true,
|
unlit: true,
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
FogSettings {
|
FogSettings {
|
||||||
color: Color::rgba_u8(43, 44, 47, 255),
|
color: LegacyColor::rgba_u8(43, 44, 47, 255),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
start: 1.0,
|
start: 1.0,
|
||||||
end: 8.0,
|
end: 8.0,
|
||||||
|
@ -109,7 +109,7 @@ fn setup_basic_scene(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)),
|
||||||
material: materials.add(Color::rgb(0.1, 0.2, 0.1)),
|
material: materials.add(LegacyColor::rgb(0.1, 0.2, 0.1)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
SceneNumber(1),
|
SceneNumber(1),
|
||||||
|
@ -141,21 +141,21 @@ fn setup_basic_scene(
|
||||||
let s_val = if i < 3 { 0.0 } else { 0.2 };
|
let s_val = if i < 3 { 0.0 } else { 0.2 };
|
||||||
let material = if j == 0 {
|
let material = if j == 0 {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(s_val, s_val, 1.0),
|
base_color: LegacyColor::rgb(s_val, s_val, 1.0),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
} else if j == 1 {
|
} else if j == 1 {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(s_val, 1.0, s_val),
|
base_color: LegacyColor::rgb(s_val, 1.0, s_val),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(1.0, s_val, s_val),
|
base_color: LegacyColor::rgb(1.0, s_val, s_val),
|
||||||
perceptual_roughness: 0.089,
|
perceptual_roughness: 0.089,
|
||||||
metallic: 0.0,
|
metallic: 0.0,
|
||||||
..default()
|
..default()
|
||||||
|
@ -266,7 +266,7 @@ fn setup_image_viewer_scene(
|
||||||
"Drag and drop an HDR or EXR file",
|
"Drag and drop an HDR or EXR file",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 36.0,
|
font_size: 36.0,
|
||||||
color: Color::BLACK,
|
color: LegacyColor::BLACK,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
|
|
||||||
app.add_plugins(DefaultPlugins)
|
app.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(ClearColor(Color::BLACK))
|
.insert_resource(ClearColor(LegacyColor::BLACK))
|
||||||
.insert_resource(PointLightShadowMap { size: 2048 })
|
.insert_resource(PointLightShadowMap { size: 2048 })
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
brightness: 0.0,
|
brightness: 0.0,
|
||||||
|
@ -117,7 +117,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: cylinder_mesh,
|
mesh: cylinder_mesh,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::rgba(0.9, 0.2, 0.3, 1.0),
|
base_color: LegacyColor::rgba(0.9, 0.2, 0.3, 1.0),
|
||||||
diffuse_transmission: 0.7,
|
diffuse_transmission: 0.7,
|
||||||
perceptual_roughness: 0.32,
|
perceptual_roughness: 0.32,
|
||||||
thickness: 0.2,
|
thickness: 0.2,
|
||||||
|
@ -138,7 +138,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: icosphere_mesh.clone(),
|
mesh: icosphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
emissive: Color::ANTIQUE_WHITE * 80.0 + Color::ORANGE_RED * 16.0,
|
emissive: LegacyColor::ANTIQUE_WHITE * 80.0 + LegacyColor::ORANGE_RED * 16.0,
|
||||||
diffuse_transmission: 1.0,
|
diffuse_transmission: 1.0,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
@ -154,7 +154,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: icosphere_mesh.clone(),
|
mesh: icosphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
specular_transmission: 0.9,
|
specular_transmission: 0.9,
|
||||||
diffuse_transmission: 1.0,
|
diffuse_transmission: 1.0,
|
||||||
thickness: 1.8,
|
thickness: 1.8,
|
||||||
|
@ -177,7 +177,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: icosphere_mesh.clone(),
|
mesh: icosphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::RED,
|
base_color: LegacyColor::RED,
|
||||||
specular_transmission: 0.9,
|
specular_transmission: 0.9,
|
||||||
diffuse_transmission: 1.0,
|
diffuse_transmission: 1.0,
|
||||||
thickness: 1.8,
|
thickness: 1.8,
|
||||||
|
@ -200,7 +200,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: icosphere_mesh.clone(),
|
mesh: icosphere_mesh.clone(),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::GREEN,
|
base_color: LegacyColor::GREEN,
|
||||||
specular_transmission: 0.9,
|
specular_transmission: 0.9,
|
||||||
diffuse_transmission: 1.0,
|
diffuse_transmission: 1.0,
|
||||||
thickness: 1.8,
|
thickness: 1.8,
|
||||||
|
@ -223,7 +223,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: icosphere_mesh,
|
mesh: icosphere_mesh,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::BLUE,
|
base_color: LegacyColor::BLUE,
|
||||||
specular_transmission: 0.9,
|
specular_transmission: 0.9,
|
||||||
diffuse_transmission: 1.0,
|
diffuse_transmission: 1.0,
|
||||||
thickness: 1.8,
|
thickness: 1.8,
|
||||||
|
@ -243,14 +243,14 @@ fn setup(
|
||||||
|
|
||||||
// Chessboard Plane
|
// Chessboard Plane
|
||||||
let black_material = materials.add(StandardMaterial {
|
let black_material = materials.add(StandardMaterial {
|
||||||
base_color: Color::BLACK,
|
base_color: LegacyColor::BLACK,
|
||||||
reflectance: 0.3,
|
reflectance: 0.3,
|
||||||
perceptual_roughness: 0.8,
|
perceptual_roughness: 0.8,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let white_material = materials.add(StandardMaterial {
|
let white_material = materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
reflectance: 0.3,
|
reflectance: 0.3,
|
||||||
perceptual_roughness: 0.8,
|
perceptual_roughness: 0.8,
|
||||||
..default()
|
..default()
|
||||||
|
@ -283,7 +283,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: plane_mesh,
|
mesh: plane_mesh,
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::WHITE,
|
base_color: LegacyColor::WHITE,
|
||||||
diffuse_transmission: 0.6,
|
diffuse_transmission: 0.6,
|
||||||
perceptual_roughness: 0.8,
|
perceptual_roughness: 0.8,
|
||||||
reflectance: 1.0,
|
reflectance: 1.0,
|
||||||
|
@ -309,7 +309,7 @@ fn setup(
|
||||||
PointLightBundle {
|
PointLightBundle {
|
||||||
transform: Transform::from_xyz(-1.0, 1.7, 0.0),
|
transform: Transform::from_xyz(-1.0, 1.7, 0.0),
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
color: Color::ANTIQUE_WHITE * 0.8 + Color::ORANGE_RED * 0.2,
|
color: LegacyColor::ANTIQUE_WHITE * 0.8 + LegacyColor::ORANGE_RED * 0.2,
|
||||||
intensity: 4_000.0,
|
intensity: 4_000.0,
|
||||||
radius: 0.2,
|
radius: 0.2,
|
||||||
range: 5.0,
|
range: 5.0,
|
||||||
|
@ -350,7 +350,7 @@ fn setup(
|
||||||
// Controls Text
|
// Controls Text
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 18.0,
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn setup(
|
||||||
// Opaque plane, uses `alpha_mode: Opaque` by default
|
// Opaque plane, uses `alpha_mode: Opaque` by default
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(6.0, 6.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(6.0, 6.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ fn setup(
|
||||||
// We set it to 0.0 here, because it will be changed over time in the
|
// We set it to 0.0 here, because it will be changed over time in the
|
||||||
// `fade_transparency` function.
|
// `fade_transparency` function.
|
||||||
// Note that the transparency has no effect on the objects shadow.
|
// Note that the transparency has no effect on the objects shadow.
|
||||||
base_color: Color::rgba(0.2, 0.7, 0.1, 0.0),
|
base_color: LegacyColor::rgba(0.2, 0.7, 0.1, 0.0),
|
||||||
// Mask sets a cutoff for transparency. Alpha values below are fully transparent,
|
// Mask sets a cutoff for transparency. Alpha values below are fully transparent,
|
||||||
// alpha values above are fully opaque.
|
// alpha values above are fully opaque.
|
||||||
alpha_mode: AlphaMode::Mask(0.5),
|
alpha_mode: AlphaMode::Mask(0.5),
|
||||||
|
@ -47,7 +47,7 @@ fn setup(
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::rgba(0.2, 0.7, 0.1, 0.0),
|
base_color: LegacyColor::rgba(0.2, 0.7, 0.1, 0.0),
|
||||||
alpha_mode: AlphaMode::Mask(0.5),
|
alpha_mode: AlphaMode::Mask(0.5),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..default()
|
||||||
|
@ -62,7 +62,7 @@ fn setup(
|
||||||
// Notice how there is no need to set the `alpha_mode` explicitly here.
|
// Notice how there is no need to set the `alpha_mode` explicitly here.
|
||||||
// When converting a color to a material using `into()`, the alpha mode is
|
// When converting a color to a material using `into()`, the alpha mode is
|
||||||
// automatically set to `Blend` if the alpha channel is anything lower than 1.0.
|
// automatically set to `Blend` if the alpha channel is anything lower than 1.0.
|
||||||
material: materials.add(Color::rgba(0.5, 0.5, 1.0, 0.0)),
|
material: materials.add(LegacyColor::rgba(0.5, 0.5, 1.0, 0.0)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -70,7 +70,7 @@ fn setup(
|
||||||
// Opaque sphere
|
// Opaque sphere
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
||||||
material: materials.add(Color::rgb(0.7, 0.2, 0.1)),
|
material: materials.add(LegacyColor::rgb(0.7, 0.2, 0.1)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, -1.5),
|
transform: Transform::from_xyz(0.0, 0.5, -1.5),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,14 +18,14 @@ fn setup(
|
||||||
// Plane
|
// Plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cube
|
// Cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn setup(
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cube
|
// cube
|
||||||
|
@ -38,7 +38,7 @@ fn setup(
|
||||||
// This is the default color, but note that vertex colors are
|
// This is the default color, but note that vertex colors are
|
||||||
// multiplied by the base color, so you'll likely want this to be
|
// multiplied by the base color, so you'll likely want this to be
|
||||||
// white if using vertex colors.
|
// white if using vertex colors.
|
||||||
material: materials.add(Color::rgb(1., 1., 1.)),
|
material: materials.add(LegacyColor::rgb(1., 1., 1.)),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn main() {
|
||||||
global: true,
|
global: true,
|
||||||
// Controls the default color of all wireframes. Used as the default color for global wireframes.
|
// Controls the default color of all wireframes. Used as the default color for global wireframes.
|
||||||
// Can be changed per mesh using the `WireframeColor` component.
|
// Can be changed per mesh using the `WireframeColor` component.
|
||||||
default_color: Color::WHITE,
|
default_color: LegacyColor::WHITE,
|
||||||
})
|
})
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, update_colors)
|
.add_systems(Update, update_colors)
|
||||||
|
@ -56,7 +56,7 @@ fn setup(
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
||||||
material: materials.add(Color::BLUE),
|
material: materials.add(LegacyColor::BLUE),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::RED),
|
material: materials.add(LegacyColor::RED),
|
||||||
transform: Transform::from_xyz(-1.0, 0.5, -1.0),
|
transform: Transform::from_xyz(-1.0, 0.5, -1.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -73,7 +73,7 @@ fn setup(
|
||||||
// Orange cube: Follows global wireframe setting
|
// Orange cube: Follows global wireframe setting
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::ORANGE),
|
material: materials.add(LegacyColor::ORANGE),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
@ -81,7 +81,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::GREEN),
|
material: materials.add(LegacyColor::GREEN),
|
||||||
transform: Transform::from_xyz(1.0, 0.5, 1.0),
|
transform: Transform::from_xyz(1.0, 0.5, 1.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -89,7 +89,7 @@ fn setup(
|
||||||
// This lets you configure the wireframe color of this entity.
|
// This lets you configure the wireframe color of this entity.
|
||||||
// If not set, this will use the color in `WireframeConfig`
|
// If not set, this will use the color in `WireframeConfig`
|
||||||
WireframeColor {
|
WireframeColor {
|
||||||
color: Color::GREEN,
|
color: LegacyColor::GREEN,
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -146,20 +146,20 @@ Color: {:?}
|
||||||
|
|
||||||
// Toggle the global wireframe color
|
// Toggle the global wireframe color
|
||||||
if keyboard_input.just_pressed(KeyCode::KeyX) {
|
if keyboard_input.just_pressed(KeyCode::KeyX) {
|
||||||
config.default_color = if config.default_color == Color::WHITE {
|
config.default_color = if config.default_color == LegacyColor::WHITE {
|
||||||
Color::PINK
|
LegacyColor::PINK
|
||||||
} else {
|
} else {
|
||||||
Color::WHITE
|
LegacyColor::WHITE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle the color of a wireframe using WireframeColor and not the global color
|
// Toggle the color of a wireframe using WireframeColor and not the global color
|
||||||
if keyboard_input.just_pressed(KeyCode::KeyC) {
|
if keyboard_input.just_pressed(KeyCode::KeyC) {
|
||||||
for mut color in &mut wireframe_colors {
|
for mut color in &mut wireframe_colors {
|
||||||
color.color = if color.color == Color::GREEN {
|
color.color = if color.color == LegacyColor::GREEN {
|
||||||
Color::RED
|
LegacyColor::RED
|
||||||
} else {
|
} else {
|
||||||
Color::GREEN
|
LegacyColor::GREEN
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use bevy::{animation::RepeatAnimation, pbr::CascadeShadowConfigBuilder, prelude:
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 2000.,
|
brightness: 2000.,
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
@ -46,7 +46,7 @@ fn setup(
|
||||||
// Plane
|
// Plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(500000.0, 500000.0)),
|
mesh: meshes.add(Plane3d::default().mesh().size(500000.0, 500000.0)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Color::WHITE,
|
color: LegacyColor::WHITE,
|
||||||
brightness: 150.0,
|
brightness: 150.0,
|
||||||
})
|
})
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
|
@ -125,7 +125,7 @@ fn setup(
|
||||||
.spawn((
|
.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Sphere::default()),
|
mesh: meshes.add(Sphere::default()),
|
||||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
// Add the animation player
|
// Add the animation player
|
||||||
|
@ -155,7 +155,7 @@ fn setup(
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
transform: Transform::from_xyz(1.5, 0.0, 0.0),
|
transform: Transform::from_xyz(1.5, 0.0, 0.0),
|
||||||
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
|
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
|
||||||
material: materials.add(Color::rgb(0.3, 0.9, 0.3)),
|
material: materials.add(LegacyColor::rgb(0.3, 0.9, 0.3)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
AnimationTarget {
|
AnimationTarget {
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::default()),
|
mesh: meshes.add(Cuboid::default()),
|
||||||
material: materials.add(Color::ORANGE),
|
material: materials.add(LegacyColor::ORANGE),
|
||||||
transform: Transform::from_translation(points[0][0]),
|
transform: Transform::from_translation(points[0][0]),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ fn setup(
|
||||||
// ground plane
|
// ground plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::default().mesh().size(50., 50.)),
|
mesh: meshes.add(Plane3d::default().mesh().size(50., 50.)),
|
||||||
material: materials.add(Color::SILVER),
|
material: materials.add(LegacyColor::SILVER),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ fn animate_cube(time: Res<Time>, mut query: Query<(&mut Transform, &Curve)>, mut
|
||||||
|
|
||||||
for (mut transform, cubic_curve) in &mut query {
|
for (mut transform, cubic_curve) in &mut query {
|
||||||
// Draw the curve
|
// Draw the curve
|
||||||
gizmos.linestrip(cubic_curve.0.iter_positions(50), Color::WHITE);
|
gizmos.linestrip(cubic_curve.0.iter_positions(50), LegacyColor::WHITE);
|
||||||
// position takes a point from the curve where 0 is the initial point
|
// position takes a point from the curve where 0 is the initial point
|
||||||
// and 1 is the last point
|
// and 1 is the last point
|
||||||
transform.translation = cubic_curve.0.position(t);
|
transform.translation = cubic_curve.0.position(t);
|
||||||
|
|
|
@ -147,7 +147,7 @@ fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: mesh.clone(),
|
mesh: mesh.clone(),
|
||||||
material: materials.add(Color::rgb(
|
material: materials.add(LegacyColor::rgb(
|
||||||
rng.gen_range(0.0..1.0),
|
rng.gen_range(0.0..1.0),
|
||||||
rng.gen_range(0.0..1.0),
|
rng.gen_range(0.0..1.0),
|
||||||
rng.gen_range(0.0..1.0),
|
rng.gen_range(0.0..1.0),
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn setup(
|
||||||
|
|
||||||
// You can also add assets directly to their Assets<T> storage:
|
// You can also add assets directly to their Assets<T> storage:
|
||||||
let material_handle = materials.add(StandardMaterial {
|
let material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(0.8, 0.7, 0.6),
|
base_color: LegacyColor::rgb(0.8, 0.7, 0.6),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn add_assets(
|
||||||
let box_mesh_handle = meshes.add(Cuboid::new(0.25, 0.25, 0.25));
|
let box_mesh_handle = meshes.add(Cuboid::new(0.25, 0.25, 0.25));
|
||||||
commands.insert_resource(BoxMeshHandle(box_mesh_handle));
|
commands.insert_resource(BoxMeshHandle(box_mesh_handle));
|
||||||
|
|
||||||
let box_material_handle = materials.add(Color::rgb(1.0, 0.2, 0.3));
|
let box_material_handle = materials.add(LegacyColor::rgb(1.0, 0.2, 0.3));
|
||||||
commands.insert_resource(BoxMaterialHandle(box_material_handle));
|
commands.insert_resource(BoxMaterialHandle(box_material_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue