Skip to content

Commit

Permalink
fix: some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
BD103 committed Apr 26, 2024
1 parent b4cd0b1 commit 00e51c5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/2d/2d_viewport_to_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn draw_cursor(
return;
};

gizmos.circle_2d(point, 10., WHITE);
gizmos.circle_2d(point, 10., WHITE.into());
}

fn setup(mut commands: Commands) {
Expand Down
28 changes: 14 additions & 14 deletions examples/2d/bounding_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) {
let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
match shape {
Shape::Rectangle(r) => {
gizmos.primitive_2d(*r, translation, rotation, color);
gizmos.primitive_2d(*r, translation, rotation, color.into());
}
Shape::Circle(c) => {
gizmos.primitive_2d(*c, translation, rotation, color);
gizmos.primitive_2d(*c, translation, rotation, color.into());
}
Shape::Triangle(t) => {
gizmos.primitive_2d(*t, translation, rotation, color);
gizmos.primitive_2d(*t, translation, rotation, color.into());
}
Shape::Line(l) => {
gizmos.primitive_2d(*l, translation, rotation, color);
gizmos.primitive_2d(*l, translation, rotation, color.into());
}
Shape::Capsule(c) => {
gizmos.primitive_2d(*c, translation, rotation, color);
gizmos.primitive_2d(*c, translation, rotation, color.into());
}
Shape::Polygon(p) => {
gizmos.primitive_2d(*p, translation, rotation, color);
gizmos.primitive_2d(*p, translation, rotation, color.into());
}
}
}
Expand Down Expand Up @@ -180,10 +180,10 @@ fn render_volumes(mut gizmos: Gizmos, query: Query<(&CurrentVolume, &Intersects)
let color = if **intersects { AQUA } else { ORANGE_RED };
match volume {
CurrentVolume::Aabb(a) => {
gizmos.rect_2d(a.center(), 0., a.half_size() * 2., color);
gizmos.rect_2d(a.center(), 0., a.half_size() * 2., color.into());
}
CurrentVolume::Circle(c) => {
gizmos.circle_2d(c.center(), c.radius(), color);
gizmos.circle_2d(c.center(), c.radius(), color.into());
}
}
}
Expand Down Expand Up @@ -286,15 +286,15 @@ fn setup(mut commands: Commands, loader: Res<AssetServer>) {

fn draw_filled_circle(gizmos: &mut Gizmos, position: Vec2, color: Srgba) {
for r in [1., 2., 3.] {
gizmos.circle_2d(position, r, color);
gizmos.circle_2d(position, r, color.into());
}
}

fn draw_ray(gizmos: &mut Gizmos, ray: &RayCast2d) {
gizmos.line_2d(
ray.ray.origin,
ray.ray.origin + *ray.ray.direction * ray.max,
WHITE,
WHITE.into(),
);
draw_filled_circle(gizmos, ray.ray.origin, FUCHSIA);
}
Expand Down Expand Up @@ -359,7 +359,7 @@ fn aabb_cast_system(
aabb_cast.ray.ray.origin + *aabb_cast.ray.ray.direction * toi,
0.,
aabb_cast.aabb.half_size() * 2.,
LIME,
LIME.into(),
);
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ fn bounding_circle_cast_system(
gizmos.circle_2d(
circle_cast.ray.ray.origin + *circle_cast.ray.ray.direction * toi,
circle_cast.circle.radius(),
LIME,
LIME.into(),
);
}
}
Expand All @@ -406,7 +406,7 @@ fn aabb_intersection_system(
) {
let center = get_intersection_position(&time);
let aabb = Aabb2d::new(center, Vec2::splat(50.));
gizmos.rect_2d(center, 0., aabb.half_size() * 2., YELLOW);
gizmos.rect_2d(center, 0., aabb.half_size() * 2., YELLOW.into());

for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
Expand All @@ -425,7 +425,7 @@ fn circle_intersection_system(
) {
let center = get_intersection_position(&time);
let circle = BoundingCircle::new(center, 50.);
gizmos.circle_2d(center, circle.radius(), YELLOW);
gizmos.circle_2d(center, circle.radius(), YELLOW.into());

for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
Expand Down
8 changes: 4 additions & 4 deletions examples/2d/wireframe_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! This is a native only feature.
use bevy::{
color::palettes::basic::{GREEN, RED, WHITE},
color::palettes::basic::{BLACK, GREEN, RED, WHITE},
prelude::*,
render::{
render_resource::WgpuFeatures,
Expand Down Expand Up @@ -67,7 +67,7 @@ fn setup(
Vec2::new(50.0, -50.0),
))
.into(),
material: materials.add(Color::BLACK),
material: materials.add(BLACK),
transform: Transform::from_xyz(-150.0, 0.0, 0.0),
..default()
},
Expand All @@ -76,15 +76,15 @@ fn setup(
// Rectangle: Follows global wireframe setting
commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(Rectangle::new(100.0, 100.0)).into(),
material: materials.add(Color::BLACK),
material: materials.add(BLACK),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
});
// Circle: Always renders a wireframe
commands.spawn((
MaterialMesh2dBundle {
mesh: meshes.add(Circle::new(50.0)).into(),
material: materials.add(Color::BLACK),
material: materials.add(BLACK),
transform: Transform::from_xyz(150.0, 0.0, 0.0),
..default()
},
Expand Down
4 changes: 2 additions & 2 deletions examples/3d/3d_viewport_to_world.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This example demonstrates how to use the `Camera::viewport_to_world` method.
use bevy::prelude::*;
use bevy::{color::palettes::basic::WHITE, prelude::*};

fn main() {
App::new()
Expand Down Expand Up @@ -41,7 +41,7 @@ fn draw_cursor(
point + ground.up() * 0.01,
Dir3::new_unchecked(ground.up()), // Up vector is already normalized.
0.2,
Color::WHITE,
WHITE.into(),
);
}

Expand Down
4 changes: 1 addition & 3 deletions examples/3d/irradiance_volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ 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 GIZMO_COLOR: Color = Color::Srgba(YELLOW);

static VOXEL_TRANSFORM: Mat4 = Mat4::from_cols_array_2d(&[
[-42.317566, 0.0, 0.0, 0.0],
[0.0, 0.0, 44.601563, 0.0],
Expand Down Expand Up @@ -632,7 +630,7 @@ fn draw_gizmo(
) {
if app_status.voxels_visible {
for transform in irradiance_volume_query.iter() {
gizmos.cuboid(*transform, GIZMO_COLOR);
gizmos.cuboid(*transform, YELLOW.into());
}
}
}
Expand Down

0 comments on commit 00e51c5

Please sign in to comment.