DR1: done. Status written; a word set one letter a span reads as its letters

The render's page manifest joined every text node of a run with a space, so a word revealed letter by letter
(content/rome's <Letters>) read "4 9 B C" for 49 BC; a run of single letters now reads as they're set, spaces
included (raea-page run_text, 1 test). A part's kind comes from its shape, never from what its author named or
propped it (the cheat test). raea world's reference page (docs/manual/reference/cli/world.md), the Check group's
order shifted by one. tools/layers.toml places raea-core-facts, raea-runtime-world and raea-app-direction.
raea-runtime-react back to 2,000 lines (scene/holders.rs, behaviour unchanged).
This commit is contained in:
shinyobjectz committed 2026-11-10 07:47:50 -08:00
1 parent ca54307223
commit fcdcd8dbaa
12 files changed
+132 -17

No files matched your search

+18 -1
View File
@@ -150,11 +150,28 @@ Feature: Direction that holds: one world of facts, findings and rules, so a pers
# =====================================================================================================================
Rule: Part 1. One world: a project read into raea/ecs, for every kind of piece (finding 8)
@needs:DR0
@needs:DR0 @done
Scenario: DR1. A composition's frame as a world, with no render
# Status 11-10: built. `raea world` reads any composition's frames into raea-core-facts worlds, each entity's
# Source from the code stamps. Real reads (release binary, M5 Pro): content/rome/film.tsx frame 900 is the 3D
# layer (camera moving, parts measured, the caesar-bg model "not measured": raea can't read its triangles), four
# cues with their sources, a picture at 7% and seven runs of laid-out type ("49 BC" 34 px, "The Dictator" 72 px,
# the caption at the bottom); content/reel/edit.tsx at 314-318 shows the cut from shot noir-lamp (221-316) to the
# next at 316; examples/games/breakout.tsx frame 60 has its 34 parts and "SCORE 10" at 60 px. Layout costs 0.33 s
# on Rome's frame (0.39 s against 0.06 s with --no-layout) and 80 ms a frame on the reel (1.02 s against 0.21 s
# for ten frames). Proved by 8 tests in
# raea-runtime-world (a page read as shots, footage, cues and text in document order, a <style>'s CSS not read as
# words; 3D as one layer with its camera's velocity and measured parts; a stamp's file, line and component; a
# transcript's lines), 2 in raea-app-direction (one find across media; a bad query or range says what it takes)
# and 1 in raea-page (letters set one a span read as their words). The cheat: a part's kind comes from its
# shape, so a box its author named and propped as 3D text "SALE" is a mesh with no Text (scene.rs). Not seen:
# content/anything/edit/scene.tsx throws its own "not a song map" error before any frame; the reel's flying
# letters (v/build/text.tsx) are one solid a glyph, not Text3D, so they read as Parts with no Text, which is what
# they are. Found on the way and fixed: the render's manifest joined a word set one letter a span as "4 9 B C".
Given the plan
| crate | file | lines | job |
| raea-core-facts | core/facts/src/components.rs | 300 | an Item, a page box, a clip, a cue as components (the names and fields below) |
| raea-core-facts | core/facts/src/words.rs | 40 | a transcript's words, as `raea check` reads them (its Word, moved here) |
| raea-runtime-world | runtime/world/src/lib.rs | 140 | a composition bundled and stepped to its frames, as a bake steps them (React only, nothing drawn), each frame read into a world |
| raea-runtime-world | runtime/world/src/scene.rs | 200 | the 3D: plates, the 3D layer with its camera and parts (measured from their triangles), 3D text, the 2D drawn over it |
| raea-runtime-world | runtime/world/src/timeline.rs | 330 | the page and timeline: layers in document order, shots (Sequences), clips, cues, lines (the project's words.json, <Speech>) |
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: "raea doctor"
summary: "Find what doesn't match this version of raea: old brief files, an older workspace format, an agent's stale skill."
order: 47
order: 48
sources: ["apps/workspace/src/doctor.rs"]
---
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: "raea hook"
summary: "Every agent's tool hooks: media opened in the Mac's viewer goes to raea show, and the quick check after a composition is saved."
order: 48
order: 49
sources: ["apps/check/src/hook.rs", "apps/tools/src/agent_hooks.rs"]
---
+1
View File
@@ -64,6 +64,7 @@ What's wrong before anyone watches it.
| [`raea check`](check.md) | Check a composition's text in a second, or an export against the floor: text, contrast, safe areas, freezes, flashing, cues and loudness. |
| [`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 scene`](scene.md) | Find floating, sunk and clipping 3D parts, say what each part rests on, and meter a shot's light. |
| [`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. |
| [`raea next`](next.md) | The two or three most useful next steps for a project, read from its brief, compositions, renders and checks. |
| [`raea doctor`](doctor.md) | Find what doesn't match this version of raea: old brief files, an older workspace format, an agent's stale skill. |
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: "raea next"
summary: "The two or three most useful next steps for a project, read from its brief, compositions, renders and checks."
order: 46
order: 47
sources: ["apps/workspace/src/next.rs"]
---
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: "raea solid"
summary: "Measure, view and export a solid: parts built from code with exact volumes, joints and parameters."
order: 45
order: 46
sources: ["apps/solid/src/lib.rs", "apps/solid/src/export.rs"]
---
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: "raea traces"
summary: "List the sessions raea apps left, newest first, with how each ended and its glitches, or tell one in full."
order: 49
order: 50
sources: ["engine/cli/src/cli.rs", "io/trace/src"]
---
+63
View File
@@ -0,0 +1,63 @@
---
title: "raea world"
summary: "A frame as one world: its layers, text, 3D parts, camera, shots, clips, cues and lines as entities, queried across media."
order: 45
sources: ["apps/direction/src/world.rs", "runtime/world/src/lib.rs", "core/facts/src/components.rs"]
---
`raea world` reads a frame of a composition into one world of facts, as raea/ecs holds a world: entities with
components by name. React is stepped to the frame and nothing is drawn. The page is laid out (styles and layout,
no paint), so a run of text has its box, size, font and line count. Every medium is in the same world: the 3D
layer with its camera and parts (each measured from its triangles), the page's text, pictures and footage in their
stacking order, the Sequences as shots, the sounds as cues and the lines sung or said on the frame. Each entity
carries its Source: the file and line that wrote it and the component it was used in.
`--find` is one query across all of it: the entities with every component `with` names, none of those `without`
names, and each `where` field equal to its value.
```sh
raea world edit.tsx --frame 120
raea world edit.tsx --at 0-29 --json > world.json
raea world edit.tsx --frame 48 --find '{"with": ["Text", "Layer"], "where": {"Layer.medium": "2d-type"}}'
raea world edit.tsx --frame 48 --find '{"with": ["Part"], "where": {"Part.kind": "text3d"}}' # the words that are 3D
```
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
## Usage
```sh
raea world EDIT.tsx [--composition ID] [--frame N | --at A-B|A,B] [--find JSON] [--no-layout] [--json] (a frame as one world: its layers, text, parts, camera, shots, clips, cues and lines as entities with components, each measured; --find '{"with": ["Text", "Layer"], "where": {"Layer.medium": "2d-type"}}' is one query across media)
```
Headless: it needs nothing running and opens no window. Takes up to 1 argument besides its flags.
## Flags
| Flag | Takes | What it does |
| --- | --- | --- |
| `--at` | `A-B\|A,B` | Several frames, each its own world: a range (`120-150`) or a list (`0,48,96`). Not with `--frame`. |
| `--composition` | `ID` | Which composition of the file to read, when it has more than one. |
| `--find` | `JSON` | Only the entities that match: `with` names components each must have, `without` those it must not, and `where` maps `Component.field` to the value it must equal. |
| `--frame` | `N` | The frame to read (0 when neither this nor `--at` is given). |
| `--json` | – | Print each frame as JSON: its size, fps and every entity with its id, parent and components. |
| `--no-layout` | – | Don't lay the page out. Faster, but text has no box, size or line count and carries `needs: "render"`. |
<!-- generated:end -->
## Components
| Component | On | What it holds |
| --- | --- | --- |
| `Layer` | each composited layer | `medium` (`2d-type`, `2d-graphic`, `3d`, `footage`, `page`), `order` from the back, `opacity`, `blend` |
| `Text` | a run of type, 2D or 3D | `words`, `font`, `size` (px of a frame 1080 on its short side), `box` (0 to 1), `extruded` (metres), `lines` |
| `Part` | a 3D mesh or model | `kind`, `name`, `at`, `rotation`, `scale`, its world box (`min`, `max`), `triangles`, `src`, `material`, `color` |
| `Camera` | the frame's camera | `eye`, `look`, `fov` or `ortho`, `near`, `far`, `velocity` (m/s to the next frame) |
| `Shot` | a Sequence on the frame | `name`, `from`, `to` (composition frames); the shot around it is its parent |
| `Clip` | footage on the timeline | `source`, `hash` (SHA-256), `time`, `in`, `out`, `at`, `words` (TAKE.words.json's) |
| `Cue` | a sound on the timeline | `source`, `at` (seconds), `gain` (dB), `bus` |
| `Line` | a line sung or said now | `text`, `from`, `to`, `words` with their times (the project's words.json) |
| `Source` | whatever was written | `file`, `line`, `component`, `key` (the layer key) |
A field raea can't know without a render says so: text from a page that wasn't laid out has `needs: "render"`, and
a `<Speech>` line has `needs: "transcript"` for its word times.
+30 -2
View File
@@ -74,8 +74,8 @@ impl BlitzPage {
if !node.is_text_node() {
continue;
}
// kept untrimmed: a space in a span of its own is where a word ends in letters set one a span
let words = node.text_content();
let words = words.trim();
if words.is_empty() {
continue;
}
@@ -99,6 +99,7 @@ impl BlitzPage {
}
}
for (owner, words) in owned {
let Some(words) = run_text(&words) else { continue };
let (Some(b), Some(node)) = (rect(owner), doc.get_node(owner)) else { continue };
let Some(s) = node.primary_styles() else { continue };
let c = s.clone_color().to_color_space(style::color::ColorSpace::Srgb);
@@ -112,7 +113,7 @@ impl BlitzPage {
TextAlignKeyword::Justify => "justify",
_ => "left",
};
let mut t = json!({"text": words.join(" "), "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (alpha(owner) * 100.0).round() / 100.0,
let mut t = json!({"text": words, "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (alpha(owner) * 100.0).round() / 100.0,
"color": color, "size": font.font_size.computed_size().px() as f64, "weight": font.font_weight.value() as f64, "align": align});
// its first named face and how many lines it was set on (docs/direction.feature DR1's Text)
if let Some(f) = font.font_family.families.iter().find_map(|f| match f { style::values::computed::font::SingleFontFamily::FamilyName(n) => Some(n.name.to_string()), _ => None }) {
@@ -127,3 +128,30 @@ impl BlitzPage {
(videos, text)
}
}
/// A run's words from its text nodes, in order: joined by a space, as caption words set one a span are; or, when every
/// one is a single letter (a word revealed letter by letter, its spaces spans of their own), as the letters read
/// ("49 BC", not "4 9 B C"). None when the run is only white space.
fn run_text(pieces: &[String]) -> Option<String> {
let words: Vec<&str> = pieces.iter().map(|p| p.trim()).filter(|p| !p.is_empty()).collect();
if words.is_empty() {
return None;
}
if words.iter().all(|w| w.chars().count() == 1) {
return Some(pieces.concat().split_whitespace().collect::<Vec<_>>().join(" "));
}
Some(words.join(" "))
}
#[cfg(test)]
mod tests {
use super::run_text;
#[test]
fn letters_set_one_a_span_read_as_their_words() {
let s = |v: &[&str]| v.iter().map(|p| p.to_string()).collect::<Vec<_>>();
assert_eq!(run_text(&s(&["4", "9", " ", "B", "C"])).as_deref(), Some("49 BC"));
assert_eq!(run_text(&s(&["won", "a", "civil war,"])).as_deref(), Some("won a civil war,"), "word spans keep a space between");
assert_eq!(run_text(&s(&[" ", "\n"])), None);
}
}
+3 -9
View File
@@ -4,10 +4,7 @@ use super::*;
/// The frame's 3D (each data-3d root in the page's order, its 3D children under it): what a render turns into rows.
pub fn scene_of(world: &mut World) -> Vec<Node3> {
let now = SCENE3D.with(|g| {
g.set(g.get() + 1);
g.get()
});
let now = SCENE3D.with(|g| { g.set(g.get() + 1); g.get() });
if now % 120 == 0 {
PROPS3D.with(|c| c.borrow_mut().retain(|_, v| v.2 + 2 >= now));
if world.contains_resource::<Kept3d>() {
@@ -24,8 +21,7 @@ pub fn scene_of(world: &mut World) -> Vec<Node3> {
/// The composition's surface (`<surface id="motion">`): the element its page and its 3D hang from.
pub fn surface(world: &mut World) -> Option<Entity> {
let mut q = world.query::<(Entity, &ReactKind, Option<&ReactProps>)>();
q.iter(world).find(|(_, k, p)| k.0 == "surface" && p.and_then(|p| p.0.get("id")).and_then(|v| v.as_str()) == Some("motion")).map(|(e, _, _)| e)
world.query::<(Entity, &ReactKind, Option<&ReactProps>)>().iter(world).find(|(_, k, p)| k.0 == "surface" && p.and_then(|p| p.0.get("id")).and_then(|v| v.as_str()) == Some("motion")).map(|(e, _, _)| e)
}
/// The elements holding the 3D (holders_of's), into `out` (ZeroHeap: live play's present asks each frame)
@@ -57,9 +53,7 @@ fn holders_walk(world: &mut World, out: &mut Vec<Entity>) {
}
path.push(e);
if let Some(kids) = world.get::<Children>(e) {
for k in kids.iter().rev() {
stack.push((k, depth + 1));
}
stack.extend(kids.iter().rev().map(|k| (k, depth + 1)));
}
}
}
+9
View File
@@ -158,4 +158,13 @@ mod tests {
assert_eq!(facts.get::<Text>(t[0].id).unwrap().extruded, 0.2);
assert!(facts.find(&["Part"]).iter().all(|p| p.parent == Some(layers[0].id)));
}
#[test]
fn what_a_part_is_comes_from_its_shape_not_what_its_author_called_it() {
let claims = serde_json::json!({"name": "SALE", "text": "SALE", "kind": "text3d", "depth": 0.2});
let mut facts = Facts::new(0, 1920, 1080, 30.0);
put(&mut facts, &[item("mesh", claims, Some("box(1, 1, 1)"), Mat4::IDENTITY)], None, 30.0, Path::new("/nowhere"), &mut 0);
assert!(facts.find(&["Text"]).is_empty(), "a box named SALE is not 3D text");
assert_eq!(facts.get::<Part>(facts.find(&["Part"])[0].id).unwrap().kind, "mesh");
}
}
+3
View File
@@ -12,6 +12,7 @@ raea-core-meshcheck = "core"
raea-core-sdf = "core"
raea-core-grow = "core"
raea-core-review = "core"
raea-core-facts = "core"
raea-core-solidinfo = "core"
raea-core-place = "core"
raea-shape-web = "runtime"
@@ -128,6 +129,7 @@ raea-runtime-export = "runtime"
raea-runtime-page = "runtime"
raea-runtime-sound = "runtime"
raea-runtime-view = "runtime"
raea-runtime-world = "runtime"
raea-runtime-encode = "runtime"
raea-runtime-plugins = "runtime"
raea-runtime-live = "runtime"
@@ -137,6 +139,7 @@ raea-runtime-scene2d = "runtime"
raea-runtime-shared = "runtime"
raea-page = "runtime"
raea-app-check = "apps"
raea-app-direction = "apps"
raea-app-ci = "apps"
raea-app-tools = "apps"
raea-app-judge = "apps"