From c1d3a4cbcbfbc833a399e0e9b177d1124784cdd9 Mon Sep 17 00:00:00 2001 From: Schmarni Date: Thu, 10 Jul 2025 14:56:08 +0200 Subject: [PATCH] fix: set spatial node transform Signed-off-by: Schmarni --- src/main.rs | 1 + src/nodes/drawable/model.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4a52c1e..c8aabf3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -371,6 +371,7 @@ fn bevy_loop( app.insert_resource(ObjectRegistryRes(object_registry)); #[cfg(feature = "bevy_debugging")] { + use bevy::remote::{RemotePlugin, http::RemoteHttpPlugin}; app.add_plugins((RemotePlugin::default(), RemoteHttpPlugin::default())); } // the Stardust server plugins diff --git a/src/nodes/drawable/model.rs b/src/nodes/drawable/model.rs index bc03eb8..3d4472a 100644 --- a/src/nodes/drawable/model.rs +++ b/src/nodes/drawable/model.rs @@ -50,7 +50,14 @@ impl Plugin for ModelNodePlugin { app.init_resource::(); app.add_systems(Update, load_models); - app.add_systems(PostUpdate, (gen_model_parts, apply_materials).chain()); + app.add_systems( + PostUpdate, + ( + gen_model_parts.after(TransformSystem::TransformPropagate), + apply_materials, + ) + .chain(), + ); } } @@ -142,6 +149,7 @@ fn gen_model_parts( children_query: Query<&Children>, part_query: Query<(&Name, Option<&Children>, &Transform), Without>, part_mesh_query: Query<(&Transform, &Aabb), With>, + global_transform_query: Query<&GlobalTransform>, has_mesh: Query>, mut cmds: Commands, ) { @@ -224,6 +232,8 @@ fn gen_model_parts( .and_then(|v| v.bounds.get().copied()) .unwrap_or_default() }); + spatial.set_local_transform(transform.compute_matrix()); + cmds.entity(entity) .insert(SpatialNode(Arc::downgrade(&spatial))); let mesh_entity = children_query