From 5bf0ee5ffc6caa95e53a82e4f08e683609aaac89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 13 Feb 2023 18:20:25 +0000 Subject: [PATCH] don't require features on examples where it's not the main focus (#7615) # Objective - Required features were added to some examples in #7051 even though those features aren't the main focus of the examples - Don't require features on examples that are useful without them ## Solution - Remove required features on examples `load_gltf` and `scene_viewer`, but log a warning when they are not enabled --- Cargo.toml | 2 -- examples/3d/load_gltf.rs | 7 +++++++ examples/tools/scene_viewer/main.rs | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 266831b4af5f27..f3228c4a1e9709 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -372,7 +372,6 @@ wasm = false [[example]] name = "load_gltf" path = "examples/3d/load_gltf.rs" -required-features = ["ktx2", "zstd"] [package.metadata.example.load_gltf] name = "Load glTF" @@ -1432,7 +1431,6 @@ wasm = true [[example]] name = "scene_viewer" path = "examples/tools/scene_viewer/main.rs" -required-features = ["ktx2", "zstd"] [package.metadata.example.scene_viewer] name = "Scene Viewer" diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index 80b4d7a041e153..30604a5ca2f2cf 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -27,11 +27,18 @@ fn setup(mut commands: Commands, asset_server: Res) { .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), ..default() }, + #[cfg(all(feature = "ktx2", feature = "zstd"))] EnvironmentMapLight { diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"), }, )); + #[cfg(not(all(feature = "ktx2", feature = "zstd")))] + { + warn!("feature ktx2 or zstd wasn't enabled."); + warn!("rerun this example with `--features=\"ktx2 zstd\" to get environment maps for ambient light"); + } + commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { shadows_enabled: true, diff --git a/examples/tools/scene_viewer/main.rs b/examples/tools/scene_viewer/main.rs index 956a9e58266fe3..0d4590e0ececb8 100644 --- a/examples/tools/scene_viewer/main.rs +++ b/examples/tools/scene_viewer/main.rs @@ -128,6 +128,7 @@ fn setup_scene_after_load( }, ..default() }, + #[cfg(all(feature = "ktx2", feature = "zstd"))] EnvironmentMapLight { diffuse_map: asset_server .load("assets/environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"), @@ -136,6 +137,11 @@ fn setup_scene_after_load( }, camera_controller, )); + #[cfg(not(all(feature = "ktx2", feature = "zstd")))] + { + warn!("feature ktx2 or zstd wasn't enabled."); + warn!("rerun this example with `--features=\"ktx2 zstd\" to get environment maps for ambient light"); + } // Spawn a default light if the scene does not have one if !scene_handle.has_light {