@algorisys/tinyfly 0.89.0 → 0.91.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 -5
- package/lib/addons/adapters.js +24 -19
- package/lib/addons/camera-C7bZOWMB.js +33 -0
- package/lib/addons/characters.js +1929 -1622
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4882 -4484
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +16 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +216 -203
- package/lib/engine/tinyfly-engine.js +849 -783
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +39 -3
- package/lib/player/tinyfly-player.es.js +183 -170
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- 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/index.d.ts +2 -0
- package/lib/types/characters/acting/lip-sync.d.ts +115 -0
- package/lib/types/characters/acting/script.d.ts +94 -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 +15 -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/timeline.d.ts +3 -0
- package/lib/types/engine/types.d.ts +6 -0
- package/lib/types/headless/video-scene.d.ts +14 -0
- package/package.json +1 -1
|
@@ -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,11 +6,13 @@
|
|
|
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';
|
|
12
13
|
export { characterObjects } from './scene-objects';
|
|
13
14
|
export * from '../adapters/canvas/sketch';
|
|
15
|
+
export * from '../adapters/canvas/camera';
|
|
14
16
|
export * from './erase';
|
|
15
17
|
export * from '../adapters/canvas/polyline';
|
|
16
18
|
export * from './hand';
|
|
@@ -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) */
|
|
@@ -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[];
|
|
@@ -78,6 +78,9 @@ export declare class Timeline {
|
|
|
78
78
|
get repeatDelayRemaining(): number;
|
|
79
79
|
get speed(): number;
|
|
80
80
|
set speed(value: number);
|
|
81
|
+
/** Drawings per second (0: every frame); see `TimelineConfig.drawingRate`. */
|
|
82
|
+
get drawingRate(): number;
|
|
83
|
+
set drawingRate(value: number);
|
|
81
84
|
/**
|
|
82
85
|
* Start or resume playback.
|
|
83
86
|
* If at the end and direction is forward, reset to beginning.
|
|
@@ -139,6 +139,12 @@ export interface TimelineConfig {
|
|
|
139
139
|
alternate?: boolean;
|
|
140
140
|
/** Milliseconds to hold at the end before starting the next loop iteration */
|
|
141
141
|
repeatDelay?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Drawings per second: values hold on each drawing for several frames, as
|
|
144
|
+
* hand-drawn animation is timed (12 is "on twos" at 24 fps, 8 "on threes").
|
|
145
|
+
* Absent or 0: every frame is a new drawing.
|
|
146
|
+
*/
|
|
147
|
+
drawingRate?: number;
|
|
142
148
|
/**
|
|
143
149
|
* Named points in time, in order — the steps of a teaching animation. Players
|
|
144
150
|
* can step between them, stop at them and show their captions.
|
|
@@ -27,6 +27,15 @@ export interface VideoScene {
|
|
|
27
27
|
* so camera moves drawn there can stay smooth. Default: every frame.
|
|
28
28
|
*/
|
|
29
29
|
drawingRate?: number;
|
|
30
|
+
/**
|
|
31
|
+
* See the scene through a camera: `true` reads the tracks of the target
|
|
32
|
+
* named `Camera` (or name another): `x`, `y` pan, `scale` zooms and `rotate`
|
|
33
|
+
* rolls about the stage centre, and `shakeX`, `shakeY`, `shakeRotate` add a
|
|
34
|
+
* shake on top. `cameraTracks()` writes them from shots. The background,
|
|
35
|
+
* the targets and `draw` are all seen through it; a colour background fills
|
|
36
|
+
* the whole frame.
|
|
37
|
+
*/
|
|
38
|
+
camera?: boolean | string;
|
|
30
39
|
/** Length in ms (default: the timeline's duration) */
|
|
31
40
|
duration?: number;
|
|
32
41
|
/** Animation data; its markers drive stills and captions */
|
|
@@ -40,6 +49,11 @@ export interface VideoScene {
|
|
|
40
49
|
background?: string | DrawFunction;
|
|
41
50
|
/** Immediate-mode drawing, called every frame after the targets */
|
|
42
51
|
draw?: DrawFunction;
|
|
52
|
+
/**
|
|
53
|
+
* Drawn last, in screen space: not seen through the `camera` (captions,
|
|
54
|
+
* titles, a frame border). Without a camera it is the same as `draw`.
|
|
55
|
+
*/
|
|
56
|
+
overlay?: DrawFunction;
|
|
43
57
|
/**
|
|
44
58
|
* Glow around what is bright, added over each finished frame: `true` for
|
|
45
59
|
* the defaults, or options (threshold, strength, radius in scene px…).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algorisys/tinyfly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight, API-driven animation engine and editor. The engine is framework-agnostic and runs in browsers, Web Workers, and Node.",
|
|
6
6
|
"license": "MIT",
|