Add support for text entities in model reification and improve logging

This commit is contained in:
MayaTheShy
2025-11-16 21:50:50 -05:00
parent ad3f079ccf
commit e4519fa47d

View File

@@ -155,6 +155,7 @@ impl Reify for BridgeState {
1 => "cube", 1 => "cube",
2 => "sphere", 2 => "sphere",
3 => "3D model", 3 => "3D model",
4 => "text",
_ => "unknown" _ => "unknown"
}; };
@@ -164,32 +165,40 @@ impl Reify for BridgeState {
format!("primitive from {}", model_path.display()) format!("primitive from {}", model_path.display())
}; };
eprintln!("[bridge/reify] Loading {} for node {} {}", eprintln!("[bridge/reify] Loading {} for node {} {}", entity_type_name, id, model_source);
entity_type_name, id, model_source);
match Model::direct(&model_path) { match node.entity_type {
Ok(mut model) => { 4 => {
// Asteroids Model now supports material color tinting. // Text entity: use node.name as text for now
if node.color != [1.0, 1.0, 1.0, 1.0] { let text = ast::elements::Text::new(&node.name)
let color = ast::elements::RgbaLinear::new( .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] node.color[0], node.color[1], node.color[2], node.color[3]
); ));
model = model.color_tint(color); Some(text.build())
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())
} }
Err(e) => { _ => {
eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e); match Model::direct(&model_path) {
None 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 { } else {