This commit is contained in:
AmadeusWM
2025-04-05 21:11:04 +02:00
parent 4dd5b14ea1
commit 4a9dc86fc0
7 changed files with 15 additions and 6 deletions

Binary file not shown.

View File

@@ -1,4 +1,7 @@
({ ({
"lebron": File (path: "images/KingLebron.png"), "lebron": File (path: "images/KingLebron.png"),
"wall": File (path: "meshes/House.glb"), "house": File (path: "meshes/House.glb"),
"library": Folder (
path: "meshes/library",
),
}) })

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
use bevy::prelude::*; use bevy::{prelude::*, utils::HashMap};
use crate::GameState; use crate::GameState;
use bevy_asset_loader::prelude::*; use bevy_asset_loader::prelude::*;
@@ -30,8 +30,10 @@ pub(crate) struct AudioAssets {}
#[derive(AssetCollection, Resource, Clone)] #[derive(AssetCollection, Resource, Clone)]
pub(crate) struct GltfAssets { pub(crate) struct GltfAssets {
#[asset(key = "wall")] #[asset(key = "house")]
pub(crate) wall: Handle<Gltf>, pub(crate) house: Handle<Gltf>,
#[asset(key = "library", collection(typed, mapped))]
pub(crate) library: HashMap<String, Handle<Gltf>>,
} }
#[derive(AssetCollection, Resource, Clone)] #[derive(AssetCollection, Resource, Clone)]

View File

@@ -11,7 +11,11 @@ fn spawn_level(
models: Res<Assets<Gltf>>, models: Res<Assets<Gltf>>,
gltf_assets: Res<GltfAssets> gltf_assets: Res<GltfAssets>
) { ) {
let gltf = models.get(&gltf_assets.wall).unwrap(); println!("LIBRARY: {:?}", gltf_assets.library);
let jumbo = gltf_assets.library.get("meshes/library/wall.glb").unwrap();
let gltf = models.get(jumbo).unwrap();
commands.spawn(SceneRoot(gltf.scenes[0].clone())); // commands.spawn(SceneRoot(gltf.scenes[0].clone()));
let asset = gltf.default_scene.as_ref().unwrap();
commands.spawn(SceneRoot(asset.clone()));
} }