@anime-studio/cli 0.0.0-stage → 0.2.1
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.
- package/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +238 -0
- package/dist/bin.js.map +1 -0
- package/dist/describe.d.ts +7 -0
- package/dist/describe.d.ts.map +1 -0
- package/dist/describe.js +48 -0
- package/dist/describe.js.map +1 -0
- package/dist/doctor.d.ts +44 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +121 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +13 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +41 -0
- package/dist/load.js.map +1 -0
- package/dist/skills.d.ts +28 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +56 -0
- package/dist/skills.js.map +1 -0
- package/package.json +55 -3
- package/skills/animestudio/SKILL.md +165 -0
- package/skills/animestudio/examples/first-frame.ts +54 -0
- package/skills/animestudio/examples/hello.scene.json +50 -0
- package/skills/animestudio/examples/hello.sequence.json +13 -0
- package/skills/animestudio/examples/remotion/Root.tsx +25 -0
- package/skills/animestudio/examples/remotion/index.ts +5 -0
- package/skills/animestudio/examples/render-video.ts +110 -0
- package/skills/animestudio/references/packages.md +54 -0
- package/skills/animestudio/references/rendering.md +127 -0
- package/skills/animestudio/references/scene-format.md +101 -0
- package/skills/animestudio/references/validation-and-debugging.md +67 -0
- package/skills/animestudio-animation/SKILL.md +176 -0
- package/skills/animestudio-animation/examples/gestures.ts +55 -0
- package/skills/animestudio-animation/examples/hold.ts +82 -0
- package/skills/animestudio-animation/examples/knockdown.ts +68 -0
- package/skills/animestudio-animation/examples/sheet.ts +80 -0
- package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
- package/skills/animestudio-animation/references/clips.md +103 -0
- package/skills/animestudio-animation/references/director-beats.md +48 -0
- package/skills/animestudio-animation/references/holding.md +106 -0
- package/skills/animestudio-animation/references/locomotion.md +86 -0
- package/skills/animestudio-animation/references/timing.md +89 -0
- package/skills/animestudio-characters/SKILL.md +211 -0
- package/skills/animestudio-characters/examples/cast.ts +63 -0
- package/skills/animestudio-characters/examples/human.ts +52 -0
- package/skills/animestudio-characters/examples/import-svg.ts +68 -0
- package/skills/animestudio-characters/examples/lumo.svg +36 -0
- package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
- package/skills/animestudio-characters/examples/sprout.ts +48 -0
- package/skills/animestudio-characters/examples/turnaround.ts +91 -0
- package/skills/animestudio-characters/references/custom-rig.md +139 -0
- package/skills/animestudio-characters/references/import-svg.md +59 -0
- package/skills/animestudio-characters/references/look-options.md +143 -0
- package/skills/animestudio-characters/references/rig-surface.md +62 -0
- package/skills/animestudio-script/SKILL.md +164 -0
- package/skills/animestudio-script/examples/director.ts +143 -0
- package/skills/animestudio-script/examples/sheet.ts +58 -0
- package/skills/animestudio-script/examples/short.ts +193 -0
- package/skills/animestudio-script/references/actions.md +84 -0
- package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
- package/skills/animestudio-script/references/director.md +110 -0
- package/skills/animestudio-script/references/shots-and-editing.md +79 -0
- package/skills/animestudio-script/references/writing-for-animation.md +84 -0
- package/skills/animestudio-sets/SKILL.md +232 -0
- package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
- package/skills/animestudio-sets/examples/render-scene.ts +35 -0
- package/skills/animestudio-sets/examples/sets.ts +257 -0
- package/skills/animestudio-sets/references/drawing-sets.md +119 -0
- package/skills/animestudio-sets/references/fx.md +92 -0
- package/skills/animestudio-sets/references/lighting-camera.md +93 -0
- package/skills/animestudio-sets/references/scene-fields.md +132 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a scene or a sequence document to MP4 without a browser:
|
|
3
|
+
* evaluate → frameToSVG → rsvg-convert (a pool of parallel jobs) → ffmpeg, plus the audio.
|
|
4
|
+
*
|
|
5
|
+
* npx tsx render-video.ts [doc.json=hello.scene.json] [--frames N] [--jobs 8] [-o out/video.mp4]
|
|
6
|
+
*
|
|
7
|
+
* `doc.json` is a `*.scene.json` or a `*.sequence.json`. `--frames N` renders only the first N
|
|
8
|
+
* frames (a quick check of the whole pipeline). Needs `rsvg-convert` and `ffmpeg` on PATH.
|
|
9
|
+
* Run first-frame.ts once first for the bundled examples (it writes the character files they use).
|
|
10
|
+
*/
|
|
11
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
12
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join, resolve } from "node:path";
|
|
14
|
+
import { parseArgs, promisify } from "node:util";
|
|
15
|
+
import {
|
|
16
|
+
type CompiledScene, type LipsyncDoc, type RenderFrame, type SceneDoc, type SequenceDoc, type ToonDoc,
|
|
17
|
+
compileSequence, evaluateScene, evaluateSequence, frameToSVG, sequenceAudio, validateScene, validateSequence,
|
|
18
|
+
} from "@anime-studio/core";
|
|
19
|
+
import { prepareScene } from "@anime-studio/rigid";
|
|
20
|
+
|
|
21
|
+
const run = promisify(execFile);
|
|
22
|
+
const { values, positionals } = parseArgs({
|
|
23
|
+
allowPositionals: true,
|
|
24
|
+
options: { frames: { type: "string" }, jobs: { type: "string" }, out: { type: "string", short: "o" } },
|
|
25
|
+
});
|
|
26
|
+
const here = import.meta.dirname;
|
|
27
|
+
const readJson = (path: string) => JSON.parse(readFileSync(path, "utf8"));
|
|
28
|
+
|
|
29
|
+
/** Loads a scene file with its assets (paths are relative to the scene file), validates and compiles it. */
|
|
30
|
+
async function loadScene(path: string): Promise<CompiledScene> {
|
|
31
|
+
const base = dirname(path);
|
|
32
|
+
const doc = readJson(path) as SceneDoc;
|
|
33
|
+
// Absolute audio paths, so ffmpeg finds them whatever document the event comes from.
|
|
34
|
+
doc.audio = Object.fromEntries(Object.entries(doc.audio ?? {}).map(([id, p]) => [id, resolve(base, p)]));
|
|
35
|
+
const assets = {
|
|
36
|
+
characters: Object.fromEntries(Object.entries(doc.characters ?? {}).map(([id, p]) => [id, readJson(resolve(base, p)) as ToonDoc])),
|
|
37
|
+
lipsync: Object.fromEntries(Object.entries(doc.lipsync ?? {}).map(([id, p]) => [id, readJson(resolve(base, p)) as LipsyncDoc])),
|
|
38
|
+
};
|
|
39
|
+
const check = validateScene(doc, assets); // with assets: the script is compiled too
|
|
40
|
+
for (const i of check.issues) console.log(`${i.severity} ${path} ${i.path}: ${i.message}`);
|
|
41
|
+
if (!check.ok) process.exit(1);
|
|
42
|
+
// prepareScene = compileScene + the rigid-body bake (props with a `body`). Always use it for renders.
|
|
43
|
+
return prepareScene(doc, assets);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// One evaluable timeline, whatever the document kind.
|
|
47
|
+
const docPath = resolve(positionals[0] ?? join(here, "hello.scene.json"));
|
|
48
|
+
const root = readJson(docPath) as { format: string };
|
|
49
|
+
let width: number, height: number, fps: number, duration: number;
|
|
50
|
+
let frameAt: (t: number) => RenderFrame;
|
|
51
|
+
let sounds: { src: string; start: number; volume: number; trimStart?: number }[];
|
|
52
|
+
if (root.format === "toon-sequence") {
|
|
53
|
+
const seqDoc = root as SequenceDoc;
|
|
54
|
+
const check = validateSequence(seqDoc);
|
|
55
|
+
for (const i of check.issues) console.log(`${i.severity} ${i.path}: ${i.message}`);
|
|
56
|
+
if (!check.ok) process.exit(1);
|
|
57
|
+
const scenes: Record<string, CompiledScene> = {};
|
|
58
|
+
for (const [id, p] of Object.entries(seqDoc.scenes)) scenes[id] = await loadScene(resolve(dirname(docPath), p));
|
|
59
|
+
const seq = compileSequence(seqDoc, { scenes });
|
|
60
|
+
({ width, height, fps, duration } = seq);
|
|
61
|
+
frameAt = (t) => evaluateSequence(seq, t);
|
|
62
|
+
sounds = sequenceAudio(seq); // already cut at shot boundaries (maxDuration is ignored here for brevity)
|
|
63
|
+
} else {
|
|
64
|
+
const scene = await loadScene(docPath);
|
|
65
|
+
({ width, height, fps, duration } = scene);
|
|
66
|
+
frameAt = (t) => evaluateScene(scene, t);
|
|
67
|
+
sounds = scene.audio;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const total = Math.ceil(duration * fps - 1e-6); // like core's frameCount
|
|
71
|
+
const n = values.frames ? Math.min(total, Number(values.frames)) : total;
|
|
72
|
+
const jobs = Number(values.jobs ?? 8);
|
|
73
|
+
const work = join(here, "out", "frames");
|
|
74
|
+
rmSync(work, { recursive: true, force: true });
|
|
75
|
+
mkdirSync(work, { recursive: true });
|
|
76
|
+
|
|
77
|
+
// Frames are pure functions of time, so any order and any parallelism is safe.
|
|
78
|
+
// SVG → PNG at the document's exact size (PNG, not JPEG: hard cartoon lines ring in JPEG).
|
|
79
|
+
let next = 0;
|
|
80
|
+
const start = Date.now();
|
|
81
|
+
await Promise.all(
|
|
82
|
+
Array.from({ length: jobs }, async () => {
|
|
83
|
+
while (next < n) {
|
|
84
|
+
const i = next++;
|
|
85
|
+
const name = join(work, String(i).padStart(5, "0"));
|
|
86
|
+
writeFileSync(`${name}.svg`, frameToSVG(frameAt(i / fps)));
|
|
87
|
+
await run("rsvg-convert", ["-w", String(width), "-h", String(height), "-o", `${name}.png`, `${name}.svg`]);
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
console.log(`${n}/${total} frames in ${((Date.now() - start) / 1000).toFixed(1)} s`);
|
|
92
|
+
|
|
93
|
+
// Encode: x264, near lossless (CRF 14), yuv420p for players. Mix the audio events if any.
|
|
94
|
+
const out = resolve(values.out ?? join(here, "out", "video.mp4"));
|
|
95
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
96
|
+
const seconds = n / fps;
|
|
97
|
+
const video = ["-framerate", String(fps), "-i", join(work, "%05d.png")];
|
|
98
|
+
const encode = ["-c:v", "libx264", "-preset", "slow", "-crf", "14", "-pix_fmt", "yuv420p"];
|
|
99
|
+
const heard = sounds.filter((a) => a.start < seconds);
|
|
100
|
+
if (heard.length === 0) {
|
|
101
|
+
execFileSync("ffmpeg", ["-y", "-v", "error", ...video, ...encode, out]);
|
|
102
|
+
} else {
|
|
103
|
+
const inputs = heard.flatMap((a) => ["-ss", String(a.trimStart ?? 0), "-i", a.src]);
|
|
104
|
+
const chains = heard.map((a, k) =>
|
|
105
|
+
`[${k + 1}:a]aresample=44100,aformat=channel_layouts=stereo,volume=${a.volume},adelay=${Math.round(a.start * 1000)}:all=1[a${k}]`);
|
|
106
|
+
const mix = `${chains.join(";")};${heard.map((_, k) => `[a${k}]`).join("")}amix=inputs=${heard.length}:normalize=0:duration=longest,apad,atrim=0:${seconds.toFixed(3)}[a]`;
|
|
107
|
+
execFileSync("ffmpeg", ["-y", "-v", "error", ...video, ...inputs, "-filter_complex", mix,
|
|
108
|
+
"-map", "0:v", "-map", "[a]", ...encode, "-c:a", "aac", "-b:a", "192k", out]);
|
|
109
|
+
}
|
|
110
|
+
console.log(out);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Packages: which one, when
|
|
2
|
+
|
|
3
|
+
All packages are ES modules with TypeScript types, published under the `@anime-studio` npm scope
|
|
4
|
+
(version 0.2.x), Node.js 22+ or any modern bundler. Exhaustive API:
|
|
5
|
+
https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md
|
|
6
|
+
|
|
7
|
+
| Package | Use it when | Key exports |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `@anime-studio/core` | Always. Formats, validation, rigs, poses, scenes, camera, lighting, FX, sequences, SVG output | `validateToon`, `validateScene`, `validateSequence`, `parseToon`, `parseScene`, `compileScene`, `evaluateScene`, `frameToSVG`, `compileSequence`, `evaluateSequence`, `sequenceAudio`, `previewScene`, `frameCount`, `frameTime`, `jsonSchemas`, types `ToonDoc`, `SceneDoc`, `SequenceDoc`, `ActionDef`, `RenderFrame` |
|
|
10
|
+
| `@anime-studio/kit` | You need characters without drawing them | `cartoonCharacter(look, opts?)` (TV-cartoon humans, 2.5D, the default choice), `humanCharacter(look)` (anime-style), `cartoonAnatomy`, `checkAnatomy`, types `CartoonLook` |
|
|
11
|
+
| `@anime-studio/rigid` | Any render. Props with a `body` (balls, crates) need the Rapier bake | `prepareScene(doc, assets)` = `compileScene` + rigid-body bake (async), `bakeRigidBodies`, `sceneHasBodies` |
|
|
12
|
+
| `@anime-studio/director` | Staging a whole episode from a staging + timed lines + a kit, instead of hand-writing scene scripts | `direct`, `check`, `describeKit` (see the `animestudio-script` skill) |
|
|
13
|
+
| `@anime-studio/lipsync` | Mouth cues from TTS timestamps, text or audio | pure helpers; `@anime-studio/lipsync/node` adds `lipsyncFile(path, { text?, language?, engine? })` (Rhubarb if installed, else alignment / amplitude) |
|
|
14
|
+
| `@anime-studio/import-svg` | Turning a layered SVG drawing into a character document | `importSvg(svg, { name })` (CLI: `toon import-svg`) |
|
|
15
|
+
| `@anime-studio/react` | Showing a scene in a React app (players, editors) | `<ToonScene scene time>`, `<ToonFrame frame>`, `useCompiledScene` |
|
|
16
|
+
| `@anime-studio/remotion` | Rendering with Remotion | `<ToonComposition>`, `toonMetadata`, `<ToonSequenceComposition>`, `toonSequenceMetadata` |
|
|
17
|
+
| `@anime-studio/cli` | Validating, describing, previewing and debugging from the shell | bin `toon`; as a library: `loadSceneAssets`, `describeCharacter`, `debugDocument`, `doctor` |
|
|
18
|
+
|
|
19
|
+
## Install recipes
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Scripted, browserless rendering (most agents want this)
|
|
23
|
+
npm install @anime-studio/core @anime-studio/kit @anime-studio/rigid
|
|
24
|
+
npm install -D tsx
|
|
25
|
+
brew install librsvg ffmpeg # rsvg-convert + ffmpeg (Debian/Ubuntu: apt install librsvg2-bin ffmpeg)
|
|
26
|
+
|
|
27
|
+
# The CLI
|
|
28
|
+
npm install -g @anime-studio/cli # then `toon --help`; or without installing: npx @anime-studio/cli --help
|
|
29
|
+
|
|
30
|
+
# Remotion
|
|
31
|
+
npm install @anime-studio/core @anime-studio/remotion remotion @remotion/cli @remotion/media react react-dom
|
|
32
|
+
|
|
33
|
+
# Lip sync from recorded audio (optional): put Rhubarb Lip Sync on PATH (or set RHUBARB_PATH).
|
|
34
|
+
# Without it, lip sync falls back to aligning the text to the audio.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Inside the animeStudio repository
|
|
38
|
+
|
|
39
|
+
The pnpm workspace maps `@anime-studio/*` to `packages/*/src`, so scripts anywhere in the repo
|
|
40
|
+
import the sources directly: `npx tsx path/to/script.ts`. The CLI is
|
|
41
|
+
`npx tsx packages/cli/src/bin.ts <command>`. Reference renders live in `examples/promo` and
|
|
42
|
+
`examples/whats-new` (`render.ts preview 0:1.5,2:2` makes a contact sheet; `render.ts video`
|
|
43
|
+
renders the MP4); the Remotion project is `apps/video`.
|
|
44
|
+
|
|
45
|
+
## Assets: how documents find each other
|
|
46
|
+
|
|
47
|
+
A scene's `characters`, `audio` and `lipsync` maps are `id → path`. Who reads the path:
|
|
48
|
+
|
|
49
|
+
- `toon validate` / `toon render` / `toon debug`: relative to the scene file.
|
|
50
|
+
- In code you pass **parsed** documents: `compileScene(doc, { characters: { maya }, lipsync: { l1 } })`.
|
|
51
|
+
The paths are then not read at all (the promo uses `"x"` as a placeholder).
|
|
52
|
+
- Remotion: characters and cues are passed in `assets`; audio paths resolve with `staticFile()`
|
|
53
|
+
(files in `public/`) unless you pass `resolveAudio`.
|
|
54
|
+
- `@anime-studio/cli` exports `loadSceneAssets(scenePath, scene)` if you want the CLI's loader.
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
The repo's own promo videos are rendered this way (`examples/promo/render.ts`). Steps:
|
|
38
|
+
|
|
39
|
+
1. Load the scene and its assets, `validateScene(doc, assets)`, `prepareScene(doc, assets)`.
|
|
40
|
+
2. Frame count: `frameCount(scene)` (= ⌈duration × fps⌉ without float noise); time of frame i:
|
|
41
|
+
`i / fps` (`frameTime(scene, i)`).
|
|
42
|
+
3. For each frame: `frameToSVG(evaluateScene(scene, t))` → write `00042.svg` →
|
|
43
|
+
`rsvg-convert -w W -h H -o 00042.png 00042.svg`. Run ~8 conversions at once (a small async
|
|
44
|
+
pool over `execFile`); frames are independent, so order does not matter.
|
|
45
|
+
4. Encode: `ffmpeg -framerate FPS -i %05d.png -c:v libx264 -preset slow -crf 14 -pix_fmt yuv420p`.
|
|
46
|
+
5. Audio: `scene.audio` lists `{ src, start, volume }` events (`say` with `audio`, `sound`). Mix
|
|
47
|
+
them with one input each, `adelay=<ms>:all=1`, `volume=`, `amix=…:normalize=0`, `apad`, `atrim`
|
|
48
|
+
to the video length, then mux with `-c:a aac`. Resolve `src` against the scene file's folder.
|
|
49
|
+
|
|
50
|
+
[`../examples/render-video.ts`](../examples/render-video.ts) does all of it for a scene or a
|
|
51
|
+
sequence:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx tsx render-video.ts hello.scene.json --frames 12 # quick end-to-end check (12 frames)
|
|
55
|
+
npx tsx render-video.ts hello.scene.json # whole video → out/video.mp4
|
|
56
|
+
npx tsx render-video.ts hello.sequence.json -o out/seq.mp4
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Measured on the 1280×720 example: about 0.2 s per frame with 8 jobs on a laptop. Lit actors
|
|
60
|
+
(`lighting.shading`), blur and many characters cost more.
|
|
61
|
+
|
|
62
|
+
## 3. Sequences
|
|
63
|
+
|
|
64
|
+
A `toon-sequence` lists `scenes` (id → path) and `shots` (`scene`, `from?`, `duration?`,
|
|
65
|
+
`transition?`: `cut`, `crossfade`, `fade`, `iris`, `wipe`, `flash`). In code:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const seq = compileSequence(seqDoc, { scenes: { hello: compiledHello } }); // compiled scenes, or { doc, assets }
|
|
69
|
+
const frame = evaluateSequence(seq, t); // global time; crossfades composite two shots
|
|
70
|
+
const audio = sequenceAudio(seq); // events with start, trimStart, maxDuration (cut at shot ends)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Pass scenes already run through `prepareScene` if they have rigid bodies. A shot that replays a
|
|
74
|
+
window of a scene (`from`) makes a cut: `toon debug` reports it as an `info` jump, which is
|
|
75
|
+
expected. Total length = sum of shot durations minus crossfade overlaps.
|
|
76
|
+
|
|
77
|
+
## 4. Remotion
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { ToonComposition, toonMetadata } from "@anime-studio/remotion";
|
|
81
|
+
<Composition id="Hello" component={ToonComposition} {...toonMetadata(scene)}
|
|
82
|
+
defaultProps={{ scene, assets: { characters: { maya, kai }, lipsync: {} } }} />
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- `scene` is the **document** (not compiled); the component compiles it and bakes rigid bodies
|
|
86
|
+
with `delayRender`. Characters and lip sync cues go in `assets` as parsed JSON.
|
|
87
|
+
- Audio paths in the scene resolve with `staticFile()` (put files in `public/`), or pass
|
|
88
|
+
`resolveAudio`.
|
|
89
|
+
- Sequences: `<ToonSequenceComposition sequence scenes>` with
|
|
90
|
+
`scenes: { id: { doc, assets } }` and `toonSequenceMetadata(sequence, scenes)`.
|
|
91
|
+
- Options: `raster` (draw each frame to a canvas before capture: no half-painted frames in heavy
|
|
92
|
+
scenes at high concurrency), `paintSettle`, `debug` (an instrumentation strip that
|
|
93
|
+
`toon doctor video.mp4 doc.json` reads), `muted`.
|
|
94
|
+
- Remotion's CLI needs a `tsconfig.json` at the project root. Use PNG frames and CRF 14 in
|
|
95
|
+
`remotion.config.ts` (`Config.setVideoImageFormat("png")`, `Config.setCrf(14)`).
|
|
96
|
+
- On some macOS setups the bundled headless Chrome crashes at GPU init ("browser has
|
|
97
|
+
disconnected"): pass a system Chrome (`--browser-executable=… --chrome-mode=chrome-for-testing`
|
|
98
|
+
or `Config.setBrowserExecutable`).
|
|
99
|
+
|
|
100
|
+
Runnable root: [`../examples/remotion/`](../examples/remotion/) —
|
|
101
|
+
`npx remotion still remotion/index.ts Hello still.png --frame=78` gives the same picture as
|
|
102
|
+
`first-frame.ts` at 2.6 s.
|
|
103
|
+
|
|
104
|
+
Choose Remotion when you need its timeline UI, React overlays or its cloud rendering; choose the
|
|
105
|
+
browserless pipeline for scripted, reproducible renders (no Chrome, no paint glitches).
|
|
106
|
+
|
|
107
|
+
## 5. Quality and performance
|
|
108
|
+
|
|
109
|
+
- PNG frames, x264 `-crf 14 -preset slow`, `yuv420p`. JPEG frames ring around flat colours and
|
|
110
|
+
hard lines.
|
|
111
|
+
- For video sites, render at 2× (`rsvg-convert -w 3840` for a 1920 scene, or Remotion
|
|
112
|
+
`--scale 2`): a 4K upload gets a far higher bitrate.
|
|
113
|
+
- Fonts: text in layers/props is drawn with installed fonts (rsvg and Chrome alike). Use fonts
|
|
114
|
+
present on the render machine, or convert text to paths.
|
|
115
|
+
- Character shading is the most expensive part of a frame; with many lit actors set
|
|
116
|
+
`lighting.shading.crowd`.
|
|
117
|
+
|
|
118
|
+
## 6. Pitfalls
|
|
119
|
+
|
|
120
|
+
| Symptom | Cause / fix |
|
|
121
|
+
|---|---|
|
|
122
|
+
| Ball or crate never moves | Scene compiled with `compileScene` only: use `prepareScene` (rigid bake) |
|
|
123
|
+
| `cannot load "…toon.json"` from the CLI | Paths in `characters` are relative to the scene file; write the character files first |
|
|
124
|
+
| Video shorter/longer than expected | Frame count must be ⌈duration × fps⌉; sequence crossfades overlap shots |
|
|
125
|
+
| Silent video | `scene.audio` is empty (text-only `say` has no sound) or audio `src` not resolved against the scene folder |
|
|
126
|
+
| A frame differs between runs | Never: frames are pure. Look for your own non-determinism (random, Date) in the build script |
|
|
127
|
+
| 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`; `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,67 @@
|
|
|
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 "…"` | The rig has no such locomotion clip; pass `clip` or use a kit character |
|
|
38
|
+
| `unknown bone "x". Known bones: …` | (characters) use a listed bone id |
|
|
39
|
+
| `parent "x" is not declared before this bone` | (characters) parents first in `skeleton` |
|
|
40
|
+
|
|
41
|
+
The compiler stops at the first script error: fix it and validate again until ✓.
|
|
42
|
+
|
|
43
|
+
## What validation does NOT catch
|
|
44
|
+
|
|
45
|
+
These pass `toon validate` and `toon debug` silently; check them yourself:
|
|
46
|
+
|
|
47
|
+
- **Unknown pose values.** `{ "action": "pose", "control": "emotion", "value": "glad" }` is
|
|
48
|
+
accepted and does nothing. Only use values `toon describe` lists (kit emotions: `neutral`,
|
|
49
|
+
`sleep`, `happy`, `joy`, `surprised`, `sad`, `smug`, `scared`, `angry`, `dead`, `determined`,
|
|
50
|
+
`calm`, `excited`, `annoyed`, `gape`).
|
|
51
|
+
- **Overlapping `walkTo`** for one actor: the second takes over from where the actor is.
|
|
52
|
+
- **Staging mistakes**: actors facing away from whom they talk to, a character walking off the
|
|
53
|
+
set, a gesture that ends before the line it accompanies, a camera that frames nobody. Only
|
|
54
|
+
looking at frames catches these (the director's `check` catches many for staged episodes).
|
|
55
|
+
- **Tracks before their first key**: a key at 40 s also applies from 0 s.
|
|
56
|
+
|
|
57
|
+
## Debugging a wrong picture
|
|
58
|
+
|
|
59
|
+
- Wrong pose at time t → `toon render scene.json --time t -o f.svg`, then check the script
|
|
60
|
+
entries active at t (start `at`, `duration`, `fadeIn/fadeOut`, `layer`). A clip on `layer: -1`
|
|
61
|
+
is the base; higher layers override it while they play.
|
|
62
|
+
- Character frozen → no looping base clip (`idle`, `loop: true`, `layer: -1`).
|
|
63
|
+
- Feet sliding → a move done with `set`/tracks on `x` instead of `walkTo` (which matches the
|
|
64
|
+
stride), or a non-walk clip used for travel.
|
|
65
|
+
- Somebody invisible → off camera (`camera` x/y/zoom), `opacity` 0, `scale` 0 from a pop track,
|
|
66
|
+
or behind a layer with higher `z`.
|
|
67
|
+
- Lip sync missing → `say` needs `audio` + `lipsync` cues, inline `cues`, or `text` + `duration`.
|
|
@@ -0,0 +1,176 @@
|
|
|
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 is accepted and silently falls back to the default
|
|
159
|
+
view. Use only the names listed above (or from `toon describe`).
|
|
160
|
+
- **Not looking.** A script that validates can still have floating feet or a hand off the prop.
|
|
161
|
+
|
|
162
|
+
## Examples (run from the repo root; output in `examples/out/`)
|
|
163
|
+
|
|
164
|
+
| File | Shows |
|
|
165
|
+
|---|---|
|
|
166
|
+
| [examples/walk-wave-run.ts](examples/walk-wave-run.ts) | Walk in, turn to front, wave, scared reaction, `scaredRun` off at natural speed |
|
|
167
|
+
| [examples/knockdown.ts](examples/knockdown.ts) | Trip mid-walk, K.O. hold, `getUp`, a punch and a thrown `fall` |
|
|
168
|
+
| [examples/hold.ts](examples/hold.ts) | Box carried in both hands and put down, a hung bag, a phone with `texting` |
|
|
169
|
+
| [examples/gestures.ts](examples/gestures.ts) | A labelled sheet of every gesture clip (pick by eye) |
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npx tsx skills/animestudio-animation/examples/walk-wave-run.ts
|
|
173
|
+
npx tsx skills/animestudio-animation/examples/gestures.ts wave shrug facepalm
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
They need `rsvg-convert` and ImageMagick (`magick`) on the PATH.
|