Skip to content

Commit

Permalink
don't require features on examples where it's not the main focus (bev…
Browse files Browse the repository at this point in the history
…yengine#7615)

# Objective

- Required features were added to some examples in bevyengine#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
  • Loading branch information
mockersf authored and myreprise1 committed Feb 14, 2023
1 parent 73f4414 commit 5bf0ee5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions examples/3d/load_gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.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,
Expand Down
6 changes: 6 additions & 0 deletions examples/tools/scene_viewer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 {
Expand Down

0 comments on commit 5bf0ee5

Please sign in to comment.