Skip to content

Commit

Permalink
Disable wireframe mode on wasm32 target arch.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Oct 27, 2024
1 parent 65b1bf6 commit 3453d23
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Update `bevy_egui`.
* Bump MSRV.
* Disable wireframe mode in examples when unsupported.

# Version 0.7.0 (2024-07-06)

Expand Down
15 changes: 13 additions & 2 deletions examples/constellation_clamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -300,6 +310,7 @@ fn uv_debug_texture() -> Image {
)
}

#[cfg(not(target_arch = "wasm32"))]
fn toggle_wireframe(
mut wireframe_config: ResMut<WireframeConfig>,
keyboard: Res<ButtonInput<KeyCode>>,
Expand Down
15 changes: 13 additions & 2 deletions examples/gliding_clamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -197,6 +207,7 @@ fn uv_debug_texture() -> Image {
)
}

#[cfg(not(target_arch = "wasm32"))]
fn toggle_wireframe(
mut wireframe_config: ResMut<WireframeConfig>,
keyboard: Res<ButtonInput<KeyCode>>,
Expand Down

0 comments on commit 3453d23

Please sign in to comment.