diff --git a/bridge/src/lib.rs b/bridge/src/lib.rs index 40c6a65..7b90f27 100644 --- a/bridge/src/lib.rs +++ b/bridge/src/lib.rs @@ -155,41 +155,50 @@ impl Reify for BridgeState { 1 => "cube", 2 => "sphere", 3 => "3D model", + 4 => "text", _ => "unknown" }; - + let model_source = if !node.model_url.is_empty() { format!("from URL: {}", node.model_url) } else { format!("primitive from {}", model_path.display()) }; - - eprintln!("[bridge/reify] Loading {} for node {} {}", - entity_type_name, id, model_source); - - match Model::direct(&model_path) { - Ok(mut model) => { - // Asteroids Model now supports material color tinting. - if node.color != [1.0, 1.0, 1.0, 1.0] { - let color = ast::elements::RgbaLinear::new( + + eprintln!("[bridge/reify] Loading {} for node {} {}", entity_type_name, id, model_source); + + match node.entity_type { + 4 => { + // Text entity: use node.name as text for now + let text = ast::elements::Text::new(&node.name) + .character_height(node.dimensions[1].max(0.01)) + .color(ast::elements::RgbaLinear::new( node.color[0], node.color[1], node.color[2], node.color[3] - ); - model = model.color_tint(color); - eprintln!("[bridge/reify] Node {}: applied color tint RGBA({:.2}, {:.2}, {:.2}, {:.2})", - id, node.color[0], node.color[1], node.color[2], node.color[3]); - } - - // TODO: Apply texture from texture_url (pending API) - if !node.texture_url.is_empty() { - eprintln!("[bridge/reify] Node {} has texture URL: {} - NOT YET APPLIED (API limitation)", - id, node.texture_url); - } - - Some(model.build()) + )); + Some(text.build()) } - Err(e) => { - eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e); - None + _ => { + match Model::direct(&model_path) { + Ok(mut model) => { + if node.color != [1.0, 1.0, 1.0, 1.0] { + let color = ast::elements::RgbaLinear::new( + node.color[0], node.color[1], node.color[2], node.color[3] + ); + model = model.color_tint(color); + eprintln!("[bridge/reify] Node {}: applied color tint RGBA({:.2}, {:.2}, {:.2}, {:.2})", + id, node.color[0], node.color[1], node.color[2], node.color[3]); + } + if !node.texture_url.is_empty() { + eprintln!("[bridge/reify] Node {} has texture URL: {} - NOT YET APPLIED (API limitation)", + id, node.texture_url); + } + Some(model.build()) + } + Err(e) => { + eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e); + None + } + } } } } else {