Render browser: scene tree with Environment, Lights, Shots and Objects rows, resolved appearances and a Browser selection (#6427)

This commit is contained in:
Nathan Dane
2026-10-28 09:58:57 +00:00
committed by GitHub
parent 54f613e4dd
commit 0b2efd60b9
24 changed files with 2356 additions and 309 deletions
+40
View File
@@ -83,6 +83,8 @@ pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("select.filter", "Selection filter", select_filter).icon("select").noundo().doc_only()
.params("mode: body|face|component → validated UI pick granularity; headless echo only, no document edits or undo"),
CommandSpec::new("select.clear", "Clear Selection", select_clear).icon("select").noundo(),
CommandSpec::new("select.same_look", "Select Same Look", select_same_look).icon("select").noundo().doc_only()
.params("body?: world body name, face?: face index; defaults to the current body/face selection → selects objects using the resolved appearance"),
];
fn undo(s: &mut Session, _p: &Value) -> Result<Value> {
@@ -1214,6 +1216,44 @@ fn select_filter(_s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"mode": request.mode}))
}
fn select_same_look(s: &mut Session, p: &Value) -> Result<Value> {
#[derive(serde::Deserialize)]
#[serde(deny_unknown_fields)]
struct Request {
body: Option<String>,
face: Option<usize>,
}
let request: Request = serde_json::from_value(p.clone()).map_err(|e| bad("select.same_look", e.to_string()))?;
let selected = s.selection.last();
let name = request
.body
.as_deref()
.or(match selected {
Some(Sel::Body { name }) => Some(name.as_str()),
Some(Sel::Face { body, .. }) => Some(body.as_str()),
_ => None,
})
.ok_or_else(|| bad("select.same_look", "select an object or face"))?;
let state = s.world_state();
let body = state.body(name).ok_or_else(|| bad("select.same_look", "unknown object"))?;
let face = request.face.or(match selected {
Some(Sel::Face { body, index, .. }) if request.body.is_none() && body == name => Some(*index),
_ => None,
});
if let Some(face) = face
&& face >= body.body.face_count()
{
return Err(bad("select.same_look", "unknown face"));
}
let look = face.map_or_else(|| s.doc.model_display_look(body), |face| s.doc.model_face_look(body, face));
let items: Vec<_> =
state.bodies.iter().filter(|b| s.doc.model_used_looks(b).contains(&look)).take(10_001).map(|b| Sel::Body { name: b.name.clone() }).collect();
if items.len() > 10_000 {
return Err(bad("select.same_look", "too many objects"));
}
select_set(s, &json!({"items":items}))
}
fn select_clear(s: &mut Session, _p: &Value) -> Result<Value> {
s.selection.clear();
s.revision += 1;