fix: set spatial node transform

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-07-10 14:56:08 +02:00
parent dfb59ee7fa
commit c1d3a4cbcb
2 changed files with 12 additions and 1 deletions

View File

@@ -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

View File

@@ -50,7 +50,14 @@ impl Plugin for ModelNodePlugin {
app.init_resource::<MaterialRegistry>();
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<Mesh3d>>,
part_mesh_query: Query<(&Transform, &Aabb), With<Mesh3d>>,
global_transform_query: Query<&GlobalTransform>,
has_mesh: Query<Has<Mesh3d>>,
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