From 3453d23401a31fe96658ad53268e34410864a175 Mon Sep 17 00:00:00 2001 From: Rouven Spreckels Date: Sun, 27 Oct 2024 10:20:09 +0100 Subject: [PATCH] Disable wireframe mode on `wasm32` target arch. --- RELEASES.md | 1 + examples/constellation_clamp.rs | 15 +++++++++++++-- examples/gliding_clamp.rs | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 9aab6ce30..6b5cf4993 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,6 +2,7 @@ * Update `bevy_egui`. * Bump MSRV. + * Disable wireframe mode in examples when unsupported. # Version 0.7.0 (2024-07-06) diff --git a/examples/constellation_clamp.rs b/examples/constellation_clamp.rs index fa1bfb1f2..bd5a58d1d 100644 --- a/examples/constellation_clamp.rs +++ b/examples/constellation_clamp.rs @@ -13,9 +13,10 @@ use std::f32::consts::PI; +#[cfg(not(target_arch = "wasm32"))] +use bevy::pbr::wireframe::{WireframeConfig, WireframePlugin}; use bevy::{ color::palettes::basic::SILVER, - pbr::wireframe::{WireframeConfig, WireframePlugin}, prelude::*, render::{ camera::Viewport, @@ -38,11 +39,19 @@ fn main() { }), ..default() }), + #[cfg(not(target_arch = "wasm32"))] WireframePlugin, )) .add_plugins(TrackballPlugin) .add_systems(Startup, setup) - .add_systems(Update, (rotate, toggle_wireframe)) + .add_systems( + Update, + ( + rotate, + #[cfg(not(target_arch = "wasm32"))] + toggle_wireframe, + ), + ) .add_systems(Update, (resize_minimap, toggle_rigid_loose)) .run(); } @@ -191,6 +200,7 @@ fn setup( )); // UI + #[cfg(not(target_arch = "wasm32"))] commands.spawn(( TargetCamera(maximap), TextBundle::from_section("Press space to toggle wireframes", TextStyle::default()) @@ -300,6 +310,7 @@ fn uv_debug_texture() -> Image { ) } +#[cfg(not(target_arch = "wasm32"))] fn toggle_wireframe( mut wireframe_config: ResMut, keyboard: Res>, diff --git a/examples/gliding_clamp.rs b/examples/gliding_clamp.rs index 0521d6d4b..f655813c4 100644 --- a/examples/gliding_clamp.rs +++ b/examples/gliding_clamp.rs @@ -5,9 +5,10 @@ use std::f32::consts::PI; +#[cfg(not(target_arch = "wasm32"))] +use bevy::pbr::wireframe::{WireframeConfig, WireframePlugin}; use bevy::{ color::palettes::basic::SILVER, - pbr::wireframe::{WireframeConfig, WireframePlugin}, prelude::*, render::{ render_asset::RenderAssetUsages, @@ -28,11 +29,19 @@ fn main() { }), ..default() }), + #[cfg(not(target_arch = "wasm32"))] WireframePlugin, )) .add_plugins(TrackballPlugin) .add_systems(Startup, setup) - .add_systems(Update, (rotate, toggle_wireframe)) + .add_systems( + Update, + ( + rotate, + #[cfg(not(target_arch = "wasm32"))] + toggle_wireframe, + ), + ) .run(); } @@ -151,6 +160,7 @@ fn setup( Camera3dBundle::default(), )); + #[cfg(not(target_arch = "wasm32"))] commands.spawn( TextBundle::from_section("Press space to toggle wireframes", TextStyle::default()) .with_style(Style { @@ -197,6 +207,7 @@ fn uv_debug_texture() -> Image { ) } +#[cfg(not(target_arch = "wasm32"))] fn toggle_wireframe( mut wireframe_config: ResMut, keyboard: Res>,