fix(Blenvy:Bevy): added safeguard against files withouth scene level metadata

* normally this should NOT happen if the blueprints to spawn are correctly generated
(by the Blender add-on) gltf files, but better safe (no unwrap!) than sorry
This commit is contained in:
kaosat.dev 2024-07-19 01:09:43 +02:00
parent a618e0035e
commit be0f4f1377

View File

@ -156,7 +156,8 @@ pub(crate) fn blueprints_prepare_spawn(
/* prefetch attempt */ /* prefetch attempt */
let gltf = RawGltf::open(format!("assets/{}", blueprint_info.path)).unwrap(); let gltf = RawGltf::open(format!("assets/{}", blueprint_info.path)).unwrap();
for scene in gltf.scenes() { for scene in gltf.scenes() {
let scene_extras = scene.extras().clone().unwrap(); if let Some(scene_extras) = scene.extras().clone()
{
let lookup: HashMap<String, Value> = serde_json::from_str(scene_extras.get()).unwrap(); let lookup: HashMap<String, Value> = serde_json::from_str(scene_extras.get()).unwrap();
if lookup.contains_key("BlueprintAssets") { if lookup.contains_key("BlueprintAssets") {
let assets_raw = &lookup["BlueprintAssets"]; let assets_raw = &lookup["BlueprintAssets"];
@ -195,6 +196,7 @@ pub(crate) fn blueprints_prepare_spawn(
} }
} }
} }
}
// now insert load tracker // now insert load tracker
// if there are assets to load // if there are assets to load