@anime-studio/core 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 +58 -2
- package/dist/camera.d.ts +172 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/camera.js +219 -0
- package/dist/camera.js.map +1 -0
- package/dist/debug.d.ts +90 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +262 -0
- package/dist/debug.js.map +1 -0
- package/dist/easing.d.ts +8 -0
- package/dist/easing.d.ts.map +1 -0
- package/dist/easing.js +109 -0
- package/dist/easing.js.map +1 -0
- package/dist/fall.d.ts +216 -0
- package/dist/fall.d.ts.map +1 -0
- package/dist/fall.js +521 -0
- package/dist/fall.js.map +1 -0
- package/dist/field.d.ts +43 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +370 -0
- package/dist/field.js.map +1 -0
- package/dist/format/schema.d.ts +2052 -0
- package/dist/format/schema.d.ts.map +1 -0
- package/dist/format/schema.js +857 -0
- package/dist/format/schema.js.map +1 -0
- package/dist/format/validate.d.ts +35 -0
- package/dist/format/validate.d.ts.map +1 -0
- package/dist/format/validate.js +113 -0
- package/dist/format/validate.js.map +1 -0
- package/dist/fx.d.ts +37 -0
- package/dist/fx.d.ts.map +1 -0
- package/dist/fx.js +346 -0
- package/dist/fx.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/keyframes.d.ts +43 -0
- package/dist/keyframes.d.ts.map +1 -0
- package/dist/keyframes.js +171 -0
- package/dist/keyframes.js.map +1 -0
- package/dist/lighting.d.ts +90 -0
- package/dist/lighting.d.ts.map +1 -0
- package/dist/lighting.js +218 -0
- package/dist/lighting.js.map +1 -0
- package/dist/lipsync.d.ts +44 -0
- package/dist/lipsync.d.ts.map +1 -0
- package/dist/lipsync.js +178 -0
- package/dist/lipsync.js.map +1 -0
- package/dist/math.d.ts +45 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +118 -0
- package/dist/math.js.map +1 -0
- package/dist/paths.d.ts +38 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +277 -0
- package/dist/paths.js.map +1 -0
- package/dist/physics.d.ts +74 -0
- package/dist/physics.d.ts.map +1 -0
- package/dist/physics.js +224 -0
- package/dist/physics.js.map +1 -0
- package/dist/pose.d.ts +130 -0
- package/dist/pose.d.ts.map +1 -0
- package/dist/pose.js +579 -0
- package/dist/pose.js.map +1 -0
- package/dist/pose3d.d.ts +211 -0
- package/dist/pose3d.d.ts.map +1 -0
- package/dist/pose3d.js +1156 -0
- package/dist/pose3d.js.map +1 -0
- package/dist/preview.d.ts +18 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +28 -0
- package/dist/preview.js.map +1 -0
- package/dist/render.d.ts +50 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +238 -0
- package/dist/render.js.map +1 -0
- package/dist/rig.d.ts +266 -0
- package/dist/rig.d.ts.map +1 -0
- package/dist/rig.js +591 -0
- package/dist/rig.js.map +1 -0
- package/dist/scene.d.ts +336 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +2761 -0
- package/dist/scene.js.map +1 -0
- package/dist/sequence.d.ts +80 -0
- package/dist/sequence.d.ts.map +1 -0
- package/dist/sequence.js +183 -0
- package/dist/sequence.js.map +1 -0
- package/dist/solid.d.ts +79 -0
- package/dist/solid.d.ts.map +1 -0
- package/dist/solid.js +445 -0
- package/dist/solid.js.map +1 -0
- package/dist/surface.d.ts +15 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +45 -0
- package/dist/surface.js.map +1 -0
- package/dist/transitions.d.ts +26 -0
- package/dist/transitions.d.ts.map +1 -0
- package/dist/transitions.js +50 -0
- package/dist/transitions.js.map +1 -0
- package/package.json +45 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dener Fernandes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @anime-studio/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@anime-studio/core)
|
|
4
|
+
[](https://github.com/denerFernandes/animeStudio/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/denerFernandes/animeStudio/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
Part of [animeStudio](https://github.com/denerFernandes/animeStudio), a deterministic 2D/2.5D cartoon animation engine: characters are
|
|
8
|
+
SVG art bound to skeletons, scenes are JSON documents, and every frame is a pure function of the
|
|
9
|
+
documents and the time.
|
|
10
|
+
|
|
11
|
+
The engine itself: the JSON formats (`*.toon.json`, `*.scene.json`, `*.sequence.json`) and their validation, rigs with IK, physics and squash & stretch, 2D and 2.5D poses, scenes, camera, lighting, FX and rendering to SVG.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @anime-studio/core @anime-studio/kit
|
|
17
|
+
# or
|
|
18
|
+
pnpm add @anime-studio/core @anime-studio/kit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires Node.js 22 or later (or a modern browser / bundler). The packages are ES modules with
|
|
22
|
+
TypeScript types included.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { writeFileSync } from "node:fs";
|
|
28
|
+
import { compileScene, evaluateScene, frameToSVG } from "@anime-studio/core";
|
|
29
|
+
import { cartoonCharacter } from "@anime-studio/kit";
|
|
30
|
+
|
|
31
|
+
// A character from a short description.
|
|
32
|
+
const maya = cartoonCharacter({
|
|
33
|
+
name: "Maya", build: "woman", female: true, skin: "#a8704f",
|
|
34
|
+
hair: "puffs", hairColor: "#2a1b14", top: "jacket", topColor: "#ff6b5b",
|
|
35
|
+
bottom: "pants", bottomColor: "#2f3a5c", shoes: "sneakers", shoeColor: "#f4f1ea",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// A scene: one actor waving. Every frame is a pure function of the documents and the time.
|
|
39
|
+
const scene = compileScene({
|
|
40
|
+
format: "toon-scene", version: 1, width: 1280, height: 720, fps: 30, duration: 3,
|
|
41
|
+
characters: { maya: "maya.toon.json" },
|
|
42
|
+
actors: [{ id: "maya", character: "maya", x: 640, y: 680 }],
|
|
43
|
+
script: [{ at: 0, actor: "maya", action: "play", clip: "wave" }],
|
|
44
|
+
}, { characters: { maya } });
|
|
45
|
+
|
|
46
|
+
writeFileSync("frame.svg", frameToSVG(evaluateScene(scene, 1.2)));
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Documentation
|
|
50
|
+
|
|
51
|
+
- [Getting started and features](https://github.com/denerFernandes/animeStudio#readme)
|
|
52
|
+
- [Format specification](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md)
|
|
53
|
+
- [API reference](https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md)
|
|
54
|
+
- [Authoring guide for AI agents](https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md)
|
|
55
|
+
- [Changelog](https://github.com/denerFernandes/animeStudio/blob/master/CHANGELOG.md)
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT © Dener Fernandes
|
package/dist/camera.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type Ease } from "./easing.js";
|
|
2
|
+
import { type Mat, type Vec2 } from "./math.js";
|
|
3
|
+
import type { Rig } from "./rig.js";
|
|
4
|
+
/**
|
|
5
|
+
* Advanced camera: smoothed follows (dead zone, look-ahead), automatic framing, curved paths,
|
|
6
|
+
* punch-in zooms, handheld drift, dolly ("vertigo") zoom, scene bounds, depth of field and motion
|
|
7
|
+
* blur. Everything is deterministic: stateful smoothing is baked at a fixed rate and cached.
|
|
8
|
+
*/
|
|
9
|
+
export interface CameraState {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
zoom: number;
|
|
13
|
+
rotation: number;
|
|
14
|
+
/** Background scale relative to the subject (parallax depth): > 0 = vertigo "dolly out". */
|
|
15
|
+
dolly: number;
|
|
16
|
+
/** Depth (parallax) in focus. */
|
|
17
|
+
focus: number;
|
|
18
|
+
/** Max depth-of-field blur in screen px (0 = off). */
|
|
19
|
+
blur: number;
|
|
20
|
+
/** Depth distance at which blur reaches `blur`. */
|
|
21
|
+
focusRange: number;
|
|
22
|
+
/** Motion blur shutter (0 = off, 1 = full frame). */
|
|
23
|
+
motionBlur: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CameraFollow {
|
|
26
|
+
actor: string;
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
offset: Vec2;
|
|
30
|
+
lag: number;
|
|
31
|
+
axes: "x" | "xy";
|
|
32
|
+
/** Half size (scene px) of the zone the actor can move in without moving the camera. */
|
|
33
|
+
deadZone: Vec2;
|
|
34
|
+
/** Seconds of velocity to lead by (frames the space the actor moves into). */
|
|
35
|
+
lookAhead: number;
|
|
36
|
+
blend: number;
|
|
37
|
+
/** Lazily baked camera positions at 60 Hz. */
|
|
38
|
+
samples?: Float64Array;
|
|
39
|
+
}
|
|
40
|
+
export interface CameraFrame {
|
|
41
|
+
targets: string[];
|
|
42
|
+
start: number;
|
|
43
|
+
end: number;
|
|
44
|
+
padding: number;
|
|
45
|
+
blend: number;
|
|
46
|
+
minZoom: number;
|
|
47
|
+
maxZoom: number;
|
|
48
|
+
/** Smoothing lag (s): framing eases towards its target instead of popping (e.g. on a flip). */
|
|
49
|
+
lag: number;
|
|
50
|
+
/** Frame whole bodies (default) or just the faces. */
|
|
51
|
+
on?: "body" | "face";
|
|
52
|
+
/** Fixed vertical extent [top, bottom] of the framed box (horizontal framing only). */
|
|
53
|
+
band?: [number, number];
|
|
54
|
+
/** Lazily baked smoothed framing [x, y, zoom] at 60 Hz. */
|
|
55
|
+
samples?: Float64Array;
|
|
56
|
+
}
|
|
57
|
+
/** Bakes a frame rig's smoothed target (x, y, log-zoom exponential smoothing). */
|
|
58
|
+
/**
|
|
59
|
+
* One step of a critically damped spring towards `target` (Game Programming Gems 4, "Critically
|
|
60
|
+
* Damped Ease-In/Ease-Out Smoothing"; Unity's SmoothDamp): `lag` is the smoothing time. Unlike an
|
|
61
|
+
* exponential lag, the velocity never jumps — a camera starting to track, or a target that moves
|
|
62
|
+
* suddenly (a character turning round, a head bobbing on a run), eases in and out instead of
|
|
63
|
+
* jolting, and quick wobbles are filtered out. Returns the new value and velocity.
|
|
64
|
+
*/
|
|
65
|
+
export declare function smoothDamp(cur: number, target: number, vel: number, lag: number, dt: number): [number, number];
|
|
66
|
+
export declare function bakeFrame(frame: CameraFrame, duration: number, fitAt: (t: number) => {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
zoom: number;
|
|
70
|
+
} | null): Float64Array;
|
|
71
|
+
export declare function sampleFrame(samples: Float64Array, start: number, t: number): {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
zoom: number;
|
|
75
|
+
} | null;
|
|
76
|
+
export interface CameraPath {
|
|
77
|
+
start: number;
|
|
78
|
+
duration: number;
|
|
79
|
+
ease: Ease;
|
|
80
|
+
/** Points including the starting position. */
|
|
81
|
+
points: Vec2[];
|
|
82
|
+
}
|
|
83
|
+
export interface CameraPunch {
|
|
84
|
+
start: number;
|
|
85
|
+
duration: number;
|
|
86
|
+
amount: number;
|
|
87
|
+
}
|
|
88
|
+
export interface CameraBounds {
|
|
89
|
+
minX: number;
|
|
90
|
+
minY: number;
|
|
91
|
+
maxX: number;
|
|
92
|
+
maxY: number;
|
|
93
|
+
}
|
|
94
|
+
/** Bakes a follow's smoothed camera position (dead zone, look-ahead, critically damped lag). */
|
|
95
|
+
export declare function bakeFollow(follow: CameraFollow, duration: number, actorPosition: (t: number) => Vec2): Float64Array;
|
|
96
|
+
export declare function sampleFollow(samples: Float64Array, start: number, t: number): Vec2;
|
|
97
|
+
/** Weight of a timed camera rig (ramps in after `start`, out after `end`). */
|
|
98
|
+
export declare function rigWeight(start: number, end: number, blend: number, t: number): number;
|
|
99
|
+
export declare function rigBounds(rig: Rig): [number, number, number, number];
|
|
100
|
+
/** Camera center/zoom that fits a scene-space box with padding. */
|
|
101
|
+
export declare function fitBox(box: [number, number, number, number], width: number, height: number, padding: number, minZoom: number, maxZoom: number): {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
zoom: number;
|
|
105
|
+
};
|
|
106
|
+
/** Point along a smooth path through `points` at normalized progress u. */
|
|
107
|
+
export declare function pathPoint(points: Vec2[], u: number): Vec2;
|
|
108
|
+
/** Zoom multiplier of a punch-in: fast attack, springy settle. A punch without a duration (≤ 0) does nothing. */
|
|
109
|
+
export declare function punchFactor(p: CameraPunch, t: number): number;
|
|
110
|
+
/** Continuous handheld drift (deterministic noise), `amount` in screen px. */
|
|
111
|
+
export declare function handheldOffset(amount: number, t: number, seed?: number): {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
rotation: number;
|
|
115
|
+
};
|
|
116
|
+
export declare function clampToBounds(state: CameraState, b: CameraBounds | undefined, width: number, height: number): void;
|
|
117
|
+
/** Depth-of-field blur (screen px) for an item at parallax depth `depth`. */
|
|
118
|
+
export declare function depthBlur(cam: CameraState, depth: number): number;
|
|
119
|
+
/**
|
|
120
|
+
* Blur (depth of field + motion blur) as a CSS `filter: blur(px)` value in screen pixels.
|
|
121
|
+
* SVG `filter="url(#…)"` references proved unreliable in frame-by-frame capture: when an element's
|
|
122
|
+
* filter reference changed between frames (motion blur crossing its threshold, depth blur levels),
|
|
123
|
+
* Chrome sometimes skipped painting it, so elements flickered. A numeric CSS blur updates cleanly.
|
|
124
|
+
* Motion blur is approximated isotropically (direction-independent).
|
|
125
|
+
*/
|
|
126
|
+
export declare function cssBlur(screenX: number, screenY: number): string | undefined;
|
|
127
|
+
/** Screen scale of a matrix (average of axes). */
|
|
128
|
+
export declare const matScale: (m: Mat) => number;
|
|
129
|
+
/** Position part of the camera that segments animate. */
|
|
130
|
+
export interface CameraPose {
|
|
131
|
+
x: number;
|
|
132
|
+
y: number;
|
|
133
|
+
zoom: number;
|
|
134
|
+
rotation: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Director model: every camera action starts a segment that begins from wherever the camera
|
|
138
|
+
* actually is at that moment (no stale positions when switching between moves and rigs).
|
|
139
|
+
*/
|
|
140
|
+
export type CameraSegment = {
|
|
141
|
+
kind: "move";
|
|
142
|
+
start: number;
|
|
143
|
+
duration: number;
|
|
144
|
+
ease: Ease;
|
|
145
|
+
x?: number;
|
|
146
|
+
y?: number;
|
|
147
|
+
zoom?: number;
|
|
148
|
+
rotation?: number;
|
|
149
|
+
from?: CameraPose;
|
|
150
|
+
} | {
|
|
151
|
+
kind: "path";
|
|
152
|
+
start: number;
|
|
153
|
+
duration: number;
|
|
154
|
+
ease: Ease;
|
|
155
|
+
points: Vec2[];
|
|
156
|
+
zoom?: number;
|
|
157
|
+
from?: CameraPose;
|
|
158
|
+
} | {
|
|
159
|
+
kind: "follow";
|
|
160
|
+
start: number;
|
|
161
|
+
follow: CameraFollow;
|
|
162
|
+
zoom?: number;
|
|
163
|
+
} | {
|
|
164
|
+
kind: "frame";
|
|
165
|
+
start: number;
|
|
166
|
+
frame: CameraFrame;
|
|
167
|
+
} | {
|
|
168
|
+
kind: "hold";
|
|
169
|
+
start: number;
|
|
170
|
+
from?: CameraPose;
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAa,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAiD,MAAM,QAAQ,CAAC;AAE5F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,UAAU,EAA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paths.js";
|
|
4
|
+
/** Bakes a frame rig's smoothed target (x, y, log-zoom exponential smoothing). */
|
|
5
|
+
/**
|
|
6
|
+
* One step of a critically damped spring towards `target` (Game Programming Gems 4, "Critically
|
|
7
|
+
* Damped Ease-In/Ease-Out Smoothing"; Unity's SmoothDamp): `lag` is the smoothing time. Unlike an
|
|
8
|
+
* exponential lag, the velocity never jumps — a camera starting to track, or a target that moves
|
|
9
|
+
* suddenly (a character turning round, a head bobbing on a run), eases in and out instead of
|
|
10
|
+
* jolting, and quick wobbles are filtered out. Returns the new value and velocity.
|
|
11
|
+
*/
|
|
12
|
+
export function smoothDamp(cur, target, vel, lag, dt) {
|
|
13
|
+
if (!(lag > 0))
|
|
14
|
+
return [target, 0];
|
|
15
|
+
const omega = 2 / lag;
|
|
16
|
+
const x = omega * dt;
|
|
17
|
+
const e = 1 / (1 + x + 0.48 * x * x + 0.235 * x * x * x);
|
|
18
|
+
const change = cur - target;
|
|
19
|
+
const temp = (vel + omega * change) * dt;
|
|
20
|
+
return [target + (change + temp) * e, (vel - omega * temp) * e];
|
|
21
|
+
}
|
|
22
|
+
export function bakeFrame(frame, duration, fitAt) {
|
|
23
|
+
const n = Math.max(1, Math.ceil((duration - frame.start) * FOLLOW_RATE) + 1);
|
|
24
|
+
const out = new Float64Array(n * 3);
|
|
25
|
+
const dt = 1 / FOLLOW_RATE;
|
|
26
|
+
// Smoothed by a critically damped spring: no jolt when the targets jump. A spring trails a target
|
|
27
|
+
// moving steadily by its speed × lag (in a tight close-up, someone running would leave the shot),
|
|
28
|
+
// so it aims ahead by the target's steady speed: its mean speed over each of the last two `lag`
|
|
29
|
+
// windows, the smaller where both agree (a head bobbing on a run averages out; a jump — someone
|
|
30
|
+
// turning round — is not a speed, and gets no lead).
|
|
31
|
+
let cur = null;
|
|
32
|
+
let vel = { x: 0, y: 0, z: 0 };
|
|
33
|
+
const w = Math.max(1, Math.round(frame.lag * FOLLOW_RATE));
|
|
34
|
+
const fits = [];
|
|
35
|
+
for (let i = 0; i < n; i++) {
|
|
36
|
+
const fit = fitAt(frame.start + i * dt);
|
|
37
|
+
fits.push(fit);
|
|
38
|
+
if (fit) {
|
|
39
|
+
const b1 = i >= w ? fits[i - w] : null, b2 = i >= 2 * w ? fits[i - 2 * w] : null;
|
|
40
|
+
const steady = (a, b, c) => {
|
|
41
|
+
const v1 = a - b, v2 = b - c;
|
|
42
|
+
return v1 * v2 > 0 ? Math.sign(v1) * Math.min(Math.abs(v1), Math.abs(v2)) : 0;
|
|
43
|
+
};
|
|
44
|
+
const k = frame.lag / (w * dt);
|
|
45
|
+
const target = { x: fit.x + (b1 && b2 ? steady(fit.x, b1.x, b2.x) * k : 0), y: fit.y + (b1 && b2 ? steady(fit.y, b1.y, b2.y) * k : 0), z: Math.log(fit.zoom) };
|
|
46
|
+
if (!cur)
|
|
47
|
+
cur = target;
|
|
48
|
+
else {
|
|
49
|
+
const [x, vx] = smoothDamp(cur.x, target.x, vel.x, frame.lag, dt);
|
|
50
|
+
const [y, vy] = smoothDamp(cur.y, target.y, vel.y, frame.lag, dt);
|
|
51
|
+
const [z, vz] = smoothDamp(cur.z, target.z, vel.z, frame.lag, dt);
|
|
52
|
+
cur = { x, y, z };
|
|
53
|
+
vel = { x: vx, y: vy, z: vz };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
out[i * 3] = cur?.x ?? NaN;
|
|
57
|
+
out[i * 3 + 1] = cur?.y ?? NaN;
|
|
58
|
+
out[i * 3 + 2] = cur ? Math.exp(cur.z) : NaN;
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
export function sampleFrame(samples, start, t) {
|
|
63
|
+
const n = samples.length / 3;
|
|
64
|
+
const u = clamp((t - start) * FOLLOW_RATE, 0, n - 1);
|
|
65
|
+
const i = Math.floor(u);
|
|
66
|
+
const j = Math.min(n - 1, i + 1);
|
|
67
|
+
const fr = u - i;
|
|
68
|
+
const x = lerp(samples[i * 3], samples[j * 3], fr);
|
|
69
|
+
if (Number.isNaN(x))
|
|
70
|
+
return null;
|
|
71
|
+
return { x, y: lerp(samples[i * 3 + 1], samples[j * 3 + 1], fr), zoom: lerp(samples[i * 3 + 2], samples[j * 3 + 2], fr) };
|
|
72
|
+
}
|
|
73
|
+
const FOLLOW_RATE = 60;
|
|
74
|
+
/** Bakes a follow's smoothed camera position (dead zone, look-ahead, critically damped lag). */
|
|
75
|
+
export function bakeFollow(follow, duration, actorPosition) {
|
|
76
|
+
const end = Math.min(duration, Number.isFinite(follow.end) ? follow.end + follow.blend : duration);
|
|
77
|
+
const n = Math.max(1, Math.ceil((end - follow.start) * FOLLOW_RATE) + 1);
|
|
78
|
+
const out = new Float64Array(n * 2);
|
|
79
|
+
const dt = 1 / FOLLOW_RATE;
|
|
80
|
+
const desired = (t) => {
|
|
81
|
+
const p = actorPosition(t);
|
|
82
|
+
const q = actorPosition(Math.max(0, t - dt));
|
|
83
|
+
const vx = (p[0] - q[0]) / dt;
|
|
84
|
+
const vy = (p[1] - q[1]) / dt;
|
|
85
|
+
return [p[0] + follow.offset[0] + vx * follow.lookAhead, p[1] + follow.offset[1] + vy * follow.lookAhead];
|
|
86
|
+
};
|
|
87
|
+
let cam = desired(follow.start);
|
|
88
|
+
// (Smoothed by a critically damped spring: the camera eases into and out of the move.)
|
|
89
|
+
const vel = [0, 0];
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
const t = follow.start + i * dt;
|
|
92
|
+
const d = desired(t);
|
|
93
|
+
const goal = [cam[0], cam[1]];
|
|
94
|
+
for (const axis of [0, 1]) {
|
|
95
|
+
const delta = d[axis] - cam[axis];
|
|
96
|
+
const zone = follow.deadZone[axis];
|
|
97
|
+
if (Math.abs(delta) > zone)
|
|
98
|
+
goal[axis] = d[axis] - Math.sign(delta) * zone;
|
|
99
|
+
}
|
|
100
|
+
const [x, vx] = smoothDamp(cam[0], goal[0], vel[0], follow.lag, dt);
|
|
101
|
+
const [y, vy] = smoothDamp(cam[1], goal[1], vel[1], follow.lag, dt);
|
|
102
|
+
cam = [x, y];
|
|
103
|
+
vel[0] = vx;
|
|
104
|
+
vel[1] = vy;
|
|
105
|
+
out[i * 2] = cam[0];
|
|
106
|
+
out[i * 2 + 1] = cam[1];
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
export function sampleFollow(samples, start, t) {
|
|
111
|
+
const n = samples.length / 2;
|
|
112
|
+
const u = clamp((t - start) * FOLLOW_RATE, 0, n - 1);
|
|
113
|
+
const i = Math.floor(u);
|
|
114
|
+
const j = Math.min(n - 1, i + 1);
|
|
115
|
+
const fr = u - i;
|
|
116
|
+
return [lerp(samples[i * 2], samples[j * 2], fr), lerp(samples[i * 2 + 1], samples[j * 2 + 1], fr)];
|
|
117
|
+
}
|
|
118
|
+
/** Weight of a timed camera rig (ramps in after `start`, out after `end`). */
|
|
119
|
+
export function rigWeight(start, end, blend, t) {
|
|
120
|
+
if (t < start)
|
|
121
|
+
return 0;
|
|
122
|
+
const wIn = blend > 0 ? clamp((t - start) / blend, 0, 1) : 1;
|
|
123
|
+
const wOut = Number.isFinite(end) ? (blend > 0 ? 1 - clamp((t - end) / blend, 0, 1) : t < end ? 1 : 0) : 1;
|
|
124
|
+
return getEasing("sineInOut")(Math.min(wIn, wOut));
|
|
125
|
+
}
|
|
126
|
+
/** Bounding box of a character in setup space (bones + margin), cached per rig. */
|
|
127
|
+
const bboxCache = new WeakMap();
|
|
128
|
+
export function rigBounds(rig) {
|
|
129
|
+
let b = bboxCache.get(rig);
|
|
130
|
+
if (!b) {
|
|
131
|
+
let minX = Infinity;
|
|
132
|
+
let minY = Infinity;
|
|
133
|
+
let maxX = -Infinity;
|
|
134
|
+
let maxY = -Infinity;
|
|
135
|
+
for (const bone of rig.bones) {
|
|
136
|
+
for (const p of [apply(bone.setupWorld, [0, 0]), apply(bone.setupWorld, [bone.length, 0])]) {
|
|
137
|
+
minX = Math.min(minX, p[0]);
|
|
138
|
+
minY = Math.min(minY, p[1]);
|
|
139
|
+
maxX = Math.max(maxX, p[0]);
|
|
140
|
+
maxY = Math.max(maxY, p[1]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const m = 30;
|
|
144
|
+
b = [minX - m, Math.min(minY - m, -m), maxX + m, Math.max(maxY, 0) + m / 3];
|
|
145
|
+
bboxCache.set(rig, b);
|
|
146
|
+
}
|
|
147
|
+
return b;
|
|
148
|
+
}
|
|
149
|
+
/** Camera center/zoom that fits a scene-space box with padding. */
|
|
150
|
+
export function fitBox(box, width, height, padding, minZoom, maxZoom) {
|
|
151
|
+
const w = Math.max(1, box[2] - box[0] + padding * 2);
|
|
152
|
+
const h = Math.max(1, box[3] - box[1] + padding * 2);
|
|
153
|
+
const zoom = clamp(Math.min(width / w, height / h), minZoom, maxZoom);
|
|
154
|
+
return { x: (box[0] + box[2]) / 2, y: (box[1] + box[3]) / 2, zoom };
|
|
155
|
+
}
|
|
156
|
+
/** Point along a smooth path through `points` at normalized progress u. */
|
|
157
|
+
export function pathPoint(points, u) {
|
|
158
|
+
if (points.length === 1)
|
|
159
|
+
return points[0];
|
|
160
|
+
const per = 24;
|
|
161
|
+
const pts = sampleCenterline(points, 1, per);
|
|
162
|
+
// Arc-length parameterization so speed follows the easing, not the point spacing.
|
|
163
|
+
const lens = [0];
|
|
164
|
+
for (let i = 1; i < pts.length; i++)
|
|
165
|
+
lens.push(lens[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]));
|
|
166
|
+
const target = clamp(u, 0, 1) * lens[lens.length - 1];
|
|
167
|
+
let i = 1;
|
|
168
|
+
while (i < lens.length - 1 && lens[i] < target)
|
|
169
|
+
i++;
|
|
170
|
+
const seg = lens[i] - lens[i - 1] || 1;
|
|
171
|
+
const fr = (target - lens[i - 1]) / seg;
|
|
172
|
+
return [lerp(pts[i - 1][0], pts[i][0], fr), lerp(pts[i - 1][1], pts[i][1], fr)];
|
|
173
|
+
}
|
|
174
|
+
/** Zoom multiplier of a punch-in: fast attack, springy settle. A punch without a duration (≤ 0) does nothing. */
|
|
175
|
+
export function punchFactor(p, t) {
|
|
176
|
+
if (!(p.duration > 0))
|
|
177
|
+
return 1;
|
|
178
|
+
const u = (t - p.start) / p.duration;
|
|
179
|
+
if (u < 0 || u > 1)
|
|
180
|
+
return 1;
|
|
181
|
+
const attack = 0.18;
|
|
182
|
+
const env = u < attack ? getEasing("easeOut")(u / attack) : Math.exp(-(u - attack) * 5) * Math.cos((u - attack) * 9);
|
|
183
|
+
return 1 + p.amount * env;
|
|
184
|
+
}
|
|
185
|
+
/** Continuous handheld drift (deterministic noise), `amount` in screen px. */
|
|
186
|
+
export function handheldOffset(amount, t, seed = 7) {
|
|
187
|
+
if (amount <= 0)
|
|
188
|
+
return { x: 0, y: 0, rotation: 0 };
|
|
189
|
+
const n = (s, freq) => noise1(seed + s, t * freq) * 0.7 + noise1(seed + s + 101, t * freq * 2.3) * 0.3;
|
|
190
|
+
return { x: n(1, 0.6) * amount, y: n(2, 0.5) * amount * 0.7, rotation: n(3, 0.4) * amount * 0.04 };
|
|
191
|
+
}
|
|
192
|
+
export function clampToBounds(state, b, width, height) {
|
|
193
|
+
if (!b)
|
|
194
|
+
return;
|
|
195
|
+
const hw = width / 2 / state.zoom;
|
|
196
|
+
const hh = height / 2 / state.zoom;
|
|
197
|
+
state.x = b.maxX - b.minX < hw * 2 ? (b.minX + b.maxX) / 2 : clamp(state.x, b.minX + hw, b.maxX - hw);
|
|
198
|
+
state.y = b.maxY - b.minY < hh * 2 ? (b.minY + b.maxY) / 2 : clamp(state.y, b.minY + hh, b.maxY - hh);
|
|
199
|
+
}
|
|
200
|
+
/** Depth-of-field blur (screen px) for an item at parallax depth `depth`. */
|
|
201
|
+
export function depthBlur(cam, depth) {
|
|
202
|
+
if (cam.blur <= 0)
|
|
203
|
+
return 0;
|
|
204
|
+
return cam.blur * clamp(Math.abs(depth - cam.focus) / Math.max(1e-3, cam.focusRange), 0, 1);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Blur (depth of field + motion blur) as a CSS `filter: blur(px)` value in screen pixels.
|
|
208
|
+
* SVG `filter="url(#…)"` references proved unreliable in frame-by-frame capture: when an element's
|
|
209
|
+
* filter reference changed between frames (motion blur crossing its threshold, depth blur levels),
|
|
210
|
+
* Chrome sometimes skipped painting it, so elements flickered. A numeric CSS blur updates cleanly.
|
|
211
|
+
* Motion blur is approximated isotropically (direction-independent).
|
|
212
|
+
*/
|
|
213
|
+
export function cssBlur(screenX, screenY) {
|
|
214
|
+
const amount = Math.round(Math.hypot(screenX, screenY) * Math.SQRT1_2 * 4) / 4;
|
|
215
|
+
return amount < 0.25 ? undefined : `blur(${Math.min(20, amount)}px)`;
|
|
216
|
+
}
|
|
217
|
+
/** Screen scale of a matrix (average of axes). */
|
|
218
|
+
export const matScale = (m) => (Math.hypot(m[0], m[1]) + Math.hypot(m[2], m[3])) / 2;
|
|
219
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAuB,KAAK,EAAE,KAAK,EAAqB,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA4D3C,kFAAkF;AAClF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,MAAc,EAAE,GAAW,EAAE,GAAW,EAAE,EAAU;IAC1F,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC;IACtB,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,G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O,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/E,OAAO,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;AACvE,CAAC;AAED,kDAAkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAM,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type RenderFrame } from "./render.js";
|
|
2
|
+
/**
|
|
3
|
+
* Debug mode: tools to find rendering problems.
|
|
4
|
+
*
|
|
5
|
+
* 1. `diagnoseFrames` — checks what the library produces (no browser): invalid numbers, broken
|
|
6
|
+
* `url(#…)` references, duplicate ids, elements that exist for a single frame, sudden jumps.
|
|
7
|
+
* 2. `withDebugOverlay` — instruments a frame for a debug render: every top-level node draws a
|
|
8
|
+
* small colored "sentinel" square *inside its own group* in a strip at the bottom of the frame,
|
|
9
|
+
* and a barcode encodes the frame index. If the browser fails to paint a node, its sentinel is
|
|
10
|
+
* missing from the captured image.
|
|
11
|
+
* 3. `readDebugStrip` — reads the barcode and sentinels back from captured pixels (used by the
|
|
12
|
+
* `toon doctor` CLI) and reports exactly which nodes were not painted in which frame.
|
|
13
|
+
*/
|
|
14
|
+
export type DiagnosticKind = "invalid-number" | "broken-reference" | "duplicate-id" | "single-frame-node" | "single-frame-gap" | "jump" | "zero-blur-axis";
|
|
15
|
+
export interface Diagnostic {
|
|
16
|
+
frame: number;
|
|
17
|
+
time: number;
|
|
18
|
+
kind: DiagnosticKind;
|
|
19
|
+
severity: "error" | "warning" | "info";
|
|
20
|
+
/** Render node key involved, when known. */
|
|
21
|
+
key?: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DiagnoseOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Screen px a top-level node may move between consecutive frames before it counts as a jump
|
|
27
|
+
* (default 160). A node drawn on twos (threes, fours) may move that much per frame of its drawing.
|
|
28
|
+
*/
|
|
29
|
+
maxJump?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Diagnoses a list of consecutive frames (frame i at time `times[i]`). */
|
|
32
|
+
export declare function diagnoseFrames(frames: RenderFrame[], times: number[], opts?: DiagnoseOptions): Diagnostic[];
|
|
33
|
+
/** Height (px) of the instrumentation strip at the bottom of debug renders. */
|
|
34
|
+
export declare const DEBUG_STRIP = 24;
|
|
35
|
+
/** Distinct, saturated sentinel color for a node key. */
|
|
36
|
+
export declare function sentinelColor(key: string): [number, number, number];
|
|
37
|
+
export interface Sentinel {
|
|
38
|
+
key: string;
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
size: number;
|
|
42
|
+
color: [number, number, number];
|
|
43
|
+
}
|
|
44
|
+
/** Sentinel cells for a frame's top-level nodes (left part of the strip). */
|
|
45
|
+
export declare function sentinelLayout(frame: RenderFrame): Sentinel[];
|
|
46
|
+
/** Barcode cells (right part of the strip): frame index in binary, most significant bit first. */
|
|
47
|
+
export declare function barcodeLayout(frame: RenderFrame): {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
size: number;
|
|
51
|
+
}[];
|
|
52
|
+
export interface DebugOverlayOptions {
|
|
53
|
+
frameIndex: number;
|
|
54
|
+
time: number;
|
|
55
|
+
/** Draw a text label with the frame index and time (default true). */
|
|
56
|
+
label?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Instruments a frame for a debug render (see module docs). Every top-level node's content is
|
|
60
|
+
* clipped out of the bottom `DEBUG_STRIP` px, where the node paints only its own sentinel square;
|
|
61
|
+
* a barcode at the right encodes the frame index.
|
|
62
|
+
*/
|
|
63
|
+
export declare function withDebugOverlay(frame: RenderFrame, opts: DebugOverlayOptions): RenderFrame;
|
|
64
|
+
/** An RGB raster (8-bit, row-major, 3 bytes per pixel). */
|
|
65
|
+
export interface Raster {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
data: Uint8Array;
|
|
69
|
+
}
|
|
70
|
+
export interface StripReading {
|
|
71
|
+
/** Frame index decoded from the barcode. */
|
|
72
|
+
frameIndex: number;
|
|
73
|
+
/** Sentinels found with their expected color. */
|
|
74
|
+
painted: string[];
|
|
75
|
+
/** Sentinels missing (the browser did not paint that node). */
|
|
76
|
+
missing: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads the debug strip of a captured frame. `frame` is the library frame expected at that
|
|
80
|
+
* index (gives the sentinel layout); `img` may be scaled (its width / frame.width).
|
|
81
|
+
*/
|
|
82
|
+
export declare function readDebugStrip(img: Raster, frame: RenderFrame, tolerance?: number): StripReading;
|
|
83
|
+
/** Frame-to-frame difference (RMSE 0..1) of two equally sized rasters. */
|
|
84
|
+
export declare function rasterDiff(a: Raster, b: Raster): number;
|
|
85
|
+
/**
|
|
86
|
+
* Finds A→B→A flickers: frames that differ from both neighbours while the neighbours match each
|
|
87
|
+
* other (a vanishing / reappearing element, not motion). Returns frame indices.
|
|
88
|
+
*/
|
|
89
|
+
export declare function findFlickers(rasters: Raster[], threshold?: number): number[];
|
|
90
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiC,MAAM,UAAU,CAAC;AAE3E;;;;;;;;;;;GAWG;AAMH,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,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