fix: refactor node creation in reify to use Spatial wrapper for entity types

This commit is contained in:
MayaTheShy
2025-11-08 22:08:57 -05:00
parent c570e5e04a
commit 0da205b080

View File

@@ -120,27 +120,35 @@ impl Reify for BridgeState {
let scale_array = [vis_scale.x, vis_scale.y, vis_scale.z]; 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); let transform = stardust_xr_fusion::spatial::Transform::from_translation_rotation_scale(trans_array, rot_array, scale_array);
// Create appropriate visual based on entity type // Create appropriate visual based on entity type - wrap all in Spatial for type consistency
let element: ast::ElementWrapper<_, _, ()> = match node.entity_type { let element = 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);
Model::namespaced("fusion", "tex_cube") Spatial::default()
.transform(transform) .transform(transform)
.part( .build()
ModelPart::new("Cube") .child(
.mat_param("color", MaterialParameter::Color(node_color)) Model::namespaced("fusion", "tex_cube")
).build() .part(
ModelPart::new("Cube")
.mat_param("color", MaterialParameter::Color(node_color))
).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);
Model::namespaced("fusion", "tex_sphere") Spatial::default()
.transform(transform) .transform(transform)
.part( .build()
ModelPart::new("Sphere") .child(
.mat_param("color", MaterialParameter::Color(node_color)) Model::namespaced("fusion", "tex_sphere")
).build() .part(
ModelPart::new("Sphere")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)
} }
3 => { 3 => {
// Model - use model URL if available, fallback to cube // Model - use model URL if available, fallback to cube
@@ -148,20 +156,28 @@ impl Reify for BridgeState {
eprintln!("[bridge/reify] Creating model from URL for node {}: {}", id, node.model_url); 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
Model::namespaced("fusion", "gyro") Spatial::default()
.transform(transform) .transform(transform)
.part( .build()
ModelPart::new("Gem") .child(
.mat_param("color", MaterialParameter::Color(node_color)) Model::namespaced("fusion", "gyro")
).build() .part(
ModelPart::new("Gem")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)
} else { } else {
eprintln!("[bridge/reify] Creating fallback cube for node {} (no model URL)", id); eprintln!("[bridge/reify] Creating fallback cube for node {} (no model URL)", id);
Model::namespaced("fusion", "tex_cube") Spatial::default()
.transform(transform) .transform(transform)
.part( .build()
ModelPart::new("Cube") .child(
.mat_param("color", MaterialParameter::Color(node_color)) Model::namespaced("fusion", "tex_cube")
).build() .part(
ModelPart::new("Cube")
.mat_param("color", MaterialParameter::Color(node_color))
).build()
)
} }
} }
_ => { _ => {