@anime-studio/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bin.js +74 -2
  2. package/dist/bin.js.map +1 -1
  3. package/dist/doctor.d.ts +8 -1
  4. package/dist/doctor.d.ts.map +1 -1
  5. package/dist/doctor.js +30 -5
  6. package/dist/doctor.js.map +1 -1
  7. package/dist/index.d.ts +6 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +6 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/mix.d.ts +21 -0
  12. package/dist/mix.d.ts.map +1 -0
  13. package/dist/mix.js +95 -0
  14. package/dist/mix.js.map +1 -0
  15. package/dist/raster.d.ts +63 -0
  16. package/dist/raster.d.ts.map +1 -0
  17. package/dist/raster.js +145 -0
  18. package/dist/raster.js.map +1 -0
  19. package/dist/render-worker.d.ts +27 -0
  20. package/dist/render-worker.d.ts.map +1 -0
  21. package/dist/render-worker.js +33 -0
  22. package/dist/render-worker.js.map +1 -0
  23. package/dist/skills.d.ts +28 -0
  24. package/dist/skills.d.ts.map +1 -0
  25. package/dist/skills.js +56 -0
  26. package/dist/skills.js.map +1 -0
  27. package/dist/video.d.ts +64 -0
  28. package/dist/video.d.ts.map +1 -0
  29. package/dist/video.js +221 -0
  30. package/dist/video.js.map +1 -0
  31. package/package.json +7 -5
  32. package/skills/animestudio/SKILL.md +168 -0
  33. package/skills/animestudio/examples/first-frame.ts +54 -0
  34. package/skills/animestudio/examples/hello.scene.json +50 -0
  35. package/skills/animestudio/examples/hello.sequence.json +13 -0
  36. package/skills/animestudio/examples/remotion/Root.tsx +25 -0
  37. package/skills/animestudio/examples/remotion/index.ts +5 -0
  38. package/skills/animestudio/examples/render-video.ts +110 -0
  39. package/skills/animestudio/references/packages.md +54 -0
  40. package/skills/animestudio/references/rendering.md +148 -0
  41. package/skills/animestudio/references/scene-format.md +101 -0
  42. package/skills/animestudio/references/validation-and-debugging.md +66 -0
  43. package/skills/animestudio-animation/SKILL.md +177 -0
  44. package/skills/animestudio-animation/examples/gestures.ts +55 -0
  45. package/skills/animestudio-animation/examples/hold.ts +82 -0
  46. package/skills/animestudio-animation/examples/knockdown.ts +68 -0
  47. package/skills/animestudio-animation/examples/sheet.ts +80 -0
  48. package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
  49. package/skills/animestudio-animation/references/clips.md +103 -0
  50. package/skills/animestudio-animation/references/director-beats.md +48 -0
  51. package/skills/animestudio-animation/references/holding.md +106 -0
  52. package/skills/animestudio-animation/references/locomotion.md +86 -0
  53. package/skills/animestudio-animation/references/timing.md +89 -0
  54. package/skills/animestudio-characters/SKILL.md +211 -0
  55. package/skills/animestudio-characters/examples/cast.ts +63 -0
  56. package/skills/animestudio-characters/examples/human.ts +52 -0
  57. package/skills/animestudio-characters/examples/import-svg.ts +68 -0
  58. package/skills/animestudio-characters/examples/lumo.svg +36 -0
  59. package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
  60. package/skills/animestudio-characters/examples/sprout.ts +48 -0
  61. package/skills/animestudio-characters/examples/turnaround.ts +91 -0
  62. package/skills/animestudio-characters/references/custom-rig.md +139 -0
  63. package/skills/animestudio-characters/references/import-svg.md +59 -0
  64. package/skills/animestudio-characters/references/look-options.md +143 -0
  65. package/skills/animestudio-characters/references/rig-surface.md +62 -0
  66. package/skills/animestudio-script/SKILL.md +164 -0
  67. package/skills/animestudio-script/examples/director.ts +143 -0
  68. package/skills/animestudio-script/examples/sheet.ts +58 -0
  69. package/skills/animestudio-script/examples/short.ts +193 -0
  70. package/skills/animestudio-script/references/actions.md +84 -0
  71. package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
  72. package/skills/animestudio-script/references/director.md +110 -0
  73. package/skills/animestudio-script/references/shots-and-editing.md +79 -0
  74. package/skills/animestudio-script/references/writing-for-animation.md +84 -0
  75. package/skills/animestudio-sets/SKILL.md +232 -0
  76. package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
  77. package/skills/animestudio-sets/examples/render-scene.ts +35 -0
  78. package/skills/animestudio-sets/examples/sets.ts +257 -0
  79. package/skills/animestudio-sets/references/drawing-sets.md +119 -0
  80. package/skills/animestudio-sets/references/fx.md +93 -0
  81. package/skills/animestudio-sets/references/lighting-camera.md +93 -0
  82. package/skills/animestudio-sets/references/scene-fields.md +132 -0
@@ -0,0 +1,148 @@
1
+ # Rendering: stills, MP4 without a browser, Remotion
2
+
3
+ Read this before producing any picture or video. Every path below was run on the examples in
4
+ `../examples/`.
5
+
6
+ ## Contents
7
+
8
+ 1. Still frames
9
+ 2. MP4 without a browser (recommended for scripts and agents)
10
+ 3. Sequences
11
+ 4. Remotion
12
+ 5. Quality and performance
13
+ 6. Pitfalls
14
+
15
+ ## 1. Still frames
16
+
17
+ ```ts
18
+ const scene = await prepareScene(doc, assets); // @anime-studio/rigid
19
+ writeFileSync("f.svg", frameToSVG(evaluateScene(scene, 2.6)));
20
+ ```
21
+
22
+ ```bash
23
+ rsvg-convert -w 1280 f.svg -o f.png # librsvg renders the engine's SVG faithfully
24
+ toon render my.scene.json --time 2.6 -o f.svg # the same from the CLI (rigid bodies simulated)
25
+ toon render hero.toon.json --clip wave --time 0.4 -o f.svg # one character alone, one clip (preview scene)
26
+ ```
27
+
28
+ Always open the PNG and check it shows what the script says at that time (who is where, facing
29
+ whom, which gesture). For several moments at once, render each and tile them
30
+ (`magick a.png b.png c.png -resize 640x +append sheet.png`), as the promo's `render.ts preview` does.
31
+
32
+ `frameToSVG` returns a standalone SVG document. Without a scene `background` (or a full-frame
33
+ layer) the picture is transparent.
34
+
35
+ ## 2. MP4 without a browser
36
+
37
+ **Use `toon video` (0.3+).** It takes a scene or a sequence, renders frames in parallel worker
38
+ threads with resvg, streams them in order into ffmpeg and mixes the audio with the engine's own
39
+ levels (fades, loops, `duck` under speech):
40
+
41
+ ```bash
42
+ toon video my.scene.json -o out/my.mp4 # H.264 + AAC
43
+ toon video my.sequence.json -o out/ep.mp4 --width 1920 # resized (one side keeps the aspect)
44
+ toon video my.scene.json -o out/quick.mp4 --to 2 --fps 12 # a quick check: 2 s at 12 fps
45
+ toon video my.scene.json -o out/clip.webm --transparent # VP9 with alpha (also .mov ProRes 4444)
46
+ toon video my.scene.json -o out/loop.gif --width 480 # no audio in a GIF
47
+ toon video my.scene.json -o out/frames # PNG frames 00000.png… + audio.wav
48
+ toon render my.scene.json --time 2.6 -o f.png # one still, rasterised the same way
49
+ ```
50
+
51
+ From code: `renderVideo(path, { out, from?, to?, fps?, width?, workers?, transparent?, mute? })`
52
+ from `@anime-studio/cli`. It needs `ffmpeg` on the PATH (not for PNG frames without audio).
53
+ Text uses the fonts the frame names, found with fontconfig; pass `--fonts <dir>` for fonts that
54
+ are not installed.
55
+
56
+ **By hand** (what `toon video` does, if you need your own pipeline):
57
+
58
+ 1. Load the scene and its assets, `validateScene(doc, assets)`, `prepareScene(doc, assets)`.
59
+ 2. Frame count: `frameCount(scene)` (= ⌈duration × fps⌉ without float noise); time of frame i:
60
+ `i / fps` (`frameTime(scene, i)`).
61
+ 3. For each frame: `frameToSVG(evaluateScene(scene, t))` → write `00042.svg` →
62
+ `rsvg-convert -w W -h H -o 00042.png 00042.svg`. Run ~8 conversions at once (a small async
63
+ pool over `execFile`); frames are independent, so order does not matter.
64
+ 4. Encode: `ffmpeg -framerate FPS -i %05d.png -c:v libx264 -preset slow -crf 14 -pix_fmt yuv420p`.
65
+ 5. Audio: `scene.audio` lists events (`say` with `audio`, `sound`) with `src`, `start`, `volume`
66
+ and the mix fields (`trimStart`, `loop`, `maxDuration`, `fadeIn`, `fadeOut`, `duck`, `kind`, `length`).
67
+ `mixAudio(events, duration)` from `@anime-studio/cli` mixes them with `audioGain` (core) and
68
+ `writeWav` saves the result; mux it with `-c:a aac`. Resolve `src` against the scene file's
69
+ folder.
70
+
71
+ [`../examples/render-video.ts`](../examples/render-video.ts) does all of it for a scene or a
72
+ sequence:
73
+
74
+ ```bash
75
+ npx tsx render-video.ts hello.scene.json --frames 12 # quick end-to-end check (12 frames)
76
+ npx tsx render-video.ts hello.scene.json # whole video → out/video.mp4
77
+ npx tsx render-video.ts hello.sequence.json -o out/seq.mp4
78
+ ```
79
+
80
+ Measured on the 1280×720 example: about 0.2 s per frame with 8 jobs on a laptop. Lit actors
81
+ (`lighting.shading`), blur and many characters cost more.
82
+
83
+ ## 3. Sequences
84
+
85
+ A `toon-sequence` lists `scenes` (id → path) and `shots` (`scene`, `from?`, `duration?`,
86
+ `transition?`: `cut`, `crossfade`, `fade`, `iris`, `wipe`, `flash`). In code:
87
+
88
+ ```ts
89
+ const seq = compileSequence(seqDoc, { scenes: { hello: compiledHello } }); // compiled scenes, or { doc, assets }
90
+ const frame = evaluateSequence(seq, t); // global time; crossfades composite two shots
91
+ const audio = sequenceAudio(seq); // events with start, trimStart, maxDuration (cut at shot ends)
92
+ ```
93
+
94
+ Pass scenes already run through `prepareScene` if they have rigid bodies. A shot that replays a
95
+ window of a scene (`from`) makes a cut: `toon debug` reports it as an `info` jump, which is
96
+ expected. Total length = sum of shot durations minus crossfade overlaps.
97
+
98
+ ## 4. Remotion
99
+
100
+ ```tsx
101
+ import { ToonComposition, toonMetadata } from "@anime-studio/remotion";
102
+ <Composition id="Hello" component={ToonComposition} {...toonMetadata(scene)}
103
+ defaultProps={{ scene, assets: { characters: { maya, kai }, lipsync: {} } }} />
104
+ ```
105
+
106
+ - `scene` is the **document** (not compiled); the component compiles it and bakes rigid bodies
107
+ with `delayRender`. Characters and lip sync cues go in `assets` as parsed JSON.
108
+ - Audio paths in the scene resolve with `staticFile()` (put files in `public/`), or pass
109
+ `resolveAudio`.
110
+ - Sequences: `<ToonSequenceComposition sequence scenes>` with
111
+ `scenes: { id: { doc, assets } }` and `toonSequenceMetadata(sequence, scenes)`.
112
+ - Options: `raster` (draw each frame to a canvas before capture: no half-painted frames in heavy
113
+ scenes at high concurrency), `paintSettle`, `debug` (an instrumentation strip that
114
+ `toon doctor video.mp4 doc.json` reads), `muted`.
115
+ - Remotion's CLI needs a `tsconfig.json` at the project root. Use PNG frames and CRF 14 in
116
+ `remotion.config.ts` (`Config.setVideoImageFormat("png")`, `Config.setCrf(14)`).
117
+ - On some macOS setups the bundled headless Chrome crashes at GPU init ("browser has
118
+ disconnected"): pass a system Chrome (`--browser-executable=… --chrome-mode=chrome-for-testing`
119
+ or `Config.setBrowserExecutable`).
120
+
121
+ Runnable root: [`../examples/remotion/`](../examples/remotion/) —
122
+ `npx remotion still remotion/index.ts Hello still.png --frame=78` gives the same picture as
123
+ `first-frame.ts` at 2.6 s.
124
+
125
+ Choose Remotion when you need its timeline UI, React overlays or its cloud rendering; choose the
126
+ browserless pipeline for scripted, reproducible renders (no Chrome, no paint glitches).
127
+
128
+ ## 5. Quality and performance
129
+
130
+ - PNG frames, x264 `-crf 14 -preset slow`, `yuv420p`. JPEG frames ring around flat colours and
131
+ hard lines.
132
+ - For video sites, render at 2× (`rsvg-convert -w 3840` for a 1920 scene, or Remotion
133
+ `--scale 2`): a 4K upload gets a far higher bitrate.
134
+ - Fonts: text in layers/props is drawn with installed fonts (rsvg and Chrome alike). Use fonts
135
+ present on the render machine, or convert text to paths.
136
+ - Character shading is the most expensive part of a frame; with many lit actors set
137
+ `lighting.shading.crowd`.
138
+
139
+ ## 6. Pitfalls
140
+
141
+ | Symptom | Cause / fix |
142
+ |---|---|
143
+ | Ball or crate never moves | Scene compiled with `compileScene` only: use `prepareScene` (rigid bake) |
144
+ | `cannot load "…toon.json"` from the CLI | Paths in `characters` are relative to the scene file; write the character files first |
145
+ | Video shorter/longer than expected | Frame count must be ⌈duration × fps⌉; sequence crossfades overlap shots |
146
+ | Silent video | `scene.audio` is empty (text-only `say` has no sound) or audio `src` not resolved against the scene folder |
147
+ | A frame differs between runs | Never: frames are pure. Look for your own non-determinism (random, Date) in the build script |
148
+ | Remotion: elements missing in a few frames | Browser capture glitch: `raster: true`, more `paintSettle`, or render those frames again; `toon doctor` pinpoints them |
@@ -0,0 +1,101 @@
1
+ # Scene documents: the essentials
2
+
3
+ Read this when writing or editing a `*.scene.json` (or the same object in TypeScript). It is a
4
+ map, not the spec: the full field tables are in
5
+ https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md (§3 scenes, §4
6
+ sequences). Characters, sets, scripts and motion have their own sibling skills.
7
+
8
+ ## Conventions (FORMAT §1)
9
+
10
+ - Lengths in px (SVG user units), **y down**, angles in **degrees clockwise**, time in seconds.
11
+ - Colours: any CSS colour; hex colours interpolate smoothly in tracks.
12
+ - A character's origin is on the ground between its feet; actor `x, y` puts that point in the
13
+ scene. Characters face right; `flip: true` faces left.
14
+ - Character channels are **offsets from the rest pose**; scene placement channels (actor `x`,
15
+ camera…) are absolute.
16
+
17
+ ## Skeleton of a scene
18
+
19
+ ```jsonc
20
+ {
21
+ "$schema": "./schemas/scene.schema.json", // optional: `toon schema --out schemas` for editor completion
22
+ "format": "toon-scene", "version": 1, // required
23
+ "width": 1920, "height": 1080, "fps": 30, "duration": 8, // required
24
+ "characters": { "hero": "hero.toon.json" }, // required: id → path (relative to this file)
25
+ "background": "#cfeaf5",
26
+ "audio": { "l1": "audio/l1.wav" }, // id → file, used by `say` / `sound`
27
+ "lipsync": { "l1": "audio/l1.cues.json" }, // id → Rhubarb-style mouth cues
28
+ "camera": { "x": 960, "y": 540, "zoom": 1 }, // the scene point at the centre of the frame
29
+ "world": { "gravity": [0, 1800], "ground": 900 }, // rigid bodies, surfaces
30
+ "lighting": { … }, "animation": { … }, // optional looks (sets skill / animation skill)
31
+ "layers": [ { "id": "sky", "art": "<rect …/>", "parallax": 0, "z": -100 } ],
32
+ "actors": [ { "id": "hero", "character": "hero", "x": 700, "y": 900, "scale": 1 } ],
33
+ "props": [ { "id": "ball", "art": "<circle r='30'/>", "x": 1200, "y": 860,
34
+ "body": { "type": "dynamic", "shape": { "circle": 30 } } } ],
35
+ "tracks": { "camera.zoom": [[0, 1], [8, 1.2, "sineInOut"]] },
36
+ "script": [ { "at": 0, "actor": "hero", "action": "play", "clip": "idle", "loop": true, "layer": -1 } ]
37
+ }
38
+ ```
39
+
40
+ - Layers, actors and props share placement fields: `x`, `y`, `rotation`, `scale` (number or
41
+ `[sx, sy]`), `z` (draw order), `parallax` (1 normal, 0 fixed to the screen, < 1 far away),
42
+ `opacity`. Art is an SVG fragment string.
43
+ - Actors also take `flip`, `palette` (recolour), `seed` (vary blinks), `shading`, `ground`.
44
+ - Unknown fields are errors. Several actors may share one character (recoloured by `palette`).
45
+
46
+ ## Script actions (FORMAT §3.3)
47
+
48
+ Every action has `at` (seconds); actor actions have `actor`. Valid `action` values:
49
+ `play`, `set`, `pose`, `walkTo`, `face`, `fall`, `getUp`, `mount`, `reach`, `lookAt`, `say`,
50
+ `grab`, `release`, `put`, `impulse`, `camera`, `transition`, `fx`, `shake`, `sound`, `light`.
51
+
52
+ | Intent | Action (main fields) |
53
+ |---|---|
54
+ | Base motion, never frozen | `play` `clip: "idle"`, `loop: true`, `layer: -1` at 0 |
55
+ | A gesture | `play` `clip`, `duration`, `fadeIn` / `fadeOut` (0.2) |
56
+ | Move somewhere | `walkTo` `x`, `y?`, `duration` or `speed`, `clip?` (`walk`, `run`, `sneak`…) |
57
+ | Emotion / view / any pose control | `pose` `control`, `value`, `duration` (0.3) |
58
+ | Talk | `say` `audio` + `lipsync`, or inline `cues`, or `text` + `duration` |
59
+ | Look at | `lookAt` `target` (actor id, prop id, `[x, y]`, or `null`) |
60
+ | Turn round | `face` `direction` (`left` / `right`) |
61
+ | Knock down / get up | `fall` (`from?` the hitter), later `getUp` |
62
+ | Any channel | `set` `channel`, `value`, `duration`, `ease` |
63
+ | Hold / drop a prop | `grab` `prop`, `anchor` (`hand`…), `fit?`, `hang?` / `release` |
64
+ | Physics kick | `impulse` `prop`, `vector` |
65
+ | Camera | `camera` `x`/`y`/`zoom`/`duration`, or `follow`, `frame: [ids]`, `punch`, `path`… |
66
+ | Cartoon effect | `fx` `type` (`surprise`, `question`, `sweat`, `sparkle`, `dust`, `hearts`, `impact`…) |
67
+ | Impact | `shake` `amount`, `duration` |
68
+ | Sound / light | `sound` `audio` (+ `volume`, `from`, `duration`, `loop`, `fadeIn`, `fadeOut`, `duck`); `light` `channel`, `value`, `duration` |
69
+ | In-scene transition | `transition` `type` (`fade`, `iris`, `wipe`, `flash`), `mode`, `duration` |
70
+
71
+ Clip layers mix in order: the `layer: -1` base loops underneath, gestures on layer 0 override it
72
+ while they play and fade back. The kit's clip and emotion lists: run `toon describe`.
73
+
74
+ ## Tracks (FORMAT §3.2)
75
+
76
+ `tracks` maps a channel to keys `[time, value, ease?]`: `camera.x|y|zoom|rotation`,
77
+ `actors.<id>.x|y|rotation|scale|opacity|flip|z`, `actors.<id>.<character channel>` (e.g.
78
+ `actors.hero.controls.emotion`), `props.<id>.…`, `layers.<id>.…`, `lights.<id>.…`,
79
+ `lighting.<section>.<prop>`. Keys without `ease` are smooth splines; a track holds its first
80
+ value before its first key. Use tracks for props, layers, titles and the camera base; use script
81
+ actions for characters.
82
+
83
+ ## Sequences (FORMAT §4)
84
+
85
+ ```json
86
+ { "format": "toon-sequence", "version": 1, "width": 1280, "height": 720, "fps": 30,
87
+ "scenes": { "hello": "hello.scene.json" },
88
+ "shots": [ { "scene": "hello", "duration": 1.8 },
89
+ { "scene": "hello", "from": 1.8, "transition": { "type": "crossfade", "duration": 0.4 } } ] }
90
+ ```
91
+
92
+ Shots take `scene`, `from`, `duration`, `transition` (`cut`, `crossfade`, `fade`, `iris`,
93
+ `wipe`, `flash`; `target` for an iris), `muteSpeech`, `speed`. Prefer one continuous scene per
94
+ location with camera cuts inside it over one scene per shot: characters then keep their places.
95
+
96
+ ## Writing scenes in TypeScript
97
+
98
+ Scene documents are plain objects, so generate them with code when it helps (loops over a cast,
99
+ helper functions for repeated beats) — the repo's promo does this (`examples/promo/shots.ts`).
100
+ Type them as `SceneDoc` / `ActionDef` from `@anime-studio/core`, pass parsed characters as assets,
101
+ and still validate with `validateScene(doc, assets)` before rendering.
@@ -0,0 +1,66 @@
1
+ # Validation and debugging
2
+
3
+ Read this when `toon validate` fails, when a render does not show what the script says, or
4
+ before handing a document to someone else.
5
+
6
+ ## The loop
7
+
8
+ 1. `toon describe hero.toon.json` — the source of truth for names: control values (emotions,
9
+ views, head angles, jaw), clips with duration / loop / stride, anchors and channels. Paste it
10
+ into your context before writing a script.
11
+ 2. `toon validate a.toon.json b.scene.json c.sequence.json` — several files at once; exit 1 on
12
+ errors. For a scene it checks the schema, then loads every referenced file (each failure is
13
+ its own issue at `characters.<id>` / `lipsync.<id>`), then compiles the whole script.
14
+ 3. `toon debug doc.json [--from s] [--to s] [--json]` — evaluates frames and reports library-side
15
+ problems: invalid numbers, broken references, duplicate ids, nodes present for a single frame,
16
+ camera / position jumps. Exit 1 on `error` findings. `info` jumps at sequence cuts are expected.
17
+ 4. Render stills at the key beats and look at them (see `rendering.md`).
18
+ 5. After a Remotion render: `toon doctor video.mp4 doc.json` finds A→B→A flickers and, for a
19
+ `debug` render, which nodes the browser failed to paint. Flickers with stable library output
20
+ are capture glitches: re-render those frames.
21
+
22
+ In code: `validateToon(doc)`, `validateScene(doc, assets)`, `validateSequence(doc)` return
23
+ `{ ok, value?, issues: [{ path, message, severity }] }`; `parseToon` / `parseScene` throw one
24
+ error listing all issues. `validateScene` **without assets checks only the schema** — pass
25
+ `{ characters, lipsync }` to compile the script too.
26
+
27
+ ## Errors you will meet (real messages)
28
+
29
+ | Message | Fix |
30
+ |---|---|
31
+ | `script[11] (play): unknown clip "wavee". Known clips: turn, idle, walk, …` | Use a listed clip (`toon describe`) |
32
+ | `script[11] (play): unknown actor "bob". Known actors: maya, kai.` | Declare the actor in `actors` or fix the id |
33
+ | `actors[0]: Unrecognized key: "rotaton"` | Typo: the format rejects unknown fields |
34
+ | `script[13].action: Invalid discriminator value. Expected 'play' \| 'set' \| …` | Not an action; use one of the listed ones (a gesture is `play` + `clip`) |
35
+ | `script[11].type: Invalid option: expected one of "surprise"\|"exclaim"\|…` | fx type not in the list |
36
+ | `characters.kai: cannot load "…": ENOENT` | Path is relative to the scene file; the file must exist |
37
+ | `walkTo needs a "walk" clip on "…". Known clips: …` | The rig has no such locomotion clip; pass `clip` or use a kit character |
38
+ | `script[4] (pose): "glad" is not a pose of the "emotion" control of "…". Valid: neutral, sleep, happy, …` | Use a listed value (`toon describe`); every key of a `{ name: weight }` blend too |
39
+ | `script[2] (pose): "~half" is not a pose of the "view" control of "…". Valid: … use "half" and turn the actor round with its "flip"` | Body views are not mirrored by name: `flip` / `face` the actor (`~` angles exist for the kit's `head` control only) |
40
+ | warn `script[7] (walkTo): walkTo of "maya" (2–3.5 s) overlaps script[5] (1–3 s): …` | Two walks of one actor at once: the later takes over mid-walk. Start it when the first ends |
41
+ | `unknown bone "x". Known bones: …` | (characters) use a listed bone id |
42
+ | `parent "x" is not declared before this bone` | (characters) parents first in `skeleton` |
43
+
44
+ Every bad script action is reported (one error each, at its own `script[i]` path), so fix them all
45
+ before validating again. (`compileScene` itself throws one `SceneError` listing them all.)
46
+
47
+ ## What validation does NOT catch
48
+
49
+ These pass `toon validate` and `toon debug` silently; check them yourself:
50
+
51
+ - **Staging mistakes**: actors facing away from whom they talk to, a character walking off the
52
+ set, a gesture that ends before the line it accompanies, a camera that frames nobody. Only
53
+ looking at frames catches these (the director's `check` catches many for staged episodes).
54
+ - **Tracks before their first key**: a key at 40 s also applies from 0 s.
55
+
56
+ ## Debugging a wrong picture
57
+
58
+ - Wrong pose at time t → `toon render scene.json --time t -o f.svg`, then check the script
59
+ entries active at t (start `at`, `duration`, `fadeIn/fadeOut`, `layer`). A clip on `layer: -1`
60
+ is the base; higher layers override it while they play.
61
+ - Character frozen → no looping base clip (`idle`, `loop: true`, `layer: -1`).
62
+ - Feet sliding → a move done with `set`/tracks on `x` instead of `walkTo` (which matches the
63
+ stride), or a non-walk clip used for travel.
64
+ - Somebody invisible → off camera (`camera` x/y/zoom), `opacity` 0, `scale` 0 from a pop track,
65
+ or behind a layer with higher `z`.
66
+ - Lip sync missing → `say` needs `audio` + `lipsync` cues, inline `cues`, or `text` + `duration`.
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: animestudio-animation
3
+ description: Animate characters in animeStudio scenes and stagings — clips and layers, idle, views and turns, walks and runs (walkTo with walk/run/sneak/strut/tired/march/scaredRun), gestures, emotions and look-ats as acting, falls and getUp, sitting/lying/riding, holding and carrying props, and cartoon timing. Use it whenever you animate, stage or fix motion in animeStudio (animate, animação, walk, run, gesture, wave, emotion, acting, fall, sit, hold object, carry, timing, clip).
4
+ ---
5
+
6
+ # Animating characters with animeStudio
7
+
8
+ Motion in animeStudio is **declared, not keyframed**: a scene's `script` lists actions (`play`,
9
+ `walkTo`, `pose`, `lookAt`, `fall`, `grab`…) that the engine compiles into clip instances and
10
+ tracks; a director staging lists beats (`walk`, `sit`, `hit`…) that become those actions. Your job
11
+ is to pick the right high-level action, time it like an animator, and **look at the frames**.
12
+
13
+ Two levels — know which one you are writing:
14
+
15
+ | Level | Where | Use for |
16
+ |---|---|---|
17
+ | Scene `script` (`toon-scene`) | [FORMAT.md §3.3](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md) | One shot, exact timing in seconds, props in hands, physics |
18
+ | Director staging (`blocks[].beats`) | [DIRECTOR.md](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md) | Whole episodes timed to dialogue; `sit`, `lie`, `ride`, `hit`, `pick`, `hold`, `hide`… are only here |
19
+
20
+ Characters below are `cartoonCharacter(look)` from `@anime-studio/kit` (2.5D rigs, twelve drawn
21
+ angles). Every clip, emotion and view name used here exists on them; check others with
22
+ `toon describe <file>` or `Object.keys(doc.clips)`.
23
+
24
+ ## The core loop
25
+
26
+ 1. Give every actor a base: `{ action: "play", clip: "idle", loop: true, layer: -1 }` at `at: 0`.
27
+ 2. Give every channel you will change a value at `t = 0` (`view`, `emotion`): a track holds its
28
+ first key *before* it, so a `view` set at 40 s would otherwise apply from frame 0.
29
+ 3. Write the actions (below), one clear action at a time per character.
30
+ 4. Render a contact sheet of key frames and **look at it** (`examples/sheet.ts` → `contactSheet`):
31
+ feet on the floor, hands on the prop, the back on the floor after a fall, nobody nose to nose.
32
+ 5. Fix by changing actions or timing — never by hand-keying bones or rotations to fake an action.
33
+
34
+ ## Clips: `play`
35
+
36
+ ```ts
37
+ { at: 1.2, actor: "ana", action: "play", clip: "wave", duration: 1.5, fadeIn: 0.2, fadeOut: 0.25 }
38
+ ```
39
+
40
+ - Fields: `clip`, `duration?`, `loop?`, `speed` (1), `fadeIn` (0.2), `fadeOut` (0.2), `layer` (0),
41
+ `blend` (`override` | `additive`), `weight` (1).
42
+ - Layers stack in order; a higher layer overrides a lower one by its faded weight. Idle on `-1`,
43
+ gestures on `0`, a held-prop pose (`carry`, `texting`) on `1` so a walk on layer 0 can play under it.
44
+ - A looping clip with no `duration` plays to the end of the scene. Give gestures a `duration`.
45
+ - `additive` adds on top (a small nod over a talk); keep `override` for whole gestures.
46
+ - Full list with what each clip does and its length: [references/clips.md](references/clips.md).
47
+
48
+ ## Views and turns
49
+
50
+ - `view` is a pose control: `{ action: "pose", control: "view", value: "front", duration: 0.35 }`.
51
+ Angles, in turning order: `front half q24 profile q50 q64 q77 side q112 away q158 back`
52
+ (`profile` is the three-quarter main view and the default).
53
+ - A `view` change **with a duration steps through every drawn angle in between** — a hand-drawn
54
+ turn. With `duration: 0` it cuts. The kit's `turn` clip (a quick squeeze) hides the change.
55
+ - Front = talking to the audience: clear the gaze with `lookAt: null`.
56
+ - A `walkTo` that reverses direction turns through the front (through the back when walking away)
57
+ instead of flipping in one frame. `face` flips at once — use it only when nobody is watching
58
+ the turn, or stage a `view` turn around it.
59
+ - The `head` control turns the head alone (any angle, `~q50` mirrored to look the other way;
60
+ `null` follows the body). Do not put `~` on the body's `view`: it is not a view pose.
61
+
62
+ ## Walking and running: `walkTo`
63
+
64
+ ```ts
65
+ { at: 0.2, actor: "ana", action: "walkTo", x: 520, duration: 2.4 } // walk
66
+ { at: 5.7, actor: "ana", action: "walkTo", x: -350, clip: "scaredRun", speed: runSpeed } // flee
67
+ ```
68
+
69
+ - Stride-matched: the clip plays at `stride × scale` per cycle, so **feet do not slide**; it eases
70
+ in and out and faces the direction of travel.
71
+ - Gaits: `walk`, `run`, `sneak`, `strut`, `tired`, `march`, `scaredRun`. Pick by mood (sneaking up →
72
+ `sneak`, showing off → `strut`, exhausted/sad → `tired`, determined → `march`, fleeing → `scaredRun`).
73
+ - **Runs need their own speed.** The scene default is 220 px/s (a walk); a run at that speed plays in
74
+ slow motion. Use the natural speed `clip.stride × scale / clip.duration` (the director's default).
75
+ - Best views: walks read in `profile` (three-quarter) or `q64`; runs read best side-on (`q64`,
76
+ `side` — `q64` is the rig's travel view). Walking away from camera: `back`.
77
+ - Never overlap two `walkTo` for the same actor. A new one takes over from where the actor is.
78
+ - Details, gait table, speeds and foreshortened walks: [references/locomotion.md](references/locomotion.md).
79
+
80
+ ## Acting: emotion, gaze, reactions
81
+
82
+ - Emotions (`pose` control `emotion`, `duration` 0.2–0.5): `neutral happy joy surprised sad smug
83
+ scared angry dead determined calm excited annoyed sleep gape`. Change the face **just before**
84
+ the body (0.1 s): the thought shows first.
85
+ - `lookAt` an actor id, a prop id or `[x, y]`; `null` clears. Look before speaking, look at the
86
+ speaker while listening, look at what you are about to react to.
87
+ - A reaction is a chain, each link a hair before the next: `fx` (surprise/exclaim/question) →
88
+ `lookAt` → emotion → body (a gesture, a `view` turn, a step back).
89
+ - `fx` punctuates: `surprise`, `exclaim`, `question`, `sweat`, `anger`, `stars`, `dust`
90
+ (`anchor: "origin"`), `sparkle`, `hearts`, `gloom`, `lightbulb`, `burst`, `impactFrame`…
91
+ - Big mouth (yawn, scream, swallow): emotion `gape`, or `pose` control `jaw` value `{ gape: 2 }`;
92
+ keep `say` off while unhinged.
93
+
94
+ ## Knock-downs: `fall` and `getUp`
95
+
96
+ ```ts
97
+ { at: 1.5, actor: "ben", action: "fall" } // trips where he stands (hips down at +0.45 s)
98
+ { at: 6.48, actor: "ben", action: "fall", from: "ana" } // thrown away from the hitter (hips down at +0.85 s)
99
+ { at: 3.5, actor: "ben", action: "getUp" } // 1.2 s: sits up into a crouch, then stands
100
+ ```
101
+
102
+ - A punch that lands: the hitter `play`s `punch`; the target `fall`s `from` the hitter **0.28 s
103
+ later** (when the fist lands). Add `burst`, `shake` and an emotion (`dead`) on that frame.
104
+ - Hold the K.O. at least **1.5 s** before `getUp`. While lying, `face` and `walkTo` are errors.
105
+ - A fall can interrupt a walk: the walk clip fades in 0.12 s and the body carries the speed on.
106
+ - Lying, the head lands ~0.6 × height past the hips: leave room inside the set.
107
+ - Options: `side: "front"` (face down), `distance`, `height`, `spin: true` (a gag), `squash: false`.
108
+
109
+ ## Holding and carrying props
110
+
111
+ - `grab` puts a prop on an anchor (`hand`, `handB`, `mouth`, `ear`, `top`…); `release` lets go
112
+ (`keep: true` leaves it where the hand put it); `put` rests a prop on another prop.
113
+ - Kit presets (`import { HOLD, holdFit, holdBoth, boxFit } from "@anime-studio/kit"`):
114
+ - phone: `fit: holdFit("phone", grip, top)`, play `HOLD.phone.clip` (`texting`); both thumbs:
115
+ `textingTwo` + `also: holdBoth`.
116
+ - book/tablet: `holdFit("book", …)` + `read` + `also: holdBoth`.
117
+ - box/tray in both hands: `fit: boxFit(left, right)`, `also: holdBoth`, play `carry`.
118
+ - bag, bucket, lantern: `grab` with `hang` (swings like a pendulum with the walk).
119
+ - An object held at the start of a scene is grabbed at `at: 0`. Measure where a released prop lands
120
+ (`propPlacement`) and put the table under it — never guess.
121
+ - Full recipes and pitfalls: [references/holding.md](references/holding.md).
122
+
123
+ ## Sitting, lying, riding
124
+
125
+ These are **director beats** (`sit`, `lie`, `sleep`, `ride`, `mount`, `dismount`, `getUp`): the
126
+ director seats the hips on the furniture's `seat` anchor, poses a 2.5D rig in 3D, keeps the feet
127
+ on the floor or the pedals. In a raw scene the building blocks are `mount` (follow another actor's
128
+ anchor) and `reach` (an IK chain — `footF`, `footB`, `handF`, `handB` — to an anchor or point).
129
+ Nobody walks while seated: `getUp` first (the director does it for you). See
130
+ [references/director-beats.md](references/director-beats.md).
131
+
132
+ ## Cartoon timing: smooth by default
133
+
134
+ - Scene `animation`: `twos`, `holds`, `smear`, `arcs`, `boil`. Director staging adds
135
+ `anticipation` (leans into walks, landings squash, limb moves overshoot) and `life` (blinks on
136
+ turns, saccades, head nods on stressed words).
137
+ - **House style: smooth motion.** Leave `twos`, `smear` and `boil` off unless the user asks for a
138
+ hand-drawn look; the result reads more fluid without them. `holds`, `arcs`, `anticipation` and
139
+ `life` add acting without stepping the motion.
140
+ - The kit's gesture clips already have anticipation and overshoot built in (`fluid()`).
141
+ - Principles applied, numbers and examples: [references/timing.md](references/timing.md).
142
+
143
+ ## What goes wrong
144
+
145
+ - **Faking a fall** with `set` on `rotation`/`y` or `bones.root`/`bones.hips` rotations. Use `fall`.
146
+ - **Animating a 2.5D rig's arms with 2D bone rotations** (`set bones.armF1.rotation`): the arm
147
+ swings round the front and through the head. Use clips, `reach`, or director `gesture` beats.
148
+ - **Characters nose to nose.** Keep a step between them (profile heads reach far past the feet).
149
+ Measure positions after falls and walks with `anchorPosition` before placing the next actor.
150
+ - **Walking while seated or lying**, a second `fall` while down, `walkTo` overlapping another.
151
+ - **A run at walk speed** (slow motion) or far faster than its stride (legs blur).
152
+ - **Gestures with no base layer**: when the gesture fades out the body freezes in setup pose.
153
+ - **A looping held-prop clip (`carry`, `texting`) left running** after `release`: give it a `duration`.
154
+ - **Stacking actions**: a wave, a turn and an emotion change all on the same frame read as noise.
155
+ Stagger them 0.1–0.3 s; one clear action at a time.
156
+ - **Front-view arm swings**: from the front a clip's arm swing reads as flapping; prefer hand
157
+ positions (the director's front gestures are IK reaches to the face).
158
+ - **Unlisted names**: an unknown `view` value (or a mirrored one, `"~half"`: flip the actor
159
+ instead) is a validation error listing the valid views. Use only the names listed above (or
160
+ from `toon describe`).
161
+ - **Not looking.** A script that validates can still have floating feet or a hand off the prop.
162
+
163
+ ## Examples (run from the repo root; output in `examples/out/`)
164
+
165
+ | File | Shows |
166
+ |---|---|
167
+ | [examples/walk-wave-run.ts](examples/walk-wave-run.ts) | Walk in, turn to front, wave, scared reaction, `scaredRun` off at natural speed |
168
+ | [examples/knockdown.ts](examples/knockdown.ts) | Trip mid-walk, K.O. hold, `getUp`, a punch and a thrown `fall` |
169
+ | [examples/hold.ts](examples/hold.ts) | Box carried in both hands and put down, a hung bag, a phone with `texting` |
170
+ | [examples/gestures.ts](examples/gestures.ts) | A labelled sheet of every gesture clip (pick by eye) |
171
+
172
+ ```bash
173
+ npx tsx skills/animestudio-animation/examples/walk-wave-run.ts
174
+ npx tsx skills/animestudio-animation/examples/gestures.ts wave shrug facepalm
175
+ ```
176
+
177
+ They need `rsvg-convert` and ImageMagick (`magick`) on the PATH.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A catalogue of the kit's gesture clips: one small scene per clip, the character in the `half`
3
+ * view (three-quarter front, the clearest for gestures), sampled at the clip's key moment.
4
+ *
5
+ * npx tsx skills/animestudio-animation/examples/gestures.ts (every gesture)
6
+ * npx tsx skills/animestudio-animation/examples/gestures.ts wave shrug (just these)
7
+ *
8
+ * Use it to pick a gesture by eye before staging it, and to check a new rig has the clips.
9
+ */
10
+ import type { ActionDef } from "@anime-studio/core";
11
+ import { FLOOR, cast, contactSheet, sceneDoc } from "./sheet";
12
+
13
+ const characters = cast("ana");
14
+ const clips = characters.ana.clips!;
15
+ // Gestures with the emotion that sells them. Locomotion, `turn`, the knock-down clips and the
16
+ // prop clips (texting, read, carry… need a grabbed prop) are left out: see the other examples.
17
+ const GESTURES: Record<string, string> = {
18
+ talk: "happy", wave: "joy", point: "determined", pointUp: "excited", present: "smug", clap: "joy",
19
+ cheer: "excited", dance: "joy", groove: "joy", sing: "happy", think: "calm", shrug: "annoyed",
20
+ laugh: "joy", cry: "sad", scared: "scared", facepalm: "annoyed", jump: "excited", teeter: "scared",
21
+ flap: "scared", stance: "determined", power: "angry", punch: "angry", toss: "happy", drink: "calm",
22
+ };
23
+ // One-shot clips: the moment of the key pose (the punch lands at 0.28 s).
24
+ const KEY: Record<string, number> = { punch: 0.3, jump: 0.35, toss: 0.4, shrug: 0.6, facepalm: 0.8, drink: 1.1, teeter: 0.5 };
25
+ const pick = process.argv.slice(2);
26
+ const names = (pick.length ? pick : Object.keys(GESTURES)).filter((n) => clips[n]);
27
+
28
+ const AT = 0.3; // the clip starts here
29
+ // One scene, the gestures one after another, each sampled 55% into its clip (after the fade-in).
30
+ let t = AT;
31
+ const script: ActionDef[] = [
32
+ { at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1 },
33
+ { at: 0, actor: "ana", action: "pose", control: "view", value: "half", duration: 0 },
34
+ ];
35
+ const times: number[] = [];
36
+ for (const n of names) {
37
+ const d = Math.max(clips[n].duration, 1.0);
38
+ // Sample one-shot clips near their strongest pose, loops halfway through a cycle.
39
+ const at = clips[n].loop ? Math.max(0.3, clips[n].duration * 0.5) : (KEY[n] ?? d * 0.5);
40
+ script.push(
41
+ { at: t - 0.2, actor: "ana", action: "pose", control: "emotion", value: GESTURES[n] ?? "neutral", duration: 0.15 },
42
+ { at: t, actor: "ana", action: "play", clip: n, duration: d, fadeIn: 0.15, fadeOut: 0.15 },
43
+ );
44
+ times.push(t + at);
45
+ t += d + 0.6;
46
+ }
47
+
48
+ const doc = sceneDoc(t + 0.5, {
49
+ characters: { ana: "ana" },
50
+ actors: [{ id: "ana", character: "ana", x: 640, y: FLOOR, scale: 0.95 }],
51
+ camera: { x: 640, y: 375, zoom: 1.2 },
52
+ script,
53
+ });
54
+ console.log(names.join(" "));
55
+ await contactSheet(doc, characters, times, "gestures", 6, names);
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Holding and carrying props on a 2.5D cartoon rig:
3
+ * - Ben carries a box in both hands (`boxFit` + `also: holdBoth` + the `carry` clip), walks to a
4
+ * counter and puts it down (`release` with `keep`), then walks off with empty hands.
5
+ * - Ana walks in with a bag hanging from her far hand (`grab` with `hang`: it swings with the walk),
6
+ * stops, takes out a phone and texts (`holdFit("phone", …)` + the `texting` clip).
7
+ *
8
+ * npx tsx skills/animestudio-animation/examples/hold.ts
9
+ */
10
+ import type { ActionDef } from "@anime-studio/core";
11
+ import { HOLD, boxFit, holdBoth, holdFit } from "@anime-studio/kit";
12
+ import { FLOOR, cast, contactSheet, sceneDoc } from "./sheet";
13
+
14
+ const characters = cast("ana", "ben");
15
+ const SCALE = 0.85;
16
+ const STOP = 840; // where Ben stops to put the box down
17
+ const COUNTER_X = 930; // measured with --measure: the box is let go at x ≈ 874…
18
+ const COUNTER_TOP = 470; // …and its bottom edge at y ≈ 470, so the counter's top goes there
19
+
20
+ // Props are drawn the way they look in the hand at rest. Coordinates are the prop's own art.
21
+ const box = `<g stroke="#1b1b1b" stroke-width="2.4"><rect x="-55" y="-40" width="110" height="80" fill="#c9965a"/>
22
+ <path d="M-55 -12 H55" fill="none"/><rect x="-14" y="-40" width="28" height="80" fill="#e0c08a"/></g>`;
23
+ // The phone: drawn upright, the grip at [0, 0], the top at [0, -100]; `back` is the case.
24
+ const phone = `<rect x="-24" y="-104" width="48" height="112" rx="8" fill="#1b1b1b"/><rect x="-19" y="-96" width="38" height="92" rx="4" fill="#8fd3f4"/>`;
25
+ const phoneBack = `<rect x="-24" y="-104" width="48" height="112" rx="8" fill="#3a4a8c" stroke="#1b1b1b" stroke-width="2.4"/>`;
26
+ // A bag hanging from its handle: the handle at [0, 0], the bag straight below it.
27
+ const bag = `<g stroke="#1b1b1b" stroke-width="2.4"><path d="M-14 18 Q0 -6 14 18" fill="none"/><rect x="-30" y="16" width="60" height="62" rx="8" fill="#5b8c5a"/></g>`;
28
+ const counter = `<g stroke="#1b1b1b" stroke-width="2.4"><rect x="-110" y="0" width="220" height="${FLOOR - COUNTER_TOP}" fill="#9c7a54"/><rect x="-120" y="0" width="240" height="14" fill="#b8936a"/></g>`;
29
+
30
+ const script: ActionDef[] = [
31
+ { at: 0, actor: "ben", action: "play", clip: "idle", loop: true, layer: -1 },
32
+ { at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1 },
33
+ { at: 0, actor: "ben", action: "pose", control: "view", value: "profile", duration: 0 },
34
+ { at: 0, actor: "ana", action: "pose", control: "view", value: "profile", duration: 0 },
35
+ { at: 0, actor: "ben", action: "pose", control: "emotion", value: "determined", duration: 0 },
36
+ { at: 0, actor: "ana", action: "pose", control: "emotion", value: "happy", duration: 0 },
37
+
38
+ // Ben: the box is in his hands from frame 0 (objects keep their history). Both hands: the near
39
+ // hand holds the left side, `also: holdBoth` draws the far hand over it too. The carry clip on
40
+ // layer 1 keeps the arms on the box over the walk (which swings arms on layer 0).
41
+ { at: 0, actor: "ben", action: "grab", prop: "box", anchor: "hand", fit: boxFit([-55, 0], [55, 0]), also: holdBoth },
42
+ { at: 0, actor: "ben", action: "play", clip: HOLD.box.clip, loop: true, layer: 1, fadeIn: 0, duration: 3.1, fadeOut: 0.3 },
43
+ { at: 0.2, actor: "ben", action: "walkTo", x: STOP, duration: 2.4 },
44
+ // Put it down: the hands let go where they are; `keep` leaves the box there (no body, no tracks).
45
+ { at: 3.0, actor: "ben", action: "release", prop: "box", keep: true },
46
+ { at: 3.3, actor: "ben", action: "pose", control: "emotion", value: "happy", duration: 0.3 },
47
+ { at: 3.6, actor: "ben", action: "walkTo", x: 1500, duration: 2.0 },
48
+
49
+ // Ana: a hung bag in the far hand swings behind the hand when she sets off and forward on the stop.
50
+ { at: 0, actor: "ana", action: "grab", prop: "bag", anchor: "handB", hang: { point: [0, 0], damping: 0.25 } },
51
+ { at: 0.4, actor: "ana", action: "walkTo", x: 330, duration: 2.2 },
52
+ // She takes out her phone: it appears in the near hand as the texting clip brings it up.
53
+ { at: 3.2, actor: "ana", action: "grab", prop: "phone", anchor: "hand", fit: holdFit("phone", [0, 0], [0, -100]) },
54
+ { at: 3.2, actor: "ana", action: "play", clip: HOLD.phone.clip, loop: true, layer: 1, fadeIn: 0.35 },
55
+ { at: 3.5, actor: "ana", action: "pose", control: "emotion", value: "smug", duration: 0.3 },
56
+ ];
57
+
58
+ const doc = sceneDoc(6.0, {
59
+ characters: { ana: "ana", ben: "ben" },
60
+ actors: [
61
+ { id: "ben", character: "ben", x: 120, y: FLOOR, scale: SCALE, z: 2 },
62
+ { id: "ana", character: "ana", x: -150, y: FLOOR, scale: SCALE, z: 1 },
63
+ ],
64
+ props: [
65
+ { id: "counter", art: counter, x: COUNTER_X, y: COUNTER_TOP, z: 0 },
66
+ { id: "box", art: box, x: 0, y: 0, z: 3 },
67
+ { id: "bag", art: bag, x: 0, y: 0, z: 1 },
68
+ { id: "phone", art: phone, back: phoneBack, x: 0, y: 0, scale: HOLD.phone.scale * SCALE, opacity: 0 },
69
+ ],
70
+ tracks: { "props.phone.opacity": [[0, 0], [3.2, 0], [3.25, 1]] },
71
+ script,
72
+ });
73
+
74
+ if (process.argv.includes("--measure")) {
75
+ // Where the box is when the hands let go: put the counter's top under its bottom edge.
76
+ const { compileScene, propPlacement } = await import("@anime-studio/core");
77
+ const sc = compileScene(doc, { characters });
78
+ const p = propPlacement(sc, sc.props.find((q) => q.id === "box")!, 3.0);
79
+ console.log("box at release", p.x, p.y, "bottom", p.y + 40);
80
+ }
81
+
82
+ await contactSheet(doc, characters, [0.1, 0.8, 1.6, 2.7, 3.1, 3.6, 4.2, 5.0, 5.9], "hold", 3);