Compare commits

...

2 Commits

Author SHA1 Message Date
MayaTheShy
69c874e106 fix: streamline node creation in reify by simplifying entity type handling and improving model fallback logic
Some checks failed
CI / build-and-test (push) Has been cancelled
Rust Quality Checks / rust-checks (push) Has been cancelled
2025-11-08 22:09:16 -05:00
MayaTheShy
2d8448cbe6 fix: refactor node creation in reify to use Spatial wrapper for entity types 2025-11-08 22:08:57 -05:00

View File

@@ -120,62 +120,62 @@ impl Reify for BridgeState {
let scale_array = [vis_scale.x, vis_scale.y, vis_scale.z];
let transform = stardust_xr_fusion::spatial::Transform::from_translation_rotation_scale(trans_array, rot_array, scale_array);
// Create appropriate visual based on entity type
let element: ast::ElementWrapper<_, _, ()> = match node.entity_type {
// Create appropriate visual based on entity type - wrap all in Spatial for type consistency
match node.entity_type {
1 => {
// Box - use cube model with color
eprintln!("[bridge/reify] Creating box model for node {}", id);
Model::namespaced("fusion", "tex_cube")
Some((*id, Spatial::default()
.transform(transform)
.part(
ModelPart::new("Cube")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
.build()
.child(
Model::namespaced("fusion", "tex_cube")
.part(
ModelPart::new("Cube")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)))
}
2 => {
// Sphere - use sphere model with color
eprintln!("[bridge/reify] Creating sphere model for node {}", id);
Model::namespaced("fusion", "tex_sphere")
Some((*id, Spatial::default()
.transform(transform)
.part(
ModelPart::new("Sphere")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
.build()
.child(
Model::namespaced("fusion", "tex_sphere")
.part(
ModelPart::new("Sphere")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)))
}
3 => {
// Model - use model URL if available, fallback to cube
if !node.model_url.is_empty() {
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
// TODO: Implement model loading and caching
Model::namespaced("fusion", "gyro")
.transform(transform)
.part(
ModelPart::new("Gem")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
} else {
eprintln!("[bridge/reify] Creating fallback cube for node {} (no model URL)", id);
Model::namespaced("fusion", "tex_cube")
.transform(transform)
.part(
ModelPart::new("Cube")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
}
eprintln!("[bridge/reify] Creating gyro model for node {}", id);
// For now, use a fallback model since we can't load arbitrary URLs yet
// TODO: Implement model loading and caching
Some((*id, Spatial::default()
.transform(transform)
.build()
.child(
Model::namespaced("fusion", "gyro")
.part(
ModelPart::new("Gem")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)))
}
_ => {
// Unknown or unsupported type - render as wireframe
eprintln!("[bridge/reify] Creating wireframe for node {} type={}", id, node.entity_type);
let cube_lines = create_wireframe_cube(node_color, 0.003);
Spatial::default()
Some((*id, Spatial::default()
.transform(transform)
.build()
.child(Lines::new(cube_lines).build())
.child(Lines::new(cube_lines).build())))
}
};
Some((*id, element))
}
});
PlaySpace.build().stable_children(children)