@anime-studio/kit 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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/dist/cartoon.d.ts +368 -0
  4. package/dist/cartoon.d.ts.map +1 -0
  5. package/dist/cartoon.js +2815 -0
  6. package/dist/cartoon.js.map +1 -0
  7. package/dist/human.d.ts +165 -0
  8. package/dist/human.d.ts.map +1 -0
  9. package/dist/human.js +433 -0
  10. package/dist/human.js.map +1 -0
  11. package/dist/humanFront.d.ts +18 -0
  12. package/dist/humanFront.d.ts.map +1 -0
  13. package/dist/humanFront.js +137 -0
  14. package/dist/humanFront.js.map +1 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +9 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/info.d.ts +96 -0
  20. package/dist/info.d.ts.map +1 -0
  21. package/dist/info.js +277 -0
  22. package/dist/info.js.map +1 -0
  23. package/dist/proportions.d.ts +37 -0
  24. package/dist/proportions.d.ts.map +1 -0
  25. package/dist/proportions.js +115 -0
  26. package/dist/proportions.js.map +1 -0
  27. package/dist/rig.d.ts +538 -0
  28. package/dist/rig.d.ts.map +1 -0
  29. package/dist/rig.js +1381 -0
  30. package/dist/rig.js.map +1 -0
  31. package/dist/room.d.ts +124 -0
  32. package/dist/room.d.ts.map +1 -0
  33. package/dist/room.js +217 -0
  34. package/dist/room.js.map +1 -0
  35. package/dist/util.d.ts +27 -0
  36. package/dist/util.d.ts.map +1 -0
  37. package/dist/util.js +29 -0
  38. package/dist/util.js.map +1 -0
  39. package/dist/views.d.ts +68 -0
  40. package/dist/views.d.ts.map +1 -0
  41. package/dist/views.js +92 -0
  42. package/dist/views.js.map +1 -0
  43. package/dist/volume.d.ts +105 -0
  44. package/dist/volume.d.ts.map +1 -0
  45. package/dist/volume.js +234 -0
  46. package/dist/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C,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7J,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;QACpD,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE;QACjC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;QAC1B,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACjE,OAAO;KACR,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,GAAyB,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AACzD,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Helpers shared by the kit's builders (colours, bone directions). Internal: not exported by the
3
+ * package.
4
+ */
5
+ import type { P } from "./rig.js";
6
+ type Bone = {
7
+ id: string;
8
+ from?: P;
9
+ to?: P;
10
+ parent?: string;
11
+ };
12
+ /** A short hex colour (`#abc`) written out (`#aabbcc`); anything else is returned as is. */
13
+ export declare const longHex: (hex: string) => string;
14
+ /** A hex colour multiplied by `k` (darker below 1, lighter above), each channel clamped. */
15
+ export declare const shade: (hex: string, k: number) => string;
16
+ /** Blends two hex colours (`t` = 0: `a`, 1: `b`). */
17
+ export declare const mix: (a: string, b: string, t: number) => string;
18
+ /** Setup-space direction of a bone's rest form (`from` → `to`), in radians; 0 for a bone without one. */
19
+ export declare function restAngle(skeleton: Bone[], id: string): number;
20
+ /**
21
+ * The `forward` of an aim target (degrees): the core aims `matAngle(bone) + forward` at the target,
22
+ * so forward is the facing direction less the bone's rest direction. `facing` is where the drawing
23
+ * looks in setup space (default 0: along +x, a profile facing right).
24
+ */
25
+ export declare const aimForward: (skeleton: Bone[], bone: string, facing?: number) => number;
26
+ export {};
27
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,OAAO,CAAC;AAE/B,KAAK,IAAI,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9D,4FAA4F;AAC5F,eAAO,MAAM,OAAO,QAAS,MAAM,WAA6F,CAAC;AAEjI,4FAA4F;AAC5F,eAAO,MAAM,KAAK,QAAS,MAAM,KAAK,MAAM,WAI3C,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,GAAG,MAAO,MAAM,KAAK,MAAM,KAAK,MAAM,WAIlD,CAAC;AAEF,yGAAyG;AACzG,wBAAgB,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,aAAc,IAAI,EAAE,QAAQ,MAAM,4BAAwE,CAAC"}
package/dist/util.js ADDED
@@ -0,0 +1,29 @@
1
+ const r = (n) => Math.round(n * 100) / 100;
2
+ /** A short hex colour (`#abc`) written out (`#aabbcc`); anything else is returned as is. */
3
+ export const longHex = (hex) => (/^#[0-9a-f]{3}$/i.test(hex) ? `#${[...hex.slice(1)].map((c) => c + c).join("")}` : hex);
4
+ /** A hex colour multiplied by `k` (darker below 1, lighter above), each channel clamped. */
5
+ export const shade = (hex, k) => {
6
+ const n = parseInt(longHex(hex).slice(1), 16);
7
+ const c = (s) => Math.max(0, Math.min(255, Math.round(((n >> s) & 255) * k)));
8
+ return `#${((c(16) << 16) | (c(8) << 8) | c(0)).toString(16).padStart(6, "0")}`;
9
+ };
10
+ /** Blends two hex colours (`t` = 0: `a`, 1: `b`). */
11
+ export const mix = (a, b, t) => {
12
+ const pa = parseInt(longHex(a).slice(1), 16), pb = parseInt(longHex(b).slice(1), 16);
13
+ const c = [16, 8, 0].map((sh) => Math.round(((pa >> sh) & 255) * (1 - t) + ((pb >> sh) & 255) * t));
14
+ return `#${((c[0] << 16) | (c[1] << 8) | c[2]).toString(16).padStart(6, "0")}`;
15
+ };
16
+ /** Setup-space direction of a bone's rest form (`from` → `to`), in radians; 0 for a bone without one. */
17
+ export function restAngle(skeleton, id) {
18
+ const b = skeleton.find((x) => x.id === id);
19
+ if (!b?.from || !b.to)
20
+ return 0;
21
+ return Math.atan2(b.to[1] - b.from[1], b.to[0] - b.from[0]);
22
+ }
23
+ /**
24
+ * The `forward` of an aim target (degrees): the core aims `matAngle(bone) + forward` at the target,
25
+ * so forward is the facing direction less the bone's rest direction. `facing` is where the drawing
26
+ * looks in setup space (default 0: along +x, a profile facing right).
27
+ */
28
+ export const aimForward = (skeleton, bone, facing = 0) => r(facing - (restAngle(skeleton, bone) * 180) / Math.PI);
29
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAEnD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC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,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { ToonDoc } from "@anime-studio/core";
2
+ /**
3
+ * Several views (profile, front, back, in-between angles) on one skeleton. A hidden `view` switch
4
+ * part selects which art is visible; the `view` pose control flips it and moves bones (arms to the
5
+ * sides, eyes and mouth to the middle of the face, …). Every clip is shared by the views. Only the
6
+ * views the spec draws exist (a spec with front art alone gives `profile` and `front`).
7
+ *
8
+ * - **front** looks at the camera: draw it symmetric about the body's centre line, eyes on that
9
+ * line with centred pupils (move `pupils` back by the profile look offset), mouth/snout/beak
10
+ * centred under the eyes, same heights as the profile.
11
+ * - **back** is for walking away from the camera (`walkDepth`): the face is hidden, the far arm
12
+ * is redrawn in front of the body (`farArm`).
13
+ */
14
+ type P = [number, number];
15
+ type Doc = Record<string, any>;
16
+ /** A view other than the profile: `front`, `back`, or any in-between angle a rig draws. */
17
+ export type ViewName = string;
18
+ export interface ViewSpec {
19
+ /** Face feature groups get their own bones so a view can move them as a unit. */
20
+ eyes: {
21
+ center: P;
22
+ parts: string[];
23
+ };
24
+ mouth: {
25
+ center: P;
26
+ parts: string[];
27
+ };
28
+ /** Parts drawn only in profile (replaced by view art). */
29
+ profileOnly: string[];
30
+ /** Parts hidden (opacity) in a view. */
31
+ hide: Partial<Record<ViewName, string[]>>;
32
+ /** Extra parts for a view, inserted before the given part id (or appended). */
33
+ parts: Partial<Record<ViewName, {
34
+ before?: string;
35
+ part: Doc;
36
+ }[]>>;
37
+ /** Screen-space displacement of bones (setup units), and extra rotations, per view. */
38
+ move: Partial<Record<ViewName, Record<string, P>>>;
39
+ rotate?: Partial<Record<ViewName, Record<string, number>>>;
40
+ /** Extra channels per view (e.g. mouth shapes). */
41
+ extra?: Partial<Record<ViewName, Record<string, number | string>>>;
42
+ /** Mouth parts used by the viseme control in addition to "mouth". */
43
+ mouths?: string[];
44
+ /** Far-arm parts, redrawn in front of the body in the back view (when the spec draws one). */
45
+ farArm?: string[];
46
+ /**
47
+ * Bones kept (almost) straight in a view: their rotation from emotions, aim and clips is scaled
48
+ * by `STILL_MIX`. A head tilting around the neck reads well in profile but looks broken from the
49
+ * front or the back. Default: `{ front: ["head"], back: ["head"] }`.
50
+ */
51
+ still?: Partial<Record<ViewName, string[]>>;
52
+ /**
53
+ * The views in turning order, e.g. `["front", "half", "profile", "side", "back"]`: a rig drawn at
54
+ * in-between angles. The director then turns characters through every drawing in between (a
55
+ * turn on twos, like hand-drawn animation) instead of switching drawings at once.
56
+ */
57
+ order?: string[];
58
+ /**
59
+ * The view a character is drawn in crossing the frame (running across it): side-on enough to read
60
+ * the move, the face still showing. The director turns runners to it and back on arrival.
61
+ */
62
+ travel?: string;
63
+ }
64
+ /** Rotation kept by `still` bones in front/back views. */
65
+ export declare const STILL_MIX = 0.15;
66
+ export declare function withViews(base: ToonDoc, spec: ViewSpec): ToonDoc;
67
+ export {};
68
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;;;;;;;;;GAWG;AAEH,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/B,2FAA2F;AAC3F,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,QAAQ;IACvB,iFAAiF;IACjF,IAAI,EAAE;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACrC,KAAK,EAAE;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAA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1
+ import { restAngle } from "./util.js";
2
+ /** World angle of a bone's parent frame in the rest pose. */
3
+ function parentAngle(doc, id) {
4
+ const b = doc.skeleton.find((x) => x.id === id);
5
+ return b?.parent ? restAngle(doc.skeleton, b.parent) : 0;
6
+ }
7
+ /** The views a spec draws (every view named anywhere in it, the profile aside), in the spec's order. */
8
+ function specViews(spec) {
9
+ const keys = [spec.parts, spec.move, spec.hide, spec.rotate ?? {}, spec.extra ?? {}, spec.still ?? {}].flatMap((o) => Object.keys(o));
10
+ return [...new Set(keys)].filter((v) => v !== "profile");
11
+ }
12
+ const r = (n) => Math.round(n * 100) / 100;
13
+ /** Rotation kept by `still` bones in front/back views. */
14
+ export const STILL_MIX = 0.15;
15
+ export function withViews(base, spec) {
16
+ const doc = structuredClone(base);
17
+ const headIdx = doc.skeleton.findIndex((b) => b.id === "head");
18
+ // Feature bones (zero length, children of the head).
19
+ doc.skeleton.splice(headIdx + 1, 0, { id: "eyesB", parent: "head", from: spec.eyes.center }, { id: "mouthB", parent: "head", from: spec.mouth.center });
20
+ const pupils = doc.skeleton.find((b) => b.id === "pupils");
21
+ if (pupils)
22
+ pupils.parent = "eyesB";
23
+ for (const p of doc.parts) {
24
+ if (spec.eyes.parts.includes(p.id))
25
+ p.bone = "eyesB";
26
+ if (spec.mouth.parts.includes(p.id))
27
+ p.bone = "mouthB";
28
+ }
29
+ // The views the spec draws: only those get a switch variant and a pose (a rig without a `back`
30
+ // drawing has no `back` view).
31
+ const names = specViews(spec);
32
+ // View selector.
33
+ doc.art.viewNone = "<g/>";
34
+ doc.parts.unshift({ id: "view", type: "switch", bone: "root", variants: Object.fromEntries(["profile", ...names].map((v) => [v, "viewNone"])), default: "profile" });
35
+ for (const p of doc.parts)
36
+ if (spec.profileOnly.includes(p.id))
37
+ p.visibleWhen = { part: "view", variant: "profile" };
38
+ // From behind, the far arm is no longer hidden by the body: draw a copy of it on top.
39
+ const farArm = names.includes("back") ? doc.parts.filter((p) => (spec.farArm ?? []).includes(p.id)) : [];
40
+ if (farArm.length) {
41
+ spec.parts.back = [...(spec.parts.back ?? []), ...farArm.map((p) => ({ part: { ...structuredClone(p), id: `${p.id}Back` } }))];
42
+ spec.hide.back = [...(spec.hide.back ?? []), ...(spec.farArm ?? [])];
43
+ }
44
+ for (const view of names) {
45
+ for (const { before, part } of spec.parts[view] ?? []) {
46
+ const at = before ? doc.parts.findIndex((p) => p.id === before) : -1;
47
+ // Shown in its view only; a part with its own switch condition (irises with open eyes) keeps
48
+ // it, the view gate added as the second condition.
49
+ const gate = { part: "view", variant: view };
50
+ const own = part.visibleWhen;
51
+ if (own?.and)
52
+ throw new Error(`${doc.name}: view part "${part.id}" already has two switch conditions; the view gate needs one of them`);
53
+ const def = { ...part, visibleWhen: own ? { ...own, and: gate } : gate };
54
+ if (at < 0)
55
+ doc.parts.push(def);
56
+ else
57
+ doc.parts.splice(at, 0, def);
58
+ }
59
+ }
60
+ if (spec.mouths?.length)
61
+ doc.controls.mouth = { type: "viseme", part: ["mouth", ...spec.mouths] };
62
+ // The view pose control.
63
+ const poses = { profile: { "parts.view.variant": "profile" } };
64
+ for (const view of names) {
65
+ const pose = { "parts.view.variant": view };
66
+ for (const [bone, [dx, dy]] of Object.entries(spec.move[view] ?? {})) {
67
+ // Screen displacement → offset in the parent's frame (rest pose).
68
+ const a = parentAngle(doc, bone);
69
+ pose[`bones.${bone}.x`] = r(dx * Math.cos(a) + dy * Math.sin(a));
70
+ pose[`bones.${bone}.y`] = r(-dx * Math.sin(a) + dy * Math.cos(a));
71
+ }
72
+ for (const [bone, deg] of Object.entries(spec.rotate?.[view] ?? {}))
73
+ pose[`bones.${bone}.rotation`] = deg;
74
+ // Feet follow the legs that a view moves sideways (IK targets are in setup space).
75
+ const legF = spec.move[view]?.legF1, legB = spec.move[view]?.legB1;
76
+ if (legF)
77
+ pose["ik.footF.x"] = legF[0];
78
+ if (legB)
79
+ pose["ik.footB.x"] = legB[0];
80
+ for (const id of spec.hide[view] ?? [])
81
+ pose[`parts.${id}.opacity`] = -1;
82
+ for (const bone of spec.still?.[view] ?? (view === "front" || view === "back" ? ["head"] : []))
83
+ if (doc.skeleton.some((b) => b.id === bone))
84
+ pose[`bones.${bone}.rotationMix`] = STILL_MIX - 1;
85
+ Object.assign(pose, spec.extra?.[view] ?? {});
86
+ poses[view] = pose;
87
+ }
88
+ doc.controls.view = { type: "pose", poses };
89
+ doc.meta = { ...(doc.meta ?? {}), views: { move: spec.move, ...(spec.order ? { order: spec.order } : {}), ...(spec.travel ? { travel: spec.travel } : {}) } };
90
+ return doc;
91
+ }
92
+ //# sourceMappingURL=views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AA2DnC,6DAA6D;AAC7D,SAAS,WAAW,CAAC,GAAQ,EAAE,EAAU;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,wGAAwG;AACxG,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACtI,OAAO,CAAC,GAAG,IAA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ACrB,CAAC;IACD,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC5C,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC9J,OAAO,GAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Turnarounds from volumes: a character piece (head, hair, torso…) is modelled as a signed
3
+ * distance function in 3D — ellipsoids, capsules and tapers blended together, cut by planes — and
4
+ * drawn from any angle around the vertical axis as flat cartoon shapes: the silhouette of the
5
+ * piece (ray marched on a grid, traced with marching squares, smoothed into curves), its colour
6
+ * regions (a stripe, a collar, a bib…) and what lies in front of another piece (the hair over the
7
+ * forehead). Features drawn on a surface (eyes, brows, mouth) are projected from the front view.
8
+ *
9
+ * Model space is the front view (looking at the camera): x to the right of the screen, y down
10
+ * (feet at y = 0), z towards the camera. A view turns the model by a yaw around the vertical
11
+ * axis x = 0: positive angles turn the face towards +x (a three-quarter view facing right).
12
+ * Everything is deterministic and runs once, when the character is built.
13
+ */
14
+ export type V3 = [number, number, number];
15
+ export type P2 = [number, number];
16
+ /** Signed distance (approximate): negative inside. */
17
+ export type Sdf = (x: number, y: number, z: number) => number;
18
+ export declare const smoothstep: (a: number, b: number, v: number) => number;
19
+ export declare function ellipsoid(c: V3, rad: V3): Sdf;
20
+ export declare function sphere(c: V3, rad: number): Sdf;
21
+ /** A rounded cylinder from a to b (radius `ra` at a, `rb` at b). */
22
+ export declare function capsule(a: V3, b: V3, ra: number, rb?: number): Sdf;
23
+ /** A box with rounded edges (`round`), centred on `c`, half sizes `h`. */
24
+ export declare function box(c: V3, h: V3, round?: number): Sdf;
25
+ /**
26
+ * An elliptic cylinder between heights y0 (top) and y1 (bottom) whose half width / half depth go
27
+ * from `top` to `bottom` (skirts, aprons, sleeves); `fwd` moves the centre towards the camera.
28
+ */
29
+ export declare function taper(y0: number, y1: number, top: P2, bottom: P2, fwd?: number, cx?: number): Sdf;
30
+ export declare const union: (...fs: Sdf[]) => Sdf;
31
+ /** Union blended over a distance `k` (soft cartoon joints). */
32
+ export declare const blend: (k: number, ...fs: Sdf[]) => Sdf;
33
+ export declare const intersect: (...fs: Sdf[]) => Sdf;
34
+ export declare const subtract: (a: Sdf, b: Sdf) => Sdf;
35
+ /** Grows (positive) or shrinks a volume. */
36
+ export declare const grow: (f: Sdf, g: number) => Sdf;
37
+ /** Keeps the part above a height that may depend on x and z (inside where y < top(x, z)). */
38
+ export declare const above: (f: Sdf, top: (x: number, z: number) => number) => Sdf;
39
+ export declare const below: (f: Sdf, bottom: (x: number, z: number) => number) => Sdf;
40
+ /** Bumpy surface (curls, an afro, a perm): small waves of amplitude `amp` and wavelength `size`. */
41
+ export declare const bumpy: (f: Sdf, amp: number, size: number) => Sdf;
42
+ /**
43
+ * A view of a volume: turned by `yaw` around the vertical axis (positive turns the model's front
44
+ * towards +x), seen from `pitch` above (radians; positive looks down at it: tops show). A number is a
45
+ * yaw with no pitch.
46
+ */
47
+ export interface View {
48
+ yaw: number;
49
+ pitch: number;
50
+ /** Screen offset down of the drawing (a part drawn at its own pitch, put back where the camera's pitch puts its pivot). */
51
+ dy?: number;
52
+ }
53
+ export type ViewLike = number | View;
54
+ export declare const toView: (v: ViewLike) => View;
55
+ /** Model point → view space: screen x, screen y (down), depth (larger = nearer the camera). */
56
+ export declare function toCam(p: V3, view: ViewLike): V3;
57
+ /** View space → model point. */
58
+ export declare function fromCam(X: number, Y: number, Z: number, view: ViewLike): V3;
59
+ /** Screen position of a model point in a view. */
60
+ export declare function project(p: V3, view: ViewLike): P2;
61
+ /** Depth of a model point in a view (larger = nearer the camera). */
62
+ export declare const depthOf: (p: V3, view: ViewLike) => number;
63
+ export interface Box3 {
64
+ x: [number, number];
65
+ y: [number, number];
66
+ z: [number, number];
67
+ }
68
+ export interface Grid {
69
+ w: number;
70
+ h: number;
71
+ x0: number;
72
+ y0: number;
73
+ step: number;
74
+ }
75
+ export interface Cast {
76
+ /** Silhouette field: negative inside (how deep the ray goes), positive outside (closest miss). */
77
+ val: Float32Array;
78
+ /** Depth of the first hit (−Infinity where the ray misses). */
79
+ depth: Float32Array;
80
+ /** Model point of the first hit (x, y, z per cell; NaN where the ray misses). */
81
+ hit: Float32Array;
82
+ }
83
+ /** The screen grid covering a set of model boxes in a view. */
84
+ export declare function gridFor(boxes: Box3[], view: ViewLike, step: number): Grid & {
85
+ zr: [number, number];
86
+ };
87
+ /** Ray marches a volume on a view's grid. */
88
+ export declare function cast(f: Sdf, g: Grid & {
89
+ zr: [number, number];
90
+ }, view: ViewLike): Cast;
91
+ export { contours, curvePath, fieldPath, smoothPath } from "@anime-studio/core";
92
+ /** The front surface point of a volume at (x, y) of the front view (undefined if it misses). */
93
+ export declare function surfaceZ(f: Sdf, x: number, y: number, zFrom?: number): number | undefined;
94
+ /** Normal of a volume (numeric gradient over `e`: a larger `e` smooths small bumps away). */
95
+ export declare function normal(f: Sdf, p: V3, e?: number): V3;
96
+ /**
97
+ * Maps front-view points drawn on a surface to a view: each point is put on the surface (plus
98
+ * `lift` along z) and turned. `visible` is false when the surface there faces away.
99
+ */
100
+ export declare function onSurface(f: Sdf, theta: ViewLike): {
101
+ point(x: number, y: number, lift?: number): P2;
102
+ /** Facing the camera at least `min` (0 = edge on, 1 = straight at it). */
103
+ visible(x: number, y: number, min?: number): boolean;
104
+ };
105
+ //# sourceMappingURL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AAED,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAM,GAAG,EAAE,CAMjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ;IAW7C,KAAK,IAAI,MAAM,KAAK,MAAM,kBAAa,EAAE;IAIzC,0EAA0E;IAC1E,OAAO,IAAI,MAAM,KAAK,MAAM;EAO/B"}
package/dist/volume.js ADDED
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Turnarounds from volumes: a character piece (head, hair, torso…) is modelled as a signed
3
+ * distance function in 3D — ellipsoids, capsules and tapers blended together, cut by planes — and
4
+ * drawn from any angle around the vertical axis as flat cartoon shapes: the silhouette of the
5
+ * piece (ray marched on a grid, traced with marching squares, smoothed into curves), its colour
6
+ * regions (a stripe, a collar, a bib…) and what lies in front of another piece (the hair over the
7
+ * forehead). Features drawn on a surface (eyes, brows, mouth) are projected from the front view.
8
+ *
9
+ * Model space is the front view (looking at the camera): x to the right of the screen, y down
10
+ * (feet at y = 0), z towards the camera. A view turns the model by a yaw around the vertical
11
+ * axis x = 0: positive angles turn the face towards +x (a three-quarter view facing right).
12
+ * Everything is deterministic and runs once, when the character is built.
13
+ */
14
+ import { refineEdges } from "@anime-studio/core";
15
+ const r2 = (n) => Math.round(n * 100) / 100;
16
+ const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
17
+ export const smoothstep = (a, b, v) => {
18
+ const t = clamp((v - a) / (b - a), 0, 1);
19
+ return t * t * (3 - 2 * t);
20
+ };
21
+ // ------------------------------------------------------------------ primitives
22
+ export function ellipsoid(c, rad) {
23
+ const [cx, cy, cz] = c, [rx, ry, rz] = rad;
24
+ return (x, y, z) => {
25
+ const px = (x - cx) / rx, py = (y - cy) / ry, pz = (z - cz) / rz;
26
+ const k0 = Math.sqrt(px * px + py * py + pz * pz);
27
+ const k1 = Math.sqrt((px / rx) ** 2 + (py / ry) ** 2 + (pz / rz) ** 2);
28
+ return k1 === 0 ? -Math.min(rx, ry, rz) : (k0 * (k0 - 1)) / k1;
29
+ };
30
+ }
31
+ export function sphere(c, rad) {
32
+ return (x, y, z) => Math.hypot(x - c[0], y - c[1], z - c[2]) - rad;
33
+ }
34
+ /** A rounded cylinder from a to b (radius `ra` at a, `rb` at b). */
35
+ export function capsule(a, b, ra, rb = ra) {
36
+ const bx = b[0] - a[0], by = b[1] - a[1], bz = b[2] - a[2];
37
+ const ll = bx * bx + by * by + bz * bz || 1;
38
+ return (x, y, z) => {
39
+ const px = x - a[0], py = y - a[1], pz = z - a[2];
40
+ const h = clamp((px * bx + py * by + pz * bz) / ll, 0, 1);
41
+ return Math.hypot(px - bx * h, py - by * h, pz - bz * h) - (ra + (rb - ra) * h);
42
+ };
43
+ }
44
+ /** A box with rounded edges (`round`), centred on `c`, half sizes `h`. */
45
+ export function box(c, h, round = 0) {
46
+ return (x, y, z) => {
47
+ const qx = Math.abs(x - c[0]) - h[0] + round, qy = Math.abs(y - c[1]) - h[1] + round, qz = Math.abs(z - c[2]) - h[2] + round;
48
+ return Math.hypot(Math.max(qx, 0), Math.max(qy, 0), Math.max(qz, 0)) + Math.min(Math.max(qx, qy, qz), 0) - round;
49
+ };
50
+ }
51
+ /**
52
+ * An elliptic cylinder between heights y0 (top) and y1 (bottom) whose half width / half depth go
53
+ * from `top` to `bottom` (skirts, aprons, sleeves); `fwd` moves the centre towards the camera.
54
+ */
55
+ export function taper(y0, y1, top, bottom, fwd = 0, cx = 0) {
56
+ return (x, y, z) => {
57
+ const t = clamp((y - y0) / (y1 - y0), 0, 1);
58
+ const a = top[0] + (bottom[0] - top[0]) * t, b = top[1] + (bottom[1] - top[1]) * t;
59
+ const k = Math.hypot((x - cx) / a, (z - fwd) / b);
60
+ const side = (k - 1) * Math.min(a, b);
61
+ return Math.max(side, y0 - y, y - y1);
62
+ };
63
+ }
64
+ export const union = (...fs) => (x, y, z) => {
65
+ let d = Infinity;
66
+ for (const f of fs)
67
+ d = Math.min(d, f(x, y, z));
68
+ return d;
69
+ };
70
+ /** Union blended over a distance `k` (soft cartoon joints). */
71
+ export const blend = (k, ...fs) => (x, y, z) => {
72
+ let d = fs[0](x, y, z);
73
+ for (let i = 1; i < fs.length; i++) {
74
+ const e = fs[i](x, y, z);
75
+ const h = clamp(0.5 + (0.5 * (e - d)) / k, 0, 1);
76
+ d = e * (1 - h) + d * h - k * h * (1 - h);
77
+ }
78
+ return d;
79
+ };
80
+ export const intersect = (...fs) => (x, y, z) => {
81
+ let d = -Infinity;
82
+ for (const f of fs)
83
+ d = Math.max(d, f(x, y, z));
84
+ return d;
85
+ };
86
+ export const subtract = (a, b) => (x, y, z) => Math.max(a(x, y, z), -b(x, y, z));
87
+ /** Grows (positive) or shrinks a volume. */
88
+ export const grow = (f, g) => (x, y, z) => f(x, y, z) - g;
89
+ /** Keeps the part above a height that may depend on x and z (inside where y < top(x, z)). */
90
+ export const above = (f, top) => (x, y, z) => Math.max(f(x, y, z), y - top(x, z));
91
+ export const below = (f, bottom) => (x, y, z) => Math.max(f(x, y, z), bottom(x, z) - y);
92
+ /** Bumpy surface (curls, an afro, a perm): small waves of amplitude `amp` and wavelength `size`. */
93
+ export const bumpy = (f, amp, size) => {
94
+ const k = (2 * Math.PI) / size;
95
+ return (x, y, z) => f(x, y, z) - amp * (Math.sin(x * k + 1.3) * Math.sin(y * k * 1.1 + 0.7) * Math.sin(z * k * 0.9 + 2.1));
96
+ };
97
+ export const toView = (v) => (typeof v === "number" ? { yaw: v, pitch: 0 } : v);
98
+ /** Model point → view space: screen x, screen y (down), depth (larger = nearer the camera). */
99
+ export function toCam(p, view) {
100
+ const { yaw, pitch } = toView(view);
101
+ const cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
102
+ const X = p[0] * cy + p[2] * sy, Z = -p[0] * sy + p[2] * cy;
103
+ return [X, p[1] * cp + Z * sp, -p[1] * sp + Z * cp];
104
+ }
105
+ /** View space → model point. */
106
+ export function fromCam(X, Y, Z, view) {
107
+ const { yaw, pitch } = toView(view);
108
+ const cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
109
+ const y = Y * cp - Z * sp, Zy = Y * sp + Z * cp;
110
+ return [X * cy - Zy * sy, y, X * sy + Zy * cy];
111
+ }
112
+ /** Screen position of a model point in a view. */
113
+ export function project(p, view) {
114
+ const c = toCam(p, view);
115
+ return [c[0], c[1] + (toView(view).dy ?? 0)];
116
+ }
117
+ /** Depth of a model point in a view (larger = nearer the camera). */
118
+ export const depthOf = (p, view) => toCam(p, view)[2];
119
+ /** The screen grid covering a set of model boxes in a view. */
120
+ export function gridFor(boxes, view, step) {
121
+ let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity, z0 = Infinity, z1 = -Infinity;
122
+ for (const b of boxes)
123
+ for (const x of b.x)
124
+ for (const y of b.y)
125
+ for (const z of b.z) {
126
+ const [X, Y0, Z] = toCam([x, y, z], view);
127
+ const Y = Y0 + (toView(view).dy ?? 0);
128
+ x0 = Math.min(x0, X);
129
+ x1 = Math.max(x1, X);
130
+ y0 = Math.min(y0, Y);
131
+ y1 = Math.max(y1, Y);
132
+ z0 = Math.min(z0, Z);
133
+ z1 = Math.max(z1, Z);
134
+ }
135
+ // One empty cell all around: every traced outline closes.
136
+ x0 = Math.floor(x0 / step - 2) * step;
137
+ y0 = Math.floor(y0 / step - 2) * step;
138
+ return { x0, y0, w: Math.ceil((x1 - x0) / step) + 3, h: Math.ceil((y1 - y0) / step) + 3, step, zr: [z0 - step, z1 + step] };
139
+ }
140
+ /** Ray marches a volume on a view's grid. */
141
+ export function cast(f, g, view) {
142
+ const n = g.w * g.h;
143
+ const val = new Float32Array(n), depth = new Float32Array(n).fill(-Infinity), hit = new Float32Array(n * 3).fill(NaN);
144
+ const { yaw, pitch, dy = 0 } = toView(view);
145
+ const cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
146
+ const [zmin, zmax] = g.zr;
147
+ const minStep = g.step * 0.25;
148
+ for (let j = 0; j < g.h; j++) {
149
+ const Y = g.y0 + j * g.step - dy;
150
+ for (let i = 0; i < g.w; i++) {
151
+ const X = g.x0 + i * g.step;
152
+ const k = j * g.w + i;
153
+ let Z = zmax, closest = Infinity, deepest = 0, entered = false;
154
+ while (Z > zmin) {
155
+ const y = Y * cp - Z * sp, Zy = Y * sp + Z * cp;
156
+ const x = X * cy - Zy * sy, z = X * sy + Zy * cy;
157
+ const d = f(x, y, z);
158
+ if (d < closest)
159
+ closest = d;
160
+ if (d <= 0) {
161
+ if (!entered) {
162
+ entered = true;
163
+ depth[k] = Z;
164
+ hit[k * 3] = x;
165
+ hit[k * 3 + 1] = y;
166
+ hit[k * 3 + 2] = z;
167
+ }
168
+ if (-d > deepest)
169
+ deepest = -d;
170
+ Z -= Math.max(minStep, -d * 0.8);
171
+ }
172
+ else
173
+ Z -= Math.max(minStep, d * 0.8);
174
+ }
175
+ val[k] = entered ? -Math.max(deepest, 0.05) : closest;
176
+ }
177
+ }
178
+ // (The crossing put on the silhouette: a clean outline.)
179
+ refineEdges(val, g.w, g.h, g.step);
180
+ return { val, depth, hit };
181
+ }
182
+ // ------------------------------------------------------------------ outlines
183
+ export { contours, curvePath, fieldPath, smoothPath } from "@anime-studio/core";
184
+ // ------------------------------------------------------------------ surfaces
185
+ /** The front surface point of a volume at (x, y) of the front view (undefined if it misses). */
186
+ export function surfaceZ(f, x, y, zFrom = 400) {
187
+ let z = zFrom;
188
+ for (let i = 0; i < 200 && z > -zFrom; i++) {
189
+ const d = f(x, y, z);
190
+ if (d < 0.05)
191
+ return z;
192
+ z -= Math.max(0.3, d * 0.9);
193
+ }
194
+ return undefined;
195
+ }
196
+ /** Normal of a volume (numeric gradient over `e`: a larger `e` smooths small bumps away). */
197
+ export function normal(f, p, e = 0.5) {
198
+ const nx = f(p[0] + e, p[1], p[2]) - f(p[0] - e, p[1], p[2]);
199
+ const ny = f(p[0], p[1] + e, p[2]) - f(p[0], p[1] - e, p[2]);
200
+ const nz = f(p[0], p[1], p[2] + e) - f(p[0], p[1], p[2] - e);
201
+ const l = Math.hypot(nx, ny, nz) || 1;
202
+ return [nx / l, ny / l, nz / l];
203
+ }
204
+ /**
205
+ * Maps front-view points drawn on a surface to a view: each point is put on the surface (plus
206
+ * `lift` along z) and turned. `visible` is false when the surface there faces away.
207
+ */
208
+ export function onSurface(f, theta) {
209
+ const cache = new Map();
210
+ const lift3 = (x, y, lift) => {
211
+ const key = `${r2(x)},${r2(y)},${lift}`;
212
+ if (cache.has(key))
213
+ return cache.get(key);
214
+ const z = surfaceZ(f, x, y);
215
+ const p = z === undefined ? null : [x, y, z + lift];
216
+ cache.set(key, p);
217
+ return p;
218
+ };
219
+ return {
220
+ point(x, y, lift = 0) {
221
+ const p = lift3(x, y, lift);
222
+ return p ? project(p, theta) : project([x, y, 0], theta);
223
+ },
224
+ /** Facing the camera at least `min` (0 = edge on, 1 = straight at it). */
225
+ visible(x, y, min = 0.12) {
226
+ const p = lift3(x, y, 0);
227
+ if (!p)
228
+ return false;
229
+ const n = normal(f, p);
230
+ return depthOf(n, theta) > min;
231
+ },
232
+ };
233
+ }
234
+ //# sourceMappingURL=volume.js.map