mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
SG10, SG12, SG13, SG14, SG15: raea render holds its 3D to type that reads, parts that don't snap, a camera that settles and a composed frame, and raea show won't post a render that still holds an error
raea-sys-stage (systems/stage) reads every frame's parts through its camera at the end of every render, beside the
clipping check: RichText too small or turned too far to read, a reveal that never starts or never finishes, words not
held long enough to read (SG10); a part's size on screen jumping in one frame, and a line built as a growing chain of
parts (SG12); a camera whose speed kinks or that goes in and back out within 1.5 s (SG13); frames with almost nothing
on screen, and the shot's subject cut by the edge (SG14). RichText read={false} leaves scenery out. raea scene stage
runs the same checks without drawing; raea scene moved from raea-runtime-export into raea-app-scene so the export crate
keeps room under its 2,000 lines.
Calibrated on the mobile-ads film (13,174 frames) and 33 clean scenes: the snap check as first written said 1,446
errors on the film and 1,252 on four clean scenes, and the lurch check 48 on Stay from f32 acos noise; what was left
out is each a measured false error (pop-ins, shared names, layout edits, parts over 6 m, speeds under what can be
seen, the gap between two long moves). The film now holds 375 errors (lurches at its spline's keys, labels at 60-75
degrees, code at 3-7 px); no type or snap error on the clean scenes.
raea show refuses a file whose newest render in its project's record holds an error it wasn't let through with,
naming each (engine/cli/src/held.ts); --despite CHECK "why" passes one and the why goes on the item. A still stepped
alone (raea check --quick, render --at) is judged for what a still shows, never for reveals or reading time.
This commit is contained in:
1 parent
d2242ed6e6
commit
8f92302403
33 files changed
+1551
-137
No files matched your search
Generated
+28
@@ -13926,6 +13926,20 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-scene"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-core-facts",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
"raea-sys-contact",
|
||||
"raea-sys-light-meter",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-solid"
|
||||
version = "0.1.0"
|
||||
@@ -14218,6 +14232,7 @@ dependencies = [
|
||||
"raea-app-media",
|
||||
"raea-app-notes",
|
||||
"raea-app-play",
|
||||
"raea-app-scene",
|
||||
"raea-app-solid",
|
||||
"raea-app-sound",
|
||||
"raea-app-targets",
|
||||
@@ -15259,6 +15274,7 @@ dependencies = [
|
||||
"raea-sys-light-meter",
|
||||
"raea-sys-mix",
|
||||
"raea-sys-page",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -16427,6 +16443,18 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-stage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-core-shape",
|
||||
"raea-io-trace",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-text3d"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -123,6 +123,7 @@ members = [
|
||||
"systems/layers",
|
||||
"systems/splat",
|
||||
"systems/sprite",
|
||||
"systems/stage",
|
||||
"systems/rt",
|
||||
"systems/text3d",
|
||||
"runtime/gpuframe",
|
||||
@@ -211,6 +212,7 @@ members = [
|
||||
"apps/interchange",
|
||||
"apps/judge",
|
||||
"apps/solid",
|
||||
"apps/scene",
|
||||
"apps/media",
|
||||
"apps/targets",
|
||||
"apps/game",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "raea-app-scene"
|
||||
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"
|
||||
|
||||
[dependencies]
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
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" }
|
||||
# its results as Findings (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,59 @@
|
||||
//! `raea scene lint|explain|light|stage`: 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).
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use raea_runtime_bundle::{bundle_composition, comp_opts};
|
||||
use raea_runtime_export::{frame_of, items};
|
||||
|
||||
mod light;
|
||||
mod stage;
|
||||
|
||||
pub const USAGE: &str = "raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--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,
|
||||
/// tilted); `explain` says what every part rests on. --json prints the findings (each part's support, gap and the y
|
||||
/// that fixes it) instead. `light` and `stage` are light.rs's and stage.rs's.
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
let usage = USAGE;
|
||||
let (Some(mode), Some(edit)) = (args.get(1).map(String::as_str), args.get(2)) else { return Err(usage.into()) };
|
||||
match mode {
|
||||
"light" => return light::cli(args),
|
||||
"stage" => return stage::cli(args),
|
||||
"lint" | "explain" => {}
|
||||
_ => 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();
|
||||
let frame = frame_of(args)?;
|
||||
let js = std::env::temp_dir().join(format!("raea-scene-{}.js", std::process::id()));
|
||||
bundle_composition(&tsx, &js, &comp_opts(args)?, None)?;
|
||||
// and the frame after it, to see what moves
|
||||
let got = raea_runtime_export::scene_frames(&js, &dir, frame + 2, false, &[frame, frame + 1]);
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, ..) = got?.ok_or("the composition has no 3D")?;
|
||||
let k = frames.iter().position(|(f, _)| *f == frame).ok_or_else(|| format!("no frame {frame}"))?;
|
||||
// the frame, and the next (or the one before, at the end) to see what moves
|
||||
let other = if k + 1 < frames.len() { k + 1 } else { k.saturating_sub(1) };
|
||||
let (mut found, errors) = raea_sys_contact::lint(&items(&frames[k].1), &items(&frames[other].1));
|
||||
// and the Blender steps its models call for (a format raea can't load, triangles over budget for the distance)
|
||||
let (more, unloadable) = raea_sys_contact::assets(&items(&frames[k].1));
|
||||
found.extend(more);
|
||||
let (errors, json_out) = (errors + unloadable, args.iter().any(|a| a == "--json"));
|
||||
let parts = found.iter().filter(|v| v["check"] != "clips" && v["check"] != "tilted" && v["check"] != "skipped").count();
|
||||
if mode == "lint" {
|
||||
// its faults as Findings (DR3), worst first, every one shown, the count last; errors fail it, with nothing after
|
||||
let fs = raea_core_facts::finding::ranked(raea_sys_contact::lint_findings(&found, frame, "raea scene lint"));
|
||||
let text = if json_out { serde_json::to_string_pretty(&json!({"frame": frame, "findings": fs})).unwrap_or_default() } else { fs.iter().map(raea_core_facts::Finding::line).chain([format!("frame {frame}: {parts} parts; {}", raea_core_facts::finding::count(&fs))]).collect::<Vec<_>>().join("\n") };
|
||||
if errors > 0 {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
return Ok(text);
|
||||
}
|
||||
// explain: every part's support
|
||||
let t: Vec<String> = found.iter().map(|v| format!("{:<8} {}", v["level"].as_str().unwrap_or(""), v["says"].as_str().unwrap_or(""))).collect();
|
||||
Ok(if json_out { serde_json::to_string_pretty(&json!({"frame": frame, "errors": errors, "found": found})).unwrap_or_default() } else { format!("{}\nframe {frame}: {parts} parts, {errors} errors", t.join("\n")) })
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//! `raea scene light`: the light on a shot's subject, metered (raea-sys-light-meter; docs/scene.feature, "A light plan").
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use raea_runtime_bundle::{bundle_composition, comp_opts, flag};
|
||||
use raea_runtime_export::{Frame, all_items, scene_frames_to};
|
||||
|
||||
/// One composition's frames, stepped.
|
||||
fn frames_of(args: &[String], tsx: &std::path::Path, comp: &str) -> Result<(Vec<(i64, Frame)>, f32), String> {
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
let mut opts = comp_opts(args)?;
|
||||
opts.composition = Some(comp.to_string()).filter(|c| !c.is_empty());
|
||||
let js = std::env::temp_dir().join(format!("raea-light-{}-{comp}.js", std::process::id()));
|
||||
bundle_composition(tsx, &js, &opts, None)?;
|
||||
let got = scene_frames_to(&js, &dir, 1);
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, w, h, _) = got?.ok_or("the composition has no 3D")?;
|
||||
Ok((frames, w as f32 / h.max(1) as f32))
|
||||
}
|
||||
|
||||
/// `raea scene light`: the light on a shot's subject, metered (raea-sys-light-meter; docs/scene.feature, "A light plan").
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let usage = "raea scene light EDIT.tsx [--composition ID[,ID...]] [--frame N|last] [--part NAME] [--json]";
|
||||
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 flag = |k: &str| flag(args, k);
|
||||
let comps: Vec<String> = flag("--composition").map(|c| c.split(',').map(str::to_string).collect()).unwrap_or_else(|| vec![String::new()]);
|
||||
let part = flag("--part");
|
||||
let json_out = args.iter().any(|a| a == "--json");
|
||||
let pick = |frames: &[(i64, Frame)], which: &str| -> Result<usize, String> {
|
||||
match which {
|
||||
"last" => Ok(frames.len() - 1),
|
||||
f => {
|
||||
let f: i64 = f.parse().map_err(|_| "--frame takes a frame number or last")?;
|
||||
frames.iter().position(|(n, _)| *n == f).ok_or_else(|| format!("no frame {f}"))
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut shots: Vec<(String, Vec<(i64, Value)>)> = Vec::new();
|
||||
for c in &comps {
|
||||
let (frames, aspect) = frames_of(args, &tsx, c)?;
|
||||
let all = all_items(&frames);
|
||||
// one composition: the frame asked for; a sequence: each shot's first and last, for its cuts
|
||||
let at: Vec<usize> = if comps.len() == 1 { vec![pick(&frames, flag("--frame").as_deref().unwrap_or("0"))?] } else { vec![0, frames.len() - 1] };
|
||||
let mut m = Vec::new();
|
||||
for k in at {
|
||||
m.push((frames[k].0, raea_sys_light_meter::meter(&all[k], part.as_deref(), aspect).map_err(|e| format!("{c} frame {}: {e}", frames[k].0))?));
|
||||
}
|
||||
shots.push((c.clone(), m));
|
||||
}
|
||||
let cuts = raea_sys_light_meter::cuts(&shots);
|
||||
if json_out {
|
||||
let shots: Vec<Value> = shots.iter().map(|(c, m)| json!({"composition": c, "frames": m.iter().map(|(f, v)| json!({"frame": f, "meter": v})).collect::<Vec<_>>()})).collect();
|
||||
return Ok(serde_json::to_string_pretty(&json!({"shots": shots, "cuts": cuts, "findings": raea_sys_light_meter::cut_findings(&cuts)})).unwrap_or_default());
|
||||
}
|
||||
// each shot's meter, each cut, and the cuts' jumps and drifts as Findings (DR3), counted last
|
||||
Ok(raea_sys_light_meter::report(&shots, &cuts))
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//! `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.
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
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] [--json]";
|
||||
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();
|
||||
let frame = |k: &str| flag(args, k).map(|v| v.parse::<i64>().map_err(|_| format!("{k} takes a frame number"))).transpose();
|
||||
let (from, to) = (frame("--from")?.unwrap_or(0), frame("--to")?);
|
||||
let js = std::env::temp_dir().join(format!("raea-stage-{}.js", std::process::id()));
|
||||
bundle_composition(&tsx, &js, &comp_opts(args)?, None)?;
|
||||
let got = scene_frames_to(&js, &dir, 1);
|
||||
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 fs = raea_sys_stage::check(&all_items(&frames), &nums, w, h, fps, "raea scene stage");
|
||||
let text = if args.iter().any(|a| a == "--json") {
|
||||
serde_json::to_string_pretty(&json!({"frames": [first, last], "findings": fs})).unwrap_or_default()
|
||||
} else {
|
||||
fs.iter().map(raea_core_facts::Finding::line).chain([format!("frames {first} to {last}: {}", finding::count(&fs))]).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
if fs.iter().any(|f| f.level == Level::Error) {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ What's wrong before anyone watches it.
|
||||
| [`raea judge`](judge.md) | Judge a 3D scene's review sheets blind, by a model on a frozen rubric or a fresh agent session, with the pass decided in code. |
|
||||
| [`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, and meter a shot's light. |
|
||||
| [`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 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 world`](world.md) | A frame as one world: its layers, text, 3D parts, camera, shots, clips, cues and lines as entities, queried across media. |
|
||||
| [`raea solid`](solid.md) | Measure, view and export a solid: parts built from code with exact volumes, joints and parameters. |
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
---
|
||||
title: "raea scene"
|
||||
summary: "Find floating, sunk and clipping 3D parts, say what each part rests on, and meter a shot's light."
|
||||
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."
|
||||
order: 46
|
||||
sources: ["runtime/export/src/scene.rs"]
|
||||
sources: ["apps/scene/src/lib.rs", "apps/scene/src/light.rs", "apps/scene/src/stage.rs", "systems/stage/src/lib.rs"]
|
||||
---
|
||||
|
||||
`raea scene` steps a composition's frames and measures its 3D scene without rendering pictures. `lint` reports
|
||||
parts that float, sink into what they stand on, clip into each other or tilt, and exits 1 on an error. `explain`
|
||||
says what every part rests on. `light` meters the light on the shot's subject; given several compositions, it
|
||||
compares their first and last frames across each cut.
|
||||
compares their first and last frames across each cut. `stage` steps every frame and holds it to the checks `raea
|
||||
render` runs at its end (docs/stage-guards.feature): 3D words too small or turned too far to read, a reveal that
|
||||
never starts or never finishes, a part whose size jumps in one frame, a camera that lurches or goes in and back out,
|
||||
frames with almost nothing on screen. It exits 1 on an error, as the render would, without drawing a frame, so it's
|
||||
the cheap look before one. RichText `read={false}` leaves a sign nobody is meant to read out of it.
|
||||
|
||||
```sh
|
||||
raea scene lint room.tsx
|
||||
raea scene explain room.tsx --frame 90 --json
|
||||
raea scene light room.tsx --part hero
|
||||
raea scene light film.tsx --composition shot1,shot2,shot3 # the light across the cuts
|
||||
raea scene stage film.tsx --from 1800 --to 2400 # the stage checks on 20 s of it
|
||||
```
|
||||
|
||||
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
|
||||
@@ -23,7 +28,7 @@ raea scene light film.tsx --composition shot1,shot2,shot3 # the light across
|
||||
|
||||
```sh
|
||||
raea 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 EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--json] (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)
|
||||
raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--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.
|
||||
@@ -35,8 +40,10 @@ Headless: it needs nothing running and opens no window. Takes up to 2 arguments
|
||||
| `--at` | `A-B` | `export`: each part's placement and the camera's field of view on every frame from A to B, for keyframes in Blender or Godot. |
|
||||
| `--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. |
|
||||
| `--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). |
|
||||
| `-o` | `DIR` | `export`: the folder scene.json is written to, with meshes/ and models/ beside it. |
|
||||
|
||||
<!-- generated:end -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: "raea show"
|
||||
summary: "Show the person something in the raea app, as an item they can use and answer: stills, a video, a sound, a script, an interactive .tsx or a question."
|
||||
order: 125
|
||||
sources: ["engine/cli/src/show.ts"]
|
||||
sources: ["engine/cli/src/show.ts", "engine/cli/src/held.ts"]
|
||||
---
|
||||
|
||||
`raea show` is how an agent working outside the app, in a terminal session such as Claude Code or Codex, shows the
|
||||
@@ -19,6 +19,11 @@ the command prints. Without the app on this Mac, the files open in the Mac's own
|
||||
posted. While the app is installed, an agent shows renders, stills, sheets and questions this way, never in Preview
|
||||
or a browser.
|
||||
|
||||
A render that still holds an error isn't shown. `raea show` looks each file up in its project's record: when the
|
||||
newest `raea render` that wrote it found an error it wasn't let through with (`raea render --despite`), the show is
|
||||
refused and each error named (`raea findings --open` lists them too). Fix it and render again, or say why it goes
|
||||
anyway with `--despite CHECK "why"`, once per check; the person reads the why on the item.
|
||||
|
||||
The person's edit comments are tasks they watch. The inbox line that carries them gives each one's id; `--on ITEM
|
||||
--working ID` marks one as being worked (with `--sub NAME` when a subagent has it), and `--done ID` marks it settled,
|
||||
or, with files and `--replaces`, settled by that version. Done stays in view, checked, until the person resolves it.
|
||||
@@ -46,7 +51,7 @@ raea show out/cut-v2.mp4 --replaces i-show-2f9c --done c-3 --done c-4 --note "Wa
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
raea show FILE... [--title T] [--ask LINE] [--project P] [--replaces ITEM] [--as NAME] [--role ROLE] [--inbox NAME] [--open] [--label LABEL] [--detail PARAGRAPH] [--labels FILE.json] | raea show --question Q --choice A --choice B [STILL...] | raea show [--title T] --question Q [--preview FILE] --choice A [--preview FILE] --choice B ... [--question Q2] ... | raea show --on ITEM [--working ID] [--ask TEXT] [--status S] [--states S1,S2] [--sign N --clip FILE --render HASH] [--done ID] [--note LINE] [--sub NAME] (shown in the raea app as an item the person can use and answer, posted quietly with a notice, the window left where they are unless --open: stills (several, a storyboard), a video, a sound, a NAME.script.ts or .md, a .tsx (an interactive artifact; a project's composition opens in its editor), or questions, all of them one item; --label "PLACE TAG" a label beside the picture, never on it, that points at PLACE (x0,y0,x1,y1 or x,y in its 0-1, then #N the Nth file, @T or @T-TO a film's seconds, or part=KEY a scene's part; the tag the rest), --detail the paragraph of the --label before it, --labels a JSON list of them as feed_post takes them, and a sheet raea media sheet made comes labelled; each question and choice with a --preview to play or read while answering (a still, a video, a sound, a script or .md; after a --choice that choice's, else the question's); what they send comes to ~/.raea/inbox/INBOX.jsonl; their edit comments are tasks: --working ID as you start one (each --ask with it one ask you read it as, for the person to correct; --status and --states where the note and each ask stand: to restate, to check, failing, to sign, passing, signed; --sign N --clip FILE --render HASH a clip under ask N for them to sign; a note closes when they retire it, never with --done), --done ID when it's settled, or with the version that settles it, FILE --replaces ITEM --done ID; never open media in Preview while the app is installed)
|
||||
raea show FILE... [--title T] [--ask LINE] [--project P] [--replaces ITEM] [--as NAME] [--role ROLE] [--inbox NAME] [--open] [--label LABEL] [--detail PARAGRAPH] [--labels FILE.json] [--despite CHECK WHY] | raea show --question Q --choice A --choice B [STILL...] | raea show [--title T] --question Q [--preview FILE] --choice A [--preview FILE] --choice B ... [--question Q2] ... | raea show --on ITEM [--working ID] [--ask TEXT] [--status S] [--states S1,S2] [--sign N --clip FILE --render HASH] [--done ID] [--note LINE] [--sub NAME] (shown in the raea app as an item the person can use and answer, posted quietly with a notice, the window left where they are unless --open: stills (several, a storyboard), a video, a sound, a NAME.script.ts or .md, a .tsx (an interactive artifact; a project's composition opens in its editor), or questions, all of them one item; --label "PLACE TAG" a label beside the picture, never on it, that points at PLACE (x0,y0,x1,y1 or x,y in its 0-1, then #N the Nth file, @T or @T-TO a film's seconds, or part=KEY a scene's part; the tag the rest), --detail the paragraph of the --label before it, --labels a JSON list of them as feed_post takes them, and a sheet raea media sheet made comes labelled; each question and choice with a --preview to play or read while answering (a still, a video, a sound, a script or .md; after a --choice that choice's, else the question's); what they send comes to ~/.raea/inbox/INBOX.jsonl; their edit comments are tasks: --working ID as you start one (each --ask with it one ask you read it as, for the person to correct; --status and --states where the note and each ask stand: to restate, to check, failing, to sign, passing, signed; --sign N --clip FILE --render HASH a clip under ask N for them to sign; a note closes when they retire it, never with --done), --done ID when it's settled, or with the version that settles it, FILE --replaces ITEM --done ID; never open media in Preview while the app is installed)
|
||||
```
|
||||
|
||||
Needs the raea app's host running on this machine; then waits for a person's click in the raea app (to answer). Takes any number of arguments besides its flags.
|
||||
@@ -59,6 +64,7 @@ Needs the raea app's host running on this machine; then waits for a person's cli
|
||||
| `--ask` | `LINE` | What you want from the person, shown with the item. With `--on` and `--working`: one ask you read the comment as (give it once per ask), shown on the comment for the person to correct. |
|
||||
| `--choice` | `A` | With `--question`: one answer to pick; give it once per answer. Stills given instead are the choices. |
|
||||
| `--clip` | `FILE` | With `--sign`: the clip the person is to sign, cut from the render (`raea notes check` cuts it). |
|
||||
| `--despite` | `CHECK WHY` | A check the render still fails, and why it goes to the person anyway; give it once per check. `raea show` refuses a render whose record still holds an error, naming each, and the why is shown on the item. |
|
||||
| `--detail` | `PARAGRAPH` | The paragraph the viewer opens from the `--label` before it. |
|
||||
| `--done` | `ID` | Marks the person's edit comment done (give it once per comment), on the item named by `--on`, or with files on the item they `--replaces`. |
|
||||
| `--inbox` | `NAME` | The inbox the answers go to, `~/.raea/inbox/NAME.jsonl` (one per session when left out). |
|
||||
|
||||
@@ -2201,6 +2201,7 @@ type Polygons = [number, number][][]
|
||||
| Field | Type | What it is |
|
||||
| --- | --- | --- |
|
||||
| `name` | `string` | what it's called across frames, and its glyphs' names over world.* (`${name}:${index}`) |
|
||||
| `read` | `boolean` | false: scenery, not words to read (a shop sign seen in passing, a page in a book), so raea render doesn't hold it to type that reads: its size on screen, its angle to the camera, its reveal and its reading time |
|
||||
| `pass` | `string` | the composition pass it draws in ("scene" by default): a frame-wide effect told to skip a pass (<Look skip>, <Outline skip>, <Bloom skip>, <Grade skip>) leaves its pixels as drawn, and <Look passes> gives one its own paint; a piece names at most three passes besides "scene"; keyed per frame |
|
||||
| `position` | `Vec3` | where the block's origin is, metres (x, y, z) |
|
||||
| `rotation` | `Vec3` | the block's rotation, radians (x, y, z) |
|
||||
|
||||
@@ -132,6 +132,7 @@ multiplied into (scale, opacity) or replacing (color, visible) what the block's
|
||||
| Field | Type | What it is |
|
||||
| --- | --- | --- |
|
||||
| `name` | `string` | what it's called across frames, and its glyphs' names over world.* (`${name}:${index}`) |
|
||||
| `read` | `boolean` | false: scenery, not words to read (a shop sign seen in passing, a page in a book), so raea render doesn't hold it to type that reads: its size on screen, its angle to the camera, its reveal and its reading time |
|
||||
| `pass` | `string` | the composition pass it draws in ("scene" by default): a frame-wide effect told to skip a pass (<Look skip>, <Outline skip>, <Bloom skip>, <Grade skip>) leaves its pixels as drawn, and <Look passes> gives one its own paint; a piece names at most three passes besides "scene"; keyed per frame |
|
||||
| `position` | `Vec3` | where the block's origin is, metres (x, y, z) |
|
||||
| `rotation` | `Vec3` | the block's rotation, radians (x, y, z) |
|
||||
|
||||
@@ -166,6 +166,7 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
# clip, which can run past the Sequence) and a VolumeSource's from/until (seconds). Screen's `from` isn't
|
||||
# checked yet: screenContent isn't a component, so it can't read the Sequence.
|
||||
|
||||
@done
|
||||
Scenario: SG6. Lines are lines
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
@@ -177,7 +178,8 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
And SG12 flags a chain of more than 8 parts named `NAME-i` whose ends touch as "a line made of parts: Line3d"
|
||||
# Status 11-21 (branch stage-guards-5): Line3d and Tube are built, one BufferMesh each, cut at p; renders of a
|
||||
# 120-point Tube and an 80-point Line3d growing over 40 frames read smooth with round ends at every frame. The
|
||||
# meshes guide's recipe uses them. The SG12 flag is SG12's.
|
||||
# meshes guide's recipe uses them. The flag is raea-sys-stage's line-of-parts (a warning, motion.rs): a chain of
|
||||
# more than 8 parts named NAME-i that grows, which on the film names its 108 fields of 16 parts each.
|
||||
|
||||
@done
|
||||
Scenario: SG7. A camera path that can't lurch
|
||||
@@ -210,6 +212,10 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
Rule: The render fails when a frame would look broken
|
||||
Each check below reads the frame's scene (as systems/contact does) and the page's layout, runs in `raea render`
|
||||
and `raea check`, and reports the part, the frame and the fix, as P1 unless it says otherwise.
|
||||
SG10, SG12, SG13 and SG14 are raea-sys-stage (systems/stage): they read each frame's parts through its camera
|
||||
(view.rs; lib.rs finds the shots' cuts), run at the end of every render beside the clipping check
|
||||
(runtime/export/src/scene.rs), and run without drawing in `raea scene stage`, which moved with lint, explain and
|
||||
light out of raea-runtime-export into raea-app-scene (apps/scene) so the export crate keeps room under 2,000 lines.
|
||||
|
||||
Scenario: SG9. A frame looks the same however it is reached
|
||||
Given a render of more than 60 frames with 3D in it
|
||||
@@ -220,6 +226,16 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
And this catches SG1–SG4 and any later fault of the same kind before a person sees it
|
||||
|
||||
Scenario: SG10. 3D type that reads
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
| raea-sys-stage | systems/stage/src/view.rs | 118 | the frame's camera (Camera3d's quaternion or a lookAt), a point and a box on screen |
|
||||
| raea-sys-stage | systems/stage/src/lib.rs | 183 | told and check, the frames as the checks read them, shots, runs, findings |
|
||||
| raea-sys-stage | systems/stage/src/text.rs | 217 | each RichText's capitals on screen, its turn from the camera, its box against title-safe, its reveal, its reading time; `read={false}` for scenery |
|
||||
| @raea/render | sdk/render/src/3d/text.tsx | +3 | RichText's `read` prop |
|
||||
| raea-app-scene | apps/scene/src/stage.rs | 38 | `raea scene stage`: every frame stepped without drawing, the checks, errors fail it |
|
||||
| raea-app-scene | apps/scene/src/lib.rs | 59 | `raea scene`, moved from raea-runtime-export (lint and explain) with light.rs |
|
||||
| raea-app-scene | apps/scene/src/light.rs | 58 | `raea scene light`, moved |
|
||||
| raea-runtime-export | runtime/export/src/scene.rs | 35 | a render's items, and its end checks: clipping, then staging |
|
||||
Then every RichText and Text3D is checked on every frame it shows:
|
||||
| measure | limit |
|
||||
| cap height on screen | at least 22 px at 1080 (scaled to the frame) |
|
||||
@@ -230,6 +246,16 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
| its reveal | finished before it unmounts |
|
||||
And on the film these flag the placement wall's labels (16 px), the floor labels (over 35°) and the store quote
|
||||
(a reveal that never starts)
|
||||
# Status 11-21 (branch stage-guards-6): RichText is checked on every frame (systems/stage/src/text.rs): capitals
|
||||
# under 22 px at 1080 are an error; turned past 35° a warning, past 50° an error (squashed under 64%, a floor seen
|
||||
# low); outside title-safe a warning; a reveal never started or never finished an error; held still for less than
|
||||
# its reading time a warning. `read={false}` leaves scenery out. A still stepped alone (raea check --quick, render
|
||||
# --at) is judged for size, angle and safe area, and says nothing of reveals or time. Measured with `raea scene
|
||||
# stage` on film2 (13,174 frames, 64 s): 182 small-type errors (code on screens at 3 to 7 px, labels at 17 to 19
|
||||
# px), 152 angle errors (195 labels at 60 to 75°: 'ASA RULING · UK' at 74° for 12 s, 'KIT' at 71°), no false
|
||||
# error on 33 clean scenes (gambit, sheet3d, lightbench, Stay, floor3, blender-loop). The film was rewritten since
|
||||
# the notes: its placement wall no longer exists, so the 16 px labels can't be named. Left: Text3D, and parts in
|
||||
# front of the words.
|
||||
|
||||
Scenario: SG11. 2D type stays off the parts
|
||||
Then a page text box that covers more than 10% of a 3D part's projected box is an error, unless one of them says
|
||||
@@ -237,28 +263,72 @@ Feature: Stage guards: a 3D render an agent can't break
|
||||
And on the film this flags the words over the curves at 2:08 and the headline on the AppLovin card at 6:40
|
||||
|
||||
Scenario: SG12. Nothing snaps
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
| raea-sys-stage | systems/stage/src/motion.rs | 311 | cuts; a named part's size or place on screen jumping in one frame, alone; a growing chain of parts named NAME-i (SG6's flag) |
|
||||
Then a part whose projected size changes by more than 25% from one frame to the next, with no cut, is an error
|
||||
And so is a RichText whose words change without a remount, until SG1 lands
|
||||
And on the film this flags the red dot at 1:10.06 and every chunk's first frame in a curve's drawing
|
||||
# Status 11-21 (branch stage-guards-6): part-snap (motion.rs) is a named part's size on screen changing over 25%
|
||||
# in one frame between steady frames, no cut: an error. Measured first as written, it said 1,446 errors on the
|
||||
# film and 1,252 on four clean scenes; what was left out, each a measured false error: a part coming in (no
|
||||
# steady frame before it), a name several items carry in one frame, four or more parts at once (the layout
|
||||
# changing: the creatures reel's 30 tiles), parts reaching over 6 m (water, floors), and a part whose words or
|
||||
# shape change that frame (spawned again as new content, SG1: kept-props2's counter). A jump across a tenth of
|
||||
# the frame is a warning (a tile recycled, a part thrown). Now 0 errors on film2 and on 33 clean scenes. Left:
|
||||
# the red dot at 1:10.06 and the chunks' first frames were drawn wrong by the engine from right props, which only
|
||||
# SG9's re-render sees; and RichText words changing without a remount (SG1).
|
||||
|
||||
Scenario: SG13. A camera that settles
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
| raea-sys-stage | systems/stage/src/motion.rs | 311 | inside each shot, a speed kink in the camera's travel or turn (2x an error, 1.5x a warning), and a dolly or pan undone within 1.5 s |
|
||||
Then the camera's speed changing by more than 2x within 3 frames, or its framing reversing (in then out, one way
|
||||
then the other) within 1.5 s, is an error, and 1.5x is a warning
|
||||
And a camera still moving while type is up past the type's reading time is a warning
|
||||
And `raea fingerprint things`'s lurch check folds into this one, so it runs on every render
|
||||
# Status 11-21 (branch stage-guards-6): camera-lurch and camera-reverse (motion.rs) run inside each shot on every
|
||||
# render. Speeds under 0.1 degrees or 3 mm a frame are below a change anyone sees; turns are measured by atan2
|
||||
# (acos of an f32 dot read 0 and 0.02 degrees on alternate frames and said 48 false lurches on Stay). A reversal
|
||||
# is the whole there-and-back within 1.5 s; a dolly in and back out is an error, a pan there and back a warning
|
||||
# (a first-person look round). Words up while the camera moves past their reading time are type-time's warning.
|
||||
# On film2: 41 lurch errors, each at a key where the stage's Catmull-Rom segments differ in length (its speed
|
||||
# jumps there); on the clean scenes, 13 lurches on cameras locked to a walking body (sheet3d) or a first-person
|
||||
# walk starting with no ease, and two dolly reversals (soma_dressed's 0.15 m, Stay's 0.84 m in and 0.43 m out at
|
||||
# 1:12). Left: `raea fingerprint things`' lurch check, still its own.
|
||||
|
||||
Scenario: SG14. The frame is composed
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
| raea-sys-stage | systems/stage/src/framing.rs | 182 | the share of the frame any part covers (a grid of their boxes), and the shot's subject cut by the edge |
|
||||
Then the part a shot is about (one a Label or pin points at, else the nearest named part) cut by the frame's edge
|
||||
for more than 10 frames is an error
|
||||
And under 8% of the frame showing any part, for more than 1 s, is an error
|
||||
And on the film these flag the AppLovin logo cut at 6:32, the dashboard cut at 0:40 and 7:00, and the empty frames
|
||||
at 3:40, 6:04 and 6:08
|
||||
# Status 11-21 (branch stage-guards-6): framing.rs says both, as warnings for now: the page's own 2D (a headline
|
||||
# over an empty 3D) isn't known to them until SG11. Coverage leaves out a slab over 12 m (a floor, a wall: a frame
|
||||
# of floor and fog is empty), and a part wholly behind the camera. On film2: empty frames at 1:59, 3:07 and 3:41
|
||||
# (the notes' 3:40), and 21 subject cuts. Left: errors once SG11 knows the page, and the subject a Label points at.
|
||||
|
||||
@done
|
||||
Scenario: SG15. A broken render can't be posted
|
||||
Given the plan
|
||||
| crate | file | lines | job |
|
||||
| - | engine/cli/src/held.ts | 82 | the newest render that wrote each file shown, from its project's record, and its errors less what was let through |
|
||||
| - | engine/cli/src/app.ts | +6 | show refuses before it posts or opens anything; Here lists a folder |
|
||||
| - | engine/cli/src/show.ts | +14 | `--despite CHECK "why"`, and the why on the item's ask line |
|
||||
| - | engine/cli/conformance/held.test.ts | 69 | refused, cleared by a later render, let through either way, frames and absolute outs, the flag |
|
||||
| raea-sys-stage | systems/stage/src/lib.rs | +12 | a still stepped alone stands for its moment; reveals and reading times only over frames all stepped |
|
||||
Then `raea show` refuses a render whose record holds an open SG9–SG14 error, naming each, unless the agent passes
|
||||
`--despite CHECK "why"`, which the person sees on the item
|
||||
And the agent's hooks run SG10–SG14 on a composition's stills after each save (`raea check --quick`), so the
|
||||
fault shows before the first full render
|
||||
# Status 11-21 (branch stage-guards-6): held.ts refuses `raea show` of any file whose newest render in its
|
||||
# project's record holds an error it wasn't let through with, every error named, before it posts or opens
|
||||
# anything (all of a render's errors, not only SG9–SG14's: each one already exited the render 1). `--despite
|
||||
# CHECK "why"` passes one, and the why goes on the item's ask line. The quick check's stills are a render's, so
|
||||
# the stage checks run on them (a still stepped alone is judged for what a still shows).
|
||||
|
||||
Rule: SG16. The 3D guide says it first
|
||||
Scenario: SG16. The guide's 3D rules, before any recipe
|
||||
|
||||
@@ -70,6 +70,8 @@ raea-app-engines = { path = "../../apps/engines" }
|
||||
raea-app-solid = { path = "../../apps/solid" }
|
||||
# raea judge: review sheets judged by clef-omni
|
||||
raea-app-judge = { path = "../../apps/judge" }
|
||||
# raea scene lint|explain|light|stage (docs/stage-guards.feature)
|
||||
raea-app-scene = { path = "../../apps/scene" }
|
||||
raea-app-ask = { path = "../../apps/ask" }
|
||||
raea-app-media = { path = "../../apps/media" }
|
||||
# `raea app run|check|bundle` and `raea rune` on either target (docs/targets.feature T0b)
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// `raea show` refuses a render that still holds an error (docs/stage-guards.feature SG15): the newest render that wrote
|
||||
// the file, from its project's record, less what that render let through and what --despite names. The record is
|
||||
// faked in memory; parseShow's side is the --despite flag itself.
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { held, openErrors } from "../src/held.ts";
|
||||
import { parseShow } from "../src/show.ts";
|
||||
|
||||
const P = "/work/ads";
|
||||
const error = (check: string, says = `${check} says`) => ({ check, level: "error", says });
|
||||
|
||||
/** A project at P whose record holds these entries, as core/facts/src/record.rs writes them. */
|
||||
function records(entries: Record<string, unknown>[]) {
|
||||
const files = new Map<string, string>([[`${P}/.raea/project`, ""], [`${P}/.raea/record`, ""]]);
|
||||
entries.forEach((e, i) => files.set(`${P}/.raea/record/2026112${i}-000000-film.json`, JSON.stringify(e)));
|
||||
return {
|
||||
exists: (p: string) => files.has(p),
|
||||
read: (p: string) => files.get(p) ?? "",
|
||||
list: (d: string) => [...files.keys()].filter((k) => k.startsWith(`${d}/`)).map((k) => k.slice(d.length + 1)),
|
||||
};
|
||||
}
|
||||
|
||||
describe("SG15: a broken render isn't shown", () => {
|
||||
test("the newest render that wrote the file holds an error: refused, the error named", () => {
|
||||
const h = records([
|
||||
{ at: 1, by: "raea render", out: "out/film.mp4", findings: [], despite: [] },
|
||||
{ at: 2, by: "raea render", out: "out/film.mp4", findings: [error("type-small", "'Reviews' is 16 px tall"), { check: "exposure", level: "warn", says: "" }], despite: [] },
|
||||
]);
|
||||
const why = held([`${P}/out/film.mp4`], P, [], h);
|
||||
expect(why).toContain("film.mp4: type-small: 'Reviews' is 16 px tall");
|
||||
expect(why).toContain(`--despite type-small "why"`);
|
||||
expect(why).not.toContain("exposure");
|
||||
});
|
||||
|
||||
test("a later clean render clears it, and an older one doesn't count", () => {
|
||||
const h = records([
|
||||
{ at: 2, by: "raea render", out: "out/film.mp4", findings: [error("camera-lurch")], despite: [] },
|
||||
{ at: 3, by: "raea render", out: "out/film.mp4", findings: [], despite: [] },
|
||||
]);
|
||||
expect(held([`${P}/out/film.mp4`], P, [], h)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("let through at the render, or with --despite: shown", () => {
|
||||
const at = records([{ at: 1, by: "raea render", out: "out/film.mp4", findings: [error("frame-empty")], despite: [{ check: "frame-empty", why: "a black beat" }] }]);
|
||||
expect(held([`${P}/out/film.mp4`], P, [], at)).toBeUndefined();
|
||||
const h = records([{ at: 1, by: "raea render", out: "out/film.mp4", findings: [error("part-snap"), error("type-angle")], despite: [] }]);
|
||||
expect(openErrors([`${P}/out/film.mp4`], P, [{ check: "part-snap", why: "a cut on the beat" }], h)).toEqual(["film.mp4: type-angle: type-angle says"]);
|
||||
});
|
||||
|
||||
test("a still from a frames render is that render's; a file no render wrote is clear", () => {
|
||||
const h = records([{ at: 1, by: "raea render", out: "out/frames", findings: [error("type-reveal")], despite: [] }]);
|
||||
expect(held([`${P}/out/frames/frame-00045.png`], P, [], h)).toContain("frame-00045.png: type-reveal");
|
||||
expect(held([`${P}/assets/photo.jpg`, "/tmp/elsewhere.mp4"], "/tmp", [], h)).toBeUndefined();
|
||||
// a check's entry isn't a render's
|
||||
const checked = records([{ at: 1, by: "raea check", out: "out/film.mp4", findings: [error("clipped")], despite: [] }]);
|
||||
expect(held([`${P}/out/film.mp4`], P, [], checked)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("an absolute out, as a render outside the project writes it", () => {
|
||||
const h = records([{ at: 1, by: "raea render", out: "/tmp/scratch/a.mp4", findings: [error("subject-cut")], despite: [] }]);
|
||||
expect(held(["/tmp/scratch/a.mp4"], P, [], h)).toContain("a.mp4: subject-cut");
|
||||
});
|
||||
|
||||
test("--despite takes the check and why, and neither is a file", () => {
|
||||
const a = parseShow(["out/film.mp4", "--despite", "type-small", "a sign seen in passing", "--title", "Cut"], P);
|
||||
expect(a.files).toEqual([`${P}/out/film.mp4`]);
|
||||
expect(a.despite).toEqual([{ check: "type-small", why: "a sign seen in passing" }]);
|
||||
expect(() => parseShow(["out/film.mp4", "--despite", "type-small"], P)).toThrow("--despite takes the check and why");
|
||||
});
|
||||
});
|
||||
@@ -3,8 +3,9 @@
|
||||
// Mac, Windows or Linux (#169: on Windows `raea show` never found the running app, since it asked `kill`, and said it
|
||||
// had opened the files "in the Mac's own viewer", which it hadn't).
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { type Despite, held } from "./held";
|
||||
import { HARNESSES } from "./show";
|
||||
|
||||
/** What these verbs ask of the computer they run on (a test gives its own: conformance/app.test.ts). */
|
||||
@@ -13,6 +14,8 @@ export interface Here {
|
||||
run: (cmd: string, args: string[]) => { status: number | null; stdout: string };
|
||||
exists: (path: string) => boolean;
|
||||
read: (path: string) => string;
|
||||
/** a folder's names: the project's record, which a show reads first (held.ts) */
|
||||
list?: (dir: string) => string[];
|
||||
env: Record<string, string | undefined>;
|
||||
home: string;
|
||||
}
|
||||
@@ -25,6 +28,7 @@ export const HERE: Here = {
|
||||
},
|
||||
exists: existsSync,
|
||||
read: (p) => readFileSync(p, "utf8"),
|
||||
list: (d) => readdirSync(d),
|
||||
env: process.env,
|
||||
home: homedir(),
|
||||
};
|
||||
@@ -115,6 +119,9 @@ function postHost(at: string, route: string, a: Record<string, unknown>): any {
|
||||
* just started (on a Mac or Linux: Windows' app has no raea:// link, so there the post lands as its notice); otherwise
|
||||
* the page finds it and says so. Without the app, the files open in the system's own viewer. */
|
||||
export function show(a: Record<string, unknown>, h: Here = HERE): unknown {
|
||||
// a render that still holds an error isn't shown, here or in a viewer (held.ts, docs/stage-guards.feature SG15)
|
||||
const refused = held((a.files as string[]) ?? [], String(a.cwd ?? ""), (a.despite as Despite[]) ?? [], h);
|
||||
if (refused) throw new Error(refused);
|
||||
let at = appHost(h);
|
||||
let launched = false;
|
||||
if (!at) {
|
||||
|
||||
@@ -134,7 +134,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
IN_HELP.set(was);
|
||||
// `raea library` (engine/cli/src/library.ts) and `raea show` (show.ts: in the raea app, not Preview, Shane 11-09), under render's usage
|
||||
let usage = format!("{usage}\n raea library [new NAME [--cloud] | add LIBRARY PATH | files LIBRARY | tag SHA TAGS | status | scan ...] | raea library search \"WORDS\" [--library LIBRARY] [--kind KIND] [--limit N] [--sound] (the person's libraries in the raea app: folders and drives indexed on this machine, searched by meaning; a folder an agent adds waits for the person's yes)");
|
||||
let usage = format!("{usage}\n raea show FILE... [--title T] [--ask LINE] [--project P] [--replaces ITEM] [--as NAME] [--role ROLE] [--inbox NAME] [--open] [--label LABEL] [--detail PARAGRAPH] [--labels FILE.json] | raea show --question Q --choice A --choice B [STILL...] | raea show [--title T] --question Q [--preview FILE] --choice A [--preview FILE] --choice B ... [--question Q2] ... | raea show --on ITEM [--working ID] [--ask TEXT] [--status S] [--states S1,S2] [--sign N --clip FILE --render HASH] [--done ID] [--note LINE] [--sub NAME] (shown in the raea app as an item the person can use and answer, posted quietly with a notice, the window left where they are unless --open: stills (several, a storyboard), a video, a sound, a NAME.script.ts or .md, a .tsx (an interactive artifact; a project's composition opens in its editor), or questions, all of them one item; --label \"PLACE TAG\" a label beside the picture, never on it, that points at PLACE (x0,y0,x1,y1 or x,y in its 0-1, then #N the Nth file, @T or @T-TO a film's seconds, or part=KEY a scene's part; the tag the rest), --detail the paragraph of the --label before it, --labels a JSON list of them as feed_post takes them, and a sheet raea media sheet made comes labelled; each question and choice with a --preview to play or read while answering (a still, a video, a sound, a script or .md; after a --choice that choice's, else the question's); what they send comes to ~/.raea/inbox/INBOX.jsonl; their edit comments are tasks: --working ID as you start one (each --ask with it one ask you read it as, for the person to correct; --status and --states where the note and each ask stand: to restate, to check, failing, to sign, passing, signed; --sign N --clip FILE --render HASH a clip under ask N for them to sign; a note closes when they retire it, never with --done), --done ID when it's settled, or with the version that settles it, FILE --replaces ITEM --done ID; never open media in Preview while the app is installed)");
|
||||
let usage = format!("{usage}\n raea show FILE... [--title T] [--ask LINE] [--project P] [--replaces ITEM] [--as NAME] [--role ROLE] [--inbox NAME] [--open] [--label LABEL] [--detail PARAGRAPH] [--labels FILE.json] [--despite CHECK WHY] | raea show --question Q --choice A --choice B [STILL...] | raea show [--title T] --question Q [--preview FILE] --choice A [--preview FILE] --choice B ... [--question Q2] ... | raea show --on ITEM [--working ID] [--ask TEXT] [--status S] [--states S1,S2] [--sign N --clip FILE --render HASH] [--done ID] [--note LINE] [--sub NAME] (shown in the raea app as an item the person can use and answer, posted quietly with a notice, the window left where they are unless --open: stills (several, a storyboard), a video, a sound, a NAME.script.ts or .md, a .tsx (an interactive artifact; a project's composition opens in its editor), or questions, all of them one item; --label \"PLACE TAG\" a label beside the picture, never on it, that points at PLACE (x0,y0,x1,y1 or x,y in its 0-1, then #N the Nth file, @T or @T-TO a film's seconds, or part=KEY a scene's part; the tag the rest), --detail the paragraph of the --label before it, --labels a JSON list of them as feed_post takes them, and a sheet raea media sheet made comes labelled; each question and choice with a --preview to play or read while answering (a still, a video, a sound, a script or .md; after a --choice that choice's, else the question's); what they send comes to ~/.raea/inbox/INBOX.jsonl; their edit comments are tasks: --working ID as you start one (each --ask with it one ask you read it as, for the person to correct; --status and --states where the note and each ask stand: to restate, to check, failing, to sign, passing, signed; --sign N --clip FILE --render HASH a clip under ask N for them to sign; a note closes when they retire it, never with --done), --done ID when it's settled, or with the version that settles it, FILE --replaces ITEM --done ID; never open media in Preview while the app is installed)");
|
||||
// clothes for SOMA's body, sewn or laid on the skin (docs/character.feature CH45c): engine/cli/src/clothes.ts, wardrobe.ts and sewn.ts
|
||||
let usage = format!("{usage}\n raea clothes [make NAME [\"WHAT IT IS\"] [--plain] [--set PATH=VALUE,...] [--colour #RRGGBB] | settings | cover NAME --parts PART[:SHARE],... --colour #RRGGBB [--stand MM] [--over UNDER] [--hard [--sole MM] [--sole-colour #RRGGBB] [--panels #RRGGBB,...]] | wear OUT_DIR GARMENT... [--body DIR] [--head HEAD_DIR]] (clothes for SOMA's body from words: make sews a garment: a sewing pattern (GarmentCode, MIT) from the words, or the plain base with --plain, its settings changed by --set PATH=VALUE (settings lists them and what each may be), cut to SOMA's measurements, draped by raea's own cloth and baked, as assets/clothes/NAME.json and its .glb, in --colour or the palette's next; the first make sets up GarmentCode and its Python in raea's models folder; cover makes one by procedure in the same file, no picture: the skin of the parts named (hips, waist, torso, chest, neck, head, upperArm, foreArm, hand, thigh, shin, foot, toes; a limb's SHARE is how far along it from its top), in one colour, MM off the skin (6 unless said), --over a garment already made as the one under it; wear puts garments on a body, innermost first (each GARMENT a name or its .json): OUT_DIR/NAME.glb each, with OUT_DIR/body.glb the body without the skin wholly under cloth; --body DIR another SOMA body folder (a headless one for a head part); --head HEAD_DIR the head that joins it (head.json), whose skin the body's is graded to at the collar; alone, the project's garments. The first use fetches SOMA's body (NVlabs/SOMA-X, Apache-2.0) into raea's models folder and needs Blender: raea setup blender)");
|
||||
// body motion made by Kimodo, on MLX on a Mac and on PyTorch elsewhere (docs/character.feature CH15c):
|
||||
@@ -144,7 +144,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
let usage = format!("{usage}\n raea bug TITLE... --text TEXT [--command CMD] [--error TEXT] [--agent NAME] [--dry-run] (a bug in raea itself, not in your own composition, sent to raea's server with raea's version and the OS, no account needed: words only, paths, emails and keys taken out before it goes; five a day from a machine, the same bug again counted on the first report; --dry-run prints what would go and sends nothing)");
|
||||
// a workspace's files and specs (docs/projects.feature), listed under render's usage like library
|
||||
let usage = format!("{usage}\n raea spec FILE.ts [--as brief|script|taste|parts] (a spec's default export as JSON, checked against its schema: brief.ts, script.ts, taste.ts, NAME.parts.ts)\n raea workspace init [NAME] [--layout LAYOUT] | raea workspace adopt DIR [--name NAME] | raea workspace [--json] (a workspace: a git repo of projects under raea.root, ~/Documents/raea unless git config says)\n raea project new NAME [--storage inline|submodule] | raea project split NAME [--remote URL] | raea project join NAME | raea project [--json] (a project in the workspace: its folder, brief.ts, media/, out/; split and join keep its history)\n raea check EDIT.tsx --quick [--shape S] [--platform P] [--taste T] [-o check.json] (three stills of a composition checked for text: clipped, cramped, safe areas, sizes; about a second)\n raea hook [claude|codex|gemini|kimi] (every agent's tool hooks, which raea skills install adds: before a shell command, media opened in the Mac's viewer while the raea app is installed is stopped once for raea show (the same command again goes through); after a save, the quick check on a composition)\n raea next [DIR] (the two or three useful next steps for the project, from its brief, compositions, renders and checks)\n raea doctor [--fix] [DIR] (what doesn't match this raea: old brief files, an older workspace format, an agent's skill from another version)\n raea app run|check|bundle APP.tsx [--target web|native] [--size WxH] [--script steps.json] [--png DIR] [-o App.app] (a TSX app on @raea/ui: its window, the headless check, a Mac app; web is Blitz on Bevy, native is Rune; the app's `export const app` sets the target, web when it doesn't; raea rune ... is --target native)\n {}\n {}\n {} ({})\n {}\n {}\n {}", skill::USAGE, tools::blender::USAGE, tools::motion::SETUP_USAGE, tools::motion::SETUP_ABOUT, raea_app_engines::godot::USAGE, raea_app_engines::shot::USAGE, raea_app_engines::round::USAGE);
|
||||
let (export_game, capcut, layers, xml, scene, physics, splat, wear) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, export::SCENE_USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE);
|
||||
let (export_game, capcut, layers, xml, scene, physics, splat, wear) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, raea_app_scene::USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE);
|
||||
let apps = format!(" {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n", raea_app_direction::check::USAGE, raea_app_check::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_ask::USAGE, raea_app_direction::USAGE, raea_app_direction::findings::USAGE, raea_app_notes::USAGE, raea_app_fingerprint::USAGE, raea_sys_index::cli::USAGE);
|
||||
return Ok(format!("raea: renders, plays and checks raea compositions (React and TypeScript) on the GPU.\n\nusage: {usage}\n raea init (a project's files where they're missing: edit.tsx, cuts.ts, components/, AGENTS.md)\n raea cut TAKE \"line\" ... | --at A-B ... [--append] (cuts.ts and words.json: a take under media/ cut in the pauses around each line it says, transcribed first if it has no TAKE.words.json; or at those seconds)\n raea frame TAKE [--at S] (how a take fits the edit: a talking take for <FaceFrame>, a screen for <ScreenFit>, from where its face is)\n raea component list | raea component add NAME ... [--shared] [--force] | raea part list | raea part add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; raea part is its old name)\n raea brand DOMAIN|URL (the brand kit read from its website on this machine: brand/brand.css, brand/brand.json, BRAND.md, logos in media/brand; says when a plain fetch saw too little)\n raea guide [NAME] (craft, the floor read before any edit; the modes: pitch, explain, story, play, tool; motion, music, layout and the rest; bevy and bevy/NAME for 3D)\n raea context PROJECT (what to read before working on a project: taste, brief, look, the floor and its modes' guides)\n{apps} raea play EDIT.tsx [--input | --input-script KEYS.json] [--size WxH] [--seconds N|end] (a game, live; also: --input-log FILE --offscreen --snapshot T FILE --json FILE --seek F FILE --pick X,Y --view YAW,PITCH,DISTANCE --scrub N --baked --autoplay --no-vsync --master --3d)\n {export_game} (a game as a program of its own: a Mac app or a command)\n {capcut}\n {layers}\n {xml}\n {scene} (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)\n {physics} (the bakes <Physics> and <Goo> make)\n {wear} (a .glb's weathering causes for raea/wear: the model with a second UV set and its cause maps, made once in the asset store)\n {splat} (footage trained into a Gaussian splat for <Splat>; setup installs its tools)\n raea run SCRIPT.ts (a TypeScript program on the engine, headless: its default export is called, what it prints is the answer; a check like a room's checkLayout; also: --timeout S)\n raea gen image|video|music|sfx|speech|mesh|text \"PROMPT\" | gen plan|run FLOW.ts|FLOW.json | gen comfy import|export|run|schema FILE | gen models | gen balance (generated media through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI; ComfyUI workflows both ways: raea gen alone lists its flags)\n {neural_usage} (DLSS 5 neural rendering on a `render --aov` folder, with its motion and depth: your own MLX-DLSS build and weights, RAEA_MLXDLSS and RAEA_DLSS_MODEL)\n {light_usage} (each scene on each light path against its path-traced reference: distance in stops, the worst tile, a moving shot's flicker, a frame's cost; DIR/report.json)\n raea mezz [--check] PATH... (an intra-only ProRes copy of each long-GOP source over 1080p, for smooth scrubbing; --check says which would get one)\n raea traces [show [N|last|DIR]] (the sessions raea left, newest first: how each ended, its glitches; show tells one in full)"));
|
||||
}
|
||||
@@ -267,7 +267,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
// `wear bake REQUEST.json [-o OUT.json]`: raea/wear's cause maps of a .glb (raea-runtime-wear, registered in thread.rs)
|
||||
Some("wear") => return raea_runtime_wear::cli(args, motion::media_path),
|
||||
// `scene lint|explain EDIT.tsx`: what each 3D part rests on; floating, sunk and clipping parts (raea-sys-contact, through motion/contact.rs)
|
||||
Some("scene") => return export::scene_cli(args),
|
||||
Some("scene") => return raea_app_scene::cli(args),
|
||||
// `song FILE [-o OUT.song.json] [--plot OUT.png]`: the song's energy map for pacing (apps/tools/src/song.rs)
|
||||
Some("song") => return tools::song::song(args),
|
||||
// `track CLIP.mp4 [--subject X,Y,W,H] [--from S]`: the clip's camera solved for <Matchmove> (motion/track.rs)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// A render that still holds an error isn't shown (docs/stage-guards.feature SG15). raea render exits 1 on an error and
|
||||
// keeps its findings in the project's record (core/facts/src/record.rs: one file a render, in the project's own .raea
|
||||
// folder), but the file it wrote is still there to post. raea show looks each file up: the newest render that wrote
|
||||
// it, and that render's errors less those it was let through with (raea render --despite) and those raea show
|
||||
// --despite CHECK "why" names. What's left refuses the show, each error named; the agent fixes it, or says why it goes
|
||||
// anyway, and the person reads the why on the item.
|
||||
|
||||
/** A check let through, and why. */
|
||||
export interface Despite {
|
||||
check: string;
|
||||
why: string;
|
||||
}
|
||||
|
||||
interface Entry {
|
||||
at?: number;
|
||||
by?: string;
|
||||
out?: string | null;
|
||||
findings?: { check?: string; level?: string; says?: string }[];
|
||||
despite?: Despite[];
|
||||
}
|
||||
|
||||
/** What it reads the record through (app.ts's Here): a file's text, whether a path exists, a folder's names. */
|
||||
export interface Records {
|
||||
exists: (path: string) => boolean;
|
||||
read: (path: string) => string;
|
||||
list?: (dir: string) => string[];
|
||||
}
|
||||
|
||||
const slashed = (p: string) => p.replace(/\\/g, "/").replace(/\/+$/, "");
|
||||
const up = (p: string) => p.slice(0, Math.max(0, p.lastIndexOf("/")));
|
||||
const rooted = (p: string) => p.startsWith("/") || /^[A-Za-z]:\//.test(p);
|
||||
|
||||
/** The nearest folder at or above `from` holding .raea/project (as the record's own up() finds it). */
|
||||
function projectAbove(from: string, h: Records): string | undefined {
|
||||
for (let d = slashed(from); d; d = up(d)) if (h.exists(`${d}/.raea/project`)) return d;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function entries(project: string, h: Records): Entry[] {
|
||||
// the project's own .raea, never ~/.raea
|
||||
const own = `${project}/.raea`;
|
||||
const dir = `${own}/record`;
|
||||
if (!h.list || !h.exists(dir)) return [];
|
||||
return h.list(dir).filter((n) => n.endsWith(".json")).flatMap((n) => {
|
||||
try {
|
||||
return [JSON.parse(h.read(`${dir}/${n}`)) as Entry];
|
||||
} catch {
|
||||
return []; // a half-written entry is no render's
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Each file's open errors, as "FILE: CHECK: what it says": none for a file no render in its project wrote. */
|
||||
export function openErrors(files: string[], cwd: string, despite: Despite[], h: Records): string[] {
|
||||
const out: string[] = [];
|
||||
const read = new Map<string, Entry[]>();
|
||||
for (const file of files.map(slashed)) {
|
||||
const project = projectAbove(up(file), h) ?? projectAbove(cwd, h);
|
||||
if (!project) continue;
|
||||
if (!read.has(project)) read.set(project, entries(project, h));
|
||||
const wrote = (e: Entry) => {
|
||||
if (e.by !== "raea render" || !e.out) return false;
|
||||
const o = slashed(rooted(slashed(e.out)) ? e.out : `${project}/${e.out}`);
|
||||
return file === o || file.startsWith(`${o}/`);
|
||||
};
|
||||
const last = read.get(project)!.filter(wrote).sort((a, b) => (b.at ?? 0) - (a.at ?? 0))[0];
|
||||
if (!last) continue;
|
||||
const let_ = new Set([...(last.despite ?? []), ...despite].map((d) => d.check));
|
||||
const name = file.slice(up(file).length + 1);
|
||||
for (const f of last.findings ?? []) if (f.level === "error" && f.check && !let_.has(f.check)) out.push(`${name}: ${f.check}: ${f.says ?? ""}`);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** The refusal, or nothing when every file is clear. */
|
||||
export function held(files: string[], cwd: string, despite: Despite[], h: Records): string | undefined {
|
||||
const open = openErrors(files, cwd, despite, h);
|
||||
if (!open.length) return undefined;
|
||||
const checks = [...new Set(open.map((l) => l.split(": ")[1]))];
|
||||
return `not shown: the render still holds ${open.length === 1 ? "an error" : `${open.length} errors`} (raea findings --open):\n ${open.slice(0, 12).join("\n ")}${open.length > 12 ? `\n and ${open.length - 12} more` : ""}\nfix ${open.length === 1 ? "it" : "them"} and render again, or say why it goes anyway: ${checks.map((c) => `--despite ${c} "why"`).join(" ")} (the person reads the why on the item)`;
|
||||
}
|
||||
|
||||
/** The ask line the person reads, with what was let through and why. */
|
||||
export const askWith = (ask: string | undefined, despite: Despite[]) =>
|
||||
[ask, ...despite.map((d) => `let through: ${d.check}, ${d.why}`)].filter(Boolean).join(" · ") || undefined;
|
||||
+17
-5
@@ -9,7 +9,8 @@
|
||||
// it (raea://item/...). Several questions are one item, each question and each choice with a preview to play or read
|
||||
// while answering (Shane 11-10: "all in one feed item rather than a bunch of them"). What the person sends on it comes
|
||||
// back as lines in the session's inbox (~/.raea/inbox/<inbox>.jsonl). Without the app on this Mac, the files open in
|
||||
// the Mac's own viewer and it says so.
|
||||
// the Mac's own viewer and it says so. A render that still holds an error isn't shown (held.ts, SG15).
|
||||
import { askWith } from "./held";
|
||||
|
||||
type Ask = (op: string, args: Record<string, unknown>) => any;
|
||||
|
||||
@@ -26,6 +27,10 @@ raea show [--title T] --question Q1 [--preview FILE] --choice A [--preview FILE]
|
||||
lists them), a folder in the project, or a Copy reference from the app; a title only when it's the only one and
|
||||
this folder isn't in another project. Else the one this folder is in. Who's showing it: --as NAME [--role ROLE]
|
||||
[--inbox NAME], else your harness's.
|
||||
raea show FILE... --despite CHECK "why"
|
||||
A render that still holds an error (raea findings --open lists them) isn't shown: fix it and render again, or say
|
||||
why it goes anyway, once per check; the person reads the why on the item. One let through at the render (raea render
|
||||
--despite) needs none.
|
||||
raea show FILE... --label "PLACE TAG" [--detail "PARAGRAPH"] --label ... | --labels LABELS.json
|
||||
Labels say what's where in what you show: each tag stands beside the picture, never on it, and points at its place
|
||||
when the person's pointer is on it. PLACE is x0,y0,x1,y1 or x,y in the picture's own 0-1, then #N for the Nth file
|
||||
@@ -45,7 +50,7 @@ raea show FILE... --replaces ITEM --done ID...
|
||||
closes when the person retires it, never with --done. raea notes post sends all of these from the notes.
|
||||
`;
|
||||
|
||||
const WITH_VALUE = new Set(["--label", "--detail", "--labels", "--title", "--ask", "--project", "--replaces", "--as", "--role", "--inbox", "--question", "--choice", "--preview", "--on", "--working", "--done", "--note", "--sub", "--status", "--states", "--sign", "--clip", "--render"]);
|
||||
const WITH_VALUE = new Set(["--despite", "--label", "--detail", "--labels", "--title", "--ask", "--project", "--replaces", "--as", "--role", "--inbox", "--question", "--choice", "--preview", "--on", "--working", "--done", "--note", "--sub", "--status", "--states", "--sign", "--clip", "--render"]);
|
||||
const FLAGS = new Set(["--open"]);
|
||||
|
||||
/** The harness an agent runs in, named as the feed shows it, from the program that started this command (native.ts
|
||||
@@ -89,7 +94,14 @@ export function parseShow(args: string[], cwd: string) {
|
||||
const unknown = args.find((a, i) => a.startsWith("--") && !WITH_VALUE.has(a) && !FLAGS.has(a) && !WITH_VALUE.has(args[i - 1] ?? ""));
|
||||
if (unknown) throw new Error(`no ${unknown} here\n${SHOW_USAGE}`);
|
||||
const abs = (f: string) => fromCwd(cwd, f);
|
||||
const files = args.filter((a, i) => !a.startsWith("--") && !WITH_VALUE.has(args[i - 1] ?? "")).map(abs);
|
||||
// --despite takes two: the check, then why
|
||||
const files = args.filter((a, i) => !a.startsWith("--") && !WITH_VALUE.has(args[i - 1] ?? "") && args[i - 2] !== "--despite").map(abs);
|
||||
const despite = args.flatMap((a, i) => {
|
||||
if (a !== "--despite") return [];
|
||||
const [check, why] = [args[i + 1], args[i + 2]];
|
||||
if (!check || !why || check.startsWith("--") || why.startsWith("--")) throw new Error(`--despite takes the check and why it goes anyway: --despite type-small "a sign seen in passing"\n${SHOW_USAGE}`);
|
||||
return [{ check, why }];
|
||||
});
|
||||
// the questions in order: each --question starts one and its --choice's follow; a --preview after a --choice is that
|
||||
// choice's, after the --question (before any choice) the question's own
|
||||
const asked: { ask: string; choices: { label: string; preview?: string }[]; preview?: string }[] = [];
|
||||
@@ -122,7 +134,7 @@ export function parseShow(args: string[], cwd: string) {
|
||||
if ((labels.length || args.includes("--labels")) && (!files.length || questions || asked.length)) throw new Error(`labels go on the files you show: raea show FILE --label "PLACE TAG"\n${SHOW_USAGE}`);
|
||||
if (labels.length && args.includes("--labels")) throw new Error(`--label or --labels, not both\n${SHOW_USAGE}`);
|
||||
if (questions && files.length) throw new Error(`with several questions or previews, each file is a --preview of the question or choice it shows\n${SHOW_USAGE}`);
|
||||
return { labels, labelsFile: one("--labels"), files, choices, questions, open: args.includes("--open"), title: one("--title"), ask: one("--ask"), asks: many("--ask"), project: one("--project"), replaces: one("--replaces"), question: questions ? undefined : one("--question"), as: one("--as"), role: one("--role"), inbox: one("--inbox"), on: one("--on"), working: many("--working"), done: many("--done"), note: one("--note"), sub: one("--sub"), status: one("--status"), states: one("--states")?.split(",").map((s) => s.trim()).filter(Boolean), sign: one("--sign"), clip: one("--clip"), render: one("--render") };
|
||||
return { labels, labelsFile: one("--labels"), files, despite, choices, questions, open: args.includes("--open"), title: one("--title"), ask: one("--ask"), asks: many("--ask"), project: one("--project"), replaces: one("--replaces"), question: questions ? undefined : one("--question"), as: one("--as"), role: one("--role"), inbox: one("--inbox"), on: one("--on"), working: many("--working"), done: many("--done"), note: one("--note"), sub: one("--sub"), status: one("--status"), states: one("--states")?.split(",").map((s) => s.trim()).filter(Boolean), sign: one("--sign"), clip: one("--clip"), render: one("--render") };
|
||||
}
|
||||
|
||||
/** A --labels file's labels, as feed_post takes them: a list, or { "labels": [...] } (raea media sheet's OUT.labels.json). */
|
||||
@@ -177,7 +189,7 @@ export function showVerb(ask: Ask, args: string[], cwd: string, env: Record<stri
|
||||
if (a.done.length && !a.replaces) throw new Error(`--done with files settles comments on the item they replace: add --replaces ITEM\n${SHOW_USAGE}`);
|
||||
if (a.labelsFile !== undefined && !listed) throw new Error(`--labels ${a.labelsFile}: its labels weren't read (raea's own handler reads the file)`);
|
||||
const labels = a.labels.length ? a.labels : listed;
|
||||
const r = ask("show", { ...(labels?.length ? { labels } : {}), files: a.files, title: a.title, ask: a.ask, question: a.question, choices: a.choices, questions: a.questions, open: a.open, project: a.project, replaces: a.replaces, cwd, by }) as
|
||||
const r = ask("show", { ...(labels?.length ? { labels } : {}), files: a.files, despite: a.despite, title: a.title, ask: askWith(a.ask, a.despite), question: a.question, choices: a.choices, questions: a.questions, open: a.open, project: a.project, replaces: a.replaces, cwd, by }) as
|
||||
| { opened: string[] }
|
||||
| { kind: "item" | "composition"; id: string; type: string; title: string; project: string; workspace: string; inbox: string; brought?: boolean };
|
||||
if ("opened" in r) return `The raea app isn't on this Mac, so ${r.opened.length === 1 ? "it opened" : `${r.opened.length} files opened`} in the Mac's own viewer: nothing was posted and nothing comes back. Install raea (raea.io) to show work as items the person can answer.\n`;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
// 15; RichText whose size grows; a box whose material colour changes at frame 15. Bottom row: a Text3D whose letters
|
||||
// count the frame; RichText first mounted at frame 10, revealed from there. Before SG1, the colour, the size and the
|
||||
// letters held their first frame's values in a sequence render (a picture's change, the material and the reveals
|
||||
// followed the frame).
|
||||
// followed the frame). The growing word starts too small to read, on purpose: read={false} keeps raea render's stage
|
||||
// checks (SG10) off it.
|
||||
import React from "react";
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { Canvas3D, Entity, RichText, Text3D } from "raea/3d";
|
||||
@@ -23,7 +24,7 @@ function Kept2() {
|
||||
<AmbientLight brightness={1000} />
|
||||
<Entity transform={Transform.fromXyz(-2.7, 1, 0)}><RichText name="reveal" size={0.35} font="Space Mono" weight={700} color="#1A1A1A" unlit enter="rise" each={2} at={5}>REVEAL</RichText></Entity>
|
||||
<Entity transform={Transform.fromXyz(-0.9, 1, 0)}><RichText name="colour" size={0.35} font="Space Mono" weight={700} color={late ? "#2F4BE0" : "#E8402E"} unlit>INK</RichText></Entity>
|
||||
<Entity transform={Transform.fromXyz(0.9, 1, 0)}><RichText name="size" size={0.15 + 0.02 * f} font="Space Mono" weight={700} color="#1A1A1A" unlit>BIG</RichText></Entity>
|
||||
<Entity transform={Transform.fromXyz(0.9, 1, 0)}><RichText name="size" size={0.15 + 0.02 * f} read={false} font="Space Mono" weight={700} color="#1A1A1A" unlit>BIG</RichText></Entity>
|
||||
<Mesh3d name="mat" transform={Transform.fromXyz(2.7, 1, 0)}><Cuboid half_size={[0.4, 0.4, 0.1]} /><StandardMaterial base_color={Srgba.hex(late ? "#2F4BE0" : "#E8402E")} unlit /></Mesh3d>
|
||||
<Mesh3d name="t3d" transform={Transform.fromXyz(0, -1.2, 0)}><Text3D size={0.6} depth={0.1}>{String(f)}</Text3D><StandardMaterial base_color={Srgba.hex("#1A1A1A")} unlit /></Mesh3d>
|
||||
{f >= 10 && <Entity transform={Transform.fromXyz(2.4, -1, 0)}><RichText name="late" size={0.35} font="Space Mono" weight={700} color="#1A1A1A" unlit enter="rise" each={2} at={10}>LATE</RichText></Entity>}
|
||||
|
||||
@@ -31,6 +31,8 @@ raea-core-program = { path = "../../core/program" }
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
raea-runtime-scene = { path = "../scene" }
|
||||
raea-sys-contact = { path = "../../systems/contact" }
|
||||
# the staging checks a render runs at its end (docs/stage-guards.feature SG10-SG14)
|
||||
raea-sys-stage = { path = "../../systems/stage" }
|
||||
# a render's findings, in one shape (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-sys-light-meter = { path = "../../systems/light-meter" }
|
||||
|
||||
@@ -47,7 +47,7 @@ pub(crate) fn frames_hold_3d(js: &Path, dir: &Path, frames: &[i64]) -> R<bool> {
|
||||
/// since frames are pure (each runtime's first frame is its whole tree). One event a frame, each waited on the JS
|
||||
/// thread and back, took the Rome film's 8,064 frames 6 s on a quiet machine and 38 s at load 50, before its engine
|
||||
/// could open. RAEA_BAKE_WORKERS sets how many runtimes (4; one for short timelines).
|
||||
pub(crate) fn scene_frames_to(js: &Path, dir: &Path, upto: i64) -> R<Option<(Vec<(i64, Frame)>, u32, u32, f64)>> {
|
||||
pub fn scene_frames_to(js: &Path, dir: &Path, upto: i64) -> R<Option<(Vec<(i64, Frame)>, u32, u32, f64)>> {
|
||||
scene_frames(js, dir, upto, true, &[])
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ mod run;
|
||||
pub use run::*;
|
||||
pub use raea_sys_page::{not_applied, render_said};
|
||||
mod scene;
|
||||
pub use scene::{USAGE as SCENE_USAGE, cli as scene_cli};
|
||||
pub use scene::{all_items, frame_of, items};
|
||||
|
||||
/// One <Audio> (or sounding <Video>) on a frame.
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
+14
-114
@@ -1,133 +1,33 @@
|
||||
//! `raea scene lint|explain|light`: a composition's frames stepped and handed to raea-sys-contact (what each part rests
|
||||
//! on, and parts that clip) and raea-sys-light-meter (the light on a subject); and the clipping check on a render's
|
||||
//! frames.
|
||||
//! A render's frames as their parts, and the checks a render runs on them at its end: raea-sys-contact's clipping and
|
||||
//! raea-sys-stage's staging (docs/stage-guards.feature SG10-SG14). `raea scene` (raea-app-scene) steps them without
|
||||
//! drawing.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::{Frame, bundle_composition, comp_opts, flag, scene_frames_to};
|
||||
use super::{Frame, flag};
|
||||
|
||||
/// A frame's 3D walked into its parts (raea-runtime-scene).
|
||||
pub(crate) fn items(f: &Frame) -> Vec<raea_core_scene::Item> {
|
||||
pub fn items(f: &Frame) -> Vec<raea_core_scene::Item> {
|
||||
raea_runtime_scene::items_of(&f.scene)
|
||||
}
|
||||
|
||||
/// Each frame's items, walked once (a frame's tree was walked again for each kind of part: 11 times a live frame)
|
||||
pub(crate) fn all_items(frames: &[(i64, Frame)]) -> Vec<Vec<raea_core_scene::Item>> {
|
||||
pub fn all_items(frames: &[(i64, Frame)]) -> Vec<Vec<raea_core_scene::Item>> {
|
||||
frames.iter().map(|(_, f)| items(f)).collect()
|
||||
}
|
||||
|
||||
/// raea_sys_contact::told on a render's frames: the parts that clip where the camera sees them, said on stderr
|
||||
/// (RAEA_CLIP_CHECK=0 skips it).
|
||||
/// raea_sys_contact::told on a render's frames, the parts that clip where the camera sees them (RAEA_CLIP_CHECK=0 skips
|
||||
/// it), and raea_sys_stage::told, the staging (RAEA_STAGE_CHECK=0), each said on stderr.
|
||||
pub(crate) fn told(frames: &[(i64, Frame)], w: u32, h: u32, fps: f64) -> Vec<raea_core_facts::Finding> {
|
||||
if std::env::var("RAEA_CLIP_CHECK").as_deref() == Ok("0") || frames.iter().all(|(_, f)| f.scene.is_empty()) {
|
||||
if frames.iter().all(|(_, f)| f.scene.is_empty()) {
|
||||
return Vec::new();
|
||||
}
|
||||
let nums: Vec<i64> = frames.iter().map(|(f, _)| *f).collect();
|
||||
raea_sys_contact::told(&all_items(frames), &nums, w, h, fps)
|
||||
}
|
||||
|
||||
pub const USAGE: &str = "raea scene lint|explain|light EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--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,
|
||||
/// tilted); `explain` says what every part rests on. --json prints the findings (each part's support, gap and the y
|
||||
/// that fixes it) instead.
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
let usage = USAGE;
|
||||
let (Some(mode), Some(edit)) = (args.get(1).map(String::as_str), args.get(2)) else { return Err(usage.into()) };
|
||||
if mode == "light" {
|
||||
return light(args);
|
||||
}
|
||||
if mode != "lint" && mode != "explain" {
|
||||
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();
|
||||
let frame = frame_of(args)?;
|
||||
let js = std::env::temp_dir().join(format!("raea-scene-{}.js", std::process::id()));
|
||||
bundle_composition(&tsx, &js, &comp_opts(args)?, None)?;
|
||||
// and the frame after it, to see what moves
|
||||
let got = super::scene_frames(&js, &dir, frame + 2, false, &[frame, frame + 1]);
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, ..) = got?.ok_or("the composition has no 3D")?;
|
||||
let k = frames.iter().position(|(f, _)| *f == frame).ok_or_else(|| format!("no frame {frame}"))?;
|
||||
// the frame, and the next (or the one before, at the end) to see what moves
|
||||
let other = if k + 1 < frames.len() { k + 1 } else { k.saturating_sub(1) };
|
||||
let (mut found, errors) = raea_sys_contact::lint(&items(&frames[k].1), &items(&frames[other].1));
|
||||
// and the Blender steps its models call for (a format raea can't load, triangles over budget for the distance)
|
||||
let (more, unloadable) = raea_sys_contact::assets(&items(&frames[k].1));
|
||||
found.extend(more);
|
||||
let (errors, json_out) = (errors + unloadable, args.iter().any(|a| a == "--json"));
|
||||
let parts = found.iter().filter(|v| v["check"] != "clips" && v["check"] != "tilted" && v["check"] != "skipped").count();
|
||||
if mode == "lint" {
|
||||
// its faults as Findings (DR3), worst first, every one shown, the count last; errors fail it, with nothing after
|
||||
let fs = raea_core_facts::finding::ranked(raea_sys_contact::lint_findings(&found, frame, "raea scene lint"));
|
||||
let text = if json_out { serde_json::to_string_pretty(&json!({"frame": frame, "findings": fs})).unwrap_or_default() } else { fs.iter().map(raea_core_facts::Finding::line).chain([format!("frame {frame}: {parts} parts; {}", raea_core_facts::finding::count(&fs))]).collect::<Vec<_>>().join("\n") };
|
||||
if errors > 0 {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
return Ok(text);
|
||||
}
|
||||
// explain: every part's support
|
||||
let t: Vec<String> = found.iter().map(|v| format!("{:<8} {}", v["level"].as_str().unwrap_or(""), v["says"].as_str().unwrap_or(""))).collect();
|
||||
Ok(if json_out { serde_json::to_string_pretty(&json!({"frame": frame, "errors": errors, "found": found})).unwrap_or_default() } else { format!("{}\nframe {frame}: {parts} parts, {errors} errors", t.join("\n")) })
|
||||
}
|
||||
|
||||
/// One composition's frames, stepped.
|
||||
fn frames_of(args: &[String], tsx: &std::path::Path, comp: &str) -> Result<(Vec<(i64, Frame)>, f32), String> {
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
let mut opts = comp_opts(args)?;
|
||||
opts.composition = Some(comp.to_string()).filter(|c| !c.is_empty());
|
||||
let js = std::env::temp_dir().join(format!("raea-light-{}-{comp}.js", std::process::id()));
|
||||
bundle_composition(tsx, &js, &opts, None)?;
|
||||
let got = scene_frames_to(&js, &dir, 1);
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, w, h, _) = got?.ok_or("the composition has no 3D")?;
|
||||
Ok((frames, w as f32 / h.max(1) as f32))
|
||||
}
|
||||
|
||||
/// `raea scene light`: the light on a shot's subject, metered (raea-sys-light-meter; docs/scene.feature, "A light plan").
|
||||
fn light(args: &[String]) -> Result<String, String> {
|
||||
let usage = "raea scene light EDIT.tsx [--composition ID[,ID...]] [--frame N|last] [--part NAME] [--json]";
|
||||
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 flag = |k: &str| flag(args, k);
|
||||
let comps: Vec<String> = flag("--composition").map(|c| c.split(',').map(str::to_string).collect()).unwrap_or_else(|| vec![String::new()]);
|
||||
let part = flag("--part");
|
||||
let json_out = args.iter().any(|a| a == "--json");
|
||||
let pick = |frames: &[(i64, Frame)], which: &str| -> Result<usize, String> {
|
||||
match which {
|
||||
"last" => Ok(frames.len() - 1),
|
||||
f => {
|
||||
let f: i64 = f.parse().map_err(|_| "--frame takes a frame number or last")?;
|
||||
frames.iter().position(|(n, _)| *n == f).ok_or_else(|| format!("no frame {f}"))
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut shots: Vec<(String, Vec<(i64, Value)>)> = Vec::new();
|
||||
for c in &comps {
|
||||
let (frames, aspect) = frames_of(args, &tsx, c)?;
|
||||
let all = all_items(&frames);
|
||||
// one composition: the frame asked for; a sequence: each shot's first and last, for its cuts
|
||||
let at: Vec<usize> = if comps.len() == 1 { vec![pick(&frames, flag("--frame").as_deref().unwrap_or("0"))?] } else { vec![0, frames.len() - 1] };
|
||||
let mut m = Vec::new();
|
||||
for k in at {
|
||||
m.push((frames[k].0, raea_sys_light_meter::meter(&all[k], part.as_deref(), aspect).map_err(|e| format!("{c} frame {}: {e}", frames[k].0))?));
|
||||
}
|
||||
shots.push((c.clone(), m));
|
||||
}
|
||||
let cuts = raea_sys_light_meter::cuts(&shots);
|
||||
if json_out {
|
||||
let shots: Vec<Value> = shots.iter().map(|(c, m)| json!({"composition": c, "frames": m.iter().map(|(f, v)| json!({"frame": f, "meter": v})).collect::<Vec<_>>()})).collect();
|
||||
return Ok(serde_json::to_string_pretty(&json!({"shots": shots, "cuts": cuts, "findings": raea_sys_light_meter::cut_findings(&cuts)})).unwrap_or_default());
|
||||
}
|
||||
// each shot's meter, each cut, and the cuts' jumps and drifts as Findings (DR3), counted last
|
||||
Ok(raea_sys_light_meter::report(&shots, &cuts))
|
||||
let (nums, all): (Vec<i64>, _) = (frames.iter().map(|(f, _)| *f).collect(), all_items(frames));
|
||||
let mut found = if std::env::var("RAEA_CLIP_CHECK").as_deref() == Ok("0") { Vec::new() } else { raea_sys_contact::told(&all, &nums, w, h, fps) };
|
||||
found.extend(raea_sys_stage::told(&all, &nums, w, h, fps));
|
||||
found
|
||||
}
|
||||
|
||||
/// `--frame N`, 0 when it isn't given (scene lint and render --review).
|
||||
pub(crate) fn frame_of(args: &[String]) -> Result<i64, String> {
|
||||
pub fn frame_of(args: &[String]) -> Result<i64, String> {
|
||||
match flag(args, "--frame") {
|
||||
Some(f) => f.parse().map_err(|_| "--frame takes a frame number".to_string()),
|
||||
None => Ok(0),
|
||||
|
||||
@@ -89,7 +89,10 @@ check names a script (`bevy/blender`). It never places, lights, frames, material
|
||||
tops, grime at the floor line (`ProceduralExtension`'s `dust`, `dirt` and `edges`, or `WearExtension` on paint; see `bevy/materials`). Leave nothing a
|
||||
flat default colour. Lay out printed matter as a 2D composition, render it to a PNG, use the PNG as the map, then
|
||||
age it.
|
||||
6. **Motion, last and small.** Then `raea render EDIT.tsx -o out/scene.mp4` and `raea check out/scene.mp4`.
|
||||
6. **Motion, last and small.** First `raea scene stage EDIT.tsx`: it steps every frame without drawing and holds it
|
||||
to the checks the render fails on (3D words too small or turned too far to read, a part that snaps, a camera that
|
||||
lurches or goes in and back out, frames with almost nothing on screen). A sign nobody is meant to read takes
|
||||
`read={false}`. Then `raea render EDIT.tsx -o out/scene.mp4` and `raea check out/scene.mp4`.
|
||||
- Once things move, check how they move. Render with `--layers`, and render `--aov -o out/scene.aov` beside it for
|
||||
depth. Then run `raea fingerprint things out/scene.mp4 --json > things.json` and
|
||||
`raea check out/scene.mp4 --things things.json`. It finds a thing floating or passing through another, the
|
||||
|
||||
@@ -70,6 +70,9 @@ export interface GlyphStyle {
|
||||
export interface RichTextProps {
|
||||
/** what it's called across frames, and its glyphs' names over world.* (`${name}:${index}`) */
|
||||
name?: string;
|
||||
/** false: scenery, not words to read (a shop sign seen in passing, a page in a book), so raea render doesn't hold it
|
||||
* to type that reads: its size on screen, its angle to the camera, its reveal and its reading time (SG10) */
|
||||
read?: boolean;
|
||||
/** the composition pass it draws in ("scene" by default): a frame-wide effect told to skip a pass (<Look skip>,
|
||||
* <Outline skip>, <Bloom skip>, <Grade skip>) leaves its pixels as drawn, and <Look passes> gives one its own paint;
|
||||
* a piece names at most three passes besides "scene"; keyed per frame */
|
||||
|
||||
+1
-1
Submodule skills updated: ccbc507578...06a182b700.
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "raea-sys-stage"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "The stage checks a render runs on its frames' scenes: 3D type that can't be read, parts that snap, a camera that lurches or reverses, frames with nothing composed in them (docs/stage-guards.feature SG10-SG14)"
|
||||
|
||||
[dependencies]
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
raea-core-shape = { path = "../../core/shape" }
|
||||
# its results as Findings (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std"] }
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,182 @@
|
||||
//! SG14, the frame is composed: frames where almost nothing of the scene is on screen, and the part a shot is about
|
||||
//! cut by the frame's edge. Both are warnings while they are measured on more films: the page's own 2D (a headline over
|
||||
//! an empty 3D) isn't known to them.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use bevy::math::Vec3;
|
||||
use raea_core_facts::{Finding, Level};
|
||||
|
||||
use super::{Stage, called, num, runs, scale_of};
|
||||
use crate::view::corners;
|
||||
|
||||
/// Under this share of the frame showing any part is an empty frame
|
||||
const EMPTY: f32 = 0.08;
|
||||
/// for this long, seconds; and not this near the piece's start or end (a fade)
|
||||
const EMPTY_SECS: f64 = 1.0;
|
||||
const FADE_SECS: f64 = 0.25;
|
||||
/// The shot's subject cut: between these shares of its box outside the frame, for more than this many frames
|
||||
const CUT_LO: f32 = 0.15;
|
||||
const CUT_HI: f32 = 0.85;
|
||||
const CUT_FRAMES: usize = 10;
|
||||
/// A backdrop, not content: a slab wider than this in the world (a floor, a set's wall, a sky plane), its thinnest side
|
||||
/// under SLAB of its widest; a frame of floor and fog is still an empty one
|
||||
const BACKDROP_M: f32 = 12.0;
|
||||
const SLAB: f32 = 0.05;
|
||||
/// The grid the frame's coverage is counted on
|
||||
const GX: usize = 48;
|
||||
const GY: usize = 27;
|
||||
|
||||
/// A part's box in its own space: a shape's, a block of words' (estimated), a picture's; None when it isn't known.
|
||||
fn own_box(it: &raea_core_scene::Item, boxes: &mut HashMap<String, Option<(Vec3, Vec3)>>) -> Option<(Vec3, Vec3)> {
|
||||
match it.kind {
|
||||
"mesh" => {
|
||||
let shape = it.shape.as_deref()?;
|
||||
*boxes.entry(shape.to_string()).or_insert_with(|| {
|
||||
let t = raea_core_shape::cached(shape).ok()?;
|
||||
let (mut lo, mut hi) = (Vec3::splat(f32::MAX), Vec3::splat(f32::MIN));
|
||||
for p in &t.positions {
|
||||
lo = lo.min(Vec3::from(*p));
|
||||
hi = hi.max(Vec3::from(*p));
|
||||
}
|
||||
(lo.x <= hi.x).then_some((lo, hi))
|
||||
})
|
||||
}
|
||||
"text" => {
|
||||
let words = it.props.get("text").and_then(serde_json::Value::as_str).unwrap_or("");
|
||||
let size = num(it, "size", 0.5) as f32;
|
||||
let w = words.split('\n').map(|l| l.chars().count()).max().unwrap_or(0) as f32 * 0.55 * size;
|
||||
let h = words.split('\n').count() as f32 * 1.2 * size;
|
||||
Some((Vec3::new(-w / 2.0, -h / 2.0, 0.0), Vec3::new(w / 2.0, h / 2.0, 0.0)))
|
||||
}
|
||||
// a picture on a card: a unit quad scaled by its props (ImagePlane, Screen)
|
||||
"panel" => Some((Vec3::new(-0.5, -0.5, 0.0), Vec3::new(0.5, 0.5, 0.0))),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn check(st: &Stage) -> Vec<Finding> {
|
||||
let n = st.all.len();
|
||||
let mut boxes = HashMap::new();
|
||||
// each frame: the share covered, whether it can be judged (no part of unknown size in view, no footage or 2D
|
||||
// over the 3D), and its subject: (name, its box on screen, the share of its box outside the frame)
|
||||
let mut covered = vec![1.0f32; n];
|
||||
let mut judged = vec![false; n];
|
||||
let mut subject: Vec<Option<(String, f32, bool)>> = vec![None; n];
|
||||
for (k, its) in st.all.iter().enumerate() {
|
||||
let Some(v) = st.views[k] else { continue };
|
||||
let mut grid = vec![false; GX * GY];
|
||||
let mut sure = true;
|
||||
let mut best: Option<(String, f32, f32, bool)> = None;
|
||||
for it in its {
|
||||
if matches!(it.kind, "plate" | "sprite" | "shape2d" | "grass" | "splat" | "meshseq") {
|
||||
sure = false;
|
||||
continue;
|
||||
}
|
||||
let Some((lo, hi)) = own_box(it, &mut boxes) else {
|
||||
// a model or other part of unknown size: judged only when its origin is well out of view
|
||||
if matches!(it.kind, "model" | "entity") {
|
||||
if let Some([x, y, _]) = v.project(super::origin(it)) {
|
||||
if x > -0.5 * st.w && x < 1.5 * st.w && y > -0.5 * st.h && y < 1.5 * st.h {
|
||||
sure = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
};
|
||||
// a floor or wall round the camera is backdrop before it is a part behind it
|
||||
let ext = (hi - lo) * it.world.to_scale_rotation_translation().0.abs();
|
||||
if ext.max_element() > BACKDROP_M && ext.min_element() < SLAB * ext.max_element() {
|
||||
continue;
|
||||
}
|
||||
let Some(b) = v.bounds(corners(&it.world, lo, hi)) else {
|
||||
// across the camera's plane it may fill the view; wholly behind it, it's out of view
|
||||
sure &= corners(&it.world, lo, hi).into_iter().all(|p| v.project(p).is_none());
|
||||
continue;
|
||||
};
|
||||
let inside = v.share(b);
|
||||
let whole = ((b[2] - b[0]) * (b[3] - b[1]) / (st.w * st.h)).max(1e-9);
|
||||
if inside > 0.0 {
|
||||
let (x0, y0) = ((b[0].max(0.0) / st.w * GX as f32) as usize, (b[1].max(0.0) / st.h * GY as f32) as usize);
|
||||
let (x1, y1) = (((b[2].min(st.w) / st.w * GX as f32).ceil() as usize).min(GX), ((b[3].min(st.h) / st.h * GY as f32).ceil() as usize).min(GY));
|
||||
for y in y0..y1 {
|
||||
for x in x0..x1 {
|
||||
grid[y * GX + x] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// the subject: the named part showing most, when it could fit in the frame
|
||||
if it.props.get("name").is_some() && inside > 0.0 && best.as_ref().is_none_or(|s| inside > s.1) {
|
||||
let fits = b[2] - b[0] < 0.9 * st.w && b[3] - b[1] < 0.9 * st.h;
|
||||
best = Some((called(it), inside, 1.0 - inside / whole, fits && scale_of(it) > 0.0));
|
||||
}
|
||||
}
|
||||
covered[k] = grid.iter().filter(|c| **c).count() as f32 / (GX * GY) as f32;
|
||||
judged[k] = sure;
|
||||
subject[k] = best.map(|(name, _, out, fits)| (name, out, fits));
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
let total = st.secs(0, n.saturating_sub(1).max(0));
|
||||
for (a, b) in runs(st, n, |k| judged[k] && covered[k] < EMPTY) {
|
||||
let (t0, t1) = ((st.frames[a] - st.frames[0]) as f64 / st.fps, (st.frames[b] - st.frames[0] + 1) as f64 / st.fps);
|
||||
if st.secs(a, b) >= EMPTY_SECS && t0 > FADE_SECS && t1 < total - FADE_SECS {
|
||||
let least = covered[a..=b].iter().copied().fold(1.0, f32::min);
|
||||
let says = format!("almost nothing is on screen from {} to {} ({:.0}% of the frame shows any part)", st.at(a), st.at(b), least * 100.0);
|
||||
out.push(st.finding("frame-empty", Level::Warn, a, b, says).fix("aim the camera at what the shot is about, or bring it into the frame"));
|
||||
}
|
||||
}
|
||||
for (a, b) in runs(st, n, |k| subject[k].as_ref().is_some_and(|(_, out, fits)| *fits && *out > CUT_LO && *out < CUT_HI)) {
|
||||
let names: Vec<&str> = subject[a..=b].iter().filter_map(|s| s.as_ref().map(|s| s.0.as_str())).collect();
|
||||
if b + 1 - a > CUT_FRAMES && names.windows(2).all(|w| w[0] == w[1]) {
|
||||
let says = format!("'{}', the part the shot shows most, is cut by the frame's edge from {} to {}", names[0], st.at(a), st.at(b));
|
||||
out.push(st.finding("subject-cut", Level::Warn, a, b, says).fix("frame it whole (move the camera back or aim it), or move in until the cut is plainly meant"));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::test_items::{cam, item};
|
||||
use super::super::*;
|
||||
use bevy::math::Mat4;
|
||||
use serde_json::json;
|
||||
|
||||
fn run(frames: Vec<Vec<Item>>) -> Vec<Finding> {
|
||||
let n: Vec<i64> = (0..frames.len() as i64).collect();
|
||||
check(&frames, &n, 1920, 1080, 30.0, "test")
|
||||
}
|
||||
|
||||
fn cube(name: &str, at: [f32; 3]) -> Item {
|
||||
let mut it = item("mesh", json!({"name": name}), Mat4::from_translation(Vec3::from(at)));
|
||||
it.shape = Some("box(1, 1, 1)".into());
|
||||
it
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_camera_aimed_past_everything_is_an_empty_frame() {
|
||||
let fs: Vec<Vec<Item>> = (0..120).map(|i| vec![cam([0.0, 0.0, 6.0], if (30..90).contains(&i) { [0.0, 40.0, 0.0] } else { [0.0; 3] }), cube("dash", [0.0; 3])]).collect();
|
||||
let f = run(fs);
|
||||
assert!(f.iter().any(|f| f.check == "frame-empty"), "{f:?}");
|
||||
let framed: Vec<Vec<Item>> = (0..120).map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), cube("dash", [0.0; 3])]).collect();
|
||||
assert!(!run(framed).iter().any(|f| f.check == "frame-empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_floor_filling_the_frame_is_no_content() {
|
||||
let mut floor = item("mesh", json!({"name": "floor"}), Mat4::from_translation(Vec3::new(0.0, -1.0, 0.0)));
|
||||
floor.shape = Some("box(100, 0.1, 100)".into());
|
||||
// a 4 m crate to the left, filling a sixth of the frame; for two seconds the camera looks along the floor, away
|
||||
let mut crate_ = cube("crate", [-5.0, 0.0, 0.0]);
|
||||
crate_.shape = Some("box(4, 4, 4)".into());
|
||||
let fs: Vec<Vec<Item>> = (0..120).map(|i| vec![cam([0.0, 1.0, 6.0], if (30..90).contains(&i) { [40.0, -1.0, 6.0] } else { [-5.0, 0.0, 0.0] }), floor.clone(), crate_.clone()]).collect();
|
||||
assert!(run(fs).iter().any(|f| f.check == "frame-empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_shots_subject_half_out_of_frame_is_cut() {
|
||||
// the cube's centre near the frame's right edge
|
||||
let fs: Vec<Vec<Item>> = (0..30).map(|_| vec![cam([0.0, 0.0, 6.0], [0.0; 3]), cube("logo", [4.9, 0.0, 0.0])]).collect();
|
||||
assert!(run(fs).iter().any(|f| f.check == "subject-cut"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
//! The stage checks a render runs on its frames' scenes (docs/stage-guards.feature SG10, SG12, SG13, SG14): 3D type
|
||||
//! that can't be read, parts that snap, a camera that lurches or reverses, and frames with nothing composed in them.
|
||||
//! Each reads the parts every frame holds (raea_core_scene's items, as raea-sys-contact does) through the frame's
|
||||
//! camera, and reports the part, the frames and the fix. They read the scene, not the pixels, so they run without
|
||||
//! drawing (`raea scene stage`) as well as at the end of every render.
|
||||
|
||||
use bevy::math::Vec3;
|
||||
use raea_core_facts::{Finding, Level};
|
||||
use raea_core_scene::{Item, base_ident};
|
||||
use serde_json::Value;
|
||||
|
||||
mod framing;
|
||||
mod motion;
|
||||
mod text;
|
||||
mod view;
|
||||
pub use view::View;
|
||||
|
||||
/// Who says these findings, in a render.
|
||||
pub const BY: &str = "raea render";
|
||||
|
||||
/// The checks on a render's frames, said on stderr and kept with its findings (RAEA_STAGE_CHECK=0 skips them).
|
||||
pub fn told(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64) -> Vec<Finding> {
|
||||
if std::env::var("RAEA_STAGE_CHECK").as_deref() == Ok("0") || all.iter().all(|its| its.is_empty()) {
|
||||
return Vec::new();
|
||||
}
|
||||
let t = std::time::Instant::now();
|
||||
let found = check(all, frames, w, h, fps, BY);
|
||||
for f in &found {
|
||||
eprintln!("raea: {}", f.line());
|
||||
}
|
||||
raea_core_facts::finding::said(&found);
|
||||
if raea_io_trace::stat("RAEA_TIMES") {
|
||||
eprintln!("raea times: the stage checks {:.0} ms", t.elapsed().as_secs_f64() * 1e3);
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
/// Every stage check on the frames (`all[k]` is frame `frames[k]`'s parts), worst first.
|
||||
pub fn check(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64, by: &str) -> Vec<Finding> {
|
||||
let st = Stage::new(all, frames, w, h, fps, by);
|
||||
let mut out = text::check(&st);
|
||||
out.extend(motion::camera(&st));
|
||||
out.extend(motion::snaps(&st));
|
||||
out.extend(framing::check(&st));
|
||||
raea_core_facts::finding::ranked(merged(out))
|
||||
}
|
||||
|
||||
/// Findings of one check over the same frames as one, the others named after it: a code listing's twenty lines too
|
||||
/// small to read are one fault, not twenty.
|
||||
fn merged(fs: Vec<Finding>) -> Vec<Finding> {
|
||||
let (mut out, mut more): (Vec<Finding>, Vec<Vec<String>>) = (Vec::new(), Vec::new());
|
||||
for f in fs {
|
||||
match out.iter().position(|o| o.check == f.check && o.level == f.level && o.frames == f.frames) {
|
||||
Some(i) => more[i].push(f.says.split('\'').nth(1).unwrap_or(&f.check).to_string()),
|
||||
None => {
|
||||
out.push(f);
|
||||
more.push(Vec::new());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (f, m) in out.iter_mut().zip(more).filter(|(_, m)| !m.is_empty()) {
|
||||
let named: Vec<String> = m.iter().take(4).map(|n| format!("'{n}'")).collect();
|
||||
f.says = format!("{}; and {} more the same: {}{}", f.says, m.len(), named.join(", "), if m.len() > 4 { ", …" } else { "" });
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The frames as the checks read them: each one's parts and camera, and where the shots cut.
|
||||
pub(crate) struct Stage<'a> {
|
||||
pub all: &'a [Vec<Item>],
|
||||
pub frames: &'a [i64],
|
||||
pub views: Vec<Option<View>>,
|
||||
/// cut[k]: frame k starts a new shot (the first frame, a gap in the frames, a camera jump or a new camera)
|
||||
pub cut: Vec<bool>,
|
||||
pub w: f32,
|
||||
pub h: f32,
|
||||
pub fps: f64,
|
||||
pub by: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> Stage<'a> {
|
||||
fn new(all: &'a [Vec<Item>], frames: &'a [i64], w: u32, h: u32, fps: f64, by: &'a str) -> Stage<'a> {
|
||||
let views: Vec<Option<View>> = all.iter().map(|its| View::of(its, w, h)).collect();
|
||||
let cut = motion::cuts(&views, frames);
|
||||
Stage { all, frames, views, cut, w: w as f32, h: h as f32, fps: fps.max(1.0), by }
|
||||
}
|
||||
|
||||
/// A finding about frames `a..=b` (indices into the frames), at `level`.
|
||||
pub fn finding(&self, check: &str, level: Level, a: usize, b: usize, says: String) -> Finding {
|
||||
Finding::new(check, level, says, self.by).frames(self.frames[a], self.frames[b] + 1)
|
||||
}
|
||||
|
||||
/// Seconds from frame index a to b, inclusive of both.
|
||||
pub fn secs(&self, a: usize, b: usize) -> f64 {
|
||||
(self.frames[b] - self.frames[a] + 1) as f64 / self.fps
|
||||
}
|
||||
|
||||
/// A frame stepped alone (raea render --at, raea check --quick's stills): neither neighbour was, so it stands for
|
||||
/// its moment, and a fault in it counts as lasting.
|
||||
pub fn alone(&self, k: usize) -> bool {
|
||||
let f = self.frames[k];
|
||||
(k == 0 || self.frames[k - 1] + 1 != f) && self.frames.get(k + 1).is_none_or(|n| *n != f + 1)
|
||||
}
|
||||
|
||||
/// Whether every frame from a to b was stepped: what a reveal and a reading time are judged over.
|
||||
pub fn stepped(&self, a: usize, b: usize) -> bool {
|
||||
self.frames[b] - self.frames[a] == (b - a) as i64
|
||||
}
|
||||
|
||||
/// A frame index as a time in the piece, "1:10.06" (minutes, seconds and frames).
|
||||
pub fn at(&self, k: usize) -> String {
|
||||
let f = self.frames[k];
|
||||
let fps = self.fps.round().max(1.0) as i64;
|
||||
let s = f / fps;
|
||||
format!("{}:{:02}.{:02}", s / 60, s % 60, f % fps)
|
||||
}
|
||||
}
|
||||
|
||||
/// What a part is called in a finding: its name, else what it draws, cut short.
|
||||
pub(crate) fn called(it: &Item) -> String {
|
||||
let s = base_ident(it);
|
||||
let s = if s.is_empty() { it.kind } else { s };
|
||||
let mut out: String = s.chars().take(40).collect();
|
||||
if s.chars().count() > 40 {
|
||||
out.push('…');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A number prop.
|
||||
pub(crate) fn num(it: &Item, k: &str, d: f64) -> f64 {
|
||||
it.props.get(k).and_then(Value::as_f64).unwrap_or(d)
|
||||
}
|
||||
|
||||
/// A part's own scale (its matrix's), the largest axis.
|
||||
pub(crate) fn scale_of(it: &Item) -> f32 {
|
||||
let (s, _, _) = it.world.to_scale_rotation_translation();
|
||||
s.abs().max_element()
|
||||
}
|
||||
|
||||
/// Runs of consecutive indices where `bad` holds, as (first, last), broken at each cut.
|
||||
pub(crate) fn runs(st: &Stage, n: usize, bad: impl Fn(usize) -> bool) -> Vec<(usize, usize)> {
|
||||
let mut out = Vec::new();
|
||||
let mut from: Option<usize> = None;
|
||||
for k in 0..n {
|
||||
let b = bad(k);
|
||||
if let Some(f) = from {
|
||||
if !b || st.cut[k] {
|
||||
out.push((f, k - 1));
|
||||
from = None;
|
||||
}
|
||||
}
|
||||
if b && from.is_none() {
|
||||
from = Some(k);
|
||||
}
|
||||
}
|
||||
if let Some(f) = from {
|
||||
out.push((f, n - 1));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The world point a part stands at.
|
||||
pub(crate) fn origin(it: &Item) -> Vec3 {
|
||||
it.world.transform_point3(Vec3::ZERO)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_items {
|
||||
use super::*;
|
||||
use bevy::math::Mat4;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub 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.
|
||||
pub fn cam(eye: [f32; 3], at: [f32; 3]) -> Item {
|
||||
item("camera", json!({"position": eye, "lookAt": at, "fov": 50}), Mat4::IDENTITY)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
//! What moves between frames: where the shots cut, a camera that lurches or reverses (SG13), and parts that snap
|
||||
//! (SG12), including a line drawn as a chain of parts.
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
|
||||
use bevy::math::Vec3;
|
||||
use raea_core_facts::{Finding, Level};
|
||||
|
||||
use super::{Stage, View, called, num, origin, scale_of};
|
||||
|
||||
/// A cut: the eye jumps or the view turns this many times its neighbours' step in one frame (and past a floor)
|
||||
const CUT_RATIO: f32 = 8.0;
|
||||
const CUT_METRES: f32 = 0.25;
|
||||
const CUT_DEGREES: f32 = 4.0;
|
||||
/// A speed change this sharp in one frame, against the changes either side of it, is a lurch
|
||||
const KINK: f32 = 3.0;
|
||||
/// The camera counts as moving above this share of the shot's top speed, and above a speed a change in can be seen at
|
||||
/// all: 0.1 degrees of turn a frame, 3 mm of travel
|
||||
const MOVING: f32 = 0.1;
|
||||
const SEEN_TURN: f32 = 0.1;
|
||||
const SEEN_TRAVEL: f32 = 0.003;
|
||||
/// A lurch's ratio: an error from 2x, a warning from 1.5x
|
||||
const LURCH: f32 = 2.0;
|
||||
const LURCH_WARN: f32 = 1.5;
|
||||
/// A reversal: a move one way then the other within this long, each at least this far
|
||||
const REVERSE_SECS: f64 = 1.5;
|
||||
const REVERSE_METRES: f32 = 0.15;
|
||||
const REVERSE_DEGREES: f32 = 3.0;
|
||||
/// A part's size or place on screen jumping more than this in one frame, alone, is a snap
|
||||
const SNAP_SIZE: f32 = 1.25;
|
||||
const SNAP_MOVE: f32 = 0.1;
|
||||
/// A part reaching further than this from its origin (water, a floor, a building) has no one size on screen to snap
|
||||
const BIG_REACH: f32 = 6.0;
|
||||
/// This many parts snapping in one frame is the layout changing (an edit), not a part drawn from a stale frame
|
||||
const EDIT_PARTS: usize = 4;
|
||||
/// A chain of more than this many parts named NAME-i is a line made of parts
|
||||
const CHAIN: usize = 8;
|
||||
|
||||
/// cut[k]: frame k starts a shot.
|
||||
pub(crate) fn cuts(views: &[Option<View>], frames: &[i64]) -> Vec<bool> {
|
||||
let n = views.len();
|
||||
let step = |k: usize| -> Option<(f32, f32)> {
|
||||
let (a, b) = (views[k - 1]?, views[k]?);
|
||||
Some(((b.eye - a.eye).length(), a.turn(&b)))
|
||||
};
|
||||
let steps: Vec<Option<(f32, f32)>> = (0..n).map(|k| if k == 0 { None } else { step(k) }).collect();
|
||||
(0..n)
|
||||
.map(|k| {
|
||||
if k == 0 || frames[k] != frames[k - 1] + 1 || views[k].is_none() != views[k - 1].is_none() {
|
||||
return true;
|
||||
}
|
||||
let Some((d, t)) = steps[k] else { return false };
|
||||
let around = |f: fn(&(f32, f32)) -> f32| [k.wrapping_sub(1), k + 1].iter().filter_map(|&j| steps.get(j).copied().flatten()).map(|s| f(&s)).fold(0.0, f32::max);
|
||||
(d > CUT_METRES && d > CUT_RATIO * around(|s| s.0)) || (t > CUT_DEGREES && t > CUT_RATIO * around(|s| s.1))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The shots: (first, last) frame indices, each with a camera throughout.
|
||||
fn shots(st: &Stage) -> Vec<(usize, usize)> {
|
||||
let n = st.views.len();
|
||||
let mut out = Vec::new();
|
||||
let mut a = 0;
|
||||
for k in 1..=n {
|
||||
if k == n || st.cut[k] {
|
||||
if st.views[a].is_some() {
|
||||
out.push((a, k - 1));
|
||||
}
|
||||
a = k;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// SG13: inside each shot, a speed that changes sharply in one frame (a lurch) or a move undone within 1.5 s.
|
||||
pub(crate) fn camera(st: &Stage) -> Vec<Finding> {
|
||||
let mut out = Vec::new();
|
||||
for (a, b) in shots(st) {
|
||||
if b < a + 3 {
|
||||
continue;
|
||||
}
|
||||
let v: Vec<View> = (a..=b).map(|k| st.views[k].unwrap()).collect();
|
||||
// each frame's step: the eye's travel (m), the view's turn (degrees); index i is the step into frame a+i
|
||||
let lin: Vec<f32> = (0..v.len()).map(|i| if i == 0 { 0.0 } else { (v[i].eye - v[i - 1].eye).length() }).collect();
|
||||
let ang: Vec<f32> = (0..v.len()).map(|i| if i == 0 { 0.0 } else { v[i - 1].turn(&v[i]) }).collect();
|
||||
for (what, s, seen) in [("travel", &lin, SEEN_TRAVEL), ("turn", &ang, SEEN_TURN)] {
|
||||
let top = s.iter().copied().fold(0.0, f32::max);
|
||||
if top <= 1e-5 {
|
||||
continue;
|
||||
}
|
||||
let mut i = 2;
|
||||
while i + 1 < s.len() {
|
||||
let (p, q) = (s[i - 1], s[i]);
|
||||
let hi = p.max(q);
|
||||
let jump = (q - p).abs();
|
||||
let around = (s[i - 1] - s[i - 2]).abs().max((s[i + 1] - s[i]).abs());
|
||||
if hi > MOVING * top && hi > seen && jump > 0.5 * hi && jump > KINK * around {
|
||||
let r = hi / p.min(q).max(1e-6);
|
||||
if r >= LURCH_WARN {
|
||||
let k = a + i;
|
||||
let level = if r >= LURCH { Level::Error } else { Level::Warn };
|
||||
let says = if p.min(q) < 1e-4 { format!("the camera's {what} {} at {} with no ease", if q > p { "starts at full speed" } else { "stops dead" }, st.at(k)) } else { format!("the camera's {what} {} {r:.1}x in one frame at {}", if q > p { "jumps faster" } else { "brakes" }, st.at(k)) };
|
||||
let mut f = st.finding("camera-lurch", level, k - 1, k, says).fix("move the camera on one smooth path through its keys (raea/camera's cameraPath, and path.check() for keys that still brake), easing only where it starts and stops");
|
||||
f.measure = Some(raea_core_facts::finding::Measure { name: "speed change".into(), value: r.min(99.0) as f64, unit: "x".into(), limit: Some(LURCH as f64) });
|
||||
out.push(f);
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
out.extend(reversals(st, a, &v));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A dolly in then out, or a pan one way then back, within REVERSE_SECS.
|
||||
fn reversals(st: &Stage, a: usize, v: &[View]) -> Vec<Finding> {
|
||||
let mut out = Vec::new();
|
||||
// signed steps: along the view (in is +), and the turn about the view's up (left is +)
|
||||
let dolly: Vec<f32> = (1..v.len()).map(|i| (v[i].eye - v[i - 1].eye).dot(v[i - 1].fwd)).collect();
|
||||
let pan: Vec<f32> = (1..v.len()).map(|i| v[i - 1].fwd.cross(v[i].fwd).dot(v[i - 1].up).asin().to_degrees()).collect();
|
||||
for (what, s, least, ways) in [("framing", &dolly, REVERSE_METRES, ("in", "out")), ("pan", &pan, REVERSE_DEGREES, ("left", "right"))] {
|
||||
// runs of one sign, each with its total and its frames (indices into s, step i is into frame a+i+1)
|
||||
let top = s.iter().map(|x| x.abs()).fold(0.0, f32::max);
|
||||
let mut moves: Vec<(usize, usize, f32)> = Vec::new();
|
||||
for (i, x) in s.iter().enumerate() {
|
||||
if x.abs() <= 0.05 * top {
|
||||
continue;
|
||||
}
|
||||
match moves.last_mut() {
|
||||
Some(m) if m.2.signum() == x.signum() && i <= m.1 + 3 => {
|
||||
m.1 = i;
|
||||
m.2 += x;
|
||||
}
|
||||
_ => moves.push((i, i, *x)),
|
||||
}
|
||||
}
|
||||
for w in moves.windows(2) {
|
||||
let (m0, m1) = (w[0], w[1]);
|
||||
// the whole there-and-back, not the pause between two long moves
|
||||
let span = (m1.1 - m0.0 + 1) as f64 / st.fps;
|
||||
if m0.2.signum() != m1.2.signum() && m0.2.abs() >= least && m1.2.abs() >= least && span <= REVERSE_SECS {
|
||||
let (k0, k1) = (a + m0.0 + 1, a + m1.1 + 1);
|
||||
let (one, other) = if m0.2 > 0.0 { ways } else { (ways.1, ways.0) };
|
||||
let unit = if what == "pan" { "°" } else { " m" };
|
||||
let says = format!("the camera's {what} goes {one} {:.2}{unit} then {other} {:.2}{unit} within {:.1} s ({} to {})", m0.2.abs(), m1.2.abs(), st.secs(k0, k1), st.at(k0), st.at(k1));
|
||||
// a dolly in and back out is a path overshooting its key; a pan there and back can be a look round (a
|
||||
// first-person camera), so it's a warning
|
||||
let level = if what == "pan" { Level::Warn } else { Level::Error };
|
||||
out.push(st.finding("camera-reverse", level, k0, k1, says).fix("let the move finish where it's going: drop the key that turns it back, or hold between the two moves"));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A part's reach from its origin, in metres, for its size on screen: a block of words' width, a shape's box.
|
||||
fn reach(it: &raea_core_scene::Item, boxes: &mut HashMap<String, Option<f32>>) -> Option<f32> {
|
||||
let own = match it.kind {
|
||||
"text" => {
|
||||
let words = it.props.get("text").and_then(serde_json::Value::as_str).unwrap_or("");
|
||||
let wide = words.split('\n').map(|l| l.chars().count()).max().unwrap_or(0) as f32 * 0.55;
|
||||
Some(0.5 * wide.max(1.0) * num(it, "size", 0.5) as f32)
|
||||
}
|
||||
"mesh" => {
|
||||
let shape = it.shape.as_deref()?;
|
||||
*boxes.entry(shape.to_string()).or_insert_with(|| {
|
||||
let t = raea_core_shape::cached(shape).ok()?;
|
||||
let r = t.positions.iter().map(|p| Vec3::from(*p).length()).fold(0.0, f32::max);
|
||||
(r > 0.0).then_some(r)
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}?;
|
||||
Some(own * scale_of(it))
|
||||
}
|
||||
|
||||
/// SG12: a named part whose size or place on screen jumps in one frame, alone (no cut, no steady move either side),
|
||||
/// and a line drawn as a growing chain of parts named NAME-i.
|
||||
pub(crate) fn snaps(st: &Stage) -> Vec<Finding> {
|
||||
let mut boxes = HashMap::new();
|
||||
// each named part's screen size (px) and centre, by frame, a run for each of what it is: new words or a new shape
|
||||
// is the part spawned again (SG1), new content and no snap (a counter's words growing as its number does)
|
||||
let mut by: BTreeMap<(String, u64), Vec<(usize, f32, [f32; 2])>> = BTreeMap::new();
|
||||
let mut chains: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new();
|
||||
for (k, its) in st.all.iter().enumerate() {
|
||||
let mut links: HashMap<String, usize> = HashMap::new();
|
||||
for it in its.iter() {
|
||||
let Some(name) = it.props.get("name").and_then(serde_json::Value::as_str) else { continue };
|
||||
if let Some((stem, i)) = name.rsplit_once('-') {
|
||||
if !stem.is_empty() && i.chars().all(|c| c.is_ascii_digit()) && !i.is_empty() {
|
||||
*links.entry(stem.to_string()).or_default() += 1;
|
||||
}
|
||||
}
|
||||
let (Some(v), Some(r)) = (st.views[k], reach(it, &mut boxes).filter(|r| *r <= BIG_REACH)) else { continue };
|
||||
let Some([x, y, depth]) = v.project(origin(it)) else { continue };
|
||||
if x < 0.0 || x > st.w || y < 0.0 || y > st.h {
|
||||
continue;
|
||||
}
|
||||
by.entry((called(it), raea_core_scene::spawn_sig(it))).or_default().push((k, r * v.focal / depth, [x, y]));
|
||||
}
|
||||
for (stem, n) in links {
|
||||
let c = chains.entry(stem).or_insert((k, n, n));
|
||||
c.1 = c.1.min(n);
|
||||
c.2 = c.2.max(n);
|
||||
}
|
||||
}
|
||||
let mut out: Vec<(usize, Finding)> = Vec::new();
|
||||
for ((name, _), seen) in &by {
|
||||
// a name several items carry in one frame has no one size to follow
|
||||
let frames: std::collections::HashSet<usize> = seen.iter().map(|s| s.0).collect();
|
||||
if frames.len() < seen.len() {
|
||||
continue;
|
||||
}
|
||||
// a step's size change (log ratio) and travel (share of the width), for consecutive frames in one shot
|
||||
let step = |i: usize| -> Option<(f32, f32)> {
|
||||
let (a, b) = (seen.get(i.checked_sub(1)?)?, seen.get(i)?);
|
||||
(b.0 == a.0 + 1 && !st.cut[b.0]).then(|| ((b.1 / a.1.max(1e-3)).ln().abs(), ((b.2[0] - a.2[0]).powi(2) + (b.2[1] - a.2[1]).powi(2)).sqrt() / st.w))
|
||||
};
|
||||
for i in 1..seen.len() {
|
||||
// steady frames on both sides: a part coming in (a pop, a fade up) has none before it
|
||||
let (Some((ds, dm)), Some(before), Some(after)) = (step(i), step(i - 1), step(i + 1)) else { continue };
|
||||
let side = |f: fn((f32, f32)) -> f32| f(before).max(f(after));
|
||||
let k = seen[i].0;
|
||||
if ds > SNAP_SIZE.ln() && ds > 3.0 * side(|s| s.0) && seen[i].1.max(seen[i - 1].1) > 4.0 {
|
||||
let says = format!("'{name}' snaps from {:.0} px to {:.0} px on screen at {} with no cut", seen[i - 1].1, seen[i].1, st.at(k));
|
||||
out.push((k, st.finding("part-snap", Level::Error, k - 1, k, says).fix("animate the change over frames, or cut to it; a part that comes in a frame late or at another's place is drawn from a stale frame (raea render's frame purity)")));
|
||||
} else if dm > SNAP_MOVE && dm > 3.0 * side(|s| s.1) {
|
||||
let says = format!("'{name}' jumps {:.0}% of the frame's width at {} with no cut", dm * 100.0, st.at(k));
|
||||
out.push((k, st.finding("part-snap", Level::Warn, k - 1, k, says).fix("move it over frames, or cut; check it isn't placed from another part's frame")));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut at: HashMap<usize, usize> = HashMap::new();
|
||||
for (k, _) in &out {
|
||||
*at.entry(*k).or_default() += 1;
|
||||
}
|
||||
let mut out: Vec<Finding> = out.into_iter().filter(|(k, _)| at[k] < EDIT_PARTS).map(|(_, f)| f).collect();
|
||||
for (stem, (k, least, most)) in chains {
|
||||
if most > CHAIN && most > least {
|
||||
let says = format!("a line made of {most} parts ('{stem}-0' to '{stem}-{}'), mounted a part at a time as it grows", most - 1);
|
||||
out.push(st.finding("line-of-parts", Level::Warn, k, k, says).fix("draw it as one Line3d or Tube (raea/mesh) and animate its `p`"));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::test_items::{cam, item};
|
||||
use super::super::*;
|
||||
use bevy::math::Mat4;
|
||||
use serde_json::json;
|
||||
|
||||
fn run(frames: Vec<Vec<Item>>) -> Vec<Finding> {
|
||||
let n: Vec<i64> = (0..frames.len() as i64).collect();
|
||||
check(&frames, &n, 1920, 1080, 30.0, "test")
|
||||
}
|
||||
|
||||
fn eased(t: f32) -> f32 {
|
||||
t * t * (3.0 - 2.0 * t)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_smooth_dolly_passes_and_a_kinked_one_lurches() {
|
||||
let smooth: Vec<Vec<Item>> = (0..90).map(|i| vec![cam([0.0, 0.0, 10.0 - 6.0 * eased(i as f32 / 89.0)], [0.0; 3])]).collect();
|
||||
assert_eq!(run(smooth).len(), 0);
|
||||
// two linear legs, the second three times as fast, joined with no ease: a 3x lurch
|
||||
let kinked: Vec<Vec<Item>> = (0..60).map(|i| { let z = if i < 30 { 10.0 - 0.02 * i as f32 } else { 9.4 - 0.06 * (i - 30) as f32 }; vec![cam([0.0, 0.0, z], [0.0, 0.0, -100.0])] }).collect();
|
||||
let f = run(kinked);
|
||||
assert!(f.iter().any(|f| f.check == "camera-lurch" && f.level == Level::Error), "{f:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cut_is_not_a_lurch_and_in_then_out_is_a_reversal() {
|
||||
let cut: Vec<Vec<Item>> = (0..60).map(|i| if i < 30 { vec![cam([0.0, 0.0, 10.0 - 0.01 * i as f32], [0.0; 3])] } else { vec![cam([5.0, 2.0, 3.0 - 0.01 * (i - 30) as f32], [5.0, 2.0, -10.0])] }).collect();
|
||||
assert_eq!(run(cut).iter().filter(|f| f.check.starts_with("camera")).count(), 0);
|
||||
// in 0.5 m over 15 frames, out 0.5 m over the next 15
|
||||
let back: Vec<Vec<Item>> = (0..40).map(|i| { let t = i.min(30) as f32; let z = if t <= 15.0 { 10.0 - 0.5 * eased(t / 15.0) } else { 9.5 + 0.5 * eased((t - 15.0) / 15.0) }; vec![cam([0.0, 0.0, z], [0.0, 0.0, -100.0])] }).collect();
|
||||
assert!(run(back).iter().any(|f| f.check == "camera-reverse"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_that_snaps_is_said_and_one_that_grows_isnt() {
|
||||
let dot = |s: f32| item("mesh", json!({"name": "dot"}), Mat4::from_scale(Vec3::splat(s)));
|
||||
let shaped = |s: f32| { let mut d = dot(s); d.shape = Some("sphere(0.1)".into()); d };
|
||||
let snap: Vec<Vec<Item>> = (0..20).map(|i| vec![cam([0.0, 0.0, 5.0], [0.0; 3]), shaped(if i < 10 { 1.0 } else { 1.6 })]).collect();
|
||||
assert!(run(snap).iter().any(|f| f.check == "part-snap"), "a 60% jump in one frame");
|
||||
let grow: Vec<Vec<Item>> = (0..20).map(|i| vec![cam([0.0, 0.0, 5.0], [0.0; 3]), shaped(1.0 + 0.05 * i as f32)]).collect();
|
||||
assert!(!run(grow).iter().any(|f| f.check == "part-snap"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_pop_in_two_long_moves_and_a_shared_name_are_not_faults() {
|
||||
let shaped = |name: &str, s: f32, x: f32| { let mut d = item("mesh", json!({"name": name}), Mat4::from_scale_rotation_translation(Vec3::splat(s), Default::default(), Vec3::new(x, 0.0, 0.0))); d.shape = Some("sphere(0.1)".into()); d };
|
||||
// absent, then in at 0.7 and up to full size: no steady frames before it
|
||||
let pop: Vec<Vec<Item>> = (0..20).map(|i| { let mut v = vec![cam([0.0, 0.0, 5.0], [0.0; 3])]; if i >= 10 { v.push(shaped("dot", if i == 10 { 0.7 } else { 1.0 }, 0.0)); } v }).collect();
|
||||
assert!(!run(pop).iter().any(|f| f.check == "part-snap"));
|
||||
// two items named alike, far apart: not one part jumping between them
|
||||
let twins: Vec<Vec<Item>> = (0..20).map(|_| vec![cam([0.0, 0.0, 5.0], [0.0; 3]), shaped("tile", 1.0, -1.5), shaped("tile", 1.6, 1.5)]).collect();
|
||||
assert!(!run(twins).iter().any(|f| f.check == "part-snap"));
|
||||
// its shape (or words) changed: spawned again as new content (SG1), not a snap
|
||||
let regrown: Vec<Vec<Item>> = (0..20).map(|i| { let mut d = shaped("count", 1.0, 0.0); d.shape = Some(if i < 10 { "sphere(0.1)" } else { "sphere(0.16)" }.into()); vec![cam([0.0, 0.0, 5.0], [0.0; 3]), d] }).collect();
|
||||
assert!(!run(regrown).iter().any(|f| f.check == "part-snap"));
|
||||
// out 2 m over 3 s, then in 2 m over 3 s: two moves, not a reversal
|
||||
let long: Vec<Vec<Item>> = (0..180).map(|i| { let t = i as f32 / 90.0; let z = if t <= 1.0 { 8.0 + 2.0 * eased(t) } else { 10.0 - 2.0 * eased(t - 1.0) }; vec![cam([0.0, 0.0, z], [0.0, 0.0, -100.0])] }).collect();
|
||||
assert!(!run(long).iter().any(|f| f.check == "camera-reverse"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_growing_chain_of_parts_is_a_line_made_of_parts() {
|
||||
let chain: Vec<Vec<Item>> = (0..20).map(|i| { let mut v = vec![cam([0.0, 0.0, 5.0], [0.0; 3])]; v.extend((0..=i).map(|j| item("mesh", json!({"name": format!("curve-{j}")}), Mat4::IDENTITY))); v }).collect();
|
||||
assert!(run(chain).iter().any(|f| f.check == "line-of-parts"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
//! SG10, 3D type that reads: each RichText checked on every frame it shows, through the frame's camera. Its letters'
|
||||
//! height on screen, its face against the line to the camera, its box against the title-safe area, whether its reveal
|
||||
//! starts and finishes while it's up, and whether it's up long enough to be read. A RichText with `read={false}` is
|
||||
//! scenery (a sign seen in passing) and isn't held to it.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use bevy::math::Vec3;
|
||||
use raea_core_facts::{Finding, Level};
|
||||
use serde_json::Value;
|
||||
|
||||
use super::{Stage, called, num, origin, runs};
|
||||
use crate::view::corners;
|
||||
|
||||
/// A capital's height, as a share of the em (Inter's is 0.727; most text faces 0.66 to 0.75)
|
||||
const CAP: f32 = 0.7;
|
||||
/// The smallest capital on screen, in px of a 1080-high frame (scaled to the frame)
|
||||
const MIN_CAP: f32 = 22.0;
|
||||
/// The most its face may turn from the line to the camera, degrees: past it a warning (squashed), past TURN_ERROR an
|
||||
/// error (squashed to under 64%: floor labels seen low)
|
||||
const MAX_TURN: f32 = 35.0;
|
||||
const TURN_ERROR: f32 = 50.0;
|
||||
/// The title-safe area's inset from each edge, a share of the frame
|
||||
const SAFE: f32 = 0.05;
|
||||
/// How long a fault must last while the words are up to be said, seconds (a fly-past isn't a label)
|
||||
const LASTS: f64 = 0.5;
|
||||
/// A glyph counts as shown above this opacity, and fully in above the next
|
||||
const SHOWN: f64 = 0.05;
|
||||
const IN: f64 = 0.9;
|
||||
/// Still enough to read: its words move less than this share of the frame's width a frame
|
||||
const STILL: f32 = 0.01;
|
||||
/// An average glyph's advance, a share of the em, for the block's width
|
||||
const ADVANCE: f32 = 0.55;
|
||||
|
||||
/// One frame of one block of words, as the camera sees it.
|
||||
#[derive(Clone, Debug)]
|
||||
struct Seen {
|
||||
k: usize,
|
||||
/// a capital's height on screen, px
|
||||
cap: f32,
|
||||
/// its face's turn from the line to the camera, degrees (over 90: seen from behind)
|
||||
turn: f32,
|
||||
/// its box on screen, None when part of it is behind the camera
|
||||
b: Option<[f32; 4]>,
|
||||
/// its centre on screen
|
||||
c: [f32; 2],
|
||||
/// some glyph shown, every glyph fully in
|
||||
shown: bool,
|
||||
whole: bool,
|
||||
}
|
||||
|
||||
pub(crate) fn check(st: &Stage) -> Vec<Finding> {
|
||||
let min_cap = MIN_CAP * st.h / 1080.0;
|
||||
// each block's frames, by what it's called, in frame order
|
||||
let mut by: BTreeMap<String, (Vec<Seen>, usize, bool)> = BTreeMap::new();
|
||||
for (k, its) in st.all.iter().enumerate() {
|
||||
let Some(v) = st.views[k] else { continue };
|
||||
for it in its.iter().filter(|i| i.kind == "text") {
|
||||
if it.props.get("read").and_then(Value::as_bool) == Some(false) {
|
||||
continue;
|
||||
}
|
||||
let words = it.props.get("text").and_then(Value::as_str).unwrap_or("");
|
||||
if words.trim().is_empty() {
|
||||
continue;
|
||||
}
|
||||
let o = origin(it);
|
||||
let Some([cx, cy, depth]) = v.project(o) else { continue };
|
||||
// its em on screen: the em's height carried by its matrix, at its depth
|
||||
let size = num(it, "size", 0.5) as f32;
|
||||
let up = it.world.transform_vector3(Vec3::Y * size);
|
||||
let cap = CAP * up.length() * v.focal / depth;
|
||||
let face = it.world.transform_vector3(Vec3::Z).normalize_or(Vec3::Z);
|
||||
let turn = face.dot((v.eye - o).normalize_or(Vec3::Z)).clamp(-1.0, 1.0).acos().to_degrees();
|
||||
let lines: Vec<&str> = words.split('\n').collect();
|
||||
let wide = lines.iter().map(|l| l.chars().count()).max().unwrap_or(0) as f32 * ADVANCE * size;
|
||||
let tall = lines.len() as f32 * num(it, "lineHeight", 1.2) as f32 * size;
|
||||
let align = num(it, "align", 0.5) as f32;
|
||||
let (x0, x1) = (-align * wide, (1.0 - align) * wide);
|
||||
let b = v.bounds(corners(&it.world, Vec3::new(x0, -tall / 2.0, 0.0), Vec3::new(x1, tall / 2.0, 0.0)));
|
||||
let os: Vec<f64> = it.props.get("glyphs").and_then(Value::as_array).map(|gs| gs.iter().map(|g| if g.get("v").and_then(Value::as_bool) == Some(false) { 0.0 } else { g.get("o").and_then(Value::as_f64).unwrap_or(1.0) }).collect()).unwrap_or_default();
|
||||
let shown = os.is_empty() || os.iter().any(|o| *o > SHOWN);
|
||||
let whole = os.iter().all(|o| *o > IN);
|
||||
let e = by.entry(called(it)).or_insert_with(|| (Vec::new(), words.split_whitespace().count(), it.props.get("at").is_some()));
|
||||
e.0.push(Seen { k, cap, turn, b, c: [cx, cy], shown, whole });
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for (name, (seen, words, has_at)) in &by {
|
||||
// the frames it's up and in frame
|
||||
let up: Vec<&Seen> = seen.iter().filter(|s| s.shown && in_frame(st, s.c)).collect();
|
||||
// the frames of a run (up is in frame order)
|
||||
let during = |a: usize, b: usize| up.iter().skip_while(move |s| s.k < a).take_while(move |s| s.k <= b);
|
||||
let lasting = |bad: &dyn Fn(&Seen) -> bool| -> Vec<(usize, usize)> {
|
||||
let flagged: std::collections::HashSet<usize> = up.iter().filter(|s| bad(s)).map(|s| s.k).collect();
|
||||
runs(st, st.all.len(), |k| flagged.contains(&k)).into_iter().filter(|(a, b)| st.secs(*a, *b) >= LASTS || (a == b && st.alone(*a))).collect()
|
||||
};
|
||||
for (a, b) in lasting(&|s| s.cap < min_cap) {
|
||||
let least = during(a, b).map(|s| s.cap).fold(f32::MAX, f32::min);
|
||||
let f = st.finding("type-small", Level::Error, a, b, format!("the words '{name}' stand {least:.0} px high on screen from {} to {} (capitals at least {min_cap:.0} px at this frame size)", st.at(a), st.at(b)));
|
||||
out.push(fix(f, "bring the camera nearer, or make its size larger: a label that points at a part reads better as page type laid over the frame; scenery nobody is meant to read takes read={false}", least, min_cap, "px"));
|
||||
}
|
||||
for (a, b) in lasting(&|s| s.turn > MAX_TURN) {
|
||||
let most = during(a, b).map(|s| s.turn).fold(0.0, f32::max);
|
||||
let says = if most > 90.0 { format!("the words '{name}' are seen from behind (turned {most:.0}°) from {} to {}", st.at(a), st.at(b)) } else { format!("the words '{name}' are turned {most:.0}° from the camera from {} to {} (at most {MAX_TURN:.0}°), so they read squashed", st.at(a), st.at(b)) };
|
||||
let level = if most > TURN_ERROR { Level::Error } else { Level::Warn };
|
||||
out.push(fix(st.finding("type-angle", level, a, b, says), "turn the words to face the camera (their rotation), or move the camera round to face them", most, MAX_TURN, "°"));
|
||||
}
|
||||
let (mx, my) = (SAFE * st.w, SAFE * st.h);
|
||||
for (a, b) in lasting(&|s| s.whole && s.b.is_some_and(|b| b[0] < mx || b[1] < my || b[2] > st.w - mx || b[3] > st.h - my)) {
|
||||
let f = st.finding("type-safe", Level::Warn, a, b, format!("the words '{name}' run outside the title-safe area from {} to {}", st.at(a), st.at(b)));
|
||||
out.push(f.fix("move them in, or the camera back, so the whole block sits inside 5% of each edge"));
|
||||
}
|
||||
// its reveal: never started while it's in frame, or never finished before it goes (out of view with frames still
|
||||
// stepped after: a still's few frames end, the words don't go); only over frames all stepped (stills far apart
|
||||
// say nothing of what came between)
|
||||
let in_view: Vec<&Seen> = seen.iter().filter(|s| in_frame(st, s.c)).collect();
|
||||
if let (Some(f), Some(l)) = (in_view.first(), in_view.last()) && st.stepped(f.k, l.k) {
|
||||
let long = st.secs(f.k, l.k) >= 1.0;
|
||||
if *has_at && long && in_view.iter().all(|s| !s.shown) {
|
||||
let f = st.finding("type-reveal", Level::Error, f.k, l.k, format!("the words '{name}' are never shown: their reveal (`at`) never starts while they're up, {} to {}", st.at(f.k), st.at(l.k)));
|
||||
out.push(f.fix("give `at` in the frames of the Sequence they play in (useCurrentFrame), never a frame of another clock"));
|
||||
} else if l.k + 1 < st.all.len() && in_view.iter().any(|s| s.shown) && !in_view.iter().any(|s| s.whole) {
|
||||
let f = st.finding("type-reveal", Level::Error, f.k, l.k, format!("the words '{name}' never finish their reveal before they go ({} to {})", st.at(f.k), st.at(l.k)));
|
||||
out.push(f.fix("start the reveal earlier, make it quicker (`each`), or keep the words up longer"));
|
||||
}
|
||||
}
|
||||
// read: still, whole, big enough and facing the camera for their reading time, all told
|
||||
let need = *words as f64 / 3.0 + 0.5;
|
||||
let readable = up.windows(2).filter(|w| w[0].k + 1 == w[1].k && !st.cut[w[1].k] && readable(st, w[0], w[1], min_cap)).count() as f64 / st.fps;
|
||||
if let (Some(f), Some(l)) = (up.first(), up.last()) && st.stepped(f.k, l.k) {
|
||||
if readable + 1e-9 < need && up.iter().any(|s| s.whole) {
|
||||
let f = st.finding("type-time", Level::Warn, f.k, l.k, format!("the words '{name}' can be read for {readable:.1} s; their {words} words need {need:.1} s (words ÷ 3 a second, plus 0.5 s)"));
|
||||
out.push(fix(f, "hold them still, whole and facing the camera longer before they or the camera move", readable as f32, need as f32, "s"));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn in_frame(st: &Stage, c: [f32; 2]) -> bool {
|
||||
c[0] >= 0.0 && c[0] <= st.w && c[1] >= 0.0 && c[1] <= st.h
|
||||
}
|
||||
|
||||
fn readable(st: &Stage, a: &Seen, b: &Seen, min_cap: f32) -> bool {
|
||||
let moved = ((b.c[0] - a.c[0]).powi(2) + (b.c[1] - a.c[1]).powi(2)).sqrt() / st.w;
|
||||
b.whole && b.cap >= min_cap && b.turn <= MAX_TURN && moved < STILL
|
||||
}
|
||||
|
||||
fn fix(f: Finding, how: &str, value: f32, limit: f32, unit: &str) -> Finding {
|
||||
let mut f = f.fix(how);
|
||||
f.measure = Some(raea_core_facts::finding::Measure { name: f.check.clone(), value: value as f64, unit: unit.into(), limit: Some(limit as f64) });
|
||||
f
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::test_items::{cam, item};
|
||||
use super::super::*;
|
||||
use bevy::math::{Mat4, Quat};
|
||||
use serde_json::json;
|
||||
|
||||
fn run(frames: Vec<Vec<Item>>) -> Vec<Finding> {
|
||||
let n: Vec<i64> = (0..frames.len() as i64).collect();
|
||||
check(&frames, &n, 1920, 1080, 30.0, "test")
|
||||
}
|
||||
|
||||
fn words(text: &str, size: f64, world: Mat4, glyph_o: f64) -> Item {
|
||||
let gs: Vec<Value> = text.chars().filter(|c| !c.is_whitespace()).map(|_| json!({"o": glyph_o})).collect();
|
||||
item("text", json!({"text": text, "size": size, "glyphs": gs, "at": 0}), world)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn small_type_far_away_is_said_and_near_type_isnt() {
|
||||
// 0.1 m em at 10 m through 50 degrees: about 8 px capitals
|
||||
let far: Vec<Vec<Item>> = (0..30).map(|_| vec![cam([0.0, 0.0, 10.0], [0.0; 3]), words("Placement wall", 0.1, Mat4::IDENTITY, 1.0)]).collect();
|
||||
let f = run(far);
|
||||
assert!(f.iter().any(|f| f.check == "type-small" && f.level == Level::Error), "{f:?}");
|
||||
let near: Vec<Vec<Item>> = (0..90).map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), words("Placement", 0.4, Mat4::IDENTITY, 1.0)]).collect();
|
||||
assert_eq!(run(near).iter().map(|f| f.check.as_str()).collect::<Vec<_>>(), Vec::<&str>::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_on_the_floor_seen_low_is_turned_too_far() {
|
||||
// lying flat (facing +y), the camera low and in front
|
||||
let flat = Mat4::from_quat(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2));
|
||||
let fs: Vec<Vec<Item>> = (0..30).map(|_| vec![cam([0.0, 1.0, 5.0], [0.0; 3]), words("Floor", 0.6, flat, 1.0)]).collect();
|
||||
let f = run(fs);
|
||||
assert!(f.iter().any(|f| f.check == "type-angle"), "{f:?}");
|
||||
// and scenery isn't held to it
|
||||
let mut sign = words("Floor", 0.6, flat, 1.0);
|
||||
std::sync::Arc::make_mut(&mut sign.props).insert("read".into(), json!(false));
|
||||
assert!(run((0..30).map(|_| vec![cam([0.0, 1.0, 5.0], [0.0; 3]), sign.clone()]).collect()).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_reveal_that_never_starts_or_never_ends_is_said() {
|
||||
let never: Vec<Vec<Item>> = (0..60).map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), words("Five stars", 0.4, Mat4::IDENTITY, 0.0)]).collect();
|
||||
assert!(run(never).iter().any(|f| f.check == "type-reveal" && f.says.contains("never shown")));
|
||||
// half revealed, then gone with the piece going on
|
||||
let half: Vec<Vec<Item>> = (0..60).map(|i| { let mut v = vec![cam([0.0, 0.0, 4.0], [0.0; 3])]; if i < 40 { v.push(words("Five stars", 0.4, Mat4::IDENTITY, 0.5)) } v }).collect();
|
||||
assert!(run(half).iter().any(|f| f.check == "type-reveal" && f.says.contains("never finish")));
|
||||
// a still's own frames (raea render --frame 10 steps its neighbours): half revealed in each, nothing gone
|
||||
let still: Vec<Vec<Item>> = (0..3).map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), words("Five stars", 0.4, Mat4::IDENTITY, 0.5)]).collect();
|
||||
assert!(check(&still, &[9, 10, 11], 1920, 1080, 30.0, "test").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stills_far_apart_are_each_judged_but_say_nothing_of_time() {
|
||||
// raea check --quick's three stills: small type in each is said; half revealed in each says nothing of the reveal
|
||||
let at = [75i64, 150, 299];
|
||||
let small: Vec<Vec<Item>> = at.iter().map(|_| vec![cam([0.0, 0.0, 10.0], [0.0; 3]), words("Placement wall", 0.1, Mat4::IDENTITY, 1.0)]).collect();
|
||||
assert!(check(&small, &at, 1920, 1080, 30.0, "test").iter().any(|f| f.check == "type-small"));
|
||||
let half: Vec<Vec<Item>> = at.iter().map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), words("Five stars", 0.4, Mat4::IDENTITY, 0.5)]).collect();
|
||||
assert!(check(&half, &at, 1920, 1080, 30.0, "test").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn words_up_too_briefly_to_read_are_a_warning() {
|
||||
let brief: Vec<Vec<Item>> = (0..20).map(|_| vec![cam([0.0, 0.0, 4.0], [0.0; 3]), words("The best ad network for growing studios", 0.3, Mat4::IDENTITY, 1.0)]).collect();
|
||||
let f = run(brief);
|
||||
let t = f.iter().find(|f| f.check == "type-time").expect("type-time");
|
||||
assert_eq!(t.level, Level::Warn);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
//! The frame's camera as the checks read it: where it is, where it looks, and a point's place on screen.
|
||||
|
||||
use bevy::math::{Mat4, Quat, Vec3, Vec4};
|
||||
use raea_core_scene::{Item, vec3};
|
||||
use serde_json::Value;
|
||||
|
||||
/// The camera a frame draws through (its first PerspectiveCamera that draws), in world space.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct View {
|
||||
pub eye: Vec3,
|
||||
/// where it looks and its up, unit vectors
|
||||
pub fwd: Vec3,
|
||||
pub up: Vec3,
|
||||
/// pixels a metre at one metre's depth (the vertical focal length in px)
|
||||
pub focal: f32,
|
||||
pub w: f32,
|
||||
pub h: f32,
|
||||
view: Mat4,
|
||||
}
|
||||
|
||||
impl View {
|
||||
/// The frame's camera, None when it has none. Camera3d gives its rotation as a quaternion; a three.js-style camera
|
||||
/// gives where it looks (lookAt). Its parent's transform is the item's matrix.
|
||||
pub fn of(its: &[Item], w: u32, h: u32) -> Option<View> {
|
||||
let c = its.iter().find(|i| i.kind == "camera" && i.props.get("active").and_then(Value::as_bool) != Some(false))?;
|
||||
let (_, parent_rot, _) = c.world.to_scale_rotation_translation();
|
||||
let p = vec3(&c.props, "position", [0.0, 0.0, 5.0]);
|
||||
let eye = c.world.transform_point3(Vec3::new(p[0] as f32, p[1] as f32, p[2] as f32));
|
||||
let q = c.props.get("rotation").and_then(Value::as_array).filter(|q| q.len() == 4).map(|q| {
|
||||
let n = |i: usize| q[i].as_f64().unwrap_or(0.0) as f32;
|
||||
Quat::from_xyzw(n(0), n(1), n(2), n(3)).normalize()
|
||||
});
|
||||
let (fwd, up) = match q {
|
||||
Some(q) => (parent_rot * (q * Vec3::NEG_Z), parent_rot * (q * Vec3::Y)),
|
||||
None => {
|
||||
let l = vec3(&c.props, "lookAt", [0.0, 0.0, 0.0]);
|
||||
let at = c.world.transform_point3(Vec3::new(l[0] as f32, l[1] as f32, l[2] as f32));
|
||||
((at - eye).normalize_or(Vec3::NEG_Z), parent_rot * Vec3::Y)
|
||||
}
|
||||
};
|
||||
let fov = c.props.get("fov").and_then(Value::as_f64).unwrap_or(50.0).clamp(1.0, 179.0) as f32;
|
||||
let focal = (h as f32 / 2.0) / (fov.to_radians() / 2.0).tan();
|
||||
Some(View::new(eye, fwd, up, focal, w as f32, h as f32))
|
||||
}
|
||||
|
||||
pub fn new(eye: Vec3, fwd: Vec3, up: Vec3, focal: f32, w: f32, h: f32) -> View {
|
||||
let f = fwd.normalize_or(Vec3::NEG_Z);
|
||||
let s = f.cross(up).normalize_or(Vec3::X);
|
||||
let u = s.cross(f);
|
||||
let view = Mat4::from_cols(Vec4::new(s.x, u.x, -f.x, 0.0), Vec4::new(s.y, u.y, -f.y, 0.0), Vec4::new(s.z, u.z, -f.z, 0.0), Vec4::new(-eye.dot(s), -eye.dot(u), eye.dot(f), 1.0));
|
||||
View { eye, fwd: f, up: u, focal, w, h, view }
|
||||
}
|
||||
|
||||
/// A point on screen: x and y in px from the frame's top left, and its depth in front of the camera; None behind it.
|
||||
pub fn project(&self, p: Vec3) -> Option<[f32; 3]> {
|
||||
let v = self.view.transform_point3(p);
|
||||
let depth = -v.z;
|
||||
(depth > 1e-3).then(|| [self.w / 2.0 + v.x * self.focal / depth, self.h / 2.0 - v.y * self.focal / depth, depth])
|
||||
}
|
||||
|
||||
/// The box on screen of world points (x0, y0, x1, y1 in px), None when any is behind the camera.
|
||||
pub fn bounds(&self, pts: impl IntoIterator<Item = Vec3>) -> Option<[f32; 4]> {
|
||||
let mut b = [f32::MAX, f32::MAX, f32::MIN, f32::MIN];
|
||||
for p in pts {
|
||||
let [x, y, _] = self.project(p)?;
|
||||
b = [b[0].min(x), b[1].min(y), b[2].max(x), b[3].max(y)];
|
||||
}
|
||||
(b[0] <= b[2]).then_some(b)
|
||||
}
|
||||
|
||||
/// The share of the frame a box on screen covers, the part inside the frame only.
|
||||
pub fn share(&self, b: [f32; 4]) -> f32 {
|
||||
let (x0, y0, x1, y1) = (b[0].max(0.0), b[1].max(0.0), b[2].min(self.w), b[3].min(self.h));
|
||||
if x1 <= x0 || y1 <= y0 { 0.0 } else { (x1 - x0) * (y1 - y0) / (self.w * self.h) }
|
||||
}
|
||||
|
||||
/// The angle between two views' directions, in degrees.
|
||||
pub fn turn(&self, o: &View) -> f32 {
|
||||
// atan2, not acos: near zero acos of an f32 dot reads 0 one frame and 0.02 degrees the next
|
||||
self.fwd.cross(o.fwd).length().atan2(self.fwd.dot(o.fwd)).to_degrees()
|
||||
}
|
||||
}
|
||||
|
||||
/// The eight corners of a box in a part's own space, carried to the world by its matrix.
|
||||
pub fn corners(world: &Mat4, lo: Vec3, hi: Vec3) -> [Vec3; 8] {
|
||||
let mut out = [Vec3::ZERO; 8];
|
||||
for (k, c) in out.iter_mut().enumerate() {
|
||||
let local = Vec3::new(if k & 1 == 0 { lo.x } else { hi.x }, if k & 2 == 0 { lo.y } else { hi.y }, if k & 4 == 0 { lo.z } else { hi.z });
|
||||
*c = world.transform_point3(local);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) fn camera(props: Value) -> Item {
|
||||
Item { kind: "camera", props: Arc::new(props.as_object().unwrap().clone()), shape: None, at: None, material: None, world: Mat4::IDENTITY }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_point_in_front_lands_where_the_lens_puts_it() {
|
||||
let v = View::of(&[camera(json!({"position": [0, 0, 5], "lookAt": [0, 0, 0], "fov": 90}))], 1920, 1080).unwrap();
|
||||
assert_eq!(v.project(Vec3::ZERO), Some([960.0, 540.0, 5.0]));
|
||||
// at 90 degrees the frame's top edge is as far up as the point is deep
|
||||
let [_, y, _] = v.project(Vec3::new(0.0, 5.0, 0.0)).unwrap();
|
||||
assert!(y.abs() < 1e-3, "{y}");
|
||||
assert_eq!(v.project(Vec3::new(0.0, 0.0, 6.0)), None, "behind the camera");
|
||||
// Camera3d's quaternion: turned a quarter about y, it looks down -x
|
||||
let q = Quat::from_rotation_y(std::f32::consts::FRAC_PI_2);
|
||||
let v = View::of(&[camera(json!({"position": [0, 0, 0], "rotation": [q.x, q.y, q.z, q.w], "fov": 50}))], 100, 100).unwrap();
|
||||
assert!(v.fwd.abs_diff_eq(Vec3::NEG_X, 1e-5), "{:?}", v.fwd);
|
||||
assert!(v.project(Vec3::new(-3.0, 0.0, 0.0)).is_some());
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,7 @@ raea-sys-a11y = "systems"
|
||||
raea-sys-bake = "systems"
|
||||
raea-sys-contact = "systems"
|
||||
raea-sys-light-meter = "systems"
|
||||
raea-sys-stage = "systems" # SG10-SG14: 3D type that reads, parts that don't snap, a camera that settles, a composed frame
|
||||
raea-sys-measure = "systems"
|
||||
raea-sys-canvas = "systems"
|
||||
raea-sys-tweak = "systems"
|
||||
@@ -198,6 +199,7 @@ raea-app-motion = "apps"
|
||||
raea-app-engines = "apps"
|
||||
raea-app-interchange = "apps"
|
||||
raea-app-judge = "apps"
|
||||
raea-app-scene = "apps" # raea scene lint|explain|light|stage
|
||||
raea-app-ask = "apps"
|
||||
raea-app-double = "apps"
|
||||
raea-app-solid = "apps"
|
||||
|
||||
Reference in new issue
Block a user