Add support for text entities in model reification and improve logging
This commit is contained in:
@@ -155,41 +155,50 @@ impl Reify for BridgeState {
|
|||||||
1 => "cube",
|
1 => "cube",
|
||||||
2 => "sphere",
|
2 => "sphere",
|
||||||
3 => "3D model",
|
3 => "3D model",
|
||||||
|
4 => "text",
|
||||||
_ => "unknown"
|
_ => "unknown"
|
||||||
};
|
};
|
||||||
|
|
||||||
let model_source = if !node.model_url.is_empty() {
|
let model_source = if !node.model_url.is_empty() {
|
||||||
format!("from URL: {}", node.model_url)
|
format!("from URL: {}", node.model_url)
|
||||||
} else {
|
} else {
|
||||||
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 node.entity_type {
|
||||||
match Model::direct(&model_path) {
|
4 => {
|
||||||
Ok(mut model) => {
|
// Text entity: use node.name as text for now
|
||||||
// Asteroids Model now supports material color tinting.
|
let text = ast::elements::Text::new(&node.name)
|
||||||
if node.color != [1.0, 1.0, 1.0, 1.0] {
|
.character_height(node.dimensions[1].max(0.01))
|
||||||
let color = ast::elements::RgbaLinear::new(
|
.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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user