diff --git a/examples/testbed/src/main.rs b/examples/testbed/src/main.rs index 88548b0..a43d115 100644 --- a/examples/testbed/src/main.rs +++ b/examples/testbed/src/main.rs @@ -79,8 +79,7 @@ async fn main() { let separate_gltf = resman.request::("assets/pos-testing/child-node-cubes.glb").unwrap(); */ //drop(resman); - //cube_gltf.wait_recurse_dependencies_load(); - thread::sleep(Duration::from_millis(500)); + cube_gltf.wait_recurse_dependencies_load(); let cube_mesh = &cube_gltf.data_ref() .unwrap().meshes[0]; /* let crate_mesh = &crate_gltf.data_ref() @@ -92,8 +91,7 @@ async fn main() { let sponza_model = resman.request::("../assets/sponza/Sponza.gltf").unwrap(); drop(resman); - //sponza_model.wait_recurse_dependencies_load(); - thread::sleep(Duration::from_millis(10000)); + sponza_model.wait_recurse_dependencies_load(); let sponza_scene = &sponza_model.data_ref() .unwrap().scenes[0]; diff --git a/lyra-resource/src/gltf/loader.rs b/lyra-resource/src/gltf/loader.rs index 4fb05ba..37dd5fd 100644 --- a/lyra-resource/src/gltf/loader.rs +++ b/lyra-resource/src/gltf/loader.rs @@ -131,7 +131,7 @@ impl ModelLoader { let handle = ResHandle::new_ready(None, new_mesh); ctx.resource_manager.store_uuid(handle.clone()); node.mesh = Some(handle.clone()); - scene.insert(&scene_node, handle); + scene.insert(&scene_node, (handle.clone(), handle.untyped_clone())); } for child in gnode.children() { diff --git a/lyra-resource/src/gltf/mod.rs b/lyra-resource/src/gltf/mod.rs index 0b14924..84910c4 100644 --- a/lyra-resource/src/gltf/mod.rs +++ b/lyra-resource/src/gltf/mod.rs @@ -2,7 +2,6 @@ pub mod loader; pub use loader::*; pub mod material; -use lyra_math::Transform; use lyra_scene::SceneGraph; use crate::ResourceData; pub use material::*; @@ -51,11 +50,4 @@ impl ResourceData for Gltf { } -} - -impl Gltf { - /// Collects all Gltf meshes and gets their world Transform. - pub fn collect_world_meshes(&self) -> Vec<(ResHandle, Transform)> { - todo!() - } } \ No newline at end of file diff --git a/lyra-resource/src/gltf/scene.rs b/lyra-resource/src/gltf/scene.rs index 9c3a47e..8bf83c8 100644 --- a/lyra-resource/src/gltf/scene.rs +++ b/lyra-resource/src/gltf/scene.rs @@ -97,7 +97,10 @@ impl GltfScene { impl ResourceData for SceneGraph { fn dependencies(&self) -> Vec { - todo!() + self.world().view::<&crate::UntypedResHandle>() + .iter() + .map(|han| han.clone()) + .collect() } fn as_any(&self) -> &dyn std::any::Any { diff --git a/lyra-resource/src/resource.rs b/lyra-resource/src/resource.rs index 7a95a6f..f20a8ac 100644 --- a/lyra-resource/src/resource.rs +++ b/lyra-resource/src/resource.rs @@ -96,7 +96,7 @@ pub struct UntypedResource { pub(crate) condvar: Arc<(Mutex, Condvar)>, } -#[derive(Clone)] +#[derive(Clone, Component)] pub struct UntypedResHandle{ pub(crate) res: Arc>, #[allow(dead_code)] diff --git a/lyra-resource/src/world_ext.rs b/lyra-resource/src/world_ext.rs index a010cc4..366bf48 100644 --- a/lyra-resource/src/world_ext.rs +++ b/lyra-resource/src/world_ext.rs @@ -1,5 +1,3 @@ -use std::any::Any; - use crossbeam::channel::Receiver; use lyra_ecs::World; use notify_debouncer_full::DebouncedEvent;