fix: streamline node creation in reify by simplifying entity type handling and improving model fallback logic
This commit is contained in:
@@ -121,11 +121,11 @@ 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);
|
||||||
|
|
||||||
// Create appropriate visual based on entity type - wrap all in Spatial for type consistency
|
// Create appropriate visual based on entity type - wrap all in Spatial for type consistency
|
||||||
let element = match node.entity_type {
|
match node.entity_type {
|
||||||
1 => {
|
1 => {
|
||||||
// Box - use cube model with color
|
// Box - use cube model with color
|
||||||
eprintln!("[bridge/reify] Creating box model for node {}", id);
|
eprintln!("[bridge/reify] Creating box model for node {}", id);
|
||||||
Spatial::default()
|
Some((*id, Spatial::default()
|
||||||
.transform(transform)
|
.transform(transform)
|
||||||
.build()
|
.build()
|
||||||
.child(
|
.child(
|
||||||
@@ -134,12 +134,12 @@ impl Reify for BridgeState {
|
|||||||
ModelPart::new("Cube")
|
ModelPart::new("Cube")
|
||||||
.mat_param("color", MaterialParameter::Color(node_color))
|
.mat_param("color", MaterialParameter::Color(node_color))
|
||||||
).build()
|
).build()
|
||||||
)
|
)))
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
// Sphere - use sphere model with color
|
// Sphere - use sphere model with color
|
||||||
eprintln!("[bridge/reify] Creating sphere model for node {}", id);
|
eprintln!("[bridge/reify] Creating sphere model for node {}", id);
|
||||||
Spatial::default()
|
Some((*id, Spatial::default()
|
||||||
.transform(transform)
|
.transform(transform)
|
||||||
.build()
|
.build()
|
||||||
.child(
|
.child(
|
||||||
@@ -148,50 +148,34 @@ impl Reify for BridgeState {
|
|||||||
ModelPart::new("Sphere")
|
ModelPart::new("Sphere")
|
||||||
.mat_param("color", MaterialParameter::Color(node_color))
|
.mat_param("color", MaterialParameter::Color(node_color))
|
||||||
).build()
|
).build()
|
||||||
)
|
)))
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
// Model - use model URL if available, fallback to cube
|
// Model - use model URL if available, fallback to cube
|
||||||
if !node.model_url.is_empty() {
|
eprintln!("[bridge/reify] Creating gyro model for node {}", id);
|
||||||
eprintln!("[bridge/reify] Creating model from URL for node {}: {}", id, node.model_url);
|
// For now, use a fallback model since we can't load arbitrary URLs yet
|
||||||
// For now, use a fallback model since we can't load arbitrary URLs yet
|
// TODO: Implement model loading and caching
|
||||||
// TODO: Implement model loading and caching
|
Some((*id, Spatial::default()
|
||||||
Spatial::default()
|
.transform(transform)
|
||||||
.transform(transform)
|
.build()
|
||||||
.build()
|
.child(
|
||||||
.child(
|
Model::namespaced("fusion", "gyro")
|
||||||
Model::namespaced("fusion", "gyro")
|
.part(
|
||||||
.part(
|
ModelPart::new("Gem")
|
||||||
ModelPart::new("Gem")
|
.mat_param("color", MaterialParameter::Color(node_color))
|
||||||
.mat_param("color", MaterialParameter::Color(node_color))
|
).build()
|
||||||
).build()
|
)))
|
||||||
)
|
|
||||||
} else {
|
|
||||||
eprintln!("[bridge/reify] Creating fallback cube for node {} (no model URL)", id);
|
|
||||||
Spatial::default()
|
|
||||||
.transform(transform)
|
|
||||||
.build()
|
|
||||||
.child(
|
|
||||||
Model::namespaced("fusion", "tex_cube")
|
|
||||||
.part(
|
|
||||||
ModelPart::new("Cube")
|
|
||||||
.mat_param("color", MaterialParameter::Color(node_color))
|
|
||||||
).build()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Unknown or unsupported type - render as wireframe
|
// Unknown or unsupported type - render as wireframe
|
||||||
eprintln!("[bridge/reify] Creating wireframe for node {} type={}", id, node.entity_type);
|
eprintln!("[bridge/reify] Creating wireframe for node {} type={}", id, node.entity_type);
|
||||||
let cube_lines = create_wireframe_cube(node_color, 0.003);
|
let cube_lines = create_wireframe_cube(node_color, 0.003);
|
||||||
Spatial::default()
|
Some((*id, Spatial::default()
|
||||||
.transform(transform)
|
.transform(transform)
|
||||||
.build()
|
.build()
|
||||||
.child(Lines::new(cube_lines).build())
|
.child(Lines::new(cube_lines).build())))
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Some((*id, element))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
PlaySpace.build().stable_children(children)
|
PlaySpace.build().stable_children(children)
|
||||||
|
|||||||
Reference in New Issue
Block a user