Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
docs: 3D and narration workflows; SKILL.md routes 3D + narration, description says when to use, law 5 allows opt-in narration
Alex Greenshpuna97fb5fdd3c5
diff --git a/skills/anidoodle/SKILL.md b/skills/anidoodle/SKILL.mdindex 76f893f..5e2df2b 100644--- a/skills/anidoodle/SKILL.md+++ b/skills/anidoodle/SKILL.md@@ -1,6 +1,6 @@---name: anidoodle-description: Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with composed scores. Matches a reference style, keeps characters consistent, teaches drawing. Deterministic, no generated assets.+description: Code-drawn stills, films, 3D motion graphics, explainers and web animations in 32 styles, with scores, narration and subtitles. Use when asked for an illustration, animation, video or drawing lesson.metadata:created_by: Alex Greenshpun (10x Company)license: Apache-2.0@@ -8,24 +8,23 @@ metadata:# anidoodle-Pictures, films and interactive pieces drawn entirely in code. One pure function paints every-frame; another composes the score and plays it. The same source rebuilds the same pixels and the-same sound on any machine, at any size, at any length. Eight acoustic instruments can play recordings-of real ones from an optional download. ASK the user before any score work; never download unasked.+Pictures, films and interactive pieces drawn entirely in code, in 2D or in 3D. One pure function+paints every frame; another composes the score and plays it. The same source rebuilds the same+pixels and the same sound on any machine, at any size, at any length. Eight acoustic instruments can+play recordings of real ones from an optional download. ASK the user before any score work; never download unasked.-The engine is the easy half. Work gets thrown away because it had no point, because the subject-was an icon of itself, because a style was only a palette swap, because the music had no form,-or because the person spent their patience approving fragments. This skill carries the craft-that prevents each of those.+The engine is the easy half. Work gets thrown away because it had no point, the subject was an+icon of itself, a style was only a palette swap, the music had no form, or the person spent their+patience approving fragments. This skill carries the craft that prevents each of those.## Start by asking, then buildRead `references/workflows/start-here.md` and run its intake: one question at a time, onlywhat the request leaves open, your recommendation first. **What** are they making, in **which-style** (show the gallery sheet, https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg; the list is `references/styles/INDEX.md`), what-**shape** (1x1, 9x16, 16x9, 4x5 or any W x H), how **long** (any length; never cap it), what-**sound** (silent or a music style and mood), which **characters**. "You pick" means pick and-say why in one line. Write the answers into a short brief before drawing.+style** (show the gallery sheet, https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg; the list is `references/styles/INDEX.md`)+or in 3D (one medium per film), what **shape** (1x1, 9x16, 16x9, 4x5 or any W x H), how **long**+(any length; never cap it), what **sound** (silent, a music style and mood, narration), which+**characters**. "You pick" means pick and say why in one line. Write the answers into a short brief before drawing.## What are you making?@@ -35,6 +34,7 @@ say why in one line. Write the answers into a short brief before drawing.| A picture that draws itself (timelapse, making-of) | `references/workflows/drawing-process.md` || A loop, sticker, animated logo, ambient header | Loop workflow below, `references/formats.md` || A story film, any length | Film workflow below, `references/workflows/long-film.md` |+| A 3D film or 3D motion graphics: extruded type, objects, puppets, a camera through space | `references/workflows/three-d.md` || An explainer or infographic; a machine that comes apart to explain an idea, in any style | `references/workflows/explainer.md`, `references/workflows/machines.md` || A launch or product video (their screenshots welcome) | `references/workflows/launch-video.md`; build it on `references/workflows/launch-video-kit.md`; its claims: `references/workflows/facts.md` || Art for a site (hero by a headline, tiles, spots, share card) on its page colour and brand; or a web animation that reacts to the UI | `references/workflows/site-art.md`; `references/workflows/interactive.md` |@@ -42,6 +42,7 @@ say why in one line. Write the answers into a short brief before drawing.| A character kept identical in any style (woodcut to toy brick) | `references/workflows/character-consistency.md`, `references/anatomy.md` || A style matched from their image | `references/workflows/adapt-a-style.md` || A score or soundtrack | `references/music/README.md` |+| Narration, a voice-over, word timing or subtitles | `references/workflows/narration.md` |- Music: pick a style vocabulary and mood, sketch the tension arc and motif, compose your own harmony, motif and form (references/music/compose.md, craft in references/music/theory/), revise until node tools/music.mjs craft shows only findings you chose, then check must PASS before a human listens. Styles give sound, never notes.- Sound effects: references/music/sound-design.md. 14 layered, seeded effects cued by film frame (filmSfx); the score ducks, and every cue must be within 6 dB of it. Effects only on real direction changes, one riser + one impact per film.@@ -58,8 +59,10 @@ say why in one line. Write the answers into a short brief before drawing.4. **Prove the look on ONE still, then build end to end.** After that, gates cost more than theysave. → `references/working-method.md`5. **The contract is absolute.** Pure in `(frame, env)` (and the input log, for interactive- pieces), `rng(seed)` only, no clock, no `ctx.filter`. Nothing generated; images they bring may be- embedded by hash, and the sound pack is a separate, hash-pinned download. → `references/determinism-and-contract.md`+ pieces), `rng(seed)` only, no clock, no `ctx.filter`. Nothing generated, with one exception the+ person opts into: narration, in the voice they chose, each take cached by hash and baked into+ the film. Images they bring may be embedded by hash; the sound pack is a separate, hash-pinned+ download. → `references/determinism-and-contract.md`, `references/workflows/narration.md`6. **Music gets a plan, never an adjective.** A style, a mood per section, the notes as data, thenmeasurements. You cannot hear it, so one human listens before it ships. → `references/music/`7. **One directs, one builds, both write everything down.** When a session degrades, reset; the@@ -74,8 +77,7 @@ header first. (4) Draw in that medium's order. (5) Render with `still.mjs` at fusize and shape asked for from the same source, and say `reproducible` was printed.**Loop.** As a still, plus: every motion is periodic over the loop, the subject never stops,-something moves every second. Check the seam (last frame against frame 0). ✋ **One approval,-on the moving file.**+something moves every second. Check the seam (last frame against frame 0). ✋ **One approval, on the moving file.****Film.** (1) **The story in three sentences** (setup, transformation, payoff) and the token; forlonger films, a spine plus one line per chapter. If you cannot write it, stop. (2) **The grid**:@@ -84,16 +86,14 @@ runs at load. (3) **Real reference** for anything that exists. (4) **ONE look stframe, critiqued in writing. ✋ **Approval.** (5) **ONE 8-second music sample.** ✋ **Approval.**(6) **Build the whole film**; mechanical checks run continuously. (7) **A fresh critic reviews, never you**(`references/workflows/review.md`): after the storyboard, each scene and the full render, a new subagent that saw none of the building returns ranked, timestamped problems and a verdict. Fix the biggest, a NEW critic rechecks; 3 rounds at most, logged in `ledger.md`.-(8) ✋ **Final approval.** Say what you verified and what you cannot.--Three approval gates at most. Approval is a budget; spend it where being wrong is expensive.+(8) ✋ **Final approval.** Say what you verified and what you cannot. Three approval gates at most. Approval is a budget; spend it where being wrong is expensive.## The craft barThe test: would a proud human illustrator ship this, or is it mechanical shape-assembly? The-full table of tells is `references/craft-bar.md`. The ones that sink most work: subjects built-from ellipses, one style recoloured into another, things that fade in instead of being drawn,-people with rubber joints, and a character drawn differently from shot to shot.+full table of tells is `references/craft-bar.md` (3D tells: `references/workflows/three-d.md`).+The ones that sink most work: subjects built from ellipses, one style recoloured into another,+things that fade in instead of being drawn, people with rubber joints, and a character drawn differently from shot to shot.**No dead air** in anything that moves: something visibly changes every second. A film thatdraws itself declares `kind: "drawing"` and is judged on a finer floor; a freeze still fails.@@ -102,6 +102,7 @@ draws itself declares `kind: "drawing"` and is judged on a finer floor; a freeze`engine/` is the portable art core plus the tooling. `engine/src/canvas-core` knows nothingabout the DOM or any backend. `W`, `H`, `fps` and `durationFrames` come from the film's `meta`.+3D: `engine/src/three-core` renders three.js onto the same frame, so every tool below works on 3D films (vendored and hash-pinned, `engine/vendor/three/PROVENANCE.md`; type face `engine/assets/fonts/PROVENANCE.md`).Camera moves (pans, dollies, lens and dolly zooms, parallax, shake) and slow motion or freeze frames: `engine/src/canvas-core/camera.ts`, `engine/src/canvas-core/timeRemap.ts`, `references/camera.md`.Seams between scenes: `references/motion-grammar.md` (cuts that carry motion: `seams.ts`; `tools/deck.mjs deal` deals each film different moves; `deck.mjs find "<name>"` turns a move's everyday name into its card). `render.mjs --blur auto` renders with motion blur (subframes per framefrom its measured on-screen speed, averaged in linear light, `--shutter 180`); the default path is untouched.@@ -120,31 +121,29 @@ node <skill>/engine/tools/soundfetch.mjs get piano rooms # on their yes (piano| Tool | What it does ||---|---|| `scaffold.mjs` | a project with a still and/or film; `--duration`, `--format` or `--size`, `--fps`, `--bpm` |-| `still.mjs` / `render.mjs` | frames drawn twice with hashes (`--frames a,b,c --sheet` in one browser) / the piece in any format (`--from/--to`, `--poster-frame`, `--hashes`) |-| `gate.mjs` | determinism, contract, dead air, artifact; `--self-test` proves it can fail |+| `still.mjs` / `render.mjs` | frames drawn twice with hashes (`--frames a,b,c --sheet <file>` in one browser) / the piece in any format (`--from/--to`, `--poster-frame`, `--hashes`) |+| `gate.mjs` | determinism, contract, dead air, artifact, 3D checks; `--self-test` proves it can fail || `registry.mjs` / `gallery.mjs` | the style list from the plates themselves / the gallery sheet || `docs-check.mjs` | fails when any doc's style count, length or path disagrees with the code || `verify-export.mjs` | QA on the rendered file: frames, duration, score, A/V sync, true peak after the encode; opt-in first frame, loop seam, `--delivery` || `launch.mjs` | a launch film: `new <name>` scaffolds the spec; `ship <name> --shapes 16x9,9x16` renders, posters, captions, verifies and framechecks each (`framecheck.mjs`: text whole, up long enough to read, clear of the 9:16 phone zones) and checks `facts.json` (`facts.mjs`) || `test.mjs` (`npm test`) | unit suites in `engine/test/`, no browser || `music.mjs` | `vocab` prints a style's vocabulary; `check` gates your composed score (key, master, guards, stems, novelty, which parts played recordings) and prints its shape (ARC); `render`, `meter` |+| `narrate.mjs` | narration: `say` (takes, cached), `time`, `check` (hears every word back; exit 1 on a dropped word), `bake`, `all`, `providers` || `soundfetch.mjs` | the sound pack: `list`, `get <id...\|all>`, `where`, `verify`, `remove <id>` || `sfx.mjs` | the sound-effects kit: `list`, `one`, `kit <dir>`, `test` |-Four backends, one art core: `playwright`, `html-player`, `remotion`, `hyperframes`.-→ `references/backends-and-adapters.md`+Four backends, one art core: `playwright`, `html-player`, `remotion`, `hyperframes` → `references/backends-and-adapters.md`.## Worked examples- **The style plates** in `engine/src/canvas-core/`: every hand has a still and a film of it beingdrawn, with the recipe in the header and `references/styles/<id>.md`.- **MECHANICAL LEPIDOPTERA** in `example/`: a 47 s scored film. `scaffold.mjs ~/study --example`.-**Study them. Do not copy them.** The craft bar is not satisfied by inheritance.## Honest limits-You cannot hear the score, watch the film move, or use the interactive piece. Every claim about-them comes from a measurement or from a human; say which. A green checkmark is a claim until you-re-run it. Render one frame at `--scale 2` before trusting a still: a layer blitted through the+You cannot hear the score or the voice, watch the film move, or use the interactive piece. Every claim about them comes from a measurement or from a human; say which.+A green checkmark is a claim until you re-run it. Render one frame at `--scale 2` before trusting a still: a layer blitted through thewrong transform looks right at 1x and breaks at 2x.diff --git a/skills/anidoodle/references/workflows/narration.md b/skills/anidoodle/references/workflows/narration.mdnew file mode 100644index 0000000..9843f5e--- /dev/null+++ b/skills/anidoodle/references/workflows/narration.md@@ -0,0 +1,175 @@+# Narration, word timing and subtitles++**Contents:** The order of work · The script: narration.json · Choosing a voice · The commands · The round trip, and why it is not optional · Narration sets the clock · Phrase subtitles · Caption files · The mix++A narrated film is timed by its voice. The script is written first, each line becomes one take,+the takes are heard back word for word, and the picture is cut to the words. Everything here works+the same for 2D and 3D films.++Narration is the one generated input anidoodle allows, and only on the person's request: the voice+they chose, each take cached by a hash of what made it, then baked into the film so the film needs+no file and no network to play. Needs `ffmpeg` and whisper.cpp (`brew install whisper-cpp`; the+tool prints the one-line model download when no model is found).++## The order of work++1. Write the script and budget its time before setting the film's length: every phrase needs+ `max(0.7 s, 0.3 s per word)` on screen, and a voice says 1.2 to 4.5 words a second. A rhymed+ narration on the last film set the runtime to 119 s on its own.+2. Draft with a free voice, cut the picture to it, then make the final takes with the chosen voice.+3. `narrate.mjs check` until it passes, then `bake`.+4. Build the shots on the words (`cue`), the subtitles from the timing, the mix with the duck.+5. Render, then `check --mix` on the finished file, `framecheck`, `verify-export --delivery`.+ A human listens before it ships: you cannot hear the voice.++## The script: narration.json++```json+{+ "fps": 24,+ "provider": "kokoro",+ "voice": { "name": "af_heart", "speed": 1 },+ "lead": 12, "tail": 30, "pause": 0.4, "lang": "en",+ "aliases": { "Clawd": ["claude"] },+ "lines": [+ { "id": "open", "text": "Every film starts as a few plain words." },+ { "id": "code", "text": "It draws itself at twenty four frames a second.", "display": "It draws itself at 24 frames a second.", "pauseAfter": 0.6 },+ { "id": "end", "text": "Then the clock rang out \"Context!\" for him.", "at": 400 }+ ]+}+```++- `lead` and `tail` are frames of air before the first line and after the last; `pause` is seconds+ between lines, `pauseAfter` overrides it for one line, `at` pins a line to a frame (refused if the+ line before is still speaking).+- `text` is what the voice says; `display` is what the screen shows. Write numbers, money and+ symbols as spoken words in `text` and as figures in `display`: each screen word takes the frames+ of the words spoken for it ("24" gets the frames of "twenty four").+- A line's own `voice` overrides the script's. `aliases` accept a name the transcriber spells+ another way.+- Write an emphasised word in plain case inside quotes, never in capitals. A cloud voice read+ "the clock rang out CONTEXT for him" as "the clock rang out for him", silently; the quoted+ plain-case form passed three takes of three.++## Choosing a voice++Ask which voice the person wants. The script's `provider` is the only way a voice is chosen; the+command line has no override, so a paid voice is called only when the script names it.++| Provider | Runs | Licence and cost | Setup |+|---|---|---|---|+| `say` | this Mac, offline | Free. Apple licenses the system voices for personal, non-commercial use, so **drafts only**: re-voice before publishing, and never commit a `say` take or a module baked from one | macOS only. `voice: { name, rate }` |+| `kokoro` | this machine, offline | Free; code and weights Apache-2.0, so a clean choice for a film that ships | `pipx install kokoro-tts`. `voice: { name, speed, lang }` |+| `files` | your own recordings | Yours | one `<id>.wav` (or aiff, flac, mp3, m4a) per line in `voice.dir` (default `takes/` beside the script) |+| `gemini` | Google's servers | Paid per use; the text goes to Google; their terms govern the audio | `GEMINI_API_KEY` or `GOOGLE_API_KEY`. `voice: { name, style, model }` |+| `openai` | OpenAI's servers | Paid per use; the text goes to OpenAI | `OPENAI_API_KEY`. `voice: { name, model, instructions, speed }` |+| `elevenlabs` | ElevenLabs' servers | Paid per use; the text goes to ElevenLabs | `ELEVENLABS_API_KEY`. `voice: { id, model, stability, similarity, seed }` |++Before a cloud voice runs, tell the person that each line's text is sent to that company and that+it costs money per use, and get their yes. Never pick a paid voice for them. Keys come from the+environment only; the tool never prints them, and they never go into the script, a command you+show, or a file. `node tools/narrate.mjs providers` lists what this machine can use.+The kokoro, openai and elevenlabs modules have not yet been run against the real service: make one+line and `check` it before voicing a whole script.++## The commands++```bash+node tools/narrate.mjs providers # which voices this machine can use+node tools/narrate.mjs say <narration.json> # make every take (cached: .cache/voice/<sha256>.wav)+node tools/narrate.mjs time <narration.json> # word timings -> out/narration/<name>/voice-timing.json + lines/<id>.wav+node tools/narrate.mjs check <narration.json> # the round trip; exit 1 on any failure+node tools/narrate.mjs bake <narration.json> # write src/canvas-core/<name>Voice.ts (timing + takes)+node tools/narrate.mjs all <narration.json> # check, then bake when it passes+```++Flags: `--out DIR` (stems and timing), `--module FILE` (the baked module), `--model FILE` (a+whisper.cpp model; `ggml-small.en.bin` hears better than base), `--shape 16x9|9x16|1x1` (subtitle+line length), `--max-wer 0.03`, `--mix out/<film>.mp4` (check the finished mix too), `--force`+(make every take again).++A take is keyed by provider, voice settings, text and processing, so editing one line re-makes+only that line, and checking, timing or baking cached cloud takes never calls the company or needs+the key. `--force` re-makes, and re-pays for, every take. Each take is trimmed, padded and levelled+to -20 LUFS. `time` also writes a voice-only stem per line: keep them, so one line can be swapped+later without re-recording the takes people liked.++## The round trip, and why it is not optional++A voice model can drop or change a word without any error, and the take still sounds fluent. A+shipped film lost the word CONTEXT this way and only a human ear caught it. So `check` transcribes+every take with whisper.cpp, with no prompt (it must hear what was said, not what was meant),+and holds it to the script word by word, after normalising numbers, money and times on both sides.++It fails on: any dropped or changed script word, named; extra heard words past `--max-wer`; a+word with no timing of its own, out of order, under 0.05 s or over 1.5 s, or a gap over 1 s inside+a sentence; clipping, a peak over -1 dBFS, too much silence at either end, a silent take, a pace+outside 1.2 to 4.5 words a second; a subtitle phrase that cannot get its reading time (TOO TIGHT);+a baked module made from other takes or another timing. With `--mix` it transcribes the finished+film as well, so a score that buries a word fails too.++On a failure, fix the script (rewrite the word, spell the number, quote the emphasis), re-run+`check` (only the changed line is re-made), then `bake`. A film plays the baked module, so a take+changed after the bake is a stale film until it is baked again. Word times come from whisper's+segments, good to about 50 to 100 ms: right for phrases and for landing a beat on a word, too+coarse for lip sync. Normalising is English only; a year spoken as words can read as a change.++## Narration sets the clock++The audio is measured first and the picture follows it, never the reverse: a picture timed to a+guessed read drifted 30 to 40 frames from the voice on the last film.++```ts+import { myFilmVoice as VOICE } from "./myFilmVoice"; // written by narrate.mjs bake+import { cue, cueEnd, drawSubtitles, phrases, toCaptions } from "./subtitles";+import { narrationAudio, syncMarks } from "./voice";+const T = VOICE.timing, EVENTS = phrases(T, { shape: "16x9" });+const HIT = cue(T, "code:24"); // the frame "24" is spoken; "code" = line start, "end:the#2" = the second "the"+```++- The film's length comes from `T.totalFrames` (rounded up to the beat). Cuts land on line+ starts, reveals on the word that names them.+- In 3D, `timeline(fps, { words })` places clips on words by name; see `references/workflows/three-d.md`.+- When shots were written before the voice, map each story frame to its spoken cue with+ `storyClock` (`engine/src/three-core/time.ts`) instead of moving every constant by hand. Cyclic+ motion keeps the real frame.++## Phrase subtitles++`phrases(timing, opts)` cuts each line into 2 to 6 word phrases, one on screen at a time, and+`drawSubtitles(ctx, env, frame, events, style)` burns them in. A whole line in a lower band was+too much to read on the last film; short phrases, each landing on its own words, read without+pulling the eye off the picture. The rules, held in code:++- A phrase appears 2 frames before its first word is spoken and holds at least+ `max(0.7 s, 0.3 s per word)` and 20 frames, at most 7 s, with 2 frames between phrases.+- Breaks fall at punctuation, then clause words. Never between an article and its noun, a number+ and its unit, a currency sign and its amount, or inside a name (`keep: ["Total Recall"]`).+- When the speech is too fast to give a phrase its reading time, `phrases` throws TOO TIGHT+ instead of squeezing it. Slow the read, cut words, or add a pause.+- At most 32 characters a line for 16x9 and 1x1, 22 for 9x16; a long phrase wraps to two lines.+- `style.home` places the phrase: one home per shot, in calm negative space, never over a face, a+ hand at work or a joke, and it moves only on a cut (pass a function of the frame). White type+ on a dark plate, never grey; `highlight: true` lights the word being spoken. On 9:16 it stays+ out of the phone's interface zones.++## Caption files++`meta.captions = toCaptions(EVENTS, fps)` hands the same phrases to the sidecar files;+`toCaptions` refuses events that break the rules. `node tools/captions.mjs <film>` writes `.srt`+and `.vtt`, and `framecheck.mjs` holds every cue to its reading time and every burned phrase to+the frame.++## The mix++```ts+audio: narrationAudio({ voice: VOICE, music: filmAudio(score, N / FPS), frames: N, musicDb: -6, depthDb: -9 }), // filmAudio: ./music/render+meta: { ..., captions: toCaptions(EVENTS, FPS), sync: syncMarks(T) },+```++The score sits 6 dB under its own level and ducks a further 9 dB under the voice, measured from+the voice itself. The dip starts 40 ms before each line, so the first syllable never lands on+full music, holds across the gaps between words and comes back over 450 ms. One delivery master+brings the mix to -16 LUFS under -1 dBTP. `syncMarks` puts a marker on each line's first word, so+`verify-export.mjs --delivery` measures the voice landing on its frame. The baked takes cost+about 64 KB of page per second of speech, fine for a short film; a long one is a size to state.diff --git a/skills/anidoodle/references/workflows/three-d.md b/skills/anidoodle/references/workflows/three-d.mdnew file mode 100644index 0000000..2bf68f2--- /dev/null+++ b/skills/anidoodle/references/workflows/three-d.md@@ -0,0 +1,180 @@+# 3D films and 3D motion graphics++**Contents:** 3D or 2D: one medium per film · A 3D shot · The contract in 3D · The kit, by job · The craft bar in 3D · The checks, and what each catches · Rendering++A 3D shot is an ordinary shot. three.js renders into WebGL, `draw3d` copies the pixels onto the+frame's 2D canvas, and every tool (still, render, gate, framecheck, captions, emit, the score)+works on it unchanged. The Film workflow in `SKILL.md` still runs in full: three sentences, one+look still, one music sample, a fresh critic. This page adds what is different in 3D.++## 3D or 2D: one medium per film++Pick 3D when the subject is solid things in light: extruded type, products and objects, toys+and puppets, a camera that travels through space, stop-motion. Pick 2D when the marks are the+point: any of the drawn styles, a drawing that makes itself, ink and paint. The 2D style plates+have no 3D version, so a request for "watercolour, but 3D" is a question to ask, not a build.++Make the medium a brief question ("all drawn, or all 3D?") and keep one medium for the whole+film. The last 3D film rejected four mixed looks before the one that worked: code-painted 2D, pasted+reference pixels, a drawn world with a 3D puppet composited on top, a painted backdrop behind 3D.+Each read as two films glued together. Build a hybrid only when the person asks for one. Finish+layers drawn over the 3D frame (subtitles, grain, vignette, a plated title) are not a second medium.++## A 3D shot++```ts+import * as THREE from "three"; // the vendored build, resolved by the bundler+import { draw3d, memo } from "../three-core/stage";+import { orbit, place } from "../three-core/camera";++const build = () => { /* scene, meshes, lights, camera: built once, never reads the frame */ };+const shot = (ctx: Ctx, f: number, env: Env) => {+ const s = memo(env, "myShot", build); // the same objects every frame+ s.star.rotation.y = (f / 96) * Math.PI * 2; // every moving value SET from f, every frame+ place(s.cam, orbit([0, 0, 0], 0, 40, 6, 1.5, 0, 96)(f), env); // camera first, then anything placed on screen+ draw3d(ctx, env, s.scene, s.cam, { clear: "#0f0d1a" });+ // 2D finish on top: subtitles, grain, vignette+};+```++`engine/src/canvas-core/threeHello.ts` is the smallest whole film. `threeMotionDemo.ts`,+`threeTypeDemo.ts` and `threeRigDemo.ts` beside it show the motion, type and character kits.++## The contract in 3D++Frames render in parallel chunks and out of order, so frame N has to be the same picture however+it is reached. 3D makes that easy to break, because a scene graph remembers.++- **Pure in the frame.** Build once with `memo`, then set every moving value (position, rotation,+ scale, opacity, colour, morph, camera) from the frame number on every draw. A value left over from+ the frame before is the classic 3D bug: on the last film a dropped broom vanished when a render+ chunk started after the drop, and a firefly was placed with the previous drawing's camera.+ When a shot needs a pose from an earlier beat, rebuild it at that fixed beat, read it, and throw+ it away. Never carry it in a `let`.+- **No clock.** No `Math.random`, `Date`, `performance.now`, `setAnimationLoop`, `THREE.Clock`,+ `mixer.update(dt)`. An `AnimationMixer` is driven with `mixer.setTime(f / fps)`. The gate's+ contract scan reads `src/three-core` as well as `src/canvas-core` and fails on these.+- **Seeded randomness**: `rand(seed)` from `three-core/stage.ts`, one seed per system, so adding+ one effect does not reshuffle another.+- **Import three as `import * as THREE from "three"` in each file, and never re-export the+ namespace.** Re-exporting stops the bundler dropping the unused parts, which drags three's file+ loaders (which can fetch) into the player, and the gate fails a player that can reach the network.+- **`ss` supersampling, default 2** (`draw3d(..., { ss })`, 1 to 3): rendered at 2x and scaled down,+ so edges are smooth and identical on every backend. MSAA varies by driver; do not turn it on.+- **Shadows are off by default** (`{ shadows: true }` turns on soft shadow maps). A shadow is a+ choice, and shadow acne is the first cheap-3D tell.+- Fonts arrive as data: `defaultFont()` is Poppins Bold, inlined from `engine/assets/fonts/`+ (OFL, provenance in `engine/assets/fonts/PROVENANCE.md`). three.js itself is vendored, scanned+ and hash-pinned: `engine/vendor/three/PROVENANCE.md`.++## The kit, by job++All in `engine/src/three-core/`. Every function takes the frame and returns or sets a value; none keeps state.++| Job | Module | What to reach for |+|---|---|---|+| Stage | `stage.ts` | `stage`, `draw3d` (render and copy to the frame), `memo`, `rand`, `probe3d` |+| Time | `time.ts` | `seg`, `tween`, `ease.*`, `spring` (closed form, seekable), `beatFrames`, `storyClock` |+| Timeline | `timeline.ts` | `timeline(fps, { labels, words, beat })` with `tl.at`, `tl.value`, `tl.check`; clips `to`, `fromTo`, `set`, `wait`, `all`, `chain`, `sequence`, `delay`, `loop`; `mix` (colours in linear light) |+| Camera | `camera.ts` | `look`, `place`, `hold`, `then`, `withMods`; `pushIn`, `pullBack`, `dolly` + `path`, `orbit`, `crane`, `truck`, `pan`, `tilt`, `whipPan`; mods `handheld`, `dutch`, `zoom`; `fitTo`, `rackFocus`; `matchCut`, `matchLens`, `screenPx`, `screenSize`, `worldForPx` |+| Motion graphics | `mograph.ts` | `popIn`/`popOut`, `dropIn`, `riseFromFloor`, `growFrom`, `fadeIn`/`fadeOut`, `extrudeIn`, `writeOn`/`drawTo`, `moveAlongPath`, `morph` + `writeTube`, `explode`/`assemble`, `indicate`, `wiggle`, `wave`; groups `lagged`, `grid`, `kinetic` (per letter) |+| Type | `type3d.ts`, `ttf.ts` | `text3d(env, font, text, opts)` (one mesh per letter, `userData.letters`), `textPlane` (flat crisp text in the scene), `defaultFont`, `parseTTF` for another TrueType face |+| Look | `look.ts` | rigs `studio`, `night`, `interior`, `sunset`; materials `matte`, `satin`, `toon`, `glass`, `emissiveGlow`; `outline` (`screen: true` for a width in pixels), `contactShadow`, `softShadows`, `grain`, `vignette` |+| Transitions | `transitions.ts` | `transition(ctx, env, t, kind, drawA, drawB)` with `crossfade`, `wipe`, `radialWipe`, `noiseWipe` (ink blot), `slide`, `zoomThrough`; t at 0 or 1 is exactly A or B |+| Characters | `rig.ts` | `makeRig`, `part`, `anchor`, `limb`, `head`, `flag`, `pose`, `bodyMatrix`, `solveTwoBone`; props `handle`, `grip`, `gripFrame`; motion `lookAt`, `anticipate`, `followThrough`, `squashStretch`, `walkCycle` |+| Checks | `checks3d.ts` | `checkGrip`, `proximity`, `selfClear`, `pathClear`, `labelVisible`, `placeLabel`, `screenSizeOk`; per frame: `resetChecks`, `register*`, `runChecks` |++Mograph verbs take `(object, f, at, len)` and set their channels from the object's rest pose:+before `at` the object is in its before-state, after `at + len` it is exactly at rest. A+`timeline` `to()` on a track that was never set throws instead of moving from a silent 0.++**Two clocks for narrated or rescored films.** Write shots against story frames and map the real+frame through `storyClock([[story, real], ...])`, so a narrator who stretches the film is a table+edit (the last film retimed about 100 beat constants this way). Cyclic motion (walks, flicker,+breathing) reads the real frame, or it plays in slow motion. Keep every story action as a named+frame constant at the top of the shot. Word cues come from narration: `references/workflows/narration.md`.++## The craft bar in 3D++The test from `references/craft-bar.md` holds: would a proud maker ship it? In 3D the question is whether it+reads as a designed miniature or as an untextured blockout.++| The cheap-3D tell | What passes |+|---|---|+| Shadow acne, self-shadow creases on a character | Shadows off unless chosen; `softShadows(light)` sets acne-free biases; characters get `receiveShadow = false` and a `contactShadow` under them |+| Plastic shine | `matte` or `satin` (sheen, low specular); metal only where the thing is metal |+| Jaggies, shimmering edges | `ss: 2`; check a 2x crop |+| Black crush in the shadows | Every rig has a sky fill; `vignette` darkens toward a tinted colour, never black |+| A muddy interior lit by the outdoor rig | `interior()`: a key from above, a warm practical, a warm fill |+| Far glows going grey in fog | `emissiveGlow` (fog off): distance reads by size |+| Glass with a second, offset outline | `glass()`: front side only, thin, low IOR |+| Boxes with a glowing plane for a window | Built like a model maker would: frames, sills, bevels, varied repeated pieces |+| A hook, a lamp or a sign floating | Every part held by something (a bracket, a string, the ground); look at the joins at 2x |+| One angle per shot, a locked camera | Each shot gets an angle, a move and a seam (`references/motion-grammar.md`, `deck.mjs deal`) |+| A whip pan with smear frames | `whipPan` holds posed frames at both ends; a match cut keeps size with `matchCut`/`matchLens` |+| Frozen arms on a walking character | Limbs that pose from the start: arm counter-swing (`walkCycle`), reach with `anticipate`, props that lag (`followThrough`) |++Five rules the last film paid for, each with its check:++- **Contact beats are framed close.** A grip, a push or a hand-off reads only when the contact+ point is at least about 40 px tall at 1080p. A gate push filmed from 17 units away showed a claw+ a few pixels wide and read as nothing. `registerSize(hand.end, 40)` holds it.+- **Thin lines are sized by screen, not world units.** A fixed-width thread vanishes in a wide+ shot. Size it with `worldForPx`, or use `outline(..., { screen: true })`.+- **Labels are placed after the camera.** A tag reading "/co act" because a claw covers two letters+ is a placement problem. Set the camera, then `placeLabel` tries positions until the label reads;+ `registerLabel` flags one still hidden or turned away.+- **Hands act.** Build every rig with posable limbs and grip points before any shot. A rig whose+ arms were fixed geometry played every shot with frozen claws, and retrofitting the arms cost+ two rendered shots. `pose` throws on a flag a rig variant does not have, so nothing silently+ does nothing.+- **Grips read.** A held handle runs along the hand's grip axis through the closed grip (`grip`),+ a lantern hangs from its bail (`hang: true`). A broom, a shovel and a jar went through the claws+ for a whole first cut and nobody saw it until a critic did. Check the rig's reach before blocking a+ hand-off: when the hands cannot meet, a toss, a drop or a set-down reads better and never clips.++## The checks, and what each catches++```bash+node tools/still.mjs <film> --frames 0,48,96,150 --out out/look/ --sheet out/look-sheet.png+node tools/still.mjs <film> --frame 126 --scale 2 --out out/grip-126.png # a 2x crop+node tools/framecheck.mjs <film>+node tools/gate.mjs <film>+```++- **Still sheets.** `--sheet` takes a file path. A bare `--sheet` swallows the next argument, so+ `--sheet --out x.png` writes the sheet to a file named `--out`.+ Then a 2x frame of every contact beat, face and join: the checks see geometry, a crop sees+ what the viewer sees.+- **framecheck** with `probe3d`: call `probe3d(ctx, env, object, camera, label)` after the camera+ is placed, for 3D type and any hero object that must be whole. framecheck then fails one cut by+ the frame edge, as it does for 2D type, and holds subtitle cues to their reading time.+- **gate**, five steps on a 3D film. DETERMINISM (the same sampled frames drawn cold and forward, then+ warm and reversed, identical) catches state carried between frames. CONTRACT catches a clock or the network.+ DEAD AIR catches stillness; declare a meant hold in `meta.holds` with its reason. ARTIFACT+ catches a player that can reach the network. **3D CHECKS** runs `checks3d` inside the page on+ about 48 sampled frames plus every frame of each grip's contact window, and fails on any finding:+ a gap or an open hand on a held prop, a prop through a hand or the holder's body, a hand off+ screen while its prop is on, a grip hidden from the lens, two rigs clipping, a walk through a+ closed prop, a label covered, a contact beat under its pixel size. For that, each draw starts with+ `resetChecks()`, registers what it holds (`registerRig`, `registerGrip`, `registerSize`,+ `registerLabel`, `registerPath`) and ends with `if (checking()) runChecks(f, camera, env)`+ (`threeRigDemo.ts`). A film that registers nothing gets a note, not a pass.+- **Rerun the whole check pass after every batch of shot changes.** A new jar swing broke a catch+ that had been clean, and only the re-run found it. A green gate with a prop through a hand is a+ failed gate, so look at the crops too.++## Rendering++- **Default: SwiftShader**, a CPU WebGL that draws the same pixels on any machine. About 1 s a+ 1080p frame at `ss: 2` with soft shadows. `render.mjs` then prints its 150 ms draw budget as OVER;+ that line is information, not a failure.+- **`ANIDOODLE_GL=gpu`** uses the machine's GPU (Metal on a Mac), about 12x faster. Its hashes+ hold only on the same machine and driver, so iterate and render long films with it, and say which+ backend a published hash came from. Any tool takes it:+ `ANIDOODLE_GL=gpu node tools/render.mjs <film>`.+- A lost WebGL context throws in `draw3d` instead of writing a broken frame; re-render in a fresh page.+- Grain changes every pixel every frame and defeats compression (69 MB for 8 s at the demo's+ amount). Keep `grain` around 0.03 for long films.+- Only pages whose bundle carries the 3D marker get WebGL flags, so 2D films keep the browser+ they always had.