Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
MK21: planned detail held to the frame: lod 0 (the hero) to 4 (far) on a make object and on parts (Mesh3d, Model, a parent Entity or Group), measured as how much of the frame a part's box spans; a render's end checks, raea scene stage and raea check --quick say lod-closer when a shot shows a part finer than planned (a warning one level finer, an error two or more), raea scene lod lists every part's plan beside what the frames show, and raea make status holds a job at it (MK22-MK24; raea-runtime-lod-plan)
shinyobjectz6735bd940feb
diff --git a/Cargo.lock b/Cargo.lockindex b44a9820..4bdfa5f8 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -13896,6 +13896,7 @@ dependencies = ["raea-core-facts","raea-core-review","raea-io-home",+ "raea-runtime-lod-plan","resvg 0.48.1","serde_json",]@@ -13976,6 +13977,7 @@ dependencies = ["raea-core-scene","raea-runtime-bundle","raea-runtime-export",+ "raea-runtime-lod-plan","raea-sys-contact","raea-sys-light-meter","raea-sys-stage",@@ -15364,6 +15366,7 @@ version = "0.1.0"dependencies = ["raea-core-facts","raea-core-scene",+ "raea-runtime-lod-plan","raea-sys-contact","raea-sys-stage","serde_json",@@ -15504,6 +15507,18 @@ dependencies = ["winit",]+[[package]]+name = "raea-runtime-lod-plan"+version = "0.1.0"+dependencies = [+ "bevy",+ "dunce",+ "raea-core-facts",+ "raea-core-scene",+ "raea-sys-stage",+ "serde_json",+]+[[package]]name = "raea-runtime-look"version = "0.1.0"diff --git a/Cargo.toml b/Cargo.tomlindex cc82e319..c7f183ac 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -193,6 +193,7 @@ members = ["runtime/canvas","runtime/export","runtime/endchecks",+ "runtime/lod-plan","runtime/live","runtime/page","runtime/appscreen",diff --git a/apps/make/Cargo.toml b/apps/make/Cargo.tomlindex 01216bb0..49b604a0 100644--- a/apps/make/Cargo.toml+++ b/apps/make/Cargo.toml@@ -11,6 +11,8 @@ description = "raea make: a scene, kit or shot held to its frozen plan; what's mraea-core-brief = { path = "../../core/brief" }# the project's record of renders and checks, and the folder it lives inraea-core-facts = { path = "../../core/facts" }+# the parts a render showed closer than their planned detail (MK24)+raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }# the judge's rounds, passes and blocking defects, read as it keeps themraea-app-judge = { path = "../judge" }# the make questions, their calibrations and a sheet's ident, as raea ask keeps them (MK4)diff --git a/apps/make/src/floor.rs b/apps/make/src/floor.rsindex 72dd4f3f..829cd820 100644--- a/apps/make/src/floor.rs+++ b/apps/make/src/floor.rs@@ -85,7 +85,7 @@ pub fn floor_svg(m: &Make) -> Result<String, String> {fd * px / 2.0);s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#111\" text-anchor=\"middle\">{}</text>", sx(at[0]), sy(at[2]) - t * 0.25, t, esc(&o.label));- s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o));+ s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m{}</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o), o.lod.map(|l| format!(", LOD {l}")).unwrap_or_default());}s += &format!("<line x1=\"20\" y1=\"{0}\" x2=\"{1:.1}\" y2=\"{0}\" stroke=\"#111\" stroke-width=\"5\"/><text x=\"20\" y=\"{2:.0}\" font-size=\"{3:.0}\" fill=\"#111\">1 m</text>", h - 18, 20.0 + px, h as f64 - 26.0, t * 0.9);s += "</svg>";@@ -102,8 +102,10 @@ pub fn blockout_tsx(m: &Make) -> String {let h = height(o);let colour = if o.source == Some(Origin::Invented) { "#b4b0bd" } else { "#bdbdb8" };let a = -o.rot.unwrap_or(0.0).to_radians() / 2.0;+ let lod = o.lod.map(|l| format!(" lod={{{l}}}")).unwrap_or_default();boxes += &format!(- " <Mesh3d transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",+ " <Mesh3d name=\"{}\"{lod} transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",+ o.id,at[0],at[1] + h / 2.0,at[2],diff --git a/apps/make/src/status.rs b/apps/make/src/status.rsindex 5a8793bf..30f6e550 100644--- a/apps/make/src/status.rs+++ b/apps/make/src/status.rs@@ -136,6 +136,13 @@ fn checks(job: &Job) -> Vec<Value> {.collect()}+/// MK24: parts a composition's last render showed closer than planned, held until replanned or answered (raea-runtime-lod-plan)+fn lods(job: &Job, notes: &str) -> Vec<Value> {+ let plans = job.make.objects.iter().any(|o| o.lod.is_some());+ let last = |c: &String| job.record.iter().rev().find(|e| e.of == job.project.map(|p| raea_core_facts::record::rel(p, &job.dir.join(c))).unwrap_or_else(|| c.clone()));+ job.make.compositions.iter().filter_map(|c| last(c).and_then(|l| raea_runtime_lod_plan::gate(c, &l.id, &l.findings, notes, plans)).map(|(clear, says)| gate("lod", Some(c), clear, says))).collect()+}+/// Tier 3: a fresh critic has judged a round newer than the newest deliverable, and each blocking defect it named is/// fixed (the round passed) or answered in NOTES.md by its name. Its score gates once the judge is calibrated.fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {@@ -188,6 +195,7 @@ pub fn status(job: &Job) -> Value {missing.push(format!("NOTES.md with a \"{SKILL_HEADING}\" section (one line per thing that cost time; what the guide got wrong for this job)"));}let mut gates = checks(job);+ gates.extend(lods(job, ¬es));gates.extend(critic(job, newest, ¬es));let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, ¬es);gates.extend(asks);diff --git a/apps/make/src/tests.rs b/apps/make/src/tests.rsindex 23c6fa47..f33d0461 100644--- a/apps/make/src/tests.rs+++ b/apps/make/src/tests.rs@@ -134,6 +134,22 @@ fn a_composition_needs_a_clean_check_newer_than_it() {assert!(s["gates"].to_string().contains("changed since"), "{s:#}");}+// MK24: a part a render showed closer than planned holds the job until it's replanned or answered in the notes+#[test]+fn a_part_seen_closer_than_planned_holds_the_job() {+ let d = dir("lod");+ delivered(&d);+ put(&d, "scene.tsx", "x");+ let mut make = kit();+ make.compositions = vec!["scene.tsx".into()];+ let future = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() + 60;+ let entry: Entry = serde_json::from_value(json!({"id": "r1", "at": future, "by": "raea render", "of": "scene.tsx", "findings": [{"check": "lod-closer", "level": "warn", "about": [{"name": "kiosk"}], "says": "'kiosk' is planned at LOD 3", "by": "raea render"}]})).unwrap();+ let s = run(&make, &d, &[entry.clone()], &[round(true, 7.5, json!([]))], later());+ assert!(s["done"] == false && s["gates"].to_string().contains("seen closer than planned at r1: kiosk"), "{s:#}");+ put(&d, "NOTES.md", "- lod kiosk: one frame at the cut, left as a box\n## What the skill got wrong\n- nothing\n");+ assert_eq!(run(&make, &d, &[entry], &[round(true, 7.5, json!([]))], later())["done"], true);+}+#[test]fn a_scene_wants_three_stills() {let d = dir("scene");diff --git a/apps/make/src/tests_steps.rs b/apps/make/src/tests_steps.rsindex 9f915609..22df4240 100644--- a/apps/make/src/tests_steps.rs+++ b/apps/make/src/tests_steps.rs@@ -156,7 +156,7 @@ fn a_shot_frames_its_start_middle_and_end() {fn the_plan_draws_a_floor_plan_and_a_blockout() {let m: Make = read("make", r#"{"kind": "scene", "references": ["media/ref.png"], "objects": [{"id": "desk", "label": "Desk", "dims": [1.6, 0.8, 0.75], "at": [2, 0, 3], "rot": 90, "source": "reference", "hero": true},- {"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented"},+ {"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented", "lod": 3},{"id": "pen", "label": "Pen", "max": 0.14}]}"#).unwrap();let (placed, b) = crate::floor::extent(&m);@@ -172,6 +172,7 @@ fn the_plan_draws_a_floor_plan_and_a_blockout() {let t = crate::floor::blockout_tsx(&m);assert_eq!(t.matches("<Cuboid").count(), 3, "the floor and two boxes");assert!(t.contains("half_size={[0.800, 0.375, 0.400]}"), "{t}");+ assert!(t.contains("<Mesh3d name=\"plant\" lod={3} transform=") && svg.contains("1.20 m, LOD 3<"), "MK22, each box named with its planned detail: {t}");let none: Make = read("make", r#"{"kind": "scene", "objects": [{"id": "pen", "label": "Pen"}]}"#).unwrap();assert!(crate::floor::floor_svg(&none).unwrap_err().contains("no object has an `at`"));}diff --git a/apps/scene/Cargo.toml b/apps/scene/Cargo.tomlindex bd583f4a..d839e964 100644--- a/apps/scene/Cargo.toml+++ b/apps/scene/Cargo.toml@@ -4,7 +4,7 @@ version = "0.1.0"edition = "2024"license = "FSL-1.1-ALv2"publish = false-description = "raea scene lint|explain|light|stage: a composition's frames stepped without drawing and held to the contact, light and stage checks"+description = "raea scene lint|explain|light|stage|lod: a composition's frames stepped without drawing and held to the contact, light and stage checks"[dependencies]raea-runtime-bundle = { path = "../../runtime/bundle" }@@ -12,6 +12,8 @@ raea-runtime-export = { path = "../../runtime/export" }raea-sys-contact = { path = "../../systems/contact" }raea-sys-light-meter = { path = "../../systems/light-meter" }raea-sys-stage = { path = "../../systems/stage" }+# each part's planned detail beside how large the frames show it (MK21, MK23)+raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }# its results as Findings (docs/direction.feature DR3)raea-core-facts = { path = "../../core/facts" }# camera clearance (MK16): the parts, their models' triangles, and the camera's point in spacediff --git a/apps/scene/src/lib.rs b/apps/scene/src/lib.rsindex 602621a2..039e0fc3 100644--- a/apps/scene/src/lib.rs+++ b/apps/scene/src/lib.rs@@ -1,6 +1,7 @@-//! `raea scene lint|explain|light|stage`: a composition's frames stepped without drawing and handed to raea-sys-contact+//! `raea scene lint|explain|light|stage|lod`: a composition's frames stepped without drawing and handed to raea-sys-contact//! (what each part rests on, and parts that clip), raea-sys-light-meter (the light on a subject) and raea-sys-stage (3D-//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature).+//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature). `lod` is+//! each part's planned detail beside how large the frames show it (docs/make.feature MK23).use serde_json::json;@@ -10,9 +11,11 @@ use raea_runtime_export::{frame_of, items};// how near the camera passes to each solid part, every frame (`--clearance M`, MK16)pub mod clearance;mod light;+// each part's planned detail beside how large the frames show it (MK23)+pub mod lod;mod stage;-pub const USAGE: &str = "raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json]";+pub const USAGE: &str = "raea scene lint|explain|light|stage|lod EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json]";/// `raea scene lint|explain EDIT.tsx [--composition ID] [--frame N] [--json]`: the frame's parts measured/// (frame 0 by default). `lint` says the faults (errors fail it: floating, sunk, clipping; warnings: in the air,@@ -24,6 +27,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {match mode {"light" => return light::cli(args),"stage" => return stage::cli(args),+ "lod" => return lod::cli(args),"lint" | "explain" => {}_ => return Err(usage.into()),}diff --git a/apps/scene/src/lod.rs b/apps/scene/src/lod.rsnew file mode 100644index 00000000..e51fa985--- /dev/null+++ b/apps/scene/src/lod.rs@@ -0,0 +1,37 @@+//! `raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]` (docs/make.feature MK23): every part's+//! planned detail beside how large the frames show it. A part's plan is its own `lod` (0 the hero to 4 far), else its+//! name's on the job's plan (`lod` on brief.ts's make objects); what a frame shows is how much of it the part's box+//! spans (raea-runtime-lod-plan). The table lists the planned parts first, the ones seen closer than planned on top,+//! then the parts nobody planned by how large they get, so a part forgotten since the plan was written is found by+//! reading down it. A part seen two or more levels finer than planned fails it, as it fails a render.++use raea_core_facts::{Finding, Level, finding};+use raea_runtime_lod_plan::{ordered, table};+use serde_json::json;++pub(crate) fn cli(args: &[String]) -> Result<String, String> {+ let crate::stage::Stepped { items, nums, size: (w, h, fps), dir } = crate::stage::stepped(args, "raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]")?;+ let (first, last) = (nums[0], nums[nums.len() - 1]);+ let plan = raea_runtime_lod_plan::plan::lods(&dir);+ let mut unseen: Vec<String> = plan.keys().cloned().collect();+ let (seen, fs) = raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene lod", plan);+ let seen = ordered(seen);+ // a level the plan gives a name no part in these frames goes by holds nothing: said, so the part gets its name+ unseen.retain(|n| !seen.iter().any(|s| s.planned.is_some() && (s.name == *n || s.name.starts_with(&format!("{n} (lod ")))));+ unseen.sort();+ let text = if args.iter().any(|a| a == "--json") {+ let parts: Vec<_> = seen.iter().map(|s| json!({"part": s.name, "planned": s.planned, "seen": s.level(), "largest": s.finest.map(|f| f.1), "at": s.finest.map(|f| f.0), "frames": s.frames, "closer": s.closer})).collect();+ serde_json::to_string_pretty(&json!({"frames": [first, last], "parts": parts, "unseen": unseen, "findings": fs})).unwrap_or_default()+ } else {+ let levels = "levels, by how much of the frame a part spans: 0 hero 50%+, 1 featured 20%+, 2 dressing 8%+, 3 background 2%+, 4 far";+ let none = seen.iter().filter(|s| s.planned.is_none()).count();+ let missing = (!unseen.is_empty()).then(|| format!("planned in brief.ts, but no part of that name is in these frames (name the part as its object's id, or its plan holds nothing): {}", unseen.join(", ")));+ let sum = format!("frames {first} to {last}: {} parts, {none} with no plan; {}", seen.len(), finding::count(&fs));+ table(&seen).into_iter().chain(fs.iter().map(Finding::line)).chain(missing).chain([levels.to_string(), sum]).collect::<Vec<_>>().join("\n")+ };+ if fs.iter().any(|f| f.level == Level::Error) {+ println!("{text}");+ std::process::exit(1);+ }+ Ok(text)+}diff --git a/apps/scene/src/stage.rs b/apps/scene/src/stage.rsindex 1a124291..bd7888f8 100644--- a/apps/scene/src/stage.rs+++ b/apps/scene/src/stage.rs@@ -1,7 +1,7 @@//! `raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--json]`: every frame's scene stepped without//! drawing and held to the stage checks a render runs at its end (raea-sys-stage, docs/stage-guards.feature SG10-SG14)://! 3D type that can't be read, parts that snap, a camera that lurches or reverses, frames with nothing composed in-//! them. Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the+//! them, a part shown closer than its planned detail (MK21). Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the//! page holds waits for a render: its words over the parts (type-over-part), a Label's part as the shot's subject, and//! a frame its words or pictures fill, which reads empty here and is said as a warning, not failed (SG11).//! `--clearance M` holds the camera M metres off every solid part on every frame (0.45 for a carried camera, MK16).@@ -12,8 +12,16 @@ use raea_core_facts::{Level, finding};use raea_runtime_bundle::{bundle_composition, comp_opts, flag};use raea_runtime_export::{all_items, scene_frames_to};-pub(crate) fn cli(args: &[String]) -> Result<String, String> {- let usage = "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]";+/// A composition's frames stepped without drawing, for `stage` and `lod`: each frame's parts from --from to --to (every+/// frame before is still stepped), their numbers, the frame's size and rate, and the composition's folder.+pub(crate) struct Stepped {+ pub items: Vec<Vec<raea_core_scene::Item>>,+ pub nums: Vec<i64>,+ pub size: (u32, u32, f64),+ pub dir: std::path::PathBuf,+}++pub(crate) fn stepped(args: &[String], usage: &str) -> Result<Stepped, String> {let Some(edit) = args.get(2) else { return Err(usage.into()) };let tsx = dunce::canonicalize(&std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;let dir = tsx.parent().unwrap().to_path_buf();@@ -25,10 +33,19 @@ pub(crate) fn cli(args: &[String]) -> Result<String, String> {let _ = std::fs::remove_file(&js);let (frames, w, h, fps) = got?.ok_or("the composition has no 3D")?;let frames: Vec<_> = frames.into_iter().filter(|(f, _)| *f >= from && to.is_none_or(|t| *f <= t)).collect();- let (Some(first), Some(last)) = (frames.first().map(|f| f.0), frames.last().map(|f| f.0)) else { return Err(format!("no frames from {from}")) };- let nums: Vec<i64> = frames.iter().map(|(f, _)| *f).collect();- let items = all_items(&frames);+ if frames.is_empty() {+ return Err(format!("no frames from {from}"));+ }+ Ok(Stepped { nums: frames.iter().map(|(f, _)| *f).collect(), items: all_items(&frames), size: (w, h, fps), dir })+}++pub(crate) fn cli(args: &[String]) -> Result<String, String> {+ let Stepped { items, nums, size: (w, h, fps), dir } = stepped(args, "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]")?;+ let (first, last) = (nums[0], nums[nums.len() - 1]);let mut fs = raea_sys_stage::check(&items, &nums, w, h, fps, "raea scene stage");+ // and each part held to its planned detail (its own `lod`, or its name's on the plan above it: MK21), as a render does+ fs.extend(raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene stage", raea_runtime_lod_plan::plan::lods(&dir)).1.into_iter().filter(|f| f.check == "lod-closer"));+ fs = raea_core_facts::finding::ranked(fs);// the camera held off every solid part, when asked: the number after the flag, else a carried camera's 0.45 mif let Some(v) = flag(args, "--clearance") {let min = v.parse::<f32>().ok().filter(|m| *m >= 0.0).ok_or_else(|| format!("--clearance takes metres (0.45 for a carried camera), got {v:?}"))?;diff --git a/core/brief/src/make.rs b/core/brief/src/make.rsindex 45f8ef9b..bdc8bbdb 100644--- a/core/brief/src/make.rs+++ b/core/brief/src/make.rs@@ -150,6 +150,10 @@ pub struct Object {pub at: Option<[f64; 3]>,pub rot: Option<f64>,pub hero: Option<bool>,+ /// how large it is planned to be seen, which is how much of it gets built: 0 the hero (half the frame or more),+ /// 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box reads), 4 far (under 2%: a+ /// silhouette). A render that shows it finer than this says so (`lod-closer`; `raea scene lod` lists every part)+ pub lod: Option<u8>,pub pick: Option<Pick>,/// what was fixed by script ("glass made transmissive, label kept opaque")#[serde(default)]@@ -240,6 +244,9 @@ pub fn doctor(m: &Make) -> Vec<String> {if o.h.is_none() && o.dims.is_none() && o.max.is_none() {out.push(format!("object `{}` has no size: give `h` (metres), `dims` for boxy things or `max` for flat ones", o.id));}+ if o.lod.is_some_and(|l| l > 4) {+ out.push(format!("object `{}` has lod {}: 0 (the hero, half the frame or more) to 4 (far, under 2% of it)", o.id, o.lod.unwrap_or(0)));+ }if o.route.is_none() && m.kind == Kind::Scene {out.push(format!("object `{}` has no route: solid, rule, gen, library or picture", o.id));}diff --git a/core/brief/src/tests.rs b/core/brief/src/tests.rsindex 90116414..1d9d3b97 100644--- a/core/brief/src/tests.rs+++ b/core/brief/src/tests.rs@@ -117,6 +117,17 @@ fn a_make_plan_reads_and_its_doctor_names_what_it_lacks() {assert!(want.contains(&"out/kit/phone/phone_lod1.glb".to_string()) && want.contains(&"out/kit/kit.json".to_string()), "{want:?}");}+// MK22: an object's planned detail, 0 (the hero) to 4 (far)+#[test]+fn an_object_plans_its_detail_and_the_doctor_holds_it_to_five_levels() {+ let m: make::Make = read("make", r#"{"kind": "scene", "objects": [+ {"id": "kiosk", "label": "Kiosk", "h": 2.4, "route": "solid", "lod": 3},+ {"id": "tower", "label": "Tower", "h": 40, "route": "picture", "lod": 7}]}"#).unwrap();+ assert_eq!(m.objects[0].lod, Some(3));+ let d = make::doctor(&m);+ assert!(d.iter().any(|x| x.contains("`tower` has lod 7")) && !d.iter().any(|x| x.contains("`kiosk`")), "{d:?}");+}+#[test]fn a_shot_plan_wants_a_still_or_a_move_per_shot() {let m: make::Make = read("make", r#"{"kind": "shot", "shots": [{"name": "counter_push", "move": "push_in"}, {"name": "Bad Name"}]}"#).unwrap();diff --git a/docs/make.feature b/docs/make.featureindex f95fc781..84ac6b74 100644--- a/docs/make.feature+++ b/docs/make.feature@@ -24,6 +24,8 @@ Feature: Make: scenes, kits and shots built to a frozen plan and held to a revieonce each is calibrated on the person's labels; a fresh critic's fixes always (fixed or answered), its scoreonce `raea judge calibrate` agrees with the person's eye.5. Every job ends with its notes, including what the skill got wrong for it, so the next job starts from them.+ 6. Every object is planned at a level of detail, by how large it is meant to be seen, and every render says+ when a shot shows one closer than that (MK21-MK24).Background:Given raea's scene loop as advice (sdk/guides/craft/bevy/scenes.md, from the 11-06 research): brief, routing,@@ -194,6 +196,53 @@ Feature: Make: scenes, kits and shots built to a frozen plan and held to a revieplan from the entrance (blockout.tsx, and `raea render --review` sheets of it) and puts the reference, theblockout and the floor plan on comparison.png, for the person to approve before anything is generated+ Rule: planned detail (MK21-MK24)+ Shane, 2026-11-24: "define objects at an LOD level based on either us grayboxing or thinking of them as generally+ distant objects and alert agents when an LOD that was at 3 or 4 for example is now appearing in frame at LOD 2+ level or 1, or 0 ... helpful for planning objects as generally distant and unseen objects versus close ones and+ knowing if we forgot about something over time". A level is how large a part is planned to be seen, which is how+ much of it gets built; the frames are measured against it on every render, so a camera move added later, or a+ box that was meant to be replaced, is said the next time anything is drawn.++ Scenario: MK21. A part shown closer than its planned detail is said+ Given a level is how much of the frame a part's box spans through the frame's camera, the larger of its width's+ and its height's share: 0 the hero (50% or more), 1 featured (20%), 2 dressing (8%), 3 background (2%), 4 far+ And a part's plan is its own `lod` (Mesh3d, Model, and every part inside an Entity with a transform or a Group+ that has one), else the `lod` of the plan's object of its name+ When a frame shows a planned part at a finer level than its plan (raea-runtime-lod-plan)+ Then the render's end checks, `raea scene stage` and `raea check --quick` say `lod-closer`: the part, its plan,+ the level it is seen at, how much of the frame it spans at its largest and on which frame, how many frames it+ is closer on, and the fix (build it for that level and plan it there, or keep the camera off it)+ And one level finer is a warning, two or more an error, which fails the render as any error does+ And a part out of the frame, behind the camera, or with another mesh's box across every line to it isn't seen;+ a part the camera stands in or beside is measured at its nearest point; RAEA_LOD_CHECK=0 leaves the check out++ @needs:MK21+ Scenario: MK22. The plan carries each object's level+ Given `lod: 0..4` on an object of `make` in brief.ts (core/brief make.rs; `doctor` refuses a level past 4)+ Then a render of a composition under that brief holds the parts named as the objects' ids to those levels+ (runtime/lod-plan plan.rs reads the brief only when its words plan a level, once a version)+ And `raea make plan` labels each footprint with its level and writes each grey box with its object's id as its+ name and its `lod`, so the blockout is held to the plan it draws++ @needs:MK21+ Scenario: MK23. `raea scene lod`: every part's plan beside what the frames show+ When `raea scene lod EDIT.tsx [--from N] [--to N] [--json]` steps the frames without drawing+ Then it lists every part: its planned level, the finest level a frame shows it at, how much of the frame it+ spans there, on which frame, and how many frames it is in; parts seen closer than planned first (the widest+ gap on top), then the rest of the planned, then the parts with no plan by how large they get+ And a planned part no frame shows as close as its plan says so (built finer than it is ever seen)+ And a level the plan gives a name that no part in the frames goes by is listed, since it holds nothing+ And it exits 1 when a part is seen two or more levels finer than planned++ @needs:MK22+ Scenario: MK24. A job is held at a part seen closer than planned+ Given a job whose composition's last render or check found `lod-closer`+ Then `raea make status` has a `lod` gate for that composition, open with the parts' names, until each is built+ for the level it is seen at and replanned, kept out of the camera's way, or answered in NOTES.md on a line+ with `lod` and its name; the Stop hook holds the agent there as at any open gate+ And a job that plans a level and whose render found none shows the gate clear+Rule: raea cloud (MK19-MK20)@needs:MK2 @donediff --git a/docs/manual/reference/cli/index.md b/docs/manual/reference/cli/index.mdindex 0ba37b14..37eabb7a 100644--- a/docs/manual/reference/cli/index.md+++ b/docs/manual/reference/cli/index.md@@ -68,7 +68,7 @@ What's wrong before anyone watches it.| [`raea make`](make.md) | A scene, kit or shot made to its plan: the plan stop, the kit's references, generators, pick, prep and landing, a shot list's framing and lens charts, and whether it's done, decided in code; the agent's Stop hook holds it there. || [`raea fingerprint`](fingerprint.md) | A person's sense of good work, learned on this Mac: axes with small heads over on-device encoders that score a render moment by moment and say what they can't judge yet. || [`raea findings`](findings.md) | What each render and check found, read back from the project's record: fixed, new and carried since the one before. |-| [`raea scene`](scene.md) | Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, and hold every frame to the stage checks a render runs. |+| [`raea scene`](scene.md) | Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, hold every frame to the stage checks a render runs, and list each part's planned detail beside how large the frames show it. || [`raea light`](light.md) | Measure a scene's light on each light path against its path-traced reference: distance in stops, the worst tile, flicker and cost. || [`raea bench`](bench.md) | Each case on each denoiser against its converged truth: FLIP, RMSE, bias, flicker, blotches, lag after a disocclusion or a light going out, a frame's cost, and how many of MetalFX's numbers each meets. || [`raea world`](world.md) | A frame as one world: its layers, text, 3D parts, camera, shots, clips, cues and lines as entities, queried across media. |diff --git a/docs/manual/reference/cli/make.md b/docs/manual/reference/cli/make.mdindex accc646a..b645917b 100644--- a/docs/manual/reference/cli/make.md+++ b/docs/manual/reference/cli/make.md@@ -12,6 +12,11 @@ sources: ["apps/make/src/lib.rs", "apps/make/src/status.rs", "apps/make/src/askeand kit.json; a shot's still or move per shot), or the plan's own `deliverables`;- NOTES.md, ending with a "What the skill got wrong" section;- each composition the plan names has a render or check newer than it that found no error (the project's record);+- no part is seen closer than its planned detail. An object's `lod` (0 the hero to 4 far; the levels are in+ [raea scene](scene.md)) says how large it is planned to be seen, so a grey box or a far backdrop is planned at 3+ or 4. A render that shows it two levels finer is an error, held by the line above; one level finer holds the job+ until the part is built for that level and replanned, the camera keeps off it, or NOTES.md answers it on a line+ with `lod` and its name. `raea scene lod` lists every part;- a fresh critic (`raea judge --kind KIND`) has judged a round newer than the newest deliverable on the job's ownkind's rubric, and each blocking defect it named is fixed or answered in NOTES.md by its name; once the judge iscalibrated against your eye, two passes in a row as well;diff --git a/docs/manual/reference/cli/scene.md b/docs/manual/reference/cli/scene.mdindex 5f40212c..8414c8b4 100644--- a/docs/manual/reference/cli/scene.md+++ b/docs/manual/reference/cli/scene.md@@ -1,8 +1,8 @@---title: "raea scene"-summary: "Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, and hold every frame to the stage checks a render runs."+summary: "Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, hold every frame to the stage checks a render runs, and list each part's planned detail beside how large the frames show it."order: 47-sources: ["apps/scene/src/lib.rs", "apps/scene/src/light.rs", "apps/scene/src/stage.rs", "systems/stage/src/lib.rs", "systems/stage/src/clearance.rs", "systems/contact/src/lint.rs", "systems/contact/src/zfight.rs"]+sources: ["apps/scene/src/lib.rs", "apps/scene/src/light.rs", "apps/scene/src/stage.rs", "apps/scene/src/lod.rs", "runtime/lod-plan/src/lib.rs", "runtime/lod-plan/src/report.rs", "runtime/lod-plan/src/plan.rs", "systems/stage/src/lib.rs", "systems/stage/src/clearance.rs", "systems/contact/src/lint.rs", "systems/contact/src/zfight.rs"]---`raea scene` steps a composition's frames and measures its 3D scene without rendering pictures. `lint` reports@@ -21,6 +21,28 @@ also holds the camera M metres off every solid part on every frame (0.45 for a cpart it comes closer to, the frames and the nearest it gets, or that it's inside the part. Glass, decals, volumes andparts under 5 cm are passed over.+`lod` lists every part's planned detail beside what the frames show. A part's plan is how large it is meant to be+seen, which is how much of it gets built:++| lod | for | across the frame |+| --- | --- | --- |+| 0 | the hero | 50% or more |+| 1 | featured | 20% to 50% |+| 2 | set dressing | 8% to 20% |+| 3 | background: a grey box reads | 2% to 8% |+| 4 | far: a silhouette | under 2% |++The plan is the part's own `lod` prop (`<Mesh3d lod={3}>`, `<Model lod={4}>`, or a parent `<Entity transform lod>`+or `<Group lod>` for every part inside), else the `lod` of the object with the part's name in the job's plan (`make`+on the brief.ts above the composition). What a frame shows is how much of it the part's box spans through that+frame's camera, the larger of its width's and its height's share. The table puts parts seen closer than planned+first, then the rest of the planned parts, then the parts nobody planned by how large they get, so a part forgotten+since the plan was written is found by reading down it. Under it: each `lod-closer` finding, and any level the plan+gives a name that no part in the frames goes by. A part seen one level finer than planned is a warning; two or more+is an error, and `lod` exits 1. `raea render`, `raea scene stage` and `raea check --quick` say the same finding, and+`raea make status` holds a job at it. A part hidden behind other meshes isn't counted as seen; RAEA_LOD_CHECK=0+leaves the check out of a render.+```shraea scene lint room.tsxraea scene explain room.tsx --frame 90 --json@@ -28,6 +50,7 @@ raea scene light room.tsx --part heroraea scene light film.tsx --composition shot1,shot2,shot3 # the light across the cutsraea scene stage film.tsx --from 1800 --to 2400 # the stage checks on 20 s of itraea scene stage walk.tsx --clearance 0.45 # and the camera kept off the set+raea scene lod walk.tsx # every part's planned detail against the frames```<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->@@ -36,7 +59,7 @@ raea scene stage walk.tsx --clearance 0.45 # and the camera```shraea scene export EDIT.tsx -o DIR [--composition ID] [--frame N | --at A-B] (the composition's 3D as data other tools build: DIR/scene.json, each part placed (y up, metres) with its shape, material or light, and the camera; meshes/ and models/ beside it)-raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json] (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)+raea scene lint|explain|light|stage|lod EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json] (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)```Headless: it needs nothing running and opens no window. Takes up to 2 arguments besides its flags.@@ -49,10 +72,10 @@ Headless: it needs nothing running and opens no window. Takes up to 2 arguments| `--clearance` | `M` | `stage`: every run of frames where the camera is nearer a solid part than M metres (0.45 carried, 0.15 on a rig). || `--composition` | `ID` | Which composition to measure. `light` takes several, comma-separated, to compare the light across their cuts. || `--frame` | `N` | The frame to measure (0 by default; `light` also takes `last`). |-| `--from` | `N` | With `stage`: the first frame held to the checks (0 when left out). Every frame before it is still stepped, so a scene that builds over time is as it would render. |-| `--json` | – | Print as JSON: `lint` its findings (check, level, the parts they are about, frames, says, measure, fix), `explain` every part with its support, gap and box. |+| `--from` | `N` | With `stage` and `lod`: the first frame held to the checks (0 when left out). Every frame before it is still stepped, so a scene that builds over time is as it would render. |+| `--json` | – | Print as JSON: `lint` its findings (check, level, the parts they are about, frames, says, measure, fix), `explain` every part with its support, gap and box, `lod` every part's row (planned, seen, largest, at, frames, closer), the plan's names no part goes by, and its findings. || `--part` | `NAME` | With `light`: the part to meter, in place of the shot's subject. |-| `--to` | `N` | With `stage`: the last frame held to the checks (the composition's last when left out). |+| `--to` | `N` | With `stage` and `lod`: the last frame held to the checks (the composition's last when left out). || `-o` | `DIR` | `export`: the folder scene.json is written to, with meshes/ and models/ beside it. |<!-- generated:end -->diff --git a/docs/manual/reference/sdk/3d.md b/docs/manual/reference/sdk/3d.mdindex 9339220e..93a19151 100644--- a/docs/manual/reference/sdk/3d.md+++ b/docs/manual/reference/sdk/3d.md@@ -279,6 +279,7 @@ hand-written element.| `scale` | `Vec3 \| number` | one number, or x, y and z || `transform` | `{ translation?: Vec3; rotation?: [number, number, number, number]; scale?: Vec3 }` | Bevy's Transform (Transform.fromXyz(..).withRotation(..)), in place of position, rotation and scale: the entity is then a parent whose children (meshes, lights, models, other entities) move with it, as Bevy's ChildOf children do (the old Group) || `pass` | `string` | with `transform`: the composition pass of every part inside that doesn't name its own (Mesh's `pass`) |+| `lod` | `PlannedLod` | with `transform`: the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far) || `children` | `ReactNode` | its Bevy components (<BevyComponent>, or the generated wrappers in raea/bevy-own); with `transform`, also the parts it carries |Used in: [ui/widgets/viewport_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/widgets/viewport_node.tsx), [3d/3d_shapes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/3d_shapes.tsx), [3d/atmospheric_fog](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/atmospheric_fog.tsx), [3d/3d_scene](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/3d_scene.tsx), [3d/parenting](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/parenting.tsx), [stress_tests/many_foxes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/stress_tests/many_foxes.tsx), [camera/projection_zoom](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/camera/projection_zoom.tsx), [animation/animated_transform](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/animation/animated_transform.tsx), and 5 more.@@ -569,6 +570,7 @@ Bevy: `bevy_pbr::mesh_material::MeshMaterial3d<raea_render::engine::look::LookMa| `flat` | `boolean` | its surfaces without light: shape and colour alone, like a drawing (the site look keeps the light: its grain is made of it) || `shadow` | `boolean` | false: its meshes cast no shadow (true by default) || `detail` | `Detail` | where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) |+| `lod` | `PlannedLod` | its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer says so (`lod-closer`); a stand-in or a far backdrop is planned at 3 or 4 (PlannedLod) || `receiveShadow` | `boolean` | false: no shadow falls on its meshes, its own included (true by default): a furry coat of many cards that would otherwise speckle itself in the shadow maps || `pixelSize` | `number` | a cell's size in frame pixels for the pixel and site looks (6 by default) || `edgeColor` | `string` | the pixel look's one-cell outline, a hex colour ("#000000" by default), or "none" |diff --git a/docs/manual/reference/sdk/mesh.md b/docs/manual/reference/sdk/mesh.mdindex c9139802..e15ebcdb 100644--- a/docs/manual/reference/sdk/mesh.md+++ b/docs/manual/reference/sdk/mesh.md@@ -114,7 +114,7 @@ One part, so a curve that grows is solid at every frame (never a chain of parts:| `normal` | `Vec3` | the way its face looks: the normal of the plane it lies in (left out: the plane of its points, else +z) || `children` | `ReactNode` | its material (a white StandardMaterial when left out) |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).### `Mesh2d`@@ -139,7 +139,7 @@ shadow="only" draws it with the shadow-only material (engine/render shadow_only.| `detail` | `Detail` | where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) || `children` | `ReactNode` | its material and child entities |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).Used in: [ui/render_ui_to_texture](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/render_ui_to_texture.tsx), [ui/widgets/viewport_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/widgets/viewport_node.tsx), [3d/fog](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/fog.tsx), [3d/vertex_colors](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/vertex_colors.tsx), [3d/rotate_environment_map](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/rotate_environment_map.tsx), [3d/transparency_3d](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/transparency_3d.tsx), [3d/spherical_area_lights](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/spherical_area_lights.tsx), [3d/animated_material](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/animated_material.tsx), and 54 more.@@ -181,7 +181,7 @@ A line through points in 3D with a round section (a pipe, a wire): one mesh, dra| `radius` | `number` | its radius in metres (0.025) || `sides` | `number` | sides around its section (12) |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).## Functionsdiff --git a/runtime/endchecks/Cargo.toml b/runtime/endchecks/Cargo.tomlindex 1a604545..43e9239f 100644--- a/runtime/endchecks/Cargo.toml+++ b/runtime/endchecks/Cargo.toml@@ -11,4 +11,6 @@ raea-core-scene = { path = "../../core/scene" }raea-core-facts = { path = "../../core/facts" }raea-sys-contact = { path = "../../systems/contact" }raea-sys-stage = { path = "../../systems/stage" }+# each part held to its planned detail (MK21)+raea-runtime-lod-plan = { path = "../lod-plan" }serde_json = "1"diff --git a/runtime/endchecks/src/lib.rs b/runtime/endchecks/src/lib.rsindex 836ad13b..2090f9a7 100644--- a/runtime/endchecks/src/lib.rs+++ b/runtime/endchecks/src/lib.rs@@ -2,6 +2,11 @@//! clipping check (raea-sys-contact; RAEA_CLIP_CHECK=0 skips it), the staging (raea-sys-stage; RAEA_STAGE_CHECK=0) and//! the manifest's word on the parts (raea_sys_stage::Mounts) keep of them, and let go, so a long render never holds its//! frames' parts for its checks. raea-runtime-export hands each frame in as it's drawn, and a still's at its end.+//! With them, each part held to its planned detail (raea-runtime-lod-plan; RAEA_LOD_CHECK=0 skips it): its own `lod`, else+//! its name's on the plan above the composition (its plan.rs: `lod` on the brief's make objects, MK22).++// where a render's composition is, for the plan above it (MK22)+pub use raea_runtime_lod_plan::plan;use raea_core_facts::Finding;use raea_core_scene::Item;@@ -10,6 +15,7 @@ use serde_json::Value;pub struct EndChecks {clip: Option<raea_sys_contact::Clipping>,stage: Option<raea_sys_stage::Staging>,+ lod: Option<raea_runtime_lod_plan::Lods>,mounts: raea_sys_stage::Mounts,any: bool,parts: usize,@@ -19,7 +25,8 @@ impl EndChecks {pub fn new(w: u32, h: u32, fps: f64) -> EndChecks {let on = |k: &str| std::env::var(k).as_deref() != Ok("0");let (clip, stage) = (on("RAEA_CLIP_CHECK").then(|| raea_sys_contact::Clipping::new(w, h, fps)), on("RAEA_STAGE_CHECK").then(|| raea_sys_stage::Staging::new(w, h, fps)));- EndChecks { clip, stage, mounts: raea_sys_stage::Mounts::new(w, h), any: false, parts: 0 }+ let lod = on("RAEA_LOD_CHECK").then(|| raea_runtime_lod_plan::Lods::new(w, h, fps, plan::here(), false));+ EndChecks { clip, stage, lod, mounts: raea_sys_stage::Mounts::new(w, h), any: false, parts: 0 }}/// The next frame (its number, `frame`): its parts, and its page where the manifest has it.@@ -31,6 +38,9 @@ impl EndChecks {if let Some(s) = &mut self.stage {s.push(frame, its, page);}+ if let Some(l) = &mut self.lod {+ l.push(frame, its);+ }self.mounts.push(frame, its);}@@ -47,9 +57,39 @@ impl EndChecks {mark("end checks: clipping");found.extend(self.stage.map_or_else(Vec::new, raea_sys_stage::Staging::told));mark("end checks: staging");+ // parts shown closer than their planned detail, said as the staging's are+ let closer = self.lod.map_or_else(Vec::new, |l| l.findings(raea_sys_stage::BY));+ closer.iter().for_each(|f| eprintln!("raea: {}", f.line()));+ raea_core_facts::finding::said(&closer);+ found.extend(closer);// the clipping check's solids, kept for the process, aren't needed again by a renderraea_sys_contact::forget();mark("end checks: done, their solids let go");(found, Some(seen))}}++#[cfg(test)]+mod tests {+ use super::*;+ use serde_json::json;+ use std::sync::Arc;++ fn item(kind: &'static str, props: Value, shape: Option<&str>) -> Item {+ Item { kind, props: Arc::new(props.as_object().cloned().unwrap_or_default()), shape: shape.map(Arc::from), at: None, material: None, world: Default::default() }+ }++ // MK21: a render's end checks say a part shown closer than its planned detail, with its other findings+ #[test]+ fn a_render_says_a_part_shown_closer_than_its_planned_detail() {+ let frame = |z: f32, lod: u8| vec![item("camera", json!({"position": [0.0, 0.0, z], "lookAt": [0, 0, 0], "fov": 50}), None), item("mesh", json!({"name": "kiosk", "lod": lod}), Some("box(1, 1, 1)"))];+ let run = |z: f32, lod: u8| {+ let mut e = EndChecks::new(1280, 720, 30.0);+ e.push(0, &frame(z, lod), None);+ e.told(|_| {}).0.into_iter().filter(|f| f.check == "lod-closer").collect::<Vec<_>>()+ };+ let found = run(2.0, 4);+ assert_eq!((found.len(), found[0].level, found[0].by.as_str()), (1, raea_core_facts::Level::Error, "raea render"), "{found:?}");+ assert!(run(2.0, 0).is_empty() && run(80.0, 4).is_empty(), "a hero up close and a far part far away are as planned");+ }+}diff --git a/runtime/export/src/render.rs b/runtime/export/src/render.rsindex 94157e9f..1ad7ea35 100644--- a/runtime/export/src/render.rs+++ b/runtime/export/src/render.rs@@ -267,6 +267,8 @@ pub(crate) fn is_game(js: &Path) -> bool {}pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Option<Vec<i64>>, fed: bool, scene: Option<raea_core_program::ir::Program>, live3d: bool) -> R<String> {+ // the end checks hold the parts to the plan above this composition (`lod` on brief.ts's make objects, MK22)+ raea_runtime_endchecks::plan::at(dir);edit_dir(dir);raea_gpu_device::check::scene_black(Some(false));raea_runtime_react::native::rendering_in(dir);diff --git a/runtime/export/src/run.rs b/runtime/export/src/run.rsindex da92c026..dbea4958 100644--- a/runtime/export/src/run.rs+++ b/runtime/export/src/run.rs@@ -70,6 +70,7 @@ pub(crate) fn scene_program_to(js: &Path, dir: &Path, upto: i64) -> R<Option<rae/// A render's 3D rows as `scene_program_to` makes them, and the 3D parts that pass through each other on screen in/// `wanted` (one frame, a still; else all): said on stderr, and kept for the render's manifest (FED_CLIPPING).pub(crate) fn scene_program_checked(js: &Path, dir: &Path, upto: i64, wanted: Option<&[i64]>) -> R<Option<raea_core_program::ir::Program>> {+ raea_runtime_endchecks::plan::at(dir);// stills: the frames asked for looked at first, each on its own (frames are pure). When none of them shows 3D,// their render needs no rows, and a 2D piece's still skips stepping its whole timeline (an 80 s film's still took// 16 s here, all of it the rows' pass finding no 3D)diff --git a/runtime/lod-plan/Cargo.toml b/runtime/lod-plan/Cargo.tomlnew file mode 100644index 00000000..e6f8aaac--- /dev/null+++ b/runtime/lod-plan/Cargo.toml@@ -0,0 +1,18 @@+[package]+name = "raea-runtime-lod-plan"+version = "0.1.0"+edition = "2024"+license = "FSL-1.1-ALv2"+publish = false+description = "Planned detail held to the frame: a part planned as a grey box or as far away (lod 0 the hero to 4 far) that a shot shows closer than its plan, the levels a job's plan gives its objects, the gate a job is held at and raea scene lod's table (docs/make.feature MK21-MK24)"++[dependencies]+raea-core-scene = { path = "../../core/scene" }+# its results as Findings (docs/direction.feature DR3)+raea-core-facts = { path = "../../core/facts" }+# the frame's camera, a part's box and what stands in front of it+raea-sys-stage = { path = "../../systems/stage" }+# the brief above a composition, found as raea make finds it (MK22)+dunce = "1"+bevy = { version = "=0.20.0", default-features = false, features = ["std"] }+serde_json = "1"diff --git a/runtime/lod-plan/src/lib.rs b/runtime/lod-plan/src/lib.rsnew file mode 100644index 00000000..b8152c5d--- /dev/null+++ b/runtime/lod-plan/src/lib.rs@@ -0,0 +1,304 @@+//! raea-runtime-lod-plan (docs/make.feature MK21), planned detail held to the frame: a part planned as a grey box or as something far away (`lod` on the part,+//! or on its object in the plan, `make` on brief.ts) that a shot then shows closer than its plan. A plan's level is how+//! large the part is meant to be seen, 0 (the hero, half the frame or more) to 4 (far, under 2% of it); a frame's level+//! is how large the part's box is on screen through that frame's camera. A part seen finer than planned was built for+//! a distance the camera no longer keeps: a warning one level finer, an error two or more. It reads the scene, not the+//! pixels: a part behind others is passed over only when every line from the camera to it crosses another mesh's box+//! (a hollow shape's box hides more than the shape does, so a part behind one may be missed; one in the open never is).++use std::collections::{BTreeMap, HashMap};++use bevy::math::Vec3;+use raea_core_facts::{Finding, Level};+use raea_core_scene::base_ident;+use serde_json::Value;++use raea_core_scene::Item;+use raea_sys_stage::{View, called, corners, crossing, model_box, own_box, see_through};++// the levels a job's plan gives its objects (`lod` on brief.ts's make objects, MK22)+pub mod plan;+// the gate a job is held at, and the table `raea scene lod` prints+mod report;+pub use report::{gate, held, ordered, table};++/// The coarsest level: far, a silhouette.+pub const COARSEST: u8 = 4;+/// SPANS[k]: a part across this share of the frame or more (the larger of its width's and its height's) is seen at+/// level k; under the last it is at level 4. Unity's and Unreal's levels switch on the same measure, size on screen.+pub const SPANS: [f32; 4] = [0.5, 0.2, 0.08, 0.02];+/// What each level is for.+pub const NAMES: [&str; 5] = ["hero", "featured", "dressing", "background", "far"];++/// The level a part across `span` of the frame is seen at.+pub fn level(span: f32) -> u8 {+ SPANS.iter().position(|s| span >= *s).unwrap_or(SPANS.len()) as u8+}++/// A level in words: "LOD 3 (background, under 8% of the frame)".+pub fn words(l: u8) -> String {+ let l = l.min(COARSEST) as usize;+ let size = if l == 0 { format!("{:.0}% of the frame or more", SPANS[0] * 100.0) } else { format!("under {:.0}% of the frame", SPANS[l - 1] * 100.0) };+ format!("LOD {l} ({}, {size})", NAMES[l])+}++/// A part's planned level: its own `lod`, else its name's in the plan.+fn planned(it: &Item, plan: &HashMap<String, u8>) -> Option<u8> {+ let own = it.props.get("lod").and_then(Value::as_f64).filter(|l| *l >= 0.0).map(|l| (l as u8).min(COARSEST));+ own.or_else(|| plan.get(base_ident(it)).copied())+}++/// How much of the frame a part's box spans through `v` (the larger of its width's and its height's share, 1 at+/// most), and the box's corners; None when its size isn't known or none of it is in the frame.+fn span(it: &Item, v: &View, boxes: &mut HashMap<String, Option<(Vec3, Vec3)>>) -> Option<(f32, [Vec3; 8])> {+ let (lo, hi) = match it.kind {+ "mesh" => own_box(it, boxes)?,+ "model" => model_box(it, boxes)?,+ _ => return None,+ };+ let pts = corners(&it.world, lo, hi);+ if let Some(b) = v.bounds(pts) {+ return (v.share(b) > 0.0).then(|| (((b[2] - b[0]) / v.w).max((b[3] - b[1]) / v.h).min(1.0), pts));+ }+ // across the camera's plane: the camera is in it or beside it, so it is measured at its nearest point+ let near = it.world.transform_point3(it.world.inverse().transform_point3(v.eye).clamp(lo, hi));+ if near.distance(v.eye) < 1e-4 {+ return Some((1.0, pts));+ }+ let [x, y, depth] = v.project(near)?;+ (x >= 0.0 && x <= v.w && y >= 0.0 && y <= v.h).then(|| (((pts[7] - pts[0]).length() * v.focal / depth / v.h).min(1.0), pts))+}++/// Whether other parts stand between the camera and all of a part: its box's middle and eight points halfway out to+/// its corners, each behind a mesh's box the line passes right through (not one the camera or the point is inside: a+/// room round either hides nothing). Models never hide: a file's box is mostly air.+fn hidden(its: &[Item], me: usize, pts: &[Vec3; 8], eye: Vec3, boxes: &mut HashMap<String, Option<(Vec3, Vec3)>>) -> bool {+ let mid = pts.iter().copied().sum::<Vec3>() / 8.0;+ let targets: Vec<Vec3> = std::iter::once(mid).chain(pts.iter().map(|p| mid + (*p - mid) * 0.5)).collect();+ let mut others = Vec::new();+ for (j, it) in its.iter().enumerate() {+ if j == me || it.kind != "mesh" || it.at.is_some() || see_through(it) {+ continue;+ }+ if let Some((lo, hi)) = own_box(it, boxes) {+ others.push((it.world.inverse(), lo, hi));+ }+ }+ targets.iter().all(|p| others.iter().any(|(inv, lo, hi)| crossing(inv.transform_point3(eye), inv.transform_point3(*p), *lo, *hi).is_some_and(|(t0, t1)| t0 > 0.0 && t1 < 1.0)))+}++/// What the frames showed of one part.+#[derive(Debug, Clone, PartialEq)]+pub struct Seen {+ pub name: String,+ pub planned: Option<u8>,+ /// how many frames it was in+ pub frames: usize,+ /// where it was largest: the frame's number, and the share of the frame it spanned there+ pub finest: Option<(i64, f32)>,+ /// how many frames showed it finer than planned+ pub closer: usize,+}++impl Seen {+ /// The finest level it was seen at.+ pub fn level(&self) -> Option<u8> {+ self.finest.map(|(_, s)| level(s))+ }+}++#[derive(Default)]+struct Part {+ planned: Option<u8>,+ frames: usize,+ /// its largest: (frame, span)+ finest: Option<(i64, f32)>,+ /// the frames it was seen finer than planned: (frame, span)+ closer: Vec<(i64, f32)>,+}++/// Each frame as it comes: per part, how often it was in the frame, where it was largest, and the frames it was seen+/// finer than its plan. A render keeps only the parts with a plan; `every` keeps all (`raea scene lod`'s table).+pub struct Lods {+ plan: HashMap<String, u8>,+ every: bool,+ w: u32,+ h: u32,+ fps: f64,+ boxes: HashMap<String, Option<(Vec3, Vec3)>>,+ parts: BTreeMap<String, Part>,+}++impl Lods {+ /// For frames w x h at `fps`. `plan` is the levels the job's plan gives its objects, by name (`lod` on brief.ts's+ /// make objects); a part's own `lod` comes first.+ pub fn new(w: u32, h: u32, fps: f64, plan: HashMap<String, u8>, every: bool) -> Lods {+ Lods { plan, every, w, h, fps: fps.max(1.0), boxes: HashMap::new(), parts: BTreeMap::new() }+ }++ /// The next frame's parts, through its camera.+ pub fn push(&mut self, frame: i64, its: &[Item]) {+ if self.plan.is_empty() && !self.every && !its.iter().any(|it| it.props.contains_key("lod")) {+ return;+ }+ let Some(v) = View::of(its, self.w, self.h) else { return };+ for (j, it) in its.iter().enumerate() {+ if !matches!(it.kind, "mesh" | "model") || it.at.is_some() {+ continue;+ }+ let plan = planned(it, &self.plan);+ if plan.is_none() && !self.every {+ continue;+ }+ let Some((s, pts)) = span(it, &v, &mut self.boxes) else { continue };+ let closer = plan.is_some_and(|p| level(s) < p);+ if closer && hidden(its, j, &pts, v.eye, &mut self.boxes) {+ continue;+ }+ // parts of one name planned apart (two crates, one a hero) are told apart+ let mut name = called(it);+ if self.parts.get(&name).is_some_and(|p| p.planned != plan) {+ name = format!("{name} (lod {})", plan.map_or("none".into(), |p| p.to_string()));+ }+ let part = self.parts.entry(name).or_default();+ part.planned = plan;+ part.frames += 1;+ if part.finest.is_none_or(|(_, best)| s > best) {+ part.finest = Some((frame, s));+ }+ if closer {+ part.closer.push((frame, s));+ }+ }+ }++ /// What the frames showed of each part, by name.+ pub fn seen(&self) -> Vec<Seen> {+ self.parts.iter().map(|(name, p)| Seen { name: name.clone(), planned: p.planned, frames: p.frames, finest: p.finest, closer: p.closer.len() }).collect()+ }++ /// One finding a part seen finer than planned, worst first: where it was largest, and for how long.+ pub fn findings(&self, by: &str) -> Vec<Finding> {+ let mut out = Vec::new();+ for (name, p) in &self.parts {+ let (Some(plan), Some(&(first, _)), Some(&(last, _))) = (p.planned, p.closer.first(), p.closer.last()) else { continue };+ let Some(&(at, s)) = p.closer.iter().max_by(|a, b| a.1.total_cmp(&b.1)) else { continue };+ let seen = level(s);+ let lasts = if p.closer.len() == 1 { "on one frame".to_string() } else { format!("on {} frames ({:.1} s)", p.closer.len(), p.closer.len() as f64 / self.fps) };+ let says = format!("'{name}' is planned at {} and is seen at {}: across {:.0}% of the frame at frame {at}, closer than planned {lasts}", words(plan), words(seen), s * 100.0);+ let fix = format!("build it for LOD {seen} and plan it there (lod={{{seen}}} on the part, or `lod: {seen}` on its object in brief.ts), or keep the camera off it");+ let level = if plan - seen >= 2 { Level::Error } else { Level::Warn };+ out.push(Finding::new("lod-closer", level, says, by).frames(first, last + 1).about(name.clone(), None).measure("span", (s * 100.0) as f64, "% of the frame", Some((SPANS[plan as usize - 1] * 100.0) as f64)).fix(fix));+ }+ raea_core_facts::finding::ranked(out)+ }+}++/// Every part of the frames against its planned detail (`all[k]` is frame `frames[k]`'s parts): each part's row, and a+/// finding a part seen finer than planned.+pub fn lods(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64, by: &str, plan: HashMap<String, u8>) -> (Vec<Seen>, Vec<Finding>) {+ let mut l = Lods::new(w, h, fps, plan, true);+ for (k, its) in all.iter().enumerate() {+ l.push(frames[k], its);+ }+ (l.seen(), l.findings(by))+}++#[cfg(test)]+mod tests {+ use super::*;+ use bevy::math::Mat4;+ use serde_json::json;+ use std::sync::Arc;++ fn item(kind: &'static str, props: Value, world: Mat4) -> Item {+ Item { kind, props: Arc::new(props.as_object().cloned().unwrap_or_default()), shape: None, at: None, material: None, world }+ }++ /// A camera at `eye` looking at `at`, 50 degrees.+ fn cam(eye: [f32; 3], at: [f32; 3]) -> Item {+ item("camera", json!({"position": eye, "lookAt": at, "fov": 50}), Mat4::IDENTITY)+ }++ /// a 1 m cube at `at`, with these props+ fn cube(props: Value, at: [f32; 3]) -> Item {+ let mut it = item("mesh", props, Mat4::from_translation(Vec3::from(at)));+ it.shape = Some(Arc::from("box(1, 1, 1)"));+ it+ }++ fn run(frames: Vec<Vec<Item>>, plan: &[(&str, u8)]) -> (Vec<Seen>, Vec<Finding>) {+ let nums: Vec<i64> = (0..frames.len() as i64).collect();+ lods(&frames, &nums, 1920, 1080, 30.0, "test", plan.iter().map(|(n, l)| (n.to_string(), *l)).collect())+ }++ #[test]+ fn a_level_is_how_much_of_the_frame_a_part_spans() {+ assert_eq!([0.9, 0.5, 0.3, 0.1, 0.05, 0.01].map(level), [0, 0, 1, 2, 3, 4]);+ assert_eq!(words(3), "LOD 3 (background, under 8% of the frame)");+ assert_eq!(words(0), "LOD 0 (hero, 50% of the frame or more)");+ }++ #[test]+ fn a_far_part_the_camera_comes_up_to_is_said_with_where_and_how_close() {+ // planned far (4); the camera dollies from 60 m to 2 m+ let frames: Vec<Vec<Item>> = [60.0, 30.0, 8.0, 2.0].iter().map(|z| vec![cam([0.0, 0.0, *z], [0.0, 0.0, 0.0]), cube(json!({"name": "crate", "lod": 4}), [0.0, 0.0, 0.0])]).collect();+ let (seen, found) = run(frames, &[]);+ assert_eq!((seen[0].planned, seen[0].level(), seen[0].closer), (Some(4), Some(0), 3), "{seen:?}");+ assert_eq!(seen[0].finest.map(|f| f.0), Some(3));+ let f = &found[0];+ assert_eq!((f.check.as_str(), f.level, f.frames), ("lod-closer", Level::Error, Some([1, 4])), "{f:?}");+ assert!(f.says.starts_with("'crate' is planned at LOD 4 (far, under 2% of the frame) and is seen at LOD 0 (hero") && f.says.contains("at frame 3, closer than planned on 3 frames (0.1 s)"), "{}", f.says);+ assert!(f.fix.as_deref().unwrap().contains("lod={0}"), "{:?}", f.fix);+ }++ #[test]+ fn one_level_finer_warns_and_a_part_at_its_plan_says_nothing() {+ // a 1 m cube 5 m off a 50 degree lens is about 23% of the frame's height: level 1+ let scene = |lod: u8| vec![vec![cam([0.0, 0.0, 5.5], [0.0, 0.0, 0.0]), cube(json!({"name": "crate", "lod": lod}), [0.0, 0.0, 0.0])]];+ assert!(run(scene(1), &[]).1.is_empty() && run(scene(0), &[]).1.is_empty());+ assert_eq!(run(scene(2), &[]).1[0].level, Level::Warn);+ assert_eq!(run(scene(3), &[]).1[0].level, Level::Error);+ }++ #[test]+ fn the_plan_names_a_part_and_its_own_lod_wins() {+ let scene = |props: Value| vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), cube(props, [0.0, 0.0, 0.0])]];+ let (seen, found) = run(scene(json!({"name": "kiosk"})), &[("kiosk", 3)]);+ assert_eq!((seen[0].planned, found.len()), (Some(3), 1));+ assert!(run(scene(json!({"name": "kiosk", "lod": 0})), &[("kiosk", 3)]).1.is_empty(), "the part's own level is the newer word");+ // a part with no plan is never a finding; the table still has its row, and a render doesn't keep it+ let (seen, found) = run(scene(json!({"name": "other"})), &[("kiosk", 3)]);+ assert_eq!((seen[0].planned, seen[0].level(), found.len()), (None, Some(1), 0));+ let mut l = Lods::new(1920, 1080, 30.0, HashMap::from([("kiosk".to_string(), 3)]), false);+ l.push(0, &scene(json!({"name": "other"}))[0]);+ assert!(l.seen().is_empty());+ }++ #[test]+ fn a_part_out_of_frame_behind_the_camera_or_behind_a_wall_is_not_seen() {+ let far = |at: [f32; 3]| cube(json!({"name": "crate", "lod": 4}), at);+ // beside the frame, and behind the camera+ assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([40.0, 0.0, 0.0])]], &[]).1.is_empty());+ assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 9.0])]], &[]).1.is_empty());+ // a wall wider than it between the two hides it; a post narrower than it doesn't+ let mut wall = cube(json!({"name": "wall"}), [0.0, 0.0, 1.5]);+ wall.world = Mat4::from_translation(Vec3::new(0.0, 0.0, 1.5)) * Mat4::from_scale(Vec3::new(6.0, 6.0, 0.2));+ assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), wall.clone()]], &[]).1.is_empty());+ wall.world = Mat4::from_translation(Vec3::new(0.0, 0.0, 1.5)) * Mat4::from_scale(Vec3::new(0.1, 6.0, 0.1));+ assert_eq!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), wall]], &[]).1.len(), 1);+ // a room round both hides nothing+ let mut room = cube(json!({"name": "room"}), [0.0, 0.0, 0.0]);+ room.world = Mat4::from_scale(Vec3::splat(20.0));+ assert_eq!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), room]], &[]).1.len(), 1);+ }++ #[test]+ fn a_camera_inside_or_beside_a_part_sees_it_at_its_nearest() {+ // a 30 m hall the camera stands in, planned as background+ let mut hall = cube(json!({"name": "hall", "lod": 3}), [0.0, 0.0, 0.0]);+ hall.world = Mat4::from_scale(Vec3::new(30.0, 4.0, 30.0));+ let (seen, found) = run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), hall]], &[]);+ assert_eq!((seen[0].level(), found[0].level), (Some(0), Level::Error));+ }+}diff --git a/runtime/lod-plan/src/plan.rs b/runtime/lod-plan/src/plan.rsnew file mode 100644index 00000000..9e426472--- /dev/null+++ b/runtime/lod-plan/src/plan.rs@@ -0,0 +1,97 @@+//! The levels a job's plan gives its objects (docs/make.feature MK22): `lod` on the objects of `make` in the brief.ts+//! at or above a composition, inside its raea project. Read only when the brief's words hold a `lod` at all, since+//! reading it runs the module (`raea spec brief.ts --as brief`, a child process: this crate carries no TS engine);+//! read once a brief's version a process. A brief that doesn't load plans nothing: a render never fails on it.++use std::collections::HashMap;+use std::path::{Path, PathBuf};+use std::sync::Mutex;+use std::time::SystemTime;++use serde_json::Value;++/// The composition's folder the next end checks plan from (`at`), and the last brief read: its path, when it last+/// changed, and its levels.+static DIR: Mutex<Option<PathBuf>> = Mutex::new(None);+static READ: Mutex<Option<(PathBuf, Option<SystemTime>, HashMap<String, u8>)>> = Mutex::new(None);++/// Where the render's composition is: its end checks hold its parts to the plan above it.+pub fn at(dir: &Path) {+ let _ = DIR.lock().map(|mut d| d.replace(dir.to_path_buf()));+}++/// The plan's levels for the composition `at` named, none when no render said where it is.+pub fn here() -> HashMap<String, u8> {+ let dir = DIR.lock().unwrap().clone();+ dir.map(|d| lods(&d)).unwrap_or_default()+}++/// The brief.ts at or above `dir` in its project whose words plan a level.+fn brief(dir: &Path) -> Option<PathBuf> {+ let dir = dunce::canonicalize(dir).ok()?;+ let project = raea_core_facts::record::up(&dir, ".raea/project");+ for d in dir.ancestors() {+ let p = d.join("brief.ts");+ if p.is_file() {+ return std::fs::read_to_string(&p).is_ok_and(|t| t.contains("lod")).then_some(p);+ }+ if project.as_deref() == Some(d) {+ break;+ }+ }+ None+}++/// The levels in a brief as `raea spec --as brief` prints it: each of make's objects with a `lod`, by its id.+pub fn of_brief(v: &Value) -> HashMap<String, u8> {+ let b = v.get("brief").unwrap_or(v);+ let objects = b["make"]["objects"].as_array().into_iter().flatten();+ objects.filter_map(|o| Some((o["id"].as_str()?.to_string(), o["lod"].as_u64()?.min(crate::COARSEST as u64) as u8))).collect()+}++/// The plan's levels for a composition in `dir`: object id to level, empty when no brief above it plans any.+pub fn lods(dir: &Path) -> HashMap<String, u8> {+ let Some(brief) = brief(dir) else { return HashMap::new() };+ let changed = std::fs::metadata(&brief).and_then(|m| m.modified()).ok();+ if let Some((p, at, plan)) = READ.lock().unwrap().as_ref() {+ if *p == brief && *at == changed {+ return plan.clone();+ }+ }+ let read = || {+ let out = std::process::Command::new(std::env::current_exe().ok()?).arg("spec").arg(&brief).args(["--as", "brief"]).env("RAEA_RECORD", "off").output().ok()?;+ let text = String::from_utf8_lossy(&out.stdout);+ Some(of_brief(&serde_json::from_str(&text[text.find('{')?..]).ok()?))+ };+ let plan = read().unwrap_or_default();+ *READ.lock().unwrap() = Some((brief, changed, plan.clone()));+ plan+}++#[cfg(test)]+mod tests {+ use super::*;+ use serde_json::json;++ #[test]+ fn a_briefs_objects_with_a_level_are_the_plan() {+ let v = json!({"brief": {"make": {"kind": "scene", "objects": [{"id": "kiosk", "lod": 3}, {"id": "desk"}, {"id": "sign", "lod": 9}]}}});+ let plan = of_brief(&v);+ assert_eq!((plan.len(), plan["kiosk"], plan["sign"]), (2, 3, 4));+ assert!(of_brief(&json!({"title": "no job"})).is_empty());+ // as `raea spec brief.ts --as brief` prints it: the brief itself, every field given, a level left out null+ let printed = json!({"title": "Kiosk square", "make": {"kind": "scene", "objects": [{"id": "kiosk", "lod": 3, "hero": null}, {"id": "desk", "lod": null}]}});+ assert_eq!(of_brief(&printed), HashMap::from([("kiosk".to_string(), 3)]));+ }++ #[test]+ fn a_folder_with_no_brief_planning_a_level_plans_nothing() {+ let d = std::env::temp_dir().join(format!("raea-lod-plan-{}", std::process::id()));+ std::fs::create_dir_all(d.join(".raea")).unwrap();+ std::fs::write(d.join(".raea/project"), "").unwrap();+ assert!(lods(&d).is_empty());+ std::fs::write(d.join("brief.ts"), "export default brief({ title: \"x\" })").unwrap();+ assert!(brief(&d).is_none(), "a brief whose words plan no level isn't run");+ let _ = std::fs::remove_dir_all(&d);+ }+}diff --git a/runtime/lod-plan/src/report.rs b/runtime/lod-plan/src/report.rsnew file mode 100644index 00000000..a8691c9c--- /dev/null+++ b/runtime/lod-plan/src/report.rs@@ -0,0 +1,95 @@+//! What is said of planned detail once the frames are read: the parts a job is held at (`raea make status`'s lod gate,+//! MK24) and the table `raea scene lod` prints (MK23).++use raea_core_facts::Finding;++use crate::{Seen, level};++/// Of a render's or check's findings, the parts seen closer than planned (`lod-closer`), and those of them not yet+/// answered in the job's notes: a line of NOTES.md with `lod` and the part's name answers it.+pub fn held<'a>(findings: &'a [Finding], notes: &str) -> (Vec<&'a str>, Vec<&'a str>) {+ let answered = |name: &str| notes.lines().any(|l| l.to_lowercase().contains("lod") && l.contains(name));+ let name = |f: &'a Finding| (f.check == "lod-closer").then(|| f.about.first()).flatten().map(|a| a.name.as_str());+ let closer: Vec<&str> = findings.iter().filter_map(name).collect();+ let open = closer.iter().copied().filter(|n| !answered(n)).collect();+ (closer, open)+}++/// A composition's lod gate, from the findings of its last render or check (the record's entry `id`): whether it is+/// clear and what it says, None when the job plans no level and the render found none. Two levels finer is an error,+/// which the checks gate holds until it's fixed; one level finer is held here until the part is replanned and rendered+/// again, or answered in the notes.+pub fn gate(of: &str, id: &str, findings: &[Finding], notes: &str, plans: bool) -> Option<(bool, String)> {+ let (closer, open) = held(findings, notes);+ if open.is_empty() {+ return (plans || !closer.is_empty()).then(|| (true, format!("no part closer than its planned detail left unanswered at {id}")));+ }+ Some((false, format!("seen closer than planned at {id}: {}. Build each for the level it's seen at and plan it there (`lod` on its object in brief.ts or on the part), keep the camera off it, or answer in NOTES.md on a line with `lod` and its name; raea scene lod {of} lists every part", open.join(", "))))+}++/// What a row says of its part: closer than planned, never as close as planned, or as planned.+fn verdict(s: &Seen) -> &'static str {+ match (s.planned, s.level()) {+ (Some(p), Some(l)) if l < p => "CLOSER than planned",+ (Some(p), Some(l)) if l > p => "never this close: planned finer than any frame shows it",+ (Some(_), _) => "as planned",+ (None, _) => "no plan",+ }+}++/// The rows in reading order: seen closer than planned (the widest gap first), the rest of the planned, then the+/// unplanned, each by how large it gets.+pub fn ordered(mut seen: Vec<Seen>) -> Vec<Seen> {+ let gap = |s: &Seen| s.planned.zip(s.level()).map_or(0, |(p, l)| p.saturating_sub(l));+ let size = |s: &Seen| s.finest.map_or(0.0, |f| f.1);+ seen.sort_by(|a, b| (gap(b), b.planned.is_some()).cmp(&(gap(a), a.planned.is_some())).then(size(b).total_cmp(&size(a))).then(a.name.cmp(&b.name)));+ seen+}++/// The table: a row a part, its plan beside the finest level a frame showed it at, how much of the frame it spanned+/// there, at which frame, and how many frames it was in.+pub fn table(seen: &[Seen]) -> Vec<String> {+ let mut t = vec![format!("{:<32} {:>7} {:>5} {:>7} {:>7} {:>7} ", "part", "planned", "seen", "largest", "at", "frames")];+ let n = |l: Option<u8>| l.map_or("-".into(), |l| l.to_string());+ for s in seen {+ let (at, span) = s.finest.map_or(("-".into(), "-".into()), |(f, sp)| (f.to_string(), format!("{:.0}%", sp * 100.0)));+ t.push(format!("{:<32} {:>7} {:>5} {:>7} {:>7} {:>7} {}", s.name.chars().take(32).collect::<String>(), n(s.planned), n(s.finest.map(|f| level(f.1))), span, at, s.frames, verdict(s)));+ }+ t+}++#[cfg(test)]+mod tests {+ use super::*;+ use raea_core_facts::Level;++ fn row(name: &str, planned: Option<u8>, span: f32) -> Seen {+ Seen { name: name.into(), planned, frames: 10, finest: Some((4, span)), closer: 0 }+ }++ #[test]+ fn the_table_reads_closer_than_planned_first_then_planned_then_the_rest_by_size() {+ let rows = ordered(vec![row("floor", None, 1.0), row("desk", Some(0), 0.6), row("kiosk", Some(3), 0.3), row("tower", Some(4), 0.05), row("lamp", None, 0.1), row("phone", Some(0), 0.04)]);+ assert_eq!(rows.iter().map(|r| r.name.as_str()).collect::<Vec<_>>(), ["kiosk", "tower", "desk", "phone", "floor", "lamp"]);+ let t = table(&rows);+ assert!(t[1].starts_with("kiosk") && t[1].ends_with("CLOSER than planned"), "{}", t[1]);+ assert!(t[3].ends_with("as planned"), "{}", t[3]);+ assert!(t[4].ends_with("never this close: planned finer than any frame shows it"), "{}", t[4]);+ assert!(t[5].ends_with("no plan"), "{}", t[5]);+ }++ #[test]+ fn a_part_seen_closer_is_held_until_a_notes_line_with_lod_and_its_name_answers_it() {+ let closer = |name: &str| Finding::new("lod-closer", Level::Warn, format!("'{name}' is planned at LOD 3"), "raea render").about(name, None);+ let fs = [closer("kiosk"), Finding::new("clips", Level::Error, "the mug is in the desk", "raea render").about("mug", None), closer("tower")];+ assert_eq!(held(&fs, ""), (vec!["kiosk", "tower"], vec!["kiosk", "tower"]));+ // a line about the part that isn't about its detail answers nothing+ assert_eq!(held(&fs, "the kiosk is fine\n- LOD tower: one frame at the cut").1, ["kiosk"]);+ assert!(held(&fs, "- lod kiosk and tower: left as boxes, the cut hides them").1.is_empty());+ // the gate: open with the parts named, clear once answered, and absent from a job that plans and found nothing+ let open = gate("scene.tsx", "r1", &fs, "", false).unwrap();+ assert!(!open.0 && open.1.starts_with("seen closer than planned at r1: kiosk, tower.") && open.1.ends_with("raea scene lod scene.tsx lists every part"), "{open:?}");+ assert_eq!(gate("scene.tsx", "r1", &fs, "lod kiosk, tower: boxes", false).map(|g| g.0), Some(true));+ assert_eq!((gate("scene.tsx", "r1", &[], "", false), gate("scene.tsx", "r1", &[], "", true).map(|g| g.0)), (None, Some(true)));+ }+}diff --git a/sdk/guides/craft/bevy/scenes.md b/sdk/guides/craft/bevy/scenes.mdindex b39daffa..3c5aaf6f 100644--- a/sdk/guides/craft/bevy/scenes.md+++ b/sdk/guides/craft/bevy/scenes.md@@ -23,6 +23,15 @@ The brief template, the builder prompt and the judge prompt to paste are in `bev- `raea make plan` is the stop before anything costs money: `review/plan/floor-plan.png` (every footprint, inventedones dashed), a grey-box blockout seen from the entrance with its review sheets, and `comparison.png` beside thereference. Show it, fix positions and sizes, and only then generate.+- Plan each object's detail with `lod`, 0 to 4, by how large it will be seen: 0 the hero (half the frame or more),+ 1 featured (20%+), 2 dressing (8%+), 3 background (2%+: a grey box reads), 4 far (a silhouette). Build to the+ plan: a 3 or 4 stays a box, a card or a quarter-triangle `_lod1`, and the budget goes to the 0s and 1s. Name the+ part as its object's id (`<Mesh3d name="kiosk">`), or put `lod={3}` on the part itself; a parent+ `<Entity transform lod={4}>` plans everything inside it. Every render then says `lod-closer` when a shot shows a+ part finer than planned (a camera move added later, a box you meant to replace and forgot), and+ `raea scene lod EDIT.tsx` lists every part's plan beside the largest the frames show it, the unplanned ones too.+ Two levels finer is an error; one holds `raea make status` until you build it up and replan it, keep the camera+ off it, or answer it in NOTES.md on a line with `lod` and its name.- NOTES.md beside the brief ends with `## What the skill got wrong`: what the guides or tools led you into. Statuschecks it's there once the work is.@@ -181,3 +190,4 @@ Three tiers, each gating once it has earned it (`raea make status` lists them):- Placing generated models by nudging transforms: fit them on the way in (`--h`, `--turn`), then lint.- Several fixes to light and materials at once: they are coupled, so do one a round.- Calling a stage done because the command ran: every claim needs an image or a check's output.+- Raising a part's `lod` plan to silence `lod-closer` without building it up: the plan is what you built it for.diff --git a/sdk/raea/conformance/lod.test.tsx b/sdk/raea/conformance/lod.test.tsxnew file mode 100644index 00000000..fb662326--- /dev/null+++ b/sdk/raea/conformance/lod.test.tsx@@ -0,0 +1,31 @@+// docs/make.feature MK21: a part's `lod` is its planned detail, a prop on its row that the stage checks read.+import { describe, expect, test } from "bun:test";+import { Cuboid, Entity, Model } from "../src/3d";+import { Group } from "@raea/render/three";+import { Mesh3d, StandardMaterial } from "@raea/render/bevy3d";+import { renderFrame } from "../src/test";++const html = (el: React.ReactElement) => renderFrame(el, { frame: 0, width: 320, height: 240, fps: 30, durationInFrames: 30 });+const props = (out: string, kind: string) => [...out.matchAll(new RegExp(`data-3d="${kind}" data-props="([^"]*)"`, "g"))].map((m) => JSON.parse(m[1]!.replaceAll(""", '"')));++describe("MK21: planned detail", () => {+ test("a Mesh3d's and a Model's lod ride on their rows, and a part that plans none carries none", () => {+ const out = html(<><Mesh3d name="kiosk" lod={3}><Cuboid /><StandardMaterial /></Mesh3d><Mesh3d name="desk"><Cuboid /></Mesh3d><Model src="tower.glb" lod={4} /></>);+ expect(props(out, "Mesh").map((p) => [p.name, p.lod])).toEqual([["kiosk", 3], ["desk", undefined]]);+ expect(props(out, "Model")[0].lod).toBe(4);+ });++ test("a Group's lod is the plan of every part inside that plans none of its own", () => {+ const out = html(<Group lod={4}><Mesh3d name="far"><Cuboid /></Mesh3d><Mesh3d name="hero" lod={0}><Cuboid /></Mesh3d><Group><Model src="a.glb" /></Group></Group>);+ expect(props(out, "Mesh").map((p) => p.lod)).toEqual([4, 0]);+ expect(props(out, "Model")[0].lod).toBe(4);+ // Bevy's parent entity is the same+ const bevy = html(<Entity transform={{ translation: [0, 0, -80] }} lod={3}><Mesh3d name="skyline"><Cuboid /></Mesh3d></Entity>);+ expect(props(bevy, "Mesh")[0].lod).toBe(3);+ });++ test("a level that isn't one of the five is refused", () => {+ expect(() => html(<Mesh3d lod={5 as 4}><Cuboid /></Mesh3d>)).toThrow("0 (the hero");+ expect(() => html(<Model src="a.glb" lod={1.5 as 1} />)).toThrow("lod is its planned detail");+ });+});diff --git a/sdk/raea/src/brief.gen.ts b/sdk/raea/src/brief.gen.tsindex eafd0e6e..7c6726d4 100644--- a/sdk/raea/src/brief.gen.ts+++ b/sdk/raea/src/brief.gen.ts@@ -279,7 +279,13 @@ crop?: [number, number, number, number],/*** where it stands in a scene: metres, the floor's front-left corner at the origin, rot 0 = facing the entrance*/-at?: [number, number, number], rot?: number, hero?: boolean, pick?: MakePick,+at?: [number, number, number], rot?: number, hero?: boolean,+/**+ * how large it is planned to be seen, which is how much of it gets built: 0 the hero (half the frame or more),+ * 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box reads), 4 far (under 2%: a+ * silhouette). A render that shows it finer than this says so (`lod-closer`; `raea scene lod` lists every part)+ */+lod?: number, pick?: MakePick,/*** what was fixed by script ("glass made transmissive, label kept opaque")*/diff --git a/sdk/render/src/3d/detail.tsx b/sdk/render/src/3d/detail.tsxindex ecfd82f1..56cfaa1a 100644--- a/sdk/render/src/3d/detail.tsx+++ b/sdk/render/src/3d/detail.tsx@@ -1,5 +1,6 @@// Where a part is drawn (docs/realism.feature LT21): its levels by distance or by size on screen, cross-faded, its// draw distance and its shadow, as raea-sys-lod's Detail component on the part (systems/lod).+import { createContext, useContext } from "react";import { BevyComponent } from "./bevy";/** Where a part is drawn. Distances in metres from the camera; sizes on screen are the part's size across in pixels,@@ -45,3 +46,22 @@ export function detailNode(who: string, d: Detail | undefined) {const value = { near: d.near ?? 0, far: d.far ?? 0, min_px: d.minPx ?? 0, max_px: d.maxPx ?? 0, fade: d.fade ?? 0.1, shadow: d.shadow ?? true, size: d.size ?? 0, edge: d.edge ?? false, bounds: d.box ?? [] };return <BevyComponent key="raea-detail" type="raea_sys_lod::Detail" value={value} />;}++/** How large a part is planned to be seen, which is how much of it gets built (docs/make.feature MK21): 0 the hero+ * (half the frame or more), 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box+ * reads), 4 far (under 2%: a silhouette). It draws nothing differently (`detail` switches levels): it is the plan a+ * render holds the part to, saying `lod-closer` when a frame shows it finer than this, and `raea scene lod` lists+ * every part's plan beside what the frames show. A part without one takes its name's level from the job's plan+ * (`lod` on its object in brief.ts's make). */+export type PlannedLod = 0 | 1 | 2 | 3 | 4;++/** the planned detail of every part inside a <Group lod> that plans none of its own */+export const PlannedLodOf = createContext<PlannedLod | undefined>(undefined);++/** a part's `lod` checked, else the level of the Group it is in */+export function usePlannedLod(who: string, own: PlannedLod | undefined): PlannedLod | undefined {+ const around = useContext(PlannedLodOf);+ if (own === undefined) return around;+ if (!(Number.isInteger(own) && own >= 0 && own <= 4)) throw new RangeError(`${who}: lod is its planned detail, 0 (the hero, half the frame or more) to 4 (far, under 2% of it), got ${JSON.stringify(own)}`);+ return own;+}diff --git a/sdk/render/src/3d/model.tsx b/sdk/render/src/3d/model.tsxindex 0dcf01f5..b94f438f 100644--- a/sdk/render/src/3d/model.tsx+++ b/sdk/render/src/3d/model.tsx@@ -6,7 +6,7 @@ import { modelScreens, type ModelScreens } from "../screen";import { pageLayers } from "../layers";import { Place3d, useCamera3d, usePlace3d } from "../events3d";import { MeshStandardMaterialProps, PerspectiveCameraProps, Vec3, checkMaterial, checkPass, checkVec, colours, node3d, samplerSpec, type SamplerSpec } from "./all";-import { detailNode, type Detail } from "./detail";+import { PlannedLodOf, detailNode, usePlannedLod, type Detail, type PlannedLod } from "./detail";/** What a light or camera holds: Bevy's own reflected components on it (<BevyComponent>, or a generated wrapper such* as bevy_light's ShadowFilteringMethod or bevy_pbr's ScreenSpaceReflections), applied through Bevy's TypeRegistry. */@@ -66,6 +66,8 @@ export interface EntityProps {transform?: { translation?: Vec3; rotation?: [number, number, number, number]; scale?: Vec3 };/** with `transform`: the composition pass of every part inside that doesn't name its own (Mesh's `pass`) */pass?: string;+ /** with `transform`: the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far) */+ lod?: PlannedLod;/** its Bevy components (<BevyComponent>, or the generated wrappers in raea/bevy-own); with `transform`, also* the parts it carries */children?: ReactNode;@@ -79,18 +81,19 @@ export interface EntityProps {* hand-written element. */export function Entity({ children, ...rest }: EntityProps) {if (rest.transform !== undefined) {- const { transform: t, pass, ...own } = rest;+ const { transform: t, pass, lod, ...own } = rest;if (own.position !== undefined || own.rotation !== undefined || own.scale !== undefined) throw new TypeError("Entity: transform, or position, rotation and scale, not both");if (own.name !== undefined) throw new TypeError("Entity: a parent entity (with a transform) takes no name yet; name a bare Entity inside it");// a parent entity draws as the old Group: its place, and its children placed in itreturn (- <Group position={t.translation ?? [0, 0, 0]} rotation={t.rotation ? eulerOf(t.rotation) : [0, 0, 0]} scale={t.scale ?? 1} {...(pass !== undefined ? { pass } : {})}>+ <Group position={t.translation ?? [0, 0, 0]} rotation={t.rotation ? eulerOf(t.rotation) : [0, 0, 0]} scale={t.scale ?? 1} {...(pass !== undefined ? { pass } : {})} {...(lod !== undefined ? { lod } : {})}>{children}</Group>);}if (rest.position !== undefined) checkVec("Entity", "position", rest.position);if (rest.rotation !== undefined) checkVec("Entity", "rotation", rest.rotation);+ if (rest.lod !== undefined) throw new TypeError("Entity: lod is a parent entity's (with a transform), for the parts inside it; a part takes its own");if (rest.name !== undefined && (typeof rest.name !== "string" || !rest.name)) throw new TypeError(`Entity: name is a non-empty string, got ${JSON.stringify(rest.name)}`);const id = useId();const m = usePlace3d(rest.position ?? [0, 0, 0], rest.rotation ?? [0, 0, 0], rest.scale ?? 1);@@ -106,6 +109,9 @@ export interface GroupProps {scale?: number | Vec3;/** the composition pass of every part inside that doesn't name its own (Mesh's `pass`) */pass?: string;+ /** the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far): a skyline's+ * buildings, a street's far end (PlannedLod) */+ lod?: PlannedLod;children?: ReactNode;}@@ -139,7 +145,8 @@ export function Group(props: GroupProps) {const q = props.quaternion;if (q !== undefined && !(Array.isArray(q) && q.length === 4 && q.every(Number.isFinite))) throw new TypeError(`Group: quaternion is [x, y, z, w], got ${JSON.stringify(q)}`);const m = usePlace3d(position, rotation, scale, q);- return node3d("Group", { position, rotation, scale, ...(q !== undefined ? { quaternion: q } : {}), ...(props.pass !== undefined ? { pass: props.pass } : {}) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>);+ const lod = usePlannedLod("Group", props.lod);+ return node3d("Group", { position, rotation, scale, ...(q !== undefined ? { quaternion: q } : {}), ...(props.pass !== undefined ? { pass: props.pass } : {}) }, <Place3d.Provider value={m}><PlannedLodOf.Provider value={lod}>{props.children}</PlannedLodOf.Provider></Place3d.Provider>);}export interface ModelProps {@@ -225,6 +232,9 @@ export interface ModelProps {shadow?: boolean;/** where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) */detail?: Detail;+ /** its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer+ * says so (`lod-closer`); a stand-in or a far backdrop is planned at 3 or 4 (PlannedLod) */+ lod?: PlannedLod;/** false: no shadow falls on its meshes, its own included (true by default): a furry coat of many cards that would* otherwise speckle itself in the shadow maps */receiveShadow?: boolean;@@ -322,7 +332,7 @@ export function Model(props: ModelProps) {if (props.sampler !== undefined) samplerSpec("Model", props.sampler);if (props.pixelSize !== undefined && !(props.pixelSize >= 1)) throw new RangeError(`Model: pixelSize must be at least 1, got ${props.pixelSize}`);if (props.bones !== undefined && (typeof props.bones !== "object" || Object.values(props.bones).some((v) => typeof v !== "string"))) throw new TypeError(`Model: bones maps each joint's name to a model's name, got ${JSON.stringify(props.bones)}`);- const p: Record<string, unknown> = { ...props, time };+ const p: Record<string, unknown> = { ...props, time, lod: usePlannedLod("Model", props.lod) };if (props.animations !== undefined) {const a = props.animations;if (props.animation !== undefined) throw new TypeError("Model: give animation (one clip) or animations (a blend), not both");diff --git a/sdk/render/src/3d/shapes.tsx b/sdk/render/src/3d/shapes.tsxindex 2077cfd3..dbd6d6df 100644--- a/sdk/render/src/3d/shapes.tsx+++ b/sdk/render/src/3d/shapes.tsx@@ -5,6 +5,7 @@ import { useAnimation3d, type Keys, type Move, type TrackSpec } from "@raea/mathimport { Place3d, usePlace3d, usePointer3d, type LocalBounds, type PointerHandlers3d } from "../events3d";import { Canvas3DProps, Vec3, checkArgs, checkPass, checkVec, node3d, sameProps, serialisable } from "./all";import { InCanvas3D } from "./model";+import { usePlannedLod, type PlannedLod } from "./detail";import type { MeshAttribute } from "./attribute";import { firstKey, useSequenceFrames } from "./clock";import { Text3D, text3dShape, type Text3DProps } from "./text3d";@@ -368,6 +369,9 @@ export interface MeshProps extends PointerHandlers3d {allowOverlap?: boolean;/** set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it tilted */posed?: boolean;+ /** its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer+ * says so (`lod-closer`); a grey box or a far backdrop is planned at 3 or 4 (PlannedLod) */+ lod?: PlannedLod;/** a Manifold solid (manifold.box(...).minus(...)) or its expression; wins over the geometry child */shape?: string | Solid;/** a Bevy plugin moves it (a rigid body): position, rotation and scale set where it starts, then the plugin's */@@ -474,11 +478,12 @@ export function Mesh(props: MeshProps) {const manifold = shape instanceof Solid ? shape.expr : shape ?? shapeFromChildren(props.children);// a Text3D's read={false} rides on its mesh, which the stage checks read (SG10)const read = props.read ?? text3dRead(props.children);+ const lod = usePlannedLod("Mesh", props.lod);const extra: Record<string, string> = {};if (manifold !== undefined) extra["data-shape"] = manifold as string;if (anim.attr) extra["data-raea-anim"] = anim.attr;const id = useId();const m = usePlace3d(position, rotation, scale, props.quaternion);usePointer3d(props.name ?? id, m, () => (shape === undefined ? boundsFromChildren(props.children) : undefined), props as Record<string, unknown>);- return node3d("Mesh", { ...props, read, animate: undefined, shape: undefined, position, rotation, scale, attributes: props.attributes && JSON.stringify(props.attributes) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>, Object.keys(extra).length ? extra : undefined);+ return node3d("Mesh", { ...props, read, lod, animate: undefined, shape: undefined, position, rotation, scale, attributes: props.attributes && JSON.stringify(props.attributes) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>, Object.keys(extra).length ? extra : undefined);}diff --git a/systems/stage/src/cover.rs b/systems/stage/src/cover.rsindex f74e6e28..4561c464 100644--- a/systems/stage/src/cover.rs+++ b/systems/stage/src/cover.rs@@ -69,7 +69,7 @@ pub(crate) fn behind(its: &[Item], parts: &[Part], me: usize, world: &Mat4, x: (}/// Whether a part lets the words through: its material's opacity (else its own) under SEE_THROUGH.-fn see_through(it: &Item) -> bool {+pub fn see_through(it: &Item) -> bool {let material = match &it.material {Some(m) => opacity(&m.props),None => None,@@ -83,6 +83,12 @@ fn opacity(props: &serde_json::Map<String, Value>) -> Option<f64> {/// Where the segment o to q first enters the box [lo, hi], as a share of its length, if it does before q.fn enters(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<f32> {+ crossing(o, q, lo, hi).map(|c| c.0)+}++/// Where the segment o to q enters the box [lo, hi] and where it leaves it, as shares of its length (1 when q is+/// inside), if it meets it before q.+pub fn crossing(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<(f32, f32)> {let d = q - o;let (mut t0, mut t1) = (0.0f32, 1.0f32);for a in 0..3 {@@ -102,7 +108,7 @@ fn enters(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<f32> {return None;}}- Some(t0)+ Some((t0, t1))}#[cfg(test)]diff --git a/systems/stage/src/lib.rs b/systems/stage/src/lib.rsindex 381ce575..23ca5480 100644--- a/systems/stage/src/lib.rs+++ b/systems/stage/src/lib.rs@@ -21,7 +21,8 @@ mod view;pub use framing::{model_box, on_screen, own_box};pub use manifest::{Mounts, pages, seen};pub use page::{Page, Words};-pub use view::View;+pub use cover::{crossing, see_through};+pub use view::{View, corners};/// Who says these findings, in a render.pub const BY: &str = "raea render";diff --git a/tools/layers.toml b/tools/layers.tomlindex ba2c1090..cc15699b 100644--- a/tools/layers.toml+++ b/tools/layers.toml@@ -188,6 +188,7 @@ raea-runtime-view = "runtime"raea-runtime-world = "runtime"raea-runtime-encode = "runtime"raea-runtime-endchecks = "runtime"+raea-runtime-lod-plan = "runtime" # MK21: a part planned far or as a grey box that a shot shows closer than its planraea-runtime-plugins = "runtime"raea-runtime-live = "runtime"raea-runtime-look = "runtime"