Port steps 2-3: the data model and the player
Steps 2 and 3 land together because the model revisions in the middle changed
code from both, and splitting them now would invent intermediate states that
never built.
domain/channel value-at across framed/keyed/dense, plus a cursor
domain/node decomposed transform, composition order, time maps
domain/scene topological order, z paths, eval-frame and resolver
clock audio-clocked frame derivation, outside app-db
db/events/subs re-frame arrives; the playhead is document state
ui/player the rAF loop; reads, blits, dispatches (almost) nothing
ui/shell transport
133 tests, 1158 assertions. The scene plays at 30fps against audio, scrubs, and
runs at 1/4x through 4x; verified by driving a real browser over CDP rather than
by assertion.
Two evaluators, on purpose. `eval-frame` is the specification -- allocating,
order-free, obviously correct. `resolver` is what playback uses: cached topo
order and z paths, a cursor per channel, a preallocated point buffer per node.
Both run the same walk, parameterised only by how a channel is read and where
points are written, because two independent implementations of frame evaluation
would drift and the drift would read as a rendering bug rather than as two
functions disagreeing. scene-test asserts they agree frame for frame in forward,
backward and random order.
Deviations and decisions, each with a reason:
- raster/fill-poly! is now a thin wrapper over fill-poly-buf!, which takes a flat
preallocated buffer. ONE scanline fill serves the analysis stages, which speak
{:x :y}, and frame evaluation, which hands over a buffer it owns. The parity
suite still passes pixel-for-pixel, which is what makes the rewrite safe.
- The state mask carries ABSENCE ONLY. An earlier draft gave it a hidden bit too,
per architecture.md's "hidden flag + palette index", and that bit was a dense
[:vis] wearing a different hat -- two mechanisms for one question, which is how
a part ends up hidden by one and shown by the other.
- The palette is a parameter of evaluation, not a global. A node names a TONE;
which ramp that tone is read in belongs to the timeline it sits in.
- :over layers and a symbol :rate THROW rather than being ignored. Neither is
built and nothing can produce one, so this can only fire on data that has run
ahead of the code. A silently dropped override is a hand correction the user
made once, watched fail, and has no reason to trust again.
Three findings the model produced rather than received:
- Presence propagates asymmetrically. An absent transform drops the subtree; an
absent [:geom :pts] drops only that node, because an absent mouth outline has
nothing to draw but the head it hangs off has not moved. That asymmetry is the
reason presence is tracked per channel and not per node.
- Z paths need lexicographic compare, not `compare`, which orders vectors by
count first -- so a cel three levels under "a1" would jump in front of a bare
"a2" and the layer order would mostly work.
- A node stencilled by something that drew nothing is dropped, not drawn
unclipped: an iris floating over the cheek is worse than a missing iris.
docs/ revised alongside, and those revisions are the load-bearing part:
- A scene, a timeline and a symbol are one type. The doc had two structures with
the same fields and never said so. Two axes of nesting are now separated --
parent/child within a timeline is flat with parent pointers, instance nesting
is by reference -- which is why "nestable" and "flat" only sounded
contradictory.
- Palettes are named, live on the project, and are ENABLED on a timeline as a
channel. Absent inherits; present travels with the timeline, so a symbol
authored against :night stays night wherever it is placed. The output index
space is the concatenation of the named ramps, which keeps one buffer and one
flat table and incidentally stops two nodes in different palettes colliding on
a stencil.
- Stabilisation is a channel, not a mode: {s, theta, tx, ty} IS [:xform :*], so
the normalise on/off/per-plate toggle is which of the three channel shapes the
:head node carries. Always measure and always store factored -- smoothing and
velocity-minimum key selection both need the split to exist in storage.
- There is no camera node and none is needed. Placement is a node transform, the
stage clips what hangs off it, and project dimensions are independent of the
footage. `makeXform` is therefore not to be ported: it bakes a cropping
decision into every stored vertex.
- Export is removed. The .take writer was for an Animator Pro render script; the
target is encoding video in the browser, and step 9 now says not to port the
old one.
demo/swarm is 120 shapes on six orbits, entirely dense blocks behind store
handles -- the shape freeze produces at step 5, and the first thing to exercise
that path under load. It plays at 30fps, and bench-test keeps a deliberately
loose floor under it because a performance regression here does not announce
itself: the picture stays correct and merely arrives late.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PDfHGdV39zu6rvgbBTfDaT
This commit is contained in:
parent
eb06be005c
commit
18d6495592
27 changed files with 3395 additions and 90 deletions
|
|
@ -14,7 +14,7 @@ decision that is currently made in two places at once.
|
|||
## What is actually wrong with the current shape
|
||||
|
||||
The pure modules are fine. `pipeline.js`, `mathutil.js`, `landmarks.js`,
|
||||
`interior.js`, `raster.js` and `take.js` are functions over data with the
|
||||
`interior.js` and `raster.js` are functions over data with the
|
||||
reasoning written down next to them, and they port nearly verbatim.
|
||||
|
||||
`app.js` is the whole problem, and not because it is long. It is long because
|
||||
|
|
@ -26,7 +26,7 @@ six unrelated jobs are braided together in it:
|
|||
- resolving what is on screen at a frame (`plateIndex`, `perfIndex`, `leadIndex`),
|
||||
- rasterising (`renderFrame`, `compositeRender`),
|
||||
- driving the clock (`tick`),
|
||||
- persisting (`saveCels`, `loadCels`, `exportTake`).
|
||||
- persisting (`saveCels`, `loadCels`).
|
||||
|
||||
Every one of those is a different layer, and `rebuild` recomputes all of them
|
||||
whenever any knob moves. That is affordable at one clip and 72 frames and is
|
||||
|
|
@ -90,7 +90,7 @@ Renaming this later costs a day.
|
|||
|
||||
## The node, decomposed
|
||||
|
||||
`take.js` today gives a part a `parent` and a `clip`, and `parent` is doing
|
||||
The prototype today gives a part a `parent` and a `clip`, and `parent` is doing
|
||||
nothing except documenting intent — `mouth_in` is already in the same
|
||||
head-local raster space as `mouth`, so composing its transform would be
|
||||
composing identity. The moment a painted cel is attached to a head plate that
|
||||
|
|
@ -100,7 +100,7 @@ two fields have to come apart:
|
|||
| Field | What it does | Wrong to conflate because |
|
||||
| --- | --- | --- |
|
||||
| `:parent` | Transform composition. Child geometry is in parent's local space. | A node can be drawn over its parent without inheriting its motion. |
|
||||
| `:stencil` | Colour-key clip, the `clip=` of the take format. | The iris is stencilled by the sclera and parented to the lid ring; those are different nodes. |
|
||||
| `:stencil` | Colour-key clip: write only where the buffer already holds that index. | The iris is stencilled by the sclera and parented to the lid ring; those are different nodes. |
|
||||
| `:z` | Draw order. | Order is authored per scene, not implied by the tree. |
|
||||
|
||||
A node is then:
|
||||
|
|
@ -125,7 +125,7 @@ data shape that keeps the promise.
|
|||
|
||||
Each node also gets an optional local transform channel — translate, rotate,
|
||||
scale, squash. That is the thing the current tool cannot express and that the
|
||||
`slot_mouth` / `scale` / `rot` / `squash` fields in `take.js` are reaching for.
|
||||
`slot_mouth` / `scale` / `rot` / `squash` fields in the prototype are reaching for.
|
||||
|
||||
## The flow, in seven stages
|
||||
|
||||
|
|
@ -165,7 +165,6 @@ dragging that slider does not re-run the interior extraction.
|
|||
| `toRasterRing`, iris placement at ring slots, `offsetRing` | 6 resolve |
|
||||
| `IndexedRaster`, `drawCel` | 7 palette |
|
||||
| `drawRegistered`, `posterizeInto` | reference only, off to the side |
|
||||
| `writeTake` | serialization, off the end |
|
||||
|
||||
Three things in `app.js` currently straddle a boundary, and each straddle is a
|
||||
bug waiting for a bigger project:
|
||||
|
|
@ -212,7 +211,6 @@ src/arthur/
|
|||
clip.cljs clip entity; the frame-space conversions
|
||||
cel.cljs painted vector layers
|
||||
timeline.cljs sequence: clip placement, qf <-> cf
|
||||
take.cljs take-file writer (port take.js)
|
||||
flow/
|
||||
ingest.cljs
|
||||
detect.cljs the MediaPipe boundary, and the only one
|
||||
|
|
@ -237,7 +235,7 @@ src/arthur/
|
|||
mode/ one ns per tool mode
|
||||
panel/ strip, worksheet, readouts, palette, layers
|
||||
canvas.cljs the one imperative sink
|
||||
fx/ mediapipe, files, audio, persistence, export
|
||||
fx/ mediapipe, files, audio, persistence
|
||||
```
|
||||
|
||||
Two rules about this tree. `domain/` may not require `flow/`, and neither may
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue