@algorisys/tinyfly 0.88.0 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/lib/addons/adapters.js +208 -177
- package/lib/addons/characters.js +2215 -1493
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4944 -4128
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/engine/tinyfly-engine.js +828 -765
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +45 -7
- package/lib/types/adapters/canvas/camera.d.ts +46 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/characters/acting/act-tracks.d.ts +28 -0
- package/lib/types/characters/acting/acting.d.ts +187 -0
- package/lib/types/characters/acting/effects.d.ts +65 -0
- package/lib/types/characters/acting/gags.d.ts +54 -0
- package/lib/types/characters/acting/index.d.ts +12 -0
- package/lib/types/characters/acting/lip-sync.d.ts +115 -0
- package/lib/types/characters/acting/rigs.d.ts +9 -0
- package/lib/types/characters/acting/script.d.ts +83 -0
- package/lib/types/characters/character.d.ts +7 -0
- package/lib/types/characters/gaits.d.ts +141 -0
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/stick-figure.d.ts +22 -0
- package/lib/types/engine/authoring/camera-shots.d.ts +73 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/engine/core/clock.d.ts +7 -0
- package/lib/types/headless/video-scene.d.ts +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CustomTarget } from '../../adapters/canvas';
|
|
2
|
+
import type { Point } from '../../adapters/canvas/sketch';
|
|
3
|
+
import type { FrameInfo } from '../../headless/video-scene';
|
|
4
|
+
/**
|
|
5
|
+
* Cartoon motion effects, drawn on a Canvas 2D context: speed lines behind
|
|
6
|
+
* fast hands, feet and heads (the smear that sells a zip), and the dust puff
|
|
7
|
+
* and impact stars of a landing or a crash.
|
|
8
|
+
*
|
|
9
|
+
* Like trails, smears are not a history of frames: they ask where the figure
|
|
10
|
+
* was at earlier times (`frame.stateAt`), so any frame draws the same way
|
|
11
|
+
* whether it is rendered in order, out of order, or scrubbed to.
|
|
12
|
+
*/
|
|
13
|
+
export interface SpeedLineStyle {
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Stroke width at the head of a line, px (default 2) */
|
|
16
|
+
lineWidth?: number;
|
|
17
|
+
/** Parallel lines per streak (default 3) */
|
|
18
|
+
lines?: number;
|
|
19
|
+
/** Gap between parallel lines, px (default 5) */
|
|
20
|
+
spacing?: number;
|
|
21
|
+
/** Opacity at the head (default 0.7); lines fade toward the tail */
|
|
22
|
+
opacity?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Streaks along a path, oldest point first: parallel lines that follow it,
|
|
26
|
+
* fading and thinning toward the tail.
|
|
27
|
+
*/
|
|
28
|
+
export declare function drawSpeedLines(ctx: CanvasRenderingContext2D, path: Point[], style?: SpeedLineStyle): void;
|
|
29
|
+
export interface SmearOptions extends SpeedLineStyle {
|
|
30
|
+
/** How far back the streaks reach, ms (default 120) */
|
|
31
|
+
length?: number;
|
|
32
|
+
/** Points along each streak (default 8) */
|
|
33
|
+
samples?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Speed (in figure heights per second) below which nothing is drawn; above
|
|
36
|
+
* it, streaks fade in (default 1.2, a brisk arm swing)
|
|
37
|
+
*/
|
|
38
|
+
threshold?: number;
|
|
39
|
+
/** Which parts streak (default hands, toes and head) */
|
|
40
|
+
parts?: Array<'hands' | 'toes' | 'head' | 'body'>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Speed lines behind a stick figure's fast-moving parts, in scene space:
|
|
44
|
+
* call it from a scene's `draw` (or `background`, to put them behind the
|
|
45
|
+
* figure). `id` is the figure's key in the scene's targets. Needs a frame
|
|
46
|
+
* with `stateAt` (video scenes have it); without one it draws nothing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function drawStickSmear(ctx: CanvasRenderingContext2D, target: CustomTarget, frame: Pick<FrameInfo, 'time' | 'state' | 'stateAt'>, id: string, options?: SmearOptions): void;
|
|
49
|
+
export interface PuffOptions {
|
|
50
|
+
/** Overall size, px (default 40) */
|
|
51
|
+
size?: number;
|
|
52
|
+
color?: string;
|
|
53
|
+
/** Varies the puff's shape (default 1) */
|
|
54
|
+
seed?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A dust puff at a point on the ground, `progress` 0 (just kicked up) → 1
|
|
58
|
+
* (gone): a few round clouds that billow outward and fade.
|
|
59
|
+
*/
|
|
60
|
+
export declare function drawDustPuff(ctx: CanvasRenderingContext2D, at: Point, progress: number, options?: PuffOptions): void;
|
|
61
|
+
/**
|
|
62
|
+
* Impact stars around a point, `progress` 0 → 1: little stars burst out,
|
|
63
|
+
* spin and fade (a bonk on the head, a crash into a wall).
|
|
64
|
+
*/
|
|
65
|
+
export declare function drawImpactStars(ctx: CanvasRenderingContext2D, at: Point, progress: number, options?: PuffOptions): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EasingType } from '../../engine/types';
|
|
2
|
+
import { type PoseKey, type PoseName, type StickPose } from '../stick-figure';
|
|
3
|
+
/**
|
|
4
|
+
* Cartoon gags as data: short, already-timed sequences of stick-figure poses
|
|
5
|
+
* that splice into a list of keys. Their timing is the gag (a held wind-up, a
|
|
6
|
+
* zip, a squash on landing), so their keys are marked `act: false` and the
|
|
7
|
+
* acting pass leaves them as written.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const keys = [
|
|
11
|
+
* { time: 0, pose: 'rest' },
|
|
12
|
+
* ...gag('take', { at: 800 }),
|
|
13
|
+
* { time: 3000, pose: 'shrug' },
|
|
14
|
+
* ]
|
|
15
|
+
* actTracks('hero', keys, { style: 'snappy' })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/** One step of a gag: when (ms after it starts), what changes from the pose it starts on, and the ease into it. */
|
|
19
|
+
export interface GagStep {
|
|
20
|
+
after: number;
|
|
21
|
+
pose: Partial<StickPose>;
|
|
22
|
+
easing?: EasingType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The gags, each built on the pose it starts from (so a take works sitting,
|
|
26
|
+
* turned or mid-wave). Each ends on a pose the next key can move on from.
|
|
27
|
+
*/
|
|
28
|
+
export declare const GAGS: {
|
|
29
|
+
/** The classic take: squash down in a squint, then shoot up stretched with eyes popping, hang, and land squashed. */
|
|
30
|
+
take: (from: StickPose) => GagStep[];
|
|
31
|
+
/** Glance at something, look away unbothered, then snap back to it in shock. */
|
|
32
|
+
doubleTake: (from: StickPose) => GagStep[];
|
|
33
|
+
/** Rear back for a zip-off: lean back, one knee up, arms cocked, hold, then pitch forward ready to run. */
|
|
34
|
+
windUp: () => GagStep[];
|
|
35
|
+
/** Coming down to the ground: stretched in the fall, squashed on contact, a spring back up. */
|
|
36
|
+
land: (from: StickPose) => GagStep[];
|
|
37
|
+
/** A frightened shiver: small, fast shakes with wide eyes, then still. */
|
|
38
|
+
tremble: (from: StickPose) => GagStep[];
|
|
39
|
+
/** A sigh: the body sags, shoulders drop, head and eyes go down. */
|
|
40
|
+
deflate: (from: StickPose) => GagStep[];
|
|
41
|
+
};
|
|
42
|
+
export type GagName = keyof typeof GAGS;
|
|
43
|
+
export interface GagOptions {
|
|
44
|
+
/** When the gag starts, ms */
|
|
45
|
+
at: number;
|
|
46
|
+
/** The pose it starts on: a name or a full pose (default rest) */
|
|
47
|
+
from?: PoseName | StickPose;
|
|
48
|
+
/** Time scale: 1 as designed, 2 twice as long (default 1) */
|
|
49
|
+
speed?: number;
|
|
50
|
+
}
|
|
51
|
+
/** The keys of a gag, starting at `at` on the pose it starts from; splice them into a key list. */
|
|
52
|
+
export declare function gag(name: GagName, options: GagOptions): PoseKey[];
|
|
53
|
+
/** How long a gag lasts at a speed, ms. */
|
|
54
|
+
export declare function gagDuration(name: GagName, speed?: number): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Acting: cartoon timing for character poses (anticipation, overshoot,
|
|
3
|
+
* overlap, eyes that lead, blinks, moving holds, jump squash), gags as data,
|
|
4
|
+
* and motion effects (speed lines, dust, impact stars).
|
|
5
|
+
*/
|
|
6
|
+
export * from './acting';
|
|
7
|
+
export * from './rigs';
|
|
8
|
+
export * from './act-tracks';
|
|
9
|
+
export * from './gags';
|
|
10
|
+
export * from './effects';
|
|
11
|
+
export * from './lip-sync';
|
|
12
|
+
export * from './script';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Keyframe, Track } from '../../engine/types';
|
|
2
|
+
/**
|
|
3
|
+
* Lip-sync from text: the mouth shapes a line of dialogue makes, timed over
|
|
4
|
+
* the span it is spoken in.
|
|
5
|
+
*
|
|
6
|
+
* No audio analysis: the text is read as a sequence of sounds (vowels open
|
|
7
|
+
* the mouth in their shape, m/b/p close it, f/v bite the lip, pauses rest
|
|
8
|
+
* it), and the sounds share the line's time by how long each one tends to
|
|
9
|
+
* take. That is how cartoon lip-sync is usually done by hand (a few mouth
|
|
10
|
+
* shapes, timed to the track), and it is close enough for stick figures and
|
|
11
|
+
* cartoon faces. It reads Latin script and Devanagari.
|
|
12
|
+
*
|
|
13
|
+
* Shapes are the face fields `mouth` (0 closed … 1 wide open) and
|
|
14
|
+
* `mouthWidth` (0.5 pursed … 1.5 wide), which the stick figure and the v2
|
|
15
|
+
* characters both have.
|
|
16
|
+
*/
|
|
17
|
+
/** A mouth shape. */
|
|
18
|
+
export interface Viseme {
|
|
19
|
+
mouth: number;
|
|
20
|
+
mouthWidth: number;
|
|
21
|
+
}
|
|
22
|
+
/** The shapes, after the classic cartoon mouth chart. */
|
|
23
|
+
export declare const VISEMES: {
|
|
24
|
+
/** Closed and relaxed */
|
|
25
|
+
rest: {
|
|
26
|
+
mouth: number;
|
|
27
|
+
mouthWidth: number;
|
|
28
|
+
};
|
|
29
|
+
/** "ah": open wide */
|
|
30
|
+
a: {
|
|
31
|
+
mouth: number;
|
|
32
|
+
mouthWidth: number;
|
|
33
|
+
};
|
|
34
|
+
/** "eh": open, wide */
|
|
35
|
+
e: {
|
|
36
|
+
mouth: number;
|
|
37
|
+
mouthWidth: number;
|
|
38
|
+
};
|
|
39
|
+
/** "ee": a little open, stretched wide */
|
|
40
|
+
i: {
|
|
41
|
+
mouth: number;
|
|
42
|
+
mouthWidth: number;
|
|
43
|
+
};
|
|
44
|
+
/** "oh": round */
|
|
45
|
+
o: {
|
|
46
|
+
mouth: number;
|
|
47
|
+
mouthWidth: number;
|
|
48
|
+
};
|
|
49
|
+
/** "oo": small and pursed */
|
|
50
|
+
u: {
|
|
51
|
+
mouth: number;
|
|
52
|
+
mouthWidth: number;
|
|
53
|
+
};
|
|
54
|
+
/** m, b, p: lips pressed */
|
|
55
|
+
m: {
|
|
56
|
+
mouth: number;
|
|
57
|
+
mouthWidth: number;
|
|
58
|
+
};
|
|
59
|
+
/** f, v: lip under the teeth */
|
|
60
|
+
f: {
|
|
61
|
+
mouth: number;
|
|
62
|
+
mouthWidth: number;
|
|
63
|
+
};
|
|
64
|
+
/** l, th, n, d, t: tongue up, a little open */
|
|
65
|
+
l: {
|
|
66
|
+
mouth: number;
|
|
67
|
+
mouthWidth: number;
|
|
68
|
+
};
|
|
69
|
+
/** Other consonants: slightly open */
|
|
70
|
+
c: {
|
|
71
|
+
mouth: number;
|
|
72
|
+
mouthWidth: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type VisemeName = keyof typeof VISEMES;
|
|
76
|
+
/** One sound of a line: its shape, and how long it takes relative to the others. */
|
|
77
|
+
export interface Sound {
|
|
78
|
+
viseme: VisemeName;
|
|
79
|
+
weight: number;
|
|
80
|
+
}
|
|
81
|
+
/** The sounds of a line, in order. */
|
|
82
|
+
export declare function soundsOf(text: string): Sound[];
|
|
83
|
+
export interface LipSyncOptions {
|
|
84
|
+
/** How wide the mouth opens: 1 as charted, less for mumbling, more for shouting (default 1) */
|
|
85
|
+
energy?: number;
|
|
86
|
+
/** Field names, if not `mouth` and `mouthWidth` */
|
|
87
|
+
fields?: {
|
|
88
|
+
mouth?: string;
|
|
89
|
+
mouthWidth?: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** A spoken line: what is said, and when (ms). */
|
|
93
|
+
export interface SpokenLine {
|
|
94
|
+
text: string;
|
|
95
|
+
start: number;
|
|
96
|
+
end: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mouth keyframes for a line spoken from `start` to `end` ms: closed at the
|
|
100
|
+
* start, a shape per sound, closed again at the end. Keys are in time order,
|
|
101
|
+
* for the `mouth` and `mouthWidth` fields.
|
|
102
|
+
*/
|
|
103
|
+
export declare function lipSyncKeyframes(line: SpokenLine, options?: LipSyncOptions): Record<string, Keyframe<number>[]>;
|
|
104
|
+
/** Mouth tracks on `target` for several spoken lines (in time order, not overlapping). */
|
|
105
|
+
export declare function lipSyncTracks(target: string, lines: SpokenLine[], options?: LipSyncOptions): Track[];
|
|
106
|
+
/**
|
|
107
|
+
* Tracks with spoken lines lip-synced over their mouth: during each line the
|
|
108
|
+
* lip-sync shapes replace the `mouth` and `mouthWidth` keys, starting and
|
|
109
|
+
* ending on whatever the face was doing, so a shocked gape or a grin carries
|
|
110
|
+
* on around the speech. Other tracks pass through. Fields missing from
|
|
111
|
+
* `tracks` start from `rest` (default: closed, normal width).
|
|
112
|
+
*/
|
|
113
|
+
export declare function lipSyncOver(target: string, tracks: Track[], lines: SpokenLine[], options?: LipSyncOptions & {
|
|
114
|
+
rest?: Record<string, number>;
|
|
115
|
+
}): Track[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ActingRig } from './acting';
|
|
2
|
+
/**
|
|
3
|
+
* Acting rigs: which pose fields lead, which drag, which wind up and how far.
|
|
4
|
+
* Limits are in each field's own units (degrees for joints).
|
|
5
|
+
*/
|
|
6
|
+
/** The v1 stick figure (`StickPose`). */
|
|
7
|
+
export declare const STICK_ACTING_RIG: ActingRig;
|
|
8
|
+
/** The v2 human body plan (`HUMAN_REST` fields). */
|
|
9
|
+
export declare const HUMAN_ACTING_RIG: ActingRig;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Track } from '../../engine/types';
|
|
2
|
+
import { type ExpressionName, type PoseKey, type PoseName, type StickPose } from '../stick-figure';
|
|
3
|
+
import { type GaitName } from '../gaits';
|
|
4
|
+
import { type GagName } from './gags';
|
|
5
|
+
import { type SpokenLine } from './lip-sync';
|
|
6
|
+
import type { ActingOptions } from './acting';
|
|
7
|
+
/**
|
|
8
|
+
* Beat scripts: a story written as what a character does, compiled into
|
|
9
|
+
* acted tracks.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const { tracks, duration, lines } = scriptTracks('crow', [
|
|
13
|
+
* { do: 'walk', to: 600, mood: 'sad' },
|
|
14
|
+
* { do: 'look', toward: 900, mood: 'surprised' },
|
|
15
|
+
* { do: 'take' },
|
|
16
|
+
* { do: 'say', say: 'A pot of water!', mood: 'joyful' },
|
|
17
|
+
* { do: 'run', to: 880 },
|
|
18
|
+
* { do: 'cheer', for: 1200 },
|
|
19
|
+
* ], { from: 200, height: 170, style: 'snappy' })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Each beat starts when the one before it ends (or at `at`). Walking beats
|
|
23
|
+
* move the figure (its `x` track, as an offset from where it was placed at
|
|
24
|
+
* `from`), turn it to face the way it goes, and pick the gait; pose beats key
|
|
25
|
+
* a named pose; gag beats splice in a gag; `say` lip-syncs a line. The poses
|
|
26
|
+
* then go through the acting pass, so the result winds up, overshoots and
|
|
27
|
+
* overlaps like any `actTracks()` output. Everything is plain keyframes.
|
|
28
|
+
*/
|
|
29
|
+
/** The ways to get somewhere. */
|
|
30
|
+
export type GaitAction = GaitName;
|
|
31
|
+
/** Everything a beat can do. */
|
|
32
|
+
export type Action = GaitAction | PoseName | GagName | 'look' | 'say' | 'hold' | 'stand' | 'face';
|
|
33
|
+
export interface Beat {
|
|
34
|
+
/** What happens */
|
|
35
|
+
do: Action;
|
|
36
|
+
/** When it starts, ms (default: when the beat before ends) */
|
|
37
|
+
at?: number;
|
|
38
|
+
/** How long it takes, ms (default: the action's own length) */
|
|
39
|
+
for?: number;
|
|
40
|
+
/** Walking: where to, scene x */
|
|
41
|
+
to?: number;
|
|
42
|
+
/** `look` and `face`: a scene x, or `viewer` (front-on), `ahead` or `back` */
|
|
43
|
+
toward?: number | 'viewer' | 'ahead' | 'back';
|
|
44
|
+
/** The face for the beat */
|
|
45
|
+
mood?: ExpressionName;
|
|
46
|
+
/** Spoken during the beat, lip-synced (with `do: 'say'`, the beat lasts as long as the line) */
|
|
47
|
+
say?: string;
|
|
48
|
+
/** Joints to change on top of the action's pose */
|
|
49
|
+
pose?: Partial<StickPose>;
|
|
50
|
+
}
|
|
51
|
+
export interface ScriptOptions extends ActingOptions {
|
|
52
|
+
/** Scene x the figure was placed at (its `x` track is an offset from here; default 0) */
|
|
53
|
+
from?: number;
|
|
54
|
+
/** Figure height, px, for stride length (default 300, the stick figure's) */
|
|
55
|
+
height?: number;
|
|
56
|
+
/** Which way it faces at the start (default 1, screen-right) */
|
|
57
|
+
facing?: 1 | -1;
|
|
58
|
+
/** The pose it starts in (default rest) */
|
|
59
|
+
start?: StickPose;
|
|
60
|
+
/** Lip-sync energy (default 1) */
|
|
61
|
+
energy?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ScriptResult {
|
|
64
|
+
/** Every track the script writes, on the target */
|
|
65
|
+
tracks: Track[];
|
|
66
|
+
/** When the last beat ends, ms */
|
|
67
|
+
duration: number;
|
|
68
|
+
/** The spoken lines with their times, for captions */
|
|
69
|
+
lines: SpokenLine[];
|
|
70
|
+
/** The key poses, before acting */
|
|
71
|
+
keys: PoseKey[];
|
|
72
|
+
/** When each beat starts and ends, ms */
|
|
73
|
+
beats: Array<{
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
/** Time for one gait cycle (two steps), ms. */
|
|
79
|
+
export declare const GAIT_CYCLE_MS: Record<GaitName, number>;
|
|
80
|
+
/** How long a line takes to say, ms. */
|
|
81
|
+
export declare function speechDuration(text: string): number;
|
|
82
|
+
/** Compile beats into tracks on `target` (a `stickFigureTarget`). */
|
|
83
|
+
export declare function scriptTracks(target: string, beats: Beat[], options?: ScriptOptions): ScriptResult;
|
|
@@ -200,7 +200,14 @@ export interface CharacterPoseKey {
|
|
|
200
200
|
pose?: HumanPoseName | Pose;
|
|
201
201
|
/** Easing into this key */
|
|
202
202
|
easing?: EasingType;
|
|
203
|
+
/** `false`: the acting pass (`actCharacterTracks`) takes the move into this key as written */
|
|
204
|
+
act?: boolean;
|
|
203
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* The pose at each key: a named pose, or the previous key's pose with the
|
|
208
|
+
* key's changes (the first builds on `rest`).
|
|
209
|
+
*/
|
|
210
|
+
export declare function resolveCharacterPoseKeys(keys: CharacterPoseKey[], rest?: Pose): Pose[];
|
|
204
211
|
/**
|
|
205
212
|
* Keyframe tracks that move a character target through a sequence of poses.
|
|
206
213
|
* Each key is a named pose or changes from the previous key (the first builds
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type StickPose } from './stick-figure';
|
|
2
|
+
/**
|
|
3
|
+
* Gaits with personality: how a stick figure walks, as plain data.
|
|
4
|
+
*
|
|
5
|
+
* A gait is a handful of numbers (how far the legs swing, how high the knee
|
|
6
|
+
* lifts, how the arms pump, how much the body bobs), so gaits serialize,
|
|
7
|
+
* blend and can be invented without code. `gaitPose()` turns one into a pose
|
|
8
|
+
* at a phase of the cycle (0 → 1 is one full cycle, two steps), the same way
|
|
9
|
+
* `walkPose()` does for the plain walk.
|
|
10
|
+
*
|
|
11
|
+
* On a `stickFigureTarget`, the `gait` prop picks one by name: a string
|
|
12
|
+
* track (`{ time: 4000, value: 'sneak' }`) switches gait mid-scene.
|
|
13
|
+
*/
|
|
14
|
+
export interface Gait {
|
|
15
|
+
/** Thigh swing either side of vertical, degrees */
|
|
16
|
+
swing: number;
|
|
17
|
+
/** How far the knee of the leg swinging forward lifts, degrees */
|
|
18
|
+
knee: number;
|
|
19
|
+
/** Arm swing either side, degrees (arms raised above 40° keep their pose) */
|
|
20
|
+
arm: number;
|
|
21
|
+
/** Forearm follow-through at the front of the swing, degrees */
|
|
22
|
+
elbow: number;
|
|
23
|
+
/** Forearms held bent forward by this much throughout: pumping running arms, sneaking paws (degrees) */
|
|
24
|
+
forearm?: number;
|
|
25
|
+
/** Upper arms held raised forward by this much (sneaking paws up), degrees */
|
|
26
|
+
shoulder?: number;
|
|
27
|
+
/** Forward lean, degrees */
|
|
28
|
+
lean: number;
|
|
29
|
+
/** Line of action: the spine curled forward (+) or the chest out (−), degrees */
|
|
30
|
+
bend?: number;
|
|
31
|
+
/** Head tilt added, degrees (+ down when facing right) */
|
|
32
|
+
headTilt?: number;
|
|
33
|
+
/** Lift off the ground at the passing position, fraction of the height (a bounce, a run's flight) */
|
|
34
|
+
bounce?: number;
|
|
35
|
+
/** Bobs per step: 1, or 2 for the double bounce */
|
|
36
|
+
bounces?: number;
|
|
37
|
+
/** Stretch on the way up and squash on the way down, 0..0.2 */
|
|
38
|
+
squash?: number;
|
|
39
|
+
/** Knees always bent this much: a crouch, degrees */
|
|
40
|
+
crouch?: number;
|
|
41
|
+
/** Toes pointed down (tiptoe), degrees */
|
|
42
|
+
tiptoe?: number;
|
|
43
|
+
/** Side-to-side sway of the upper body, degrees (a strut, a waddle) */
|
|
44
|
+
sway?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Ready-made gaits. `walk` matches `walkPose()` exactly.
|
|
48
|
+
* - `bouncy`: springs up on every step, arms swinging high.
|
|
49
|
+
* - `doubleBounce`: the classic cartoon walk, two bobs a step.
|
|
50
|
+
* - `sneak`: tiptoeing in a crouch, knees high, paws up.
|
|
51
|
+
* - `strut`: chest out, head high, a swagger.
|
|
52
|
+
* - `tired`: slumped, dragging, arms hanging.
|
|
53
|
+
* - `run`: leaning in, knees high, arms pumping, off the ground between steps.
|
|
54
|
+
*/
|
|
55
|
+
export declare const GAITS: {
|
|
56
|
+
walk: {
|
|
57
|
+
swing: number;
|
|
58
|
+
knee: number;
|
|
59
|
+
arm: number;
|
|
60
|
+
elbow: number;
|
|
61
|
+
lean: number;
|
|
62
|
+
};
|
|
63
|
+
bouncy: {
|
|
64
|
+
swing: number;
|
|
65
|
+
knee: number;
|
|
66
|
+
arm: number;
|
|
67
|
+
elbow: number;
|
|
68
|
+
lean: number;
|
|
69
|
+
bend: number;
|
|
70
|
+
bounce: number;
|
|
71
|
+
squash: number;
|
|
72
|
+
};
|
|
73
|
+
doubleBounce: {
|
|
74
|
+
swing: number;
|
|
75
|
+
knee: number;
|
|
76
|
+
arm: number;
|
|
77
|
+
elbow: number;
|
|
78
|
+
lean: number;
|
|
79
|
+
bounce: number;
|
|
80
|
+
bounces: number;
|
|
81
|
+
squash: number;
|
|
82
|
+
};
|
|
83
|
+
sneak: {
|
|
84
|
+
swing: number;
|
|
85
|
+
knee: number;
|
|
86
|
+
arm: number;
|
|
87
|
+
elbow: number;
|
|
88
|
+
forearm: number;
|
|
89
|
+
shoulder: number;
|
|
90
|
+
lean: number;
|
|
91
|
+
bend: number;
|
|
92
|
+
headTilt: number;
|
|
93
|
+
crouch: number;
|
|
94
|
+
tiptoe: number;
|
|
95
|
+
};
|
|
96
|
+
strut: {
|
|
97
|
+
swing: number;
|
|
98
|
+
knee: number;
|
|
99
|
+
arm: number;
|
|
100
|
+
elbow: number;
|
|
101
|
+
lean: number;
|
|
102
|
+
bend: number;
|
|
103
|
+
headTilt: number;
|
|
104
|
+
sway: number;
|
|
105
|
+
bounce: number;
|
|
106
|
+
};
|
|
107
|
+
tired: {
|
|
108
|
+
swing: number;
|
|
109
|
+
knee: number;
|
|
110
|
+
arm: number;
|
|
111
|
+
elbow: number;
|
|
112
|
+
lean: number;
|
|
113
|
+
bend: number;
|
|
114
|
+
headTilt: number;
|
|
115
|
+
};
|
|
116
|
+
run: {
|
|
117
|
+
swing: number;
|
|
118
|
+
knee: number;
|
|
119
|
+
arm: number;
|
|
120
|
+
elbow: number;
|
|
121
|
+
forearm: number;
|
|
122
|
+
lean: number;
|
|
123
|
+
bend: number;
|
|
124
|
+
bounce: number;
|
|
125
|
+
squash: number;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export type GaitName = keyof typeof GAITS;
|
|
129
|
+
/** A gait by name or as data; an unknown name is the plain walk. */
|
|
130
|
+
export declare function resolveGait(gait: GaitName | Gait | string | undefined): Gait;
|
|
131
|
+
/**
|
|
132
|
+
* The pose `phase` cycles into a gait (0 → 1 is two steps), built on `base`:
|
|
133
|
+
* the legs and hanging arms move, raised arms and the face keep `base`'s
|
|
134
|
+
* pose. `stride` scales the swing. The plain `walk` gait is `walkPose()`.
|
|
135
|
+
*/
|
|
136
|
+
export declare function gaitPose(gait: GaitName | Gait | string | undefined, phase: number, base?: StickPose, stride?: number): StickPose;
|
|
137
|
+
/**
|
|
138
|
+
* Ground covered by one cycle of a gait (two steps) for a figure `height` px
|
|
139
|
+
* tall. Move the figure this far per unit of phase and its feet stay planted.
|
|
140
|
+
*/
|
|
141
|
+
export declare function gaitStrideLength(gait: GaitName | Gait | string | undefined, height: number, stride?: number): number;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export * from './stick-figure';
|
|
8
8
|
export * from './dance';
|
|
9
|
+
export * from './gaits';
|
|
9
10
|
export * from './acrobatics';
|
|
10
11
|
export { stickToHuman } from './stick-to-human';
|
|
11
12
|
export { skeletonInView, solvePlanSpace, stagePlanSpace, type ViewProjection, type PlanSpace, type StagedSpace } from './rig/skeleton';
|
|
@@ -20,3 +21,4 @@ export type { BodyPlan, ChainSpec, BoneSpec, BoneAngles, ContactSpec, HeadSpec,
|
|
|
20
21
|
export { createPen, ellipsePoints, type Pen, type Look, type PencilOptions, type PenOptions } from './look/pen';
|
|
21
22
|
export { basicOutfit, type BasicOutfitOptions } from './wardrobe/basic-outfit';
|
|
22
23
|
export * from './hands';
|
|
24
|
+
export * from './acting';
|
|
@@ -16,6 +16,13 @@ import { type HandPose } from './hands/hand-rig';
|
|
|
16
16
|
export interface StickPose {
|
|
17
17
|
/** Upper-body tilt about the hips, degrees (+ leans to the figure's right, +x) */
|
|
18
18
|
lean: number;
|
|
19
|
+
/**
|
|
20
|
+
* The line of action: the spine curved, degrees from hips to neck (+ curls
|
|
21
|
+
* forward the way `lean` tips, − arches back). Unlike `lean`, which tips a
|
|
22
|
+
* straight back, the curve spreads along the spine, and the chest, arms and
|
|
23
|
+
* head turn with its end: a slump, a recoil, a cheer arched back.
|
|
24
|
+
*/
|
|
25
|
+
bend: number;
|
|
19
26
|
/** Head tilt, degrees */
|
|
20
27
|
headTilt: number;
|
|
21
28
|
/** Upper arms: 0 hangs down, 90 is straight out, 180 straight up */
|
|
@@ -370,10 +377,18 @@ export interface StickFigureProps extends StickPose {
|
|
|
370
377
|
walk: number;
|
|
371
378
|
/** How much of the walk cycle is applied, 0..1 (0 standing) */
|
|
372
379
|
walking: number;
|
|
380
|
+
/** How it walks: a `GAITS` name (default `walk`); a string track switches it */
|
|
381
|
+
gait?: string;
|
|
373
382
|
/** How much the mouth chatters, 0..1 */
|
|
374
383
|
talk: number;
|
|
375
384
|
/** Limbs from jointed (0) to rubber hose (1); starts at the style's `rubber` */
|
|
376
385
|
rubber: number;
|
|
386
|
+
/**
|
|
387
|
+
* Which way it faces: 1 screen-right, -1 screen-left (the sign counts);
|
|
388
|
+
* starts at the style's `facing`. Key it a step (two keys a millisecond
|
|
389
|
+
* apart) while `turn` is near 0, so the flip does not show.
|
|
390
|
+
*/
|
|
391
|
+
facing?: number;
|
|
377
392
|
/** Beats into the target's dance (animate it 0 → n at the tempo); see `danceTracks` */
|
|
378
393
|
beat?: number;
|
|
379
394
|
/** How much of the dance is applied, 0..1 (0 standing) */
|
|
@@ -447,7 +462,14 @@ export interface PoseKey {
|
|
|
447
462
|
expression?: ExpressionName | Partial<Expression>;
|
|
448
463
|
/** Easing into this key */
|
|
449
464
|
easing?: EasingType;
|
|
465
|
+
/** `false`: the acting pass (`actTracks`) takes the move into this key as written */
|
|
466
|
+
act?: boolean;
|
|
450
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* The full pose at each key: a named pose, or the previous key's pose with
|
|
470
|
+
* the key's changes (the first builds on rest), with the key's face applied.
|
|
471
|
+
*/
|
|
472
|
+
export declare function resolvePoseKeys(keys: PoseKey[]): StickPose[];
|
|
451
473
|
/**
|
|
452
474
|
* Keyframe tracks that move `target` through a sequence of poses. Each key is
|
|
453
475
|
* a named pose or changes from the previous key (the first builds on rest),
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { EasingType, Keyframe, Track } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Camera acting: a list of shots in, camera tracks out.
|
|
4
|
+
*
|
|
5
|
+
* Shots say what the camera does and when: frame a point (push in, pull
|
|
6
|
+
* out, or cut when the move takes no time), shake on an impact, or follow a
|
|
7
|
+
* moving subject a beat behind it. The result is ordinary keyframe tracks on
|
|
8
|
+
* the camera target (`x`, `y`, `scale`, `rotate`, and `shakeX`, `shakeY`,
|
|
9
|
+
* `shakeRotate` for shakes), the same JSON as any other animation, which
|
|
10
|
+
* `applyCamera` (canvas) or the editor's camera layer turn into a view.
|
|
11
|
+
*/
|
|
12
|
+
/** Frame a point: the camera moves so `focus` is at the centre of the picture, at `scale`. */
|
|
13
|
+
export interface FrameShot {
|
|
14
|
+
at: number;
|
|
15
|
+
/** How long the move takes, ms (0 cuts; default 600) */
|
|
16
|
+
duration?: number;
|
|
17
|
+
easing?: EasingType;
|
|
18
|
+
frame: {
|
|
19
|
+
/** The scene point to centre (default: the stage centre) */
|
|
20
|
+
focus?: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
/** Zoom (default 1) */
|
|
25
|
+
scale?: number;
|
|
26
|
+
/** Roll, degrees (default 0) */
|
|
27
|
+
rotate?: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Shake the picture: an impact, a stomp, a scream. It dies away over `duration`. */
|
|
31
|
+
export interface ShakeShot {
|
|
32
|
+
at: number;
|
|
33
|
+
duration: number;
|
|
34
|
+
shake: {
|
|
35
|
+
/** How far, px, at the start (default 12) */
|
|
36
|
+
strength?: number;
|
|
37
|
+
/** Jolts per second (default 24) */
|
|
38
|
+
frequency?: number;
|
|
39
|
+
/** Roll in the shake, degrees at the start (default 1.5) */
|
|
40
|
+
roll?: number;
|
|
41
|
+
seed?: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Follow a subject across: the camera keeps it centred, `lag` ms behind it. */
|
|
45
|
+
export interface FollowShot {
|
|
46
|
+
at: number;
|
|
47
|
+
/** When the camera stops following and holds, ms */
|
|
48
|
+
until: number;
|
|
49
|
+
follow: {
|
|
50
|
+
/** The subject's scene x over time: its x track's keyframes */
|
|
51
|
+
x: Keyframe<number>[];
|
|
52
|
+
/** Added to the subject's x: frame ahead of a runner (default 0) */
|
|
53
|
+
lead?: number;
|
|
54
|
+
/** Scene y to keep centred (default: keeps the current framing's) */
|
|
55
|
+
y?: number;
|
|
56
|
+
/** How far behind the subject the camera is, ms (default 250) */
|
|
57
|
+
lag?: number;
|
|
58
|
+
/** Zoom while following (default: the current one) */
|
|
59
|
+
scale?: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export type CameraShot = FrameShot | ShakeShot | FollowShot;
|
|
63
|
+
export interface CameraTrackOptions {
|
|
64
|
+
/** The stage size: framing centres on its middle */
|
|
65
|
+
stage: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
/** The camera's target name (default `Camera`) */
|
|
70
|
+
target?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Camera tracks for a list of shots (any order; they are played in time order). */
|
|
73
|
+
export declare function cameraTracks(shots: CameraShot[], options: CameraTrackOptions): Track[];
|
|
@@ -42,3 +42,10 @@ export declare class Clock {
|
|
|
42
42
|
private _scheduleFrame;
|
|
43
43
|
private _onFrame;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Time held to the last drawing: animating "on twos" (12 drawings a second
|
|
47
|
+
* against a 24 fps film) means each pose shows for two frames. Given a
|
|
48
|
+
* time in ms and the drawings per second, the time of the drawing on screen.
|
|
49
|
+
* A rate of 0 (or less) leaves time continuous.
|
|
50
|
+
*/
|
|
51
|
+
export declare function heldTime(time: number, drawingsPerSecond: number): number;
|