Allow Skybox to take a Color (#57)

This PR Adds the ability to set the color of the skybox using the URL
parameters.

- Now you can pass a color's hexadecimal number (without the #) in the
  skybox parameter, and that will set the skybox to that color.
This commit is contained in:
Brooks Palin
2024-02-27 22:11:37 -07:00
committed by GitHub
parent c788bcf6b7
commit 343919a9f5
6 changed files with 91 additions and 22 deletions
+15 -6
View File
@@ -39,12 +39,21 @@ struct SkyboxAssets {
}
fn load_skybox(mut cmd: Commands, assets: Res<AssetServer>, id: Res<SkyboxId>) {
let paths = SkyboxPaths::new(&**id);
cmd.insert_resource(SkyboxAssets {
cubemap: assets.load(paths.cubemap),
env_diffuse: assets.load(paths.env_diffuse),
env_specular: assets.load(paths.env_specular),
});
let id = &**id;
if let Ok(color) = Color::hex(id) {
cmd.insert_resource(ClearColor(color));
cmd.insert_resource(AmbientLight {
color,
brightness: 1.0,
})
} else {
let paths = SkyboxPaths::new(id);
cmd.insert_resource(SkyboxAssets {
cubemap: assets.load(paths.cubemap),
env_diffuse: assets.load(paths.env_diffuse),
env_specular: assets.load(paths.env_specular),
});
}
}
fn skybox_assets_loaded(