From 6d149fe787e490ff7065e3be90851a81e26f76f4 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 30 May 2024 15:47:42 -0400 Subject: [PATCH 1/2] add wireframe to 3d_shapes example --- examples/3d/3d_shapes.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/examples/3d/3d_shapes.rs b/examples/3d/3d_shapes.rs index 9a92dcd3ce37f..2c23dfa09f8e2 100644 --- a/examples/3d/3d_shapes.rs +++ b/examples/3d/3d_shapes.rs @@ -5,6 +5,7 @@ use std::f32::consts::PI; use bevy::{ color::palettes::basic::SILVER, + pbr::wireframe::{WireframeConfig, WireframePlugin}, prelude::*, render::{ render_asset::RenderAssetUsages, @@ -14,9 +15,12 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) + .add_plugins(( + DefaultPlugins.set(ImagePlugin::default_nearest()), + WireframePlugin, + )) .add_systems(Startup, setup) - .add_systems(Update, rotate) + .add_systems(Update, (rotate, toggle_wireframe)) .run(); } @@ -91,6 +95,22 @@ fn setup( transform: Transform::from_xyz(0.0, 6., 12.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y), ..default() }); + + commands.spawn( + TextBundle::from_section( + "Press space to toggle wireframes", + TextStyle { + font_size: 24.0, + ..default() + }, + ) + .with_style(Style { + position_type: PositionType::Absolute, + top: Val::Px(10.0), + left: Val::Px(10.0), + ..default() + }), + ); } fn rotate(mut query: Query<&mut Transform, With>, time: Res