feat: refactor model loading in reify function to improve entity type handling
This commit is contained in:
@@ -107,7 +107,7 @@ impl Reify for BridgeState {
|
|||||||
let transform = stardust_xr_fusion::spatial::Transform::from_translation_rotation_scale(trans_array, rot_array, scale_array);
|
let transform = stardust_xr_fusion::spatial::Transform::from_translation_rotation_scale(trans_array, rot_array, scale_array);
|
||||||
|
|
||||||
// Try to load the appropriate model based on entity type
|
// Try to load the appropriate model based on entity type
|
||||||
if let Some(model_path) = get_model_path(node.entity_type) {
|
let model_child = if let Some(model_path) = get_model_path(node.entity_type) {
|
||||||
eprintln!("[bridge/reify] Loading {} model for node {} from {}",
|
eprintln!("[bridge/reify] Loading {} model for node {} from {}",
|
||||||
match node.entity_type {
|
match node.entity_type {
|
||||||
1 => "cube",
|
1 => "cube",
|
||||||
@@ -117,27 +117,21 @@ impl Reify for BridgeState {
|
|||||||
}, id, model_path.display());
|
}, id, model_path.display());
|
||||||
|
|
||||||
match Model::direct(&model_path) {
|
match Model::direct(&model_path) {
|
||||||
Ok(model) => {
|
Ok(model) => Some(model.build()),
|
||||||
Some((*id, Spatial::default()
|
|
||||||
.transform(transform)
|
|
||||||
.build()
|
|
||||||
.child(model.build())))
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e);
|
eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e);
|
||||||
// Fall back to spatial-only node
|
None
|
||||||
Some((*id, Spatial::default()
|
|
||||||
.transform(transform)
|
|
||||||
.build()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eprintln!("[bridge/reify] No model available for entity type {} (node {})", node.entity_type, id);
|
eprintln!("[bridge/reify] No model available for entity type {} (node {})", node.entity_type, id);
|
||||||
// Fallback to empty spatial
|
None
|
||||||
Some((*id, Spatial::default()
|
};
|
||||||
.transform(transform)
|
|
||||||
.build()))
|
Some((*id, Spatial::default()
|
||||||
}
|
.transform(transform)
|
||||||
|
.build()
|
||||||
|
.maybe_child(model_child)))
|
||||||
});
|
});
|
||||||
|
|
||||||
PlaySpace.build().stable_children(children)
|
PlaySpace.build().stable_children(children)
|
||||||
|
|||||||
Reference in New Issue
Block a user