Skip to content

Commit 6539334

Browse files
committed
Fix example build for wasm (#16557)
# Objective - Some examples failed to build for wasm on the website ## Solution - Fix them - `Msaa` is now a component instead of a resource
1 parent 3f2baf8 commit 6539334

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

examples/3d/blend_modes.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ fn main() {
2020
.add_systems(Startup, setup)
2121
.add_systems(Update, example_control_system);
2222

23-
// Unfortunately, MSAA and HDR are not supported simultaneously under WebGL.
24-
// Since this example uses HDR, we must disable MSAA for Wasm builds, at least
25-
// until WebGPU is ready and no longer behind a feature flag in Web browsers.
26-
#[cfg(target_arch = "wasm32")]
27-
app.insert_resource(Msaa::Off);
28-
2923
app.run();
3024
}
3125

@@ -155,6 +149,11 @@ fn setup(
155149
commands.spawn((
156150
Camera3d::default(),
157151
Transform::from_xyz(0.0, 2.5, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
152+
// Unfortunately, MSAA and HDR are not supported simultaneously under WebGL.
153+
// Since this example uses HDR, we must disable MSAA for Wasm builds, at least
154+
// until WebGPU is ready and no longer behind a feature flag in Web browsers.
155+
#[cfg(target_arch = "wasm32")]
156+
Msaa::Off,
158157
));
159158

160159
// Controls Text

examples/3d/motion_blur.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ use bevy::{
1111
fn main() {
1212
let mut app = App::new();
1313

14-
// MSAA and Motion Blur together are not compatible on WebGL
15-
#[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))]
16-
app.insert_resource(Msaa::Off);
17-
1814
app.add_plugins(DefaultPlugins)
1915
.add_systems(Startup, (setup_camera, setup_scene, setup_ui))
2016
.add_systems(Update, (keyboard_inputs, move_cars, move_camera).chain())
@@ -33,6 +29,9 @@ fn setup_camera(mut commands: Commands) {
3329
#[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))]
3430
_webgl2_padding: Default::default(),
3531
},
32+
// MSAA and Motion Blur together are not compatible on WebGL
33+
#[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))]
34+
Msaa::Off,
3635
));
3736
}
3837

0 commit comments

Comments
 (0)