@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,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);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knock-downs: a character trips mid-walk (`fall` without `from`), lies, gets up (`getUp`); then
|
|
3
|
+
* another walks up and punches him, and he is thrown back on an arc (`fall` `from` the hitter).
|
|
4
|
+
*
|
|
5
|
+
* npx tsx skills/animestudio-animation/examples/knockdown.ts
|
|
6
|
+
*
|
|
7
|
+
* Shows: the engine's fall (never fake it with rotation tracks), the K.O. hold (≥ 1.5 s before
|
|
8
|
+
* getUp), the punch timing (the fist lands 0.28 s into the kit's `punch`), emotions and fx as the
|
|
9
|
+
* reaction, characters kept a step apart before the hit.
|
|
10
|
+
*/
|
|
11
|
+
import type { ActionDef } from "@anime-studio/core";
|
|
12
|
+
import { FLOOR, cast, contactSheet, sceneDoc } from "./sheet";
|
|
13
|
+
|
|
14
|
+
const characters = cast("ana", "ben");
|
|
15
|
+
const TRIP = 1.5; // Ben trips here, mid-walk
|
|
16
|
+
const UP = TRIP + 2.0; // the K.O. is held 2 s before getting up (≥ 1.5 s)
|
|
17
|
+
const PUNCH = 6.2; // Ana's punch starts…
|
|
18
|
+
const HIT = PUNCH + 0.28; // …and the fist lands 0.28 s into the kit's punch clip
|
|
19
|
+
|
|
20
|
+
const script: ActionDef[] = [
|
|
21
|
+
{ at: 0, actor: "ben", action: "play", clip: "idle", loop: true, layer: -1 },
|
|
22
|
+
{ at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1 },
|
|
23
|
+
{ at: 0, actor: "ben", action: "pose", control: "view", value: "profile", duration: 0 },
|
|
24
|
+
{ at: 0, actor: "ana", action: "pose", control: "view", value: "profile", duration: 0 },
|
|
25
|
+
{ at: 0, actor: "ben", action: "pose", control: "emotion", value: "happy", duration: 0 },
|
|
26
|
+
{ at: 0, actor: "ana", action: "pose", control: "emotion", value: "annoyed", duration: 0 },
|
|
27
|
+
|
|
28
|
+
// 1. The trip: fall while the walk is still under way. The fall takes over the placement; the
|
|
29
|
+
// walk's clip fades out in 0.12 s and the body carries the walk's speed on.
|
|
30
|
+
{ at: 0.1, actor: "ben", action: "walkTo", x: 640, duration: 2.0 },
|
|
31
|
+
{ at: TRIP - 0.12, actor: "ben", action: "pose", control: "emotion", value: "surprised", duration: 0.06 },
|
|
32
|
+
{ at: TRIP - 0.1, actor: "ben", action: "fx", type: "exclaim" },
|
|
33
|
+
{ at: TRIP, actor: "ben", action: "fall" }, // tripping where he stands, on his back
|
|
34
|
+
{ at: TRIP + 0.45, action: "shake", duration: 0.25, amount: 8 }, // the hips touch down at 0.45 s
|
|
35
|
+
{ at: TRIP + 0.45, actor: "ben", action: "fx", type: "dust", anchor: "origin" },
|
|
36
|
+
{ at: TRIP + 0.6, actor: "ben", action: "pose", control: "emotion", value: "dead", duration: 0.2 },
|
|
37
|
+
{ at: TRIP + 0.7, actor: "ben", action: "fx", type: "stars", duration: 1.2 },
|
|
38
|
+
{ at: UP, actor: "ben", action: "getUp" }, // sits up into a crouch, then stands (1.2 s)
|
|
39
|
+
{ at: UP + 0.6, actor: "ben", action: "pose", control: "emotion", value: "annoyed", duration: 0.3 },
|
|
40
|
+
|
|
41
|
+
// 2. The punch: Ana walks in behind him and stops a fist's reach away (not nose to nose). He
|
|
42
|
+
// stands at x ≈ 420 after getting up (the fall moved him back); measure, don't guess.
|
|
43
|
+
{ at: 4.6, actor: "ana", action: "walkTo", x: 270, duration: 1.3 },
|
|
44
|
+
{ at: 5.0, actor: "ben", action: "face", direction: "left" },
|
|
45
|
+
{ at: 4.6, actor: "ana", action: "lookAt", target: "ben" },
|
|
46
|
+
{ at: 5.0, actor: "ben", action: "lookAt", target: "ana" },
|
|
47
|
+
{ at: 5.6, actor: "ana", action: "pose", control: "emotion", value: "angry", duration: 0.2 },
|
|
48
|
+
{ at: 5.7, actor: "ana", action: "fx", type: "anger" },
|
|
49
|
+
{ at: PUNCH, actor: "ana", action: "play", clip: "punch", duration: 0.9, fadeIn: 0.05 },
|
|
50
|
+
{ at: HIT, actor: "ben", action: "fx", type: "burst" },
|
|
51
|
+
{ at: HIT, action: "shake", duration: 0.3, amount: 14 },
|
|
52
|
+
{ at: HIT, actor: "ben", action: "pose", control: "emotion", value: "dead", duration: 0.05 },
|
|
53
|
+
// Thrown away from Ana on an arc: up, the hips land first, the shoulders slap down, a bounce.
|
|
54
|
+
{ at: HIT, actor: "ben", action: "fall", from: "ana" },
|
|
55
|
+
{ at: HIT + 0.9, actor: "ben", action: "fx", type: "stars", duration: 1.5 },
|
|
56
|
+
{ at: HIT + 0.5, actor: "ana", action: "pose", control: "emotion", value: "smug", duration: 0.3 },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const doc = sceneDoc(9.0, {
|
|
60
|
+
characters: { ana: "ana", ben: "ben" },
|
|
61
|
+
actors: [
|
|
62
|
+
{ id: "ben", character: "ben", x: 220, y: FLOOR, scale: 0.85 },
|
|
63
|
+
{ id: "ana", character: "ana", x: -200, y: FLOOR, scale: 0.85 },
|
|
64
|
+
],
|
|
65
|
+
script,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await contactSheet(doc, characters, [1.3, 1.65, 2.0, 2.6, 3.8, 4.2, 6.1, HIT, HIT + 0.3, HIT + 0.85, HIT + 1.3, 8.9], "knockdown");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the animation examples: a plain set, a cast built by the kit, and a contact
|
|
3
|
+
* sheet of key frames (evaluateScene → frameToSVG → rsvg-convert → magick montage).
|
|
4
|
+
* Every output goes to `skills/animestudio-animation/examples/out/`.
|
|
5
|
+
*/
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { type SceneDoc, type ToonDoc, evaluateScene, frameToSVG } from "@anime-studio/core";
|
|
10
|
+
import { type CartoonLook, cartoonCharacter } from "@anime-studio/kit";
|
|
11
|
+
import { prepareScene } from "@anime-studio/rigid";
|
|
12
|
+
|
|
13
|
+
export const W = 1280;
|
|
14
|
+
export const H = 720;
|
|
15
|
+
/** Where the feet stand. */
|
|
16
|
+
export const FLOOR = 620;
|
|
17
|
+
export const OUT = join(import.meta.dirname, "out");
|
|
18
|
+
const FONTS = [
|
|
19
|
+
"/System/Library/Fonts/Supplemental/Arial.ttf",
|
|
20
|
+
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
|
|
21
|
+
"/usr/share/fonts/TTF/DejaVuSans.ttf",
|
|
22
|
+
"C:\\Windows\\Fonts\\arial.ttf",
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/** Two generic looks; any `CartoonLook` works. */
|
|
26
|
+
export const LOOKS: Record<string, CartoonLook> = {
|
|
27
|
+
ana: {
|
|
28
|
+
name: "Ana", build: "woman", female: true, skin: "#c68863", hair: "ponytail", hairColor: "#3a2418",
|
|
29
|
+
top: "tee", topColor: "#e2584a", bottom: "pants", bottomColor: "#34406b", shoes: "sneakers", shoeColor: "#f4f1ea",
|
|
30
|
+
} as CartoonLook,
|
|
31
|
+
ben: {
|
|
32
|
+
name: "Ben", build: "man", skin: "#f0c8a8", hair: "sidePart", hairColor: "#5a3b22",
|
|
33
|
+
top: "polo", topColor: "#3f8fd2", bottom: "pants", bottomColor: "#4a4038", shoes: "sneakers", shoeColor: "#2b2b2b",
|
|
34
|
+
} as CartoonLook,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const cast = (...ids: string[]): Record<string, ToonDoc> =>
|
|
38
|
+
Object.fromEntries(ids.map((id) => [id, cartoonCharacter(LOOKS[id])]));
|
|
39
|
+
|
|
40
|
+
/** A flat room: a wall, a floor from FLOOR down, a ruler of ticks so sliding feet show. */
|
|
41
|
+
export const room = () => {
|
|
42
|
+
const ticks = Array.from({ length: 17 }, (_, i) => `<path d="M${i * 80} ${FLOOR} v14" stroke="#b9a98f" stroke-width="3"/>`).join("");
|
|
43
|
+
return `<rect x="0" y="0" width="${W}" height="${FLOOR}" fill="#f3ead8"/>
|
|
44
|
+
<rect x="0" y="${FLOOR}" width="${W}" height="${H - FLOOR}" fill="#d8c7a6"/>
|
|
45
|
+
<path d="M0 ${FLOOR} H${W}" stroke="#8c7a5c" stroke-width="4"/>${ticks}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** A scene document with the room as its only layer. */
|
|
49
|
+
export const sceneDoc = (duration: number, extra: Partial<SceneDoc>): SceneDoc =>
|
|
50
|
+
({
|
|
51
|
+
format: "toon-scene", version: 1, width: W, height: H, fps: 30, duration, background: "#f3ead8",
|
|
52
|
+
camera: { x: W / 2, y: H / 2, zoom: 1 },
|
|
53
|
+
layers: [{ id: "room", art: room() }],
|
|
54
|
+
...extra,
|
|
55
|
+
}) as SceneDoc;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Renders the frames at `times` and tiles them, labelled with their time (or `labels`), into `out/<name>.png`.
|
|
59
|
+
* Returns the sheet's path. Look at it: a contact sheet is the only proof the motion reads.
|
|
60
|
+
*/
|
|
61
|
+
export async function contactSheet(doc: SceneDoc, characters: Record<string, ToonDoc>, times: number[], name: string, cols = 4, labels?: string[]) {
|
|
62
|
+
const work = join(OUT, name);
|
|
63
|
+
mkdirSync(work, { recursive: true });
|
|
64
|
+
// prepareScene = compileScene + the rigid-body bake (needed for falls with physics props, harmless otherwise).
|
|
65
|
+
const scene = await prepareScene(doc, { characters });
|
|
66
|
+
const args: string[] = [];
|
|
67
|
+
times.forEach((t, i) => {
|
|
68
|
+
const svg = join(work, `f${i}.svg`), png = join(work, `f${i}.png`);
|
|
69
|
+
writeFileSync(svg, frameToSVG(evaluateScene(scene, t)));
|
|
70
|
+
execFileSync("rsvg-convert", ["-w", String(W / 2), "-h", String(H / 2), "-o", png, svg]);
|
|
71
|
+
args.push("-label", labels?.[i] ?? `t=${t.toFixed(2)}s`, png);
|
|
72
|
+
});
|
|
73
|
+
const out = join(OUT, `${name}.png`);
|
|
74
|
+
// ImageMagick needs a font file for the labels; without one found, the sheet is tiled unlabelled.
|
|
75
|
+
const font = FONTS.find((f) => existsSync(f));
|
|
76
|
+
const tiles = font ? args : args.filter((a, i) => a !== "-label" && args[i - 1] !== "-label");
|
|
77
|
+
execFileSync("magick", ["montage", ...(font ? ["-font", font, "-pointsize", "18"] : []), ...tiles, "-tile", `${cols}x`, "-geometry", "+4+4", out]);
|
|
78
|
+
console.log(out);
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A character walks in, stops, turns to the audience, waves, hears something off screen, takes a
|
|
3
|
+
* scared beat and runs off the other way.
|
|
4
|
+
*
|
|
5
|
+
* npx tsx skills/animestudio-animation/examples/walk-wave-run.ts
|
|
6
|
+
*
|
|
7
|
+
* Shows: idle on layer -1, walkTo with the plain walk (stride-matched), a `view` change with a
|
|
8
|
+
* duration (steps through the drawn angles), a gesture clip with fadeIn, emotion and lookAt as
|
|
9
|
+
* acting, an fx on the reaction, a run at the clip's natural speed in the travel view (q64).
|
|
10
|
+
*/
|
|
11
|
+
import type { ActionDef } from "@anime-studio/core";
|
|
12
|
+
import { FLOOR, cast, contactSheet, sceneDoc } from "./sheet";
|
|
13
|
+
|
|
14
|
+
const characters = cast("ana");
|
|
15
|
+
const SCALE = 0.9;
|
|
16
|
+
|
|
17
|
+
// A run must go at its own pace: speed = stride × scale / cycle. Slower plays in slow motion,
|
|
18
|
+
// faster blurs the legs. (The scene's walkTo default is 220 px/s, right for a walk, wrong for a run.)
|
|
19
|
+
const run = characters.ana.clips!.scaredRun;
|
|
20
|
+
const runSpeed = (run.stride! * SCALE) / run.duration;
|
|
21
|
+
|
|
22
|
+
const T = { walk: 0.2, arrive: 2.6, turn: 2.8, wave: 3.25, noise: 5.0, flee: 5.75 };
|
|
23
|
+
|
|
24
|
+
const script: ActionDef[] = [
|
|
25
|
+
// Base layer: a looping idle under everything, so the body never freezes between actions.
|
|
26
|
+
{ at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1 },
|
|
27
|
+
// Give every changing channel a value at t = 0 (a track holds its first key before it).
|
|
28
|
+
{ at: 0, actor: "ana", action: "pose", control: "view", value: "profile", duration: 0 },
|
|
29
|
+
{ at: 0, actor: "ana", action: "pose", control: "emotion", value: "happy", duration: 0 },
|
|
30
|
+
// Walk in: the walk clip is stride-matched by walkTo (no sliding feet); it faces the way it goes.
|
|
31
|
+
{ at: T.walk, actor: "ana", action: "walkTo", x: 520, duration: T.arrive - T.walk },
|
|
32
|
+
// Turn to the audience: a view change with a duration steps through every drawn angle in between.
|
|
33
|
+
{ at: T.turn, actor: "ana", action: "pose", control: "view", value: "front", duration: 0.35 },
|
|
34
|
+
{ at: T.turn, actor: "ana", action: "lookAt", target: null },
|
|
35
|
+
// One clear action: the wave, faded in over the idle; the emotion rises just before it.
|
|
36
|
+
{ at: T.wave - 0.1, actor: "ana", action: "pose", control: "emotion", value: "joy", duration: 0.3 },
|
|
37
|
+
{ at: T.wave, actor: "ana", action: "play", clip: "wave", duration: 1.5, fadeIn: 0.2, fadeOut: 0.25 },
|
|
38
|
+
// The reaction: the effect a hair before the look, the look before the body.
|
|
39
|
+
{ at: T.noise - 0.05, actor: "ana", action: "fx", type: "surprise" },
|
|
40
|
+
{ at: T.noise, actor: "ana", action: "lookAt", target: [1400, 360] },
|
|
41
|
+
{ at: T.noise, actor: "ana", action: "pose", control: "emotion", value: "scared", duration: 0.12 },
|
|
42
|
+
{ at: T.noise + 0.05, actor: "ana", action: "pose", control: "view", value: "profile", duration: 0.25 },
|
|
43
|
+
{ at: T.noise + 0.1, actor: "ana", action: "play", clip: "scared", duration: 0.55, fadeIn: 0.08 },
|
|
44
|
+
{ at: T.flee - 0.1, actor: "ana", action: "fx", type: "sweat" },
|
|
45
|
+
// Flee: the run's travel view (q64, side-on with the face still showing); walkTo reverses her
|
|
46
|
+
// facing and turns her through the in-between angles instead of flipping in one frame.
|
|
47
|
+
{ at: T.flee, actor: "ana", action: "pose", control: "view", value: "q64", duration: 0.2 },
|
|
48
|
+
{ at: T.flee, actor: "ana", action: "lookAt", target: null },
|
|
49
|
+
{ at: T.flee, actor: "ana", action: "walkTo", x: -350, clip: "scaredRun", speed: runSpeed },
|
|
50
|
+
{ at: T.flee + 0.1, actor: "ana", action: "fx", type: "dust", anchor: "origin" },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const doc = sceneDoc(7.2, {
|
|
54
|
+
characters: { ana: "ana" },
|
|
55
|
+
actors: [{ id: "ana", character: "ana", x: -120, y: FLOOR, scale: SCALE }],
|
|
56
|
+
script,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await contactSheet(doc, characters, [0.9, 1.6, 2.7, 2.95, 3.2, 3.8, 5.05, 5.5, 5.8, 5.9, 6.0, 6.1], "walk-wave-run");
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Kit clips (`cartoonCharacter`)
|
|
2
|
+
|
|
3
|
+
Every `cartoonCharacter(look)` carries these clips (durations at the default proportions; read
|
|
4
|
+
`doc.clips[name].duration` for yours). "loop" clips repeat until the `play`'s `duration`; one-shot
|
|
5
|
+
clips play once and hold their end until faded out. `clear`: on a 2.5D rig the engine keeps the
|
|
6
|
+
arms off the face (wave, cheer…); the others are face-contact clips that keep their contact
|
|
7
|
+
(drink, facepalm, phone…). See them all on one sheet:
|
|
8
|
+
`npx tsx skills/animestudio-animation/examples/gestures.ts`.
|
|
9
|
+
|
|
10
|
+
Source of truth: `Object.keys(doc.clips)`, [API.md → kit](https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md#anime-studiokit).
|
|
11
|
+
|
|
12
|
+
## Base and transitions
|
|
13
|
+
|
|
14
|
+
| Clip | s | Kind | Use |
|
|
15
|
+
|---|---|---|---|
|
|
16
|
+
| `idle` | 3.2 | loop | Breathing base under everything: `layer: -1`, `loop: true`, at `t = 0` |
|
|
17
|
+
| `turn` | 0.24 | once | A quick squeeze hiding a change of view (played automatically by the director) |
|
|
18
|
+
|
|
19
|
+
## Locomotion (play through `walkTo`, not `play`)
|
|
20
|
+
|
|
21
|
+
| Clip | s / cycle | Stride px | Mood |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| `walk` | 0.84 | ≈ 234 | Plain walk (long legs, hips drop into each step) |
|
|
24
|
+
| `run` | 0.6 | ≈ 434 | Cartoon run: flights, heel kick, runner's arms |
|
|
25
|
+
| `sneak` | 2.0 | ≈ 404 | Big slow creeping steps, "tiptoe fingers" |
|
|
26
|
+
| `strut` | 0.6 | ≈ 257 | Chest out, hip sway, double bounce, fists |
|
|
27
|
+
| `tired` | 0.95 | ≈ 187 | Slumped, dragging feet, hanging arms |
|
|
28
|
+
| `march` | 0.5 | ≈ 234 | Knees up, pumping fists |
|
|
29
|
+
| `scaredRun` | 0.41 | ≈ 665 | Panic sprint, arms flung up and out |
|
|
30
|
+
|
|
31
|
+
Strides are per cycle at scale 1 for one build; skirts shorten runs. See [locomotion.md](locomotion.md).
|
|
32
|
+
|
|
33
|
+
## Gestures
|
|
34
|
+
|
|
35
|
+
| Clip | s | Kind | What it does / when |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| `talk` | 1.6 | loop | Conversational hands while speaking |
|
|
38
|
+
| `wave` | 1.2 | loop | Hand up beside the head, waving: greetings, goodbyes |
|
|
39
|
+
| `point` | 1.0 | loop | Points forward (finger hand): "that one", "you" |
|
|
40
|
+
| `pointUp` | 1.2 | loop | Finger up: "I've got it", "listen" |
|
|
41
|
+
| `present` | 1.4 | loop | Open hand out to the side: presenting, "ta-da", "here it is" |
|
|
42
|
+
| `clap` | 0.5 | loop | Clapping in front of the chest |
|
|
43
|
+
| `cheer` | 0.8 | loop | Both arms up: victory, joy |
|
|
44
|
+
| `dance` | 1.2 | loop | Dancing, one arm up |
|
|
45
|
+
| `groove` | 0.9 | loop | Hips swaying with a bounce, hands up in turn |
|
|
46
|
+
| `sing` | 2.0 | loop | Singing, hand on the chest |
|
|
47
|
+
| `think` | 2.4 | loop | Hand to the chin (face contact) |
|
|
48
|
+
| `shrug` | 1.2 | once | Shoulders and palms up: "who knows" |
|
|
49
|
+
| `laugh` | 0.6 | loop | Laughing, hands to the belly |
|
|
50
|
+
| `cry` | 0.8 | loop | Hands to the eyes (face contact) |
|
|
51
|
+
| `scared` | 0.24 | loop | Hands up in front, shivering |
|
|
52
|
+
| `facepalm` | 1.6 | once | Hand to the face (face contact) |
|
|
53
|
+
| `jump` | 0.8 | once | A jump, arms up |
|
|
54
|
+
| `teeter` | 1.1 | once | Arms out, losing balance |
|
|
55
|
+
| `flap` | 0.28 | loop | Arms flapping (panic, or flying rigs) |
|
|
56
|
+
| `toss` | 0.9 | once | Throws something up, both arms up |
|
|
57
|
+
| `dribble` | 0.6 | loop | Bouncing a ball (sync a prop to the hand) |
|
|
58
|
+
| `drink` | 2.2 | once | Hand to the mouth, wrist tips, head back |
|
|
59
|
+
| `smoke` | 1.8 | once | Hand to the mouth for a puff and back |
|
|
60
|
+
| `phone` | 2.4 | loop | Phone at the ear along the jaw |
|
|
61
|
+
| `read` | 2.4 | loop | Holding a book/tablet (with `HOLD.book`) |
|
|
62
|
+
| `texting` | 2.4 | loop | Phone in one hand at the lower chest, head bent 24° (with `HOLD.phone`) |
|
|
63
|
+
| `textingTwo` | 1.2 | loop | Both thumbs (`also: holdBoth`) |
|
|
64
|
+
| `carry` | 1.6 | loop | A box between both hands in front of the belly (with `boxFit`) |
|
|
65
|
+
| `hold` | 2.0 | loop | Holding something up in front |
|
|
66
|
+
| `gamepad` | 1.0 | loop | A controller in both hands, thumbs busy |
|
|
67
|
+
| `cue` | 1.6 | loop | Leaning over a pool table, stroking |
|
|
68
|
+
| `ride` | 1.0 | loop | Leaning into a ride (bicycle), head up |
|
|
69
|
+
| `roll` | 0.8 | once | A roll |
|
|
70
|
+
|
|
71
|
+
## Fighting and knock-downs
|
|
72
|
+
|
|
73
|
+
| Clip | s | Kind | Use |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| `stance` | 1.6 | loop | Guard up; a fight's base instead of `idle` (`layer: -1`) |
|
|
76
|
+
| `power` | 1.2 | loop | Powering up (pair with `fx` `aura`) |
|
|
77
|
+
| `punch` | 0.9 | once | The fist lands at **0.28 s**: the target's `fall from` goes there |
|
|
78
|
+
| `knocked` | 0.85 | once | Limbs in the air during `fall` (used by `fall` itself — do not `play`) |
|
|
79
|
+
| `down` | 3.6 | once | The K.O. lying pose (used by `fall`) |
|
|
80
|
+
| `rise` | 1.2 | once | Limbs while getting up (used by `getUp`) |
|
|
81
|
+
|
|
82
|
+
## Emotions (`pose` control `emotion`)
|
|
83
|
+
|
|
84
|
+
`neutral`, `happy`, `joy`, `surprised`, `sad`, `smug`, `scared`, `angry`, `dead`, `determined`,
|
|
85
|
+
`calm`, `excited`, `annoyed`, `sleep`, `gape`. Weighted values blend:
|
|
86
|
+
`{ "happy": 0.5, "surprised": 0.5 }`.
|
|
87
|
+
|
|
88
|
+
## Other controls
|
|
89
|
+
|
|
90
|
+
| Control | Values |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `view` | `front half q24 profile q50 q64 q77 side q112 away q158 back` |
|
|
93
|
+
| `head` | the same angles, `~<angle>` mirrored, `null` follows `view` |
|
|
94
|
+
| `jaw` | `shut`, `gape`, weighted `{ "gape": 2 }` (unhinged) |
|
|
95
|
+
| `look` | aim control driven by `lookAt` |
|
|
96
|
+
| `mouth` | viseme control driven by `say` |
|
|
97
|
+
|
|
98
|
+
## Reading a clip in code
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const c = doc.clips!.run; // { duration, loop, stride?, clear?, tracks }
|
|
102
|
+
const natural = (c.stride! * scale) / c.duration; // px/s: a gait's own speed
|
|
103
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Director beats for motion (stagings)
|
|
2
|
+
|
|
3
|
+
In a director staging (`@anime-studio/director`, `direct(staging, lines, kit)`) beats are timed to
|
|
4
|
+
lines (`{ "line": 12, "word": "now", "offset": 0.1 }`) and places are marks or people, never
|
|
5
|
+
coordinates. The director turns them into the scene actions of this skill, plus what a person
|
|
6
|
+
would forget (idle loops, listeners turning to the speaker, spacing, talking hands).
|
|
7
|
+
Full table: [DIRECTOR.md → Beats](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md#beats-do).
|
|
8
|
+
|
|
9
|
+
## Motion beats
|
|
10
|
+
|
|
11
|
+
| Beat | Fields | Notes |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `walk`, `run` | `who`, `to`, `until?` | Speed from the cast (walk 170 px/s, a run at its clip's natural speed). Turns through the angles; a run is drawn in the travel view |
|
|
14
|
+
| `enter` / `exit` | `who`, `from`/`to`, `run?`, `fly?` | Invisible before entering; from the top drops in and lands |
|
|
15
|
+
| `face`, `view`, `look` | `who`, `direction` / `value` / `target` | `view` turns through every drawing in between, one every two frames |
|
|
16
|
+
| `emotion` | `who`, `value` | Emotion pose |
|
|
17
|
+
| `gesture` | `who`, `clip`, `until?` | A clip (looped until `until`, else once). From the front `facepalm`, `despair`, `think`, `cover`, `excited`, `shout` are IK hand positions on the face |
|
|
18
|
+
| `take` | `who`, `target?`, `double?` | A cartoon take: squash and lean away, eyes shut, then stretch towards it, eyes wide, `surprised` |
|
|
19
|
+
| `hit` | `who`, `target`, `ko?` | Dash in, `punch`, impact frame, target thrown back spinning, K.O. until `getUp` |
|
|
20
|
+
| `fall` | `who`, `side?` | Trips (standing), thrown clear (riding), slips off (carried); stars; until `getUp` |
|
|
21
|
+
| `getUp` | `who` | From a seat, a bed, the ground or a fall |
|
|
22
|
+
| `sit` | `who`, `on?`, `view?`, `legs?`, `hands?` | Walks there and sits: hips on the seat, feet on the floor; 2.5D rigs posed in 3D, hands on knees or lap; on the ground `legs: "straight" \| "hug"`. Crossed legs are not supported |
|
|
23
|
+
| `lie`, `sleep` | `who`, `on?` | Face up on the bed's `pillow`/`bed` anchor or the ground; `sleep` adds Zzz and the `sleep` emotion |
|
|
24
|
+
| `mount`, `ride`, `dismount` | `who`, `vehicle`, `to`, `wobble?` | Seat on the saddle, feet on the pedals, hands on the bars; `wobble` for a beginner |
|
|
25
|
+
| `hide`, `peek` | `who`, `behind`, `until?` | Crouches behind something lower than the head; `peek` pops up and back |
|
|
26
|
+
| `hold` / `release` (people) | `who` (list) | Hand in hand |
|
|
27
|
+
| `highFive`, `hug`, `carry` (piggyback), `cradle` | `who`, `target?` | Contact beats: the closeness is intended, no spacing warning |
|
|
28
|
+
| `pick`, `drop`, `give`, `throw`, `hold` (prop), `use`, `take` (prop), `putBack`, `dribble` | `who`, `prop`, … | Prop handling; the director walks over and picks the free hand |
|
|
29
|
+
| `press` | `who`, `at` | Presses a button/bell: walks within reach, the hand pushes in and back |
|
|
30
|
+
| `fly` | `who`, `to` | Rigs with wings: crouch, one arc, soft landing |
|
|
31
|
+
|
|
32
|
+
## Rules the director enforces (stage within them)
|
|
33
|
+
|
|
34
|
+
- One walks facing where one goes; a `face` the other way while walking waits for the walk.
|
|
35
|
+
- A second walk while walking starts when the first arrives.
|
|
36
|
+
- Walking while sitting or lying stands up first.
|
|
37
|
+
- Arms on 2.5D rigs move as 3D reaches along arcs in front of the body, one move at a time; a held
|
|
38
|
+
object stays in the same hand when its holder turns round.
|
|
39
|
+
- `check(staging, lines, kit)` reports characters on top of each other or nose to nose for more
|
|
40
|
+
than 0.5 s, bodies past the set's bounds, faces covered by scenery, legs too short for pedals.
|
|
41
|
+
Run it (`{ strict: true }` before a render) and fix every warning.
|
|
42
|
+
|
|
43
|
+
## Scene-level equivalents
|
|
44
|
+
|
|
45
|
+
Without the director, build sitting and riding from `mount` (`on`, `anchor: "seat"`, `point`: the
|
|
46
|
+
hip joint, `behind`: the far leg's parts, `facing`) and `reach` (`footF`/`footB` to pedals or floor
|
|
47
|
+
points, `handF`/`handB` to a handlebar). It is much more work and easy to get wrong on a 2.5D rig
|
|
48
|
+
(the director poses the seated legs in 3D); prefer a staging for anything seated.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Holding and carrying props
|
|
2
|
+
|
|
3
|
+
Reference: [FORMAT.md §2.6 anchors and `fit`](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#26-anchors),
|
|
4
|
+
[§3.3 `grab` / `release` / `put` / hung props](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#33-script-actions),
|
|
5
|
+
[API.md → `HOLD`, `holdFit`, `holdBoth`, `boxFit`](https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md#anime-studiokit).
|
|
6
|
+
Worked example: [examples/hold.ts](../examples/hold.ts).
|
|
7
|
+
|
|
8
|
+
## Actions
|
|
9
|
+
|
|
10
|
+
| Action | Fields | Effect |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| `grab` | `prop`, `anchor`, `also?`, `fit?`, `hang?` | Attaches the prop to the anchor every frame; the hand closes (`grip`) and is drawn over it |
|
|
13
|
+
| `release` | `prop`, `velocity?`, `keep?` | Lets go. A body prop flies with the hand's velocity; `keep: true` leaves a body-less prop where the hand put it |
|
|
14
|
+
| `put` | `prop`, `on` | The prop rides on another prop (cup on a tray); `null` leaves it there |
|
|
15
|
+
| `reach` | `chain`, `target`, `duration` | An IK chain (`handF`, `handB`, `footF`, `footB`) to an anchor, a prop point or a scene point |
|
|
16
|
+
|
|
17
|
+
`cartoonCharacter` anchors: `hand` (near), `handB` (far), `fist`, `head`, `face`, `ear`, `earB`,
|
|
18
|
+
`mouth`, `eye`, `top`. The head ones move with each drawn angle.
|
|
19
|
+
|
|
20
|
+
## Draw props for the hand
|
|
21
|
+
|
|
22
|
+
- Draw the prop the way it looks in the hand at rest, in its own coordinates; the `fit` points
|
|
23
|
+
are in those coordinates (scaled and mirrored with the prop).
|
|
24
|
+
- Two-sided flat props (phone, book, card): give `art` (front) and `back` (seen from behind). With
|
|
25
|
+
`face`, the engine shows the back to the camera when the front faces away and foreshortens it.
|
|
26
|
+
- Hung props: draw them hanging straight down from the handle at `[0, 0]`.
|
|
27
|
+
|
|
28
|
+
## Recipes
|
|
29
|
+
|
|
30
|
+
**Phone, one hand, texting**
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { HOLD, holdFit } from "@anime-studio/kit";
|
|
34
|
+
props: [{ id: "phone", art: SCREEN, back: CASE, x: 0, y: 0, scale: HOLD.phone.scale * actorScale }],
|
|
35
|
+
{ at: 3.2, actor: "ana", action: "grab", prop: "phone", anchor: "hand", fit: holdFit("phone", [0, 0], [0, -100]) },
|
|
36
|
+
{ at: 3.2, actor: "ana", action: "play", clip: HOLD.phone.clip, loop: true, layer: 1, fadeIn: 0.35 },
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The phone is drawn upright, grip at `[0, 0]`, top at `[0, -100]`. Seen from the front or the side
|
|
40
|
+
you see the case (correct: the screen faces her eyes). Hide the prop until it is taken
|
|
41
|
+
(`props.<id>.opacity` track) — a prop at opacity 0 is not drawn.
|
|
42
|
+
|
|
43
|
+
**Two thumbs / a book**: `textingTwo` or `read`, `fit: holdFit("phone" | "book", grip, top)`,
|
|
44
|
+
`also: holdBoth` (the far hand wraps it too).
|
|
45
|
+
|
|
46
|
+
**A box in both hands**
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { HOLD, boxFit, holdBoth } from "@anime-studio/kit";
|
|
50
|
+
{ at: 0, actor: "ben", action: "grab", prop: "box", anchor: "hand", fit: boxFit([-55, 0], [55, 0]), also: holdBoth },
|
|
51
|
+
{ at: 0, actor: "ben", action: "play", clip: HOLD.box.clip, loop: true, layer: 1, fadeIn: 0, duration: 3.1, fadeOut: 0.3 },
|
|
52
|
+
{ at: 0.2, actor: "ben", action: "walkTo", x: 840, duration: 2.4 }, // carry pose on layer 1 over the walk
|
|
53
|
+
{ at: 3.0, actor: "ben", action: "release", prop: "box", keep: true }, // put down where the hands are
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`boxFit(left, right)`: the box's left point on `hand`, turned so its right point is on `handB`.
|
|
57
|
+
Give the `carry` clip a `duration` that ends just after the release, or the arms keep carrying air.
|
|
58
|
+
|
|
59
|
+
**A bag swinging from the hand**
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
{ at: 0, actor: "ana", action: "grab", prop: "bag", anchor: "handB", hang: { point: [0, 0], damping: 0.25 } },
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`hang`: `point` (the handle), `length`, `damping` (0.25 loose … 1 no overshoot), `limit` (70°),
|
|
66
|
+
`gravity`. It swings back on setting off and forward on the stop; it restarts at rest on a flip.
|
|
67
|
+
`hang` and `fit` cannot be combined. Use the far hand for carried bags so the near hand stays free
|
|
68
|
+
for gestures.
|
|
69
|
+
|
|
70
|
+
**Held to the face** (phone at the ear, cigarette, bottle): `fit` with two anchors
|
|
71
|
+
(`[{ point: EAR_PT, anchor: "ear" }, { point: MOUTH_PT, anchor: "mouth" }]`) or a 3D `dir`, then
|
|
72
|
+
play `phone`, `smoke` or `drink`. In a staging, the director's `use` beat and the `phone` / `smoke`
|
|
73
|
+
/ `drink` gestures do this when the prop kind declares its points.
|
|
74
|
+
|
|
75
|
+
## Putting something down on a table
|
|
76
|
+
|
|
77
|
+
The hand lets go where it is; the prop does not fall unless it has a `body`. So:
|
|
78
|
+
|
|
79
|
+
1. Stage the walk and the release.
|
|
80
|
+
2. Measure: `propPlacement(compileScene(doc, assets), prop, tRelease)` → `x`, `y`.
|
|
81
|
+
3. Put the table's top under the prop's bottom edge (`y + half its height`), and its body under
|
|
82
|
+
the prop's `x` — or move where the character stops.
|
|
83
|
+
|
|
84
|
+
`examples/hold.ts --measure` prints it.
|
|
85
|
+
|
|
86
|
+
## Physics props
|
|
87
|
+
|
|
88
|
+
A prop with `body` (`dynamic`) follows the hand while held and leaves with the hand's velocity on
|
|
89
|
+
`release` (or `velocity`). Bake with `prepareScene` from `@anime-studio/rigid` (it runs the
|
|
90
|
+
Rapier simulation); add a static floor prop so it lands.
|
|
91
|
+
|
|
92
|
+
## Director beats for props
|
|
93
|
+
|
|
94
|
+
`pick`, `drop`, `give`, `throw`, `hold` (a prop), `use`, `take`, `putBack`, `dribble`, `carry`
|
|
95
|
+
(piggyback), `cradle` (a baby): the director walks the character over, chooses the free hand and
|
|
96
|
+
keeps props in the same hand when the holder turns round. Prefer them in stagings.
|
|
97
|
+
|
|
98
|
+
## Pitfalls
|
|
99
|
+
|
|
100
|
+
- A prop popping in: an object held in a scene is grabbed from `at: 0`.
|
|
101
|
+
- Two props in one hand: use `hand` and `handB`.
|
|
102
|
+
- `walkTo`, `fall` and `getUp` play their clips on layer 0. A held-prop clip (`carry`, `texting`,
|
|
103
|
+
`read`) on layer 0 competes with the gait: put it on layer 1. End it (a `duration`) before a
|
|
104
|
+
`fall`, or it overrides the falling limbs.
|
|
105
|
+
- `fit` without `face` on a flat prop: one side is drawn from every angle.
|
|
106
|
+
- Validate twice: look at the sheet and zoom into the hands (`magick f.png -crop … -resize 400%`).
|