@algorisys/tinyfly 0.98.0 → 0.99.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 +8 -8
- package/docs/acting.md +76 -13
- package/docs/character-appearance.md +51 -3
- package/docs/editor-guide.md +41 -4
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +9 -2
- package/docs/maps.md +2 -2
- package/docs/scene-3d.md +3 -1
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +4779 -4342
- package/lib/browser/tinyfly.iife.js +15 -15
- package/lib/browser/tinyfly.js +5699 -5262
- package/lib/browser/tinyfly.umd.js +15 -15
- package/lib/types/characters/acting/character-script.d.ts +44 -0
- package/lib/types/characters/acting/index.d.ts +1 -0
- package/lib/types/characters/character.d.ts +13 -1
- package/lib/types/characters/chart.d.ts +52 -14
- package/lib/types/characters/hair-follow.d.ts +76 -0
- package/lib/types/characters/head/hair.d.ts +27 -1
- package/lib/types/characters/head/head-look.d.ts +5 -2
- package/lib/types/characters/head/index.d.ts +1 -1
- package/lib/types/characters/index.d.ts +1 -0
- package/lib/types/characters/props/draw.d.ts +9 -0
- package/lib/types/characters/props/prop-surface.d.ts +14 -3
- package/lib/types/characters/props/ride-3d.d.ts +31 -2
- package/lib/types/characters/props/target.d.ts +5 -1
- package/lib/types/characters/species/human.d.ts +2 -0
- package/lib/types/characters/whiteboard.d.ts +13 -1
- package/llms-full.txt +210 -45
- package/llms.txt +29 -29
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +9 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Beat, type ScriptOptions, type ScriptResult } from './script';
|
|
2
|
+
import { type Gait } from '../gaits';
|
|
3
|
+
import { type Character, type CharacterPoseKey } from '../character';
|
|
4
|
+
/**
|
|
5
|
+
* Beat scripts for v2 characters: the same beats `scriptTracks` compiles for
|
|
6
|
+
* the stick figure (walk and the other gaits, `say`, `look`, `face`, poses,
|
|
7
|
+
* gags, `zip`, `leap`, `grab`, `throw`, `kick`, `put`, `write`, `push`, your
|
|
8
|
+
* own actions and gaits), compiled into tracks for a `characterTarget`.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* const amy = character(castMember('youngWoman', 170))
|
|
12
|
+
* const script = characterScript('amy', amy, [
|
|
13
|
+
* { do: 'walk', to: 330, mood: 'happy' },
|
|
14
|
+
* { do: 'say', say: 'Is that box ticking?', mood: 'worried' },
|
|
15
|
+
* { do: 'take' },
|
|
16
|
+
* { do: 'zip', to: -200 },
|
|
17
|
+
* ], { from: 90 })
|
|
18
|
+
* const timeline = deserializeTimeline({ id: 'scene', tracks: script.tracks })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* How it works: the stick-figure script plans the story (timing, where the
|
|
22
|
+
* figure is, which way it faces, its gait, its speech); its key poses are
|
|
23
|
+
* taken onto the human body (`stickToHuman`, mirrored when it faces left, so
|
|
24
|
+
* the character's `turn` runs negative that way); the human acting pass then
|
|
25
|
+
* winds up, overshoots and overlaps on this body, and the lines are
|
|
26
|
+
* lip-synced over its mouth. The walk phase is rekeyed to the character's own
|
|
27
|
+
* stride (its height and legs), so its feet stay planted. The `walk`,
|
|
28
|
+
* `walking` and `gait` tracks step the gait as the target draws, as the 3D
|
|
29
|
+
* character object does.
|
|
30
|
+
*
|
|
31
|
+
* Hands reach in the stick figure's proportions, so a `grab` or a `point`
|
|
32
|
+
* lands near its target on the human body, not exactly on it.
|
|
33
|
+
*/
|
|
34
|
+
export type CharacterScriptOptions = Omit<ScriptOptions, 'height'>;
|
|
35
|
+
export interface CharacterScriptResult extends Omit<ScriptResult, 'keys'> {
|
|
36
|
+
/** The key poses on the human body, before acting */
|
|
37
|
+
keys: CharacterPoseKey[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Ground one gait cycle covers for this character, px: its own height and
|
|
41
|
+
* legs (a child's are shorter), so the feet stay planted.
|
|
42
|
+
*/
|
|
43
|
+
export declare function characterStrideLength(who: Character, gait: Gait | string | undefined, stride?: number): number;
|
|
44
|
+
export declare function characterScript(target: string, who: Character, beats: Beat[], options?: CharacterScriptOptions): CharacterScriptResult;
|
|
@@ -7,6 +7,7 @@ import { type SolvedHead, type ViewProjection } from './rig/skeleton';
|
|
|
7
7
|
import { type Look, type Pen, type PencilOptions } from './look/pen';
|
|
8
8
|
import { type HeadLook, type HeadLookOptions } from './head/head-look';
|
|
9
9
|
import { type HumanBuildName, type HumanPoseName } from './species/human';
|
|
10
|
+
import type { Gait } from './gaits';
|
|
10
11
|
import { type BasicOutfitOptions } from './wardrobe/basic-outfit';
|
|
11
12
|
import { type Holding, type HoldingSpec } from './hands/held-items';
|
|
12
13
|
import { type HandPose } from './hands/hand-rig';
|
|
@@ -209,14 +210,25 @@ export interface CharacterTargetOptions {
|
|
|
209
210
|
character: Character;
|
|
210
211
|
/** Starting pose (default rest) */
|
|
211
212
|
pose?: Pose;
|
|
213
|
+
/** Your own gaits, by the names a `gait` track uses (built-in names need no entry) */
|
|
214
|
+
gaits?: Record<string, Gait>;
|
|
212
215
|
}
|
|
213
216
|
/** A `custom` target made by {@link characterTarget}. */
|
|
214
217
|
export interface CharacterTarget extends CustomTarget {
|
|
215
218
|
readonly character: Character;
|
|
219
|
+
readonly gaits?: Record<string, Gait>;
|
|
216
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* The pose a target's props describe: its pose fields, with its gait stepped
|
|
223
|
+
* in as far as `walking` says (`walk` is the phase, `gait` which gait), on the
|
|
224
|
+
* pose it holds. Props that are not pose fields (`facing`, strings) are left
|
|
225
|
+
* out.
|
|
226
|
+
*/
|
|
227
|
+
export declare function characterPoseOf(props: Record<string, unknown>, rest?: Pose, gaits?: Record<string, Gait>): Pose;
|
|
217
228
|
/**
|
|
218
229
|
* A `custom` canvas target that draws a character. Every pose field is a
|
|
219
|
-
* prop, so timeline tracks pose, turn and roll it
|
|
230
|
+
* prop, so timeline tracks pose, turn and roll it; `walk`, `walking` and
|
|
231
|
+
* `gait` tracks step its gait (see `characterScript`). `x`/`y` are the feet.
|
|
220
232
|
*/
|
|
221
233
|
export declare function characterTarget(options: CharacterTargetOptions): CharacterTarget;
|
|
222
234
|
/** Joints moved from a character's drawing space to a scene where its feet stand at (x, y). */
|
|
@@ -5,8 +5,9 @@ import { type FlingOptions, type SurfacePiece, type TimedPoint } from './surface
|
|
|
5
5
|
import { type Surface, type SurfaceAbout, type SurfaceEditOptions } from './surface/surface';
|
|
6
6
|
import { type SurfaceBox } from './surface/surface-box';
|
|
7
7
|
/**
|
|
8
|
-
* A bar or
|
|
9
|
-
* bar, highlight the dip,
|
|
8
|
+
* A bar, line, pie or donut chart as a scene object figures act on: they
|
|
9
|
+
* point at a bar, highlight the dip, stand on a bar as it grows, pull a
|
|
10
|
+
* slice out of a pie and kick it away.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const sales = chart({
|
|
@@ -20,17 +21,27 @@ import { type SurfaceBox } from './surface/surface-box';
|
|
|
20
21
|
* sales.edit('highlight', 'bar:q2', { at: 600 })
|
|
21
22
|
* sales.edit('show', 'bar:q3', { at: 1200 }) // grows in from the axis
|
|
22
23
|
* sales.edit('set', 'bar:q1', { at: 2000, value: 80 }) // and its value label counts up
|
|
24
|
+
*
|
|
25
|
+
* const traffic = chart({ x: 500, y: 30, width: 300, height: 280, kind: 'donut', data: [...] })
|
|
26
|
+
* traffic.edit('pull', 'slice:mobile', { at: 400 }) // out from the centre
|
|
27
|
+
* traffic.fling(traffic.piece('slice:other'), { at: 900 })
|
|
23
28
|
* ```
|
|
24
29
|
*
|
|
30
|
+
* Several series (`series: [{ id: 'a' }, { id: 'b' }]`, values as
|
|
31
|
+
* `values: { a: 10, b: 12 }`) draw grouped bars or one line each, with a
|
|
32
|
+
* legend; their places are `bar:ID:SERIES`. A pie shows one series.
|
|
33
|
+
*
|
|
25
34
|
* The data is declared up front; the scale (`max`) is fixed when it is made
|
|
26
35
|
* (from the data, or given), so a bar set past it grows out of the plot.
|
|
27
36
|
* Its places follow the values: `anchor('bar:q1', time)` is the bar as it
|
|
28
37
|
* stands at `time` (default: after every edit; a surface script aims beats
|
|
29
38
|
* at it as laid out). A figure standing on a bar's top is carried up and
|
|
30
39
|
* down with it (`ride()`). Edits are keys on its props: `bar.ID.value`,
|
|
31
|
-
* `bar.ID.show`, `bar.ID.highlight` (or `point.ID.…` on a line chart
|
|
40
|
+
* `bar.ID.show`, `bar.ID.highlight` (or `point.ID.…` on a line chart,
|
|
41
|
+
* `slice.ID.…` and `slice.ID.pull` on a pie; `bar.ID.SERIES.…` with several
|
|
42
|
+
* series).
|
|
32
43
|
*/
|
|
33
|
-
export type ChartKind = 'bar' | 'line';
|
|
44
|
+
export type ChartKind = 'bar' | 'line' | 'pie' | 'donut';
|
|
34
45
|
export declare const CHART_KINDS: readonly ChartKind[];
|
|
35
46
|
export type ChartThemeName = 'light' | 'dark';
|
|
36
47
|
export interface ChartTheme {
|
|
@@ -38,20 +49,33 @@ export interface ChartTheme {
|
|
|
38
49
|
text: string;
|
|
39
50
|
/** Axis and grid lines */
|
|
40
51
|
grid: string;
|
|
41
|
-
/** Bars, the line and its points */
|
|
52
|
+
/** Bars, the line and its points (the first series) */
|
|
42
53
|
color: string;
|
|
43
|
-
/** A highlighted bar or
|
|
54
|
+
/** A highlighted bar, point or slice */
|
|
44
55
|
highlight: string;
|
|
56
|
+
/** Slices and series in turn (the first is `color`) */
|
|
57
|
+
palette: string[];
|
|
45
58
|
font: string;
|
|
46
59
|
}
|
|
47
60
|
export declare const CHART_THEMES: Record<ChartThemeName, ChartTheme>;
|
|
48
|
-
/** One bar or
|
|
61
|
+
/** One of several series: its own colour, a bar in each group or a line of its own. */
|
|
62
|
+
export interface ChartSeries {
|
|
63
|
+
id: string;
|
|
64
|
+
/** In the legend (default its id) */
|
|
65
|
+
label?: string;
|
|
66
|
+
/** Its colour (default the theme's palette, in turn) */
|
|
67
|
+
color?: string;
|
|
68
|
+
}
|
|
69
|
+
/** One bar, point or slice. */
|
|
49
70
|
export interface ChartDatum {
|
|
50
71
|
id: string;
|
|
51
72
|
/** Under it, on the axis (default its id) */
|
|
52
73
|
label?: string;
|
|
53
|
-
value
|
|
54
|
-
|
|
74
|
+
/** Its value (one series) */
|
|
75
|
+
value?: number;
|
|
76
|
+
/** Its value in each series, by series id (several series) */
|
|
77
|
+
values?: Record<string, number>;
|
|
78
|
+
/** Start at nothing: a bar flat on the axis, a point the line has not reached, a slice of no width; brought in with `show` */
|
|
55
79
|
hidden?: boolean;
|
|
56
80
|
}
|
|
57
81
|
export interface ChartOptions {
|
|
@@ -62,28 +86,42 @@ export interface ChartOptions {
|
|
|
62
86
|
height: number;
|
|
63
87
|
kind: ChartKind;
|
|
64
88
|
data: ChartDatum[];
|
|
89
|
+
/** Several series (bar and line charts): each datum then gives `values` by series id */
|
|
90
|
+
series?: ChartSeries[];
|
|
65
91
|
/** The value at the top of the plot (default: a round number above the largest value) */
|
|
66
92
|
max?: number;
|
|
67
93
|
title?: string;
|
|
94
|
+
/** Axis titles (bar and line charts) */
|
|
95
|
+
axis?: {
|
|
96
|
+
x?: string;
|
|
97
|
+
y?: string;
|
|
98
|
+
};
|
|
99
|
+
/** Show the legend with several series (default true) */
|
|
100
|
+
legend?: boolean;
|
|
68
101
|
theme?: ChartThemeName | Partial<ChartTheme>;
|
|
69
102
|
/** Value labels: decimal places (default 0), and text before and after the number */
|
|
70
103
|
decimals?: number;
|
|
71
104
|
prefix?: string;
|
|
72
105
|
suffix?: string;
|
|
73
|
-
/** Show each value above its bar or point (default true) */
|
|
106
|
+
/** Show each value above its bar or point, or on its slice (default true) */
|
|
74
107
|
values?: boolean;
|
|
75
108
|
}
|
|
109
|
+
/** A slice of a pie or donut that has come loose. */
|
|
110
|
+
export interface ChartSlicePiece extends SurfacePiece {
|
|
111
|
+
/** The datum it is the slice of */
|
|
112
|
+
readonly datum: string;
|
|
113
|
+
}
|
|
76
114
|
export interface Chart extends Surface {
|
|
77
115
|
readonly kind: 'chart';
|
|
78
116
|
readonly chartKind: ChartKind;
|
|
79
117
|
readonly target: CustomTarget;
|
|
80
118
|
readonly box: SurfaceBox;
|
|
81
|
-
/** The value at the top of the plot */
|
|
119
|
+
/** The value at the top of the plot (pies: the total of the data) */
|
|
82
120
|
readonly max: number;
|
|
83
|
-
/** The box at a named place, as it stands at `time`: `box`, `bar:ID
|
|
121
|
+
/** The box at a named place, as it stands at `time`: `box`, `bar:ID`, `point:ID`, `slice:ID` (`:SERIES` after the id with several series), `label:ID`, `value:ID`, `legend:SERIES` */
|
|
84
122
|
anchor(name: string, time?: number): SurfaceBox;
|
|
85
|
-
/**
|
|
86
|
-
piece(anchor: string):
|
|
123
|
+
/** Make the slice at a `slice:` place a piece that can come loose (pies and donuts) */
|
|
124
|
+
piece(anchor: string): ChartSlicePiece;
|
|
87
125
|
/** Change the chart at a time by name, at named places (see `CHART_SURFACE.edits`) */
|
|
88
126
|
edit(name: string, anchor: string | string[], options: SurfaceEditOptions): Chart;
|
|
89
127
|
follow(piece: SurfacePiece, path: TimedPoint[]): Chart;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Track } from '../engine/types';
|
|
2
|
+
import type { Pose } from './rig/body-plan';
|
|
3
|
+
import { type Character } from './character';
|
|
4
|
+
/**
|
|
5
|
+
* Hair follow-through: hanging hair (long hair, ponytails, braids) lags
|
|
6
|
+
* behind the head, swinging round it after a turn, streaming back on a run,
|
|
7
|
+
* dropping on a jump and lifting on the landing. The drawing stays stateless:
|
|
8
|
+
* the lag is three pose fields (`hair.swing`, `hair.trail`, `hair.lift`), and
|
|
9
|
+
* this module works them out ahead of time from the head's motion, the way
|
|
10
|
+
* `Prop.follow` does for a car's antenna or a dog's tail.
|
|
11
|
+
*
|
|
12
|
+
* // Timelines: add the hair's tracks after the character's own.
|
|
13
|
+
* const tracks = characterPoseTracks('amy', keys)
|
|
14
|
+
* tracks.push(...hairFollowTracks('amy', tracks, amy))
|
|
15
|
+
*
|
|
16
|
+
* // Code that poses a character every frame: key the lag once for the
|
|
17
|
+
* // loop, then read it at each frame's time.
|
|
18
|
+
* const keys = hairFollow((t) => ({ x: xAt(t), y: 0, turn: turnAt(t) }), { end: 8000, headRadius: 24 })
|
|
19
|
+
* drawCharacter(ctx, amy, humanPose({ turn: turnAt(t), ...hairMotionAt(keys, t) }), t)
|
|
20
|
+
*
|
|
21
|
+
* Each lag chases its primary on a spring stepped in fixed 1 ms steps
|
|
22
|
+
* (`springFollow`), so the same motion always gives the same keys.
|
|
23
|
+
*/
|
|
24
|
+
/** Where the head is at a time: screen x and y (px) and the body's view (`turn`), plus the head's own turn (degrees). */
|
|
25
|
+
export interface HairFollowSample {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
/** The pose's `turn` (0 front, 1 profile facing screen-right, 2 back…) */
|
|
29
|
+
turn: number;
|
|
30
|
+
/** The pose's `head.turn`, degrees toward the character's left (default 0) */
|
|
31
|
+
headTurn?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface HairFollowOptions {
|
|
34
|
+
/** From and to, ms (start defaults to 0) */
|
|
35
|
+
start?: number;
|
|
36
|
+
end: number;
|
|
37
|
+
/** The head's radius on screen, px: the lag is measured in head radii */
|
|
38
|
+
headRadius: number;
|
|
39
|
+
/** Key spacing, ms (default 33) */
|
|
40
|
+
step?: number;
|
|
41
|
+
/** Spring stiffness (default 70): higher follows the head more tightly */
|
|
42
|
+
stiffness?: number;
|
|
43
|
+
/** Damping (default 6): lower swings longer */
|
|
44
|
+
damping?: number;
|
|
45
|
+
/** How much the hair lags, 1 the default feel; 0 pins it to the head */
|
|
46
|
+
amount?: number;
|
|
47
|
+
}
|
|
48
|
+
/** The hair's lag at one time. */
|
|
49
|
+
export interface HairFollowKey {
|
|
50
|
+
time: number;
|
|
51
|
+
/** `hair.swing`: round the head toward the character's left (+), degrees */
|
|
52
|
+
swing: number;
|
|
53
|
+
/** `hair.trail`: streaming back behind the head (+), head radii */
|
|
54
|
+
trail: number;
|
|
55
|
+
/** `hair.lift`: lifted (+) or dropped (−), head radii */
|
|
56
|
+
lift: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Key the hair's lag over a span, from where the head is at each moment.
|
|
60
|
+
* Returns a key every `step` ms from `start` to `end`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function hairFollow(sample: (time: number) => HairFollowSample, options: HairFollowOptions): HairFollowKey[];
|
|
63
|
+
/** The hair's lag at a time, between keys, as the pose fields it sets (`hair.swing`, `hair.trail`, `hair.lift`). */
|
|
64
|
+
export declare function hairMotionAt(keys: HairFollowKey[], time: number): Pose;
|
|
65
|
+
export interface HairFollowTrackOptions extends Pick<HairFollowOptions, 'step' | 'stiffness' | 'damping' | 'amount'> {
|
|
66
|
+
/** How long the hair keeps settling after the last key, ms (default 1500) */
|
|
67
|
+
settle?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Tracks that key a character target's hair lag from its own tracks: the
|
|
71
|
+
* target's `x` and `y`, and the pose's `turn` and `head.turn`. Nothing is
|
|
72
|
+
* added for hair that has nothing to swing (short hair, a bun, no hair).
|
|
73
|
+
* Hair fields the tracks already key (a flick written by hand) keep their
|
|
74
|
+
* values, with the lag added on.
|
|
75
|
+
*/
|
|
76
|
+
export declare function hairFollowTracks(target: string, tracks: Track[], who: Character, options?: HairFollowTrackOptions): Track[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Pose } from '../rig/body-plan';
|
|
1
2
|
import type { SolvedHead } from '../rig/skeleton';
|
|
2
3
|
import type { Pen } from '../look/pen';
|
|
3
4
|
import { type ShellRegion } from './shell';
|
|
@@ -13,7 +14,30 @@ import { type ShellRegion } from './shell';
|
|
|
13
14
|
* turn, the back view shows the back of the hair, and a ponytail stays tied
|
|
14
15
|
* to the same place. The part facing away is drawn before the head, the part
|
|
15
16
|
* facing the viewer after it.
|
|
17
|
+
*
|
|
18
|
+
* Hair that hangs (long hair, ponytails, braids) also swings: three pose
|
|
19
|
+
* fields (`hair.swing`, `hair.trail`, `hair.lift`) carry how far its ends
|
|
20
|
+
* lag behind the head, and `hairFollow` works them out from the head's
|
|
21
|
+
* motion as keyframes, so drawing stays stateless.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* How far hanging hair lags behind the head, at its ends (the roots stay on
|
|
25
|
+
* the head). Plain numbers that live in the pose as `hair.swing`,
|
|
26
|
+
* `hair.trail` and `hair.lift`, so they key, save and mirror like any field.
|
|
16
27
|
*/
|
|
28
|
+
export interface HairMotion {
|
|
29
|
+
/** Swung round the head toward the character's left (+) or right (−), degrees */
|
|
30
|
+
swing: number;
|
|
31
|
+
/** Streaming back behind the head (+) or thrown forward (−), head radii */
|
|
32
|
+
trail: number;
|
|
33
|
+
/** Lifted (+) or dropped (−), head radii */
|
|
34
|
+
lift: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const HAIR_STILL: HairMotion;
|
|
37
|
+
/** The hair motion a pose carries (`hair.swing`, `hair.trail`, `hair.lift`; missing fields are still). */
|
|
38
|
+
export declare function hairMotionOf(pose: Pose | undefined): HairMotion;
|
|
39
|
+
/** Whether a style has anything that swings: hair hanging below the head, or a ponytail or braid. */
|
|
40
|
+
export declare function hairHangs(hair: Hair): boolean;
|
|
17
41
|
export type HairTexture = 'smooth' | 'spiky' | 'curly' | 'wavy' | 'locs';
|
|
18
42
|
/** Detail lines drawn on the hair: none, a parting, strands swept from a parting, combed back, hanging strands, a few thin strands */
|
|
19
43
|
export type HairStrands = 'none' | 'part' | 'sweep' | 'combed' | 'hanging' | 'thin';
|
|
@@ -544,12 +568,14 @@ export declare function hairlineAt(hair: Hair, around: number): number;
|
|
|
544
568
|
* The hair as a region on the head. `pad` (head radii) lifts it clear of
|
|
545
569
|
* the head's own outline, so a thick head line never shows through it.
|
|
546
570
|
*/
|
|
547
|
-
export declare function hairRegion(hair: Hair, pad: number): ShellRegion;
|
|
571
|
+
export declare function hairRegion(hair: Hair, pad: number, motion?: HairMotion): ShellRegion;
|
|
548
572
|
export interface HairDrawOptions {
|
|
549
573
|
/** The character's line width, px */
|
|
550
574
|
lineWidth: number;
|
|
551
575
|
/** Skin colour, for the scalp under close-cropped hair */
|
|
552
576
|
skin: string;
|
|
577
|
+
/** How far hanging hair lags behind the head (default still) */
|
|
578
|
+
motion?: HairMotion;
|
|
553
579
|
}
|
|
554
580
|
/**
|
|
555
581
|
* The hair behind the head: the part facing away, and ties on the far side.
|
|
@@ -21,6 +21,9 @@ import { type Hat, type HatSpec, type HatStyle } from './hats';
|
|
|
21
21
|
* Which part wins where two overlap is fixed by that order: the face's eyes
|
|
22
22
|
* and brows draw over a fringe, the mouth over a beard (which leaves an
|
|
23
23
|
* opening for it), a moustache over the mouth's top, and a hat over the hair.
|
|
24
|
+
*
|
|
25
|
+
* Hanging hair lags behind the head by the pose's `hair.swing`, `hair.trail`
|
|
26
|
+
* and `hair.lift` (see `hairFollow`); the passes read them from the pose.
|
|
24
27
|
*/
|
|
25
28
|
export interface HeadLookOptions {
|
|
26
29
|
/** Hair: a style name, a style with changes (`{ style: 'bob', color: '#9a4426' }`), or null for none (the default) */
|
|
@@ -46,8 +49,8 @@ export interface HeadDrawOptions {
|
|
|
46
49
|
lineWidth: number;
|
|
47
50
|
skin: string;
|
|
48
51
|
}
|
|
49
|
-
export declare function drawHeadBehind(ctx: CanvasRenderingContext2D, pen: Pen, look: HeadLook, head: SolvedHead,
|
|
52
|
+
export declare function drawHeadBehind(ctx: CanvasRenderingContext2D, pen: Pen, look: HeadLook, head: SolvedHead, pose: Pose, options: HeadDrawOptions): void;
|
|
50
53
|
/** The head's front pass; `drawFace` draws the face at its place in the order. */
|
|
51
54
|
export declare function drawHeadFront(_ctx: CanvasRenderingContext2D, pen: Pen, look: HeadLook, head: SolvedHead, pose: Pose, options: HeadDrawOptions, drawFace: () => void): void;
|
|
52
55
|
/** After the whole figure: the hair and hat, when the head is turned away. */
|
|
53
|
-
export declare function drawHeadOver(_ctx: CanvasRenderingContext2D, pen: Pen, look: HeadLook, head: SolvedHead,
|
|
56
|
+
export declare function drawHeadOver(_ctx: CanvasRenderingContext2D, pen: Pen, look: HeadLook, head: SolvedHead, pose: Pose, options: HeadDrawOptions): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HAIR_STYLES, HAIR_COLORS, resolveHair, hairlineAt, type Hair, type HairSpec, type HairStyleName, type HairTexture, type HairStrands, type HairTie } from './hair';
|
|
1
|
+
export { HAIR_STYLES, HAIR_COLORS, HAIR_STILL, resolveHair, hairlineAt, hairHangs, hairMotionOf, type Hair, type HairMotion, type HairSpec, type HairStyleName, type HairTexture, type HairStrands, type HairTie } from './hair';
|
|
2
2
|
export { FACIAL_HAIR_STYLES, resolveFacialHair, type FacialHair, type FacialHairSpec, type FacialHairStyleName, type MoustacheStyle, type BeardStyle } from './facial-hair';
|
|
3
3
|
export { GLASSES_STYLES, resolveGlasses, type Glasses, type GlassesSpec, type GlassesStyle } from './glasses';
|
|
4
4
|
export { HAT_STYLES, resolveHat, type Hat, type HatSpec, type HatStyle } from './hats';
|
|
@@ -31,6 +31,7 @@ export type { BodyPlan, ChainSpec, BoneSpec, BoneAngles, ContactSpec, HeadSpec,
|
|
|
31
31
|
export { createPen, ellipsePoints, type Pen, type Look, type PencilOptions, type PenOptions } from './look/pen';
|
|
32
32
|
export { basicOutfit, type BasicOutfitOptions } from './wardrobe/basic-outfit';
|
|
33
33
|
export * from './head';
|
|
34
|
+
export { hairFollow, hairFollowTracks, hairMotionAt, type HairFollowSample, type HairFollowOptions, type HairFollowKey, type HairFollowTrackOptions } from './hair-follow';
|
|
34
35
|
export * from './hands';
|
|
35
36
|
export * from './acting';
|
|
36
37
|
export * from './capabilities';
|
|
@@ -31,6 +31,15 @@ export interface PropDrawOptions {
|
|
|
31
31
|
paper?: string;
|
|
32
32
|
/** The fog's colour, for faces lit by a scene (`light`, `fog` on the solved faces) */
|
|
33
33
|
fog?: string;
|
|
34
|
+
/** Parts that have come loose (see `propSurface().piece`): drawn carried from where they sit and turned about their middle, by part id */
|
|
35
|
+
loose?: Record<string, LoosePart>;
|
|
36
|
+
}
|
|
37
|
+
/** Where a loose part has gone: px from its place in the prop's space, its turn (degrees) and how faded it is. */
|
|
38
|
+
export interface LoosePart {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
rotate: number;
|
|
42
|
+
opacity: number;
|
|
34
43
|
}
|
|
35
44
|
/** Draws in the prop's own space: feet at 0, 0, up is −y. */
|
|
36
45
|
export declare function drawSolvedProp(ctx: CanvasRenderingContext2D, solved: SolvedProp, options?: PropDrawOptions): void;
|
|
@@ -30,6 +30,12 @@ import { type PropTarget } from './target';
|
|
|
30
30
|
* that drives off. Edits are keys on its controls, written out by `tracks()`
|
|
31
31
|
* on the prop target's id. Do not key a control both here and in its own
|
|
32
32
|
* script: the later track wins.
|
|
33
|
+
*
|
|
34
|
+
* A part can come loose: `piece('part:wheel-0-left')` makes it a piece that
|
|
35
|
+
* `fling`, `follow` and `move` carry off (or the `fling` and `move` edits),
|
|
36
|
+
* drawn where it went. Every anchor and part is a floor: a figure standing
|
|
37
|
+
* on the roof (`onto: { surface, anchor: 'anchor:roof' }`) is carried with
|
|
38
|
+
* it as the prop lifts, drives or is squashed (`ride()`).
|
|
33
39
|
*/
|
|
34
40
|
export interface PropSurfaceOptions {
|
|
35
41
|
/** The prop's own tracks (its `propScript` result), so its places follow it as it moves */
|
|
@@ -40,8 +46,8 @@ export interface PropSurface extends Surface {
|
|
|
40
46
|
readonly prop: PropTarget;
|
|
41
47
|
/** The box at a named place, at `time` (default: after every edit): `box`, `anchor:NAME`, `part:ID`, `control:NAME` */
|
|
42
48
|
anchor(name: string, time?: number): SurfaceBox;
|
|
43
|
-
/**
|
|
44
|
-
piece(anchor: string):
|
|
49
|
+
/** Make the part at a `part:` place a piece that can come loose (with the parts built on it: a wheel and its hub) */
|
|
50
|
+
piece(anchor: string): PropPiece;
|
|
45
51
|
/** Change the prop at a time: `set` a control to a value, or `switch` it on (open) or off (shut) */
|
|
46
52
|
edit(name: string, anchor: string | string[], options: SurfaceEditOptions): PropSurface;
|
|
47
53
|
follow(piece: SurfacePiece, path: TimedPoint[]): PropSurface;
|
|
@@ -52,12 +58,17 @@ export interface PropSurface extends Surface {
|
|
|
52
58
|
y: number;
|
|
53
59
|
};
|
|
54
60
|
}): PropSurface;
|
|
55
|
-
/**
|
|
61
|
+
/** A figure's tracks with it carried by the anchor or part it stands on, as the prop moves */
|
|
56
62
|
ride(tracks: Track[], target: string, options: {
|
|
57
63
|
ground: number;
|
|
58
64
|
every?: number;
|
|
59
65
|
}): Track[];
|
|
60
66
|
tracks(target: string): Track[];
|
|
61
67
|
}
|
|
68
|
+
/** A part of a prop that has come loose. */
|
|
69
|
+
export interface PropPiece extends SurfacePiece {
|
|
70
|
+
/** The part's id */
|
|
71
|
+
readonly part: string;
|
|
72
|
+
}
|
|
62
73
|
export declare const PROP_SURFACE: SurfaceAbout;
|
|
63
74
|
export declare function propSurface(target: PropTarget, options?: PropSurfaceOptions): PropSurface;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Track } from '../../engine/types';
|
|
2
2
|
import type { Vec3 } from '../../engine/math';
|
|
3
3
|
import type { Pose } from '../rig/body-plan';
|
|
4
|
-
import { type CharacterOptions } from '../character';
|
|
4
|
+
import { type CharacterOptions, type CharacterPoseKey } from '../character';
|
|
5
5
|
import type { Prop } from './target';
|
|
6
6
|
/**
|
|
7
7
|
* Riding in a 3D scene: a character carried by a prop, its hips kept on a
|
|
@@ -62,10 +62,39 @@ export interface PropRide3DOptions {
|
|
|
62
62
|
/** Sample spacing, ms (default 33) */
|
|
63
63
|
every?: number;
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Riding poses for a human: on a seat, astride a saddle (legs apart round a
|
|
67
|
+
* horse's barrel), driving (hands forward on a wheel) and on a bike's saddle
|
|
68
|
+
* (leaning to the handlebars; the legs cycle with `pedallingPose`).
|
|
69
|
+
*/
|
|
66
70
|
export declare const RIDING_POSES: {
|
|
67
71
|
seated: Pose;
|
|
68
72
|
astride: Pose;
|
|
73
|
+
driving: Pose;
|
|
74
|
+
cycling: Pose;
|
|
69
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* The cycling pose with the legs part way round the pedals: `phase` 0 → 1
|
|
78
|
+
* is one turn of the cranks (the left foot at the top at 0, the right half a
|
|
79
|
+
* turn behind), built on `base` (default `RIDING_POSES.cycling`).
|
|
80
|
+
*/
|
|
81
|
+
export declare function pedallingPose(phase: number, base?: Pose): Pose;
|
|
82
|
+
export interface PedallingOptions {
|
|
83
|
+
/** From and to, ms */
|
|
84
|
+
start: number;
|
|
85
|
+
end: number;
|
|
86
|
+
/** Turns of the cranks per second (default 1.2) */
|
|
87
|
+
cadence?: number;
|
|
88
|
+
/** The pose the legs cycle on (default `RIDING_POSES.cycling`) */
|
|
89
|
+
base?: Pose;
|
|
90
|
+
/** Keys per turn (default 8) */
|
|
91
|
+
samplesPerTurn?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Pose keys that pedal from `start` to `end` (`act: false`: a cycle is
|
|
95
|
+
* already timed), for a rider's own pose tracks (`characterPoseTracks` or
|
|
96
|
+
* `actCharacterTracks`) while `propRide3D` or `propRide` carries it.
|
|
97
|
+
*/
|
|
98
|
+
export declare function pedallingKeys(options: PedallingOptions): CharacterPoseKey[];
|
|
70
99
|
/** The rider's `x`, `y`, `z` and `rotateY` tracks while it rides (see the module's notes). */
|
|
71
100
|
export declare function propRide3D(options: PropRide3DOptions): Track[];
|
|
@@ -3,7 +3,7 @@ import type { PropertyInfo } from '../../adapters/canvas/target-properties';
|
|
|
3
3
|
import type { FrameInfo } from '../../headless/video-scene';
|
|
4
4
|
import type { ActingRig } from '../acting/acting';
|
|
5
5
|
import { type PropRig, type SolvedProp } from './rig';
|
|
6
|
-
import { type PropDrawOptions } from './draw';
|
|
6
|
+
import { type LoosePart, type PropDrawOptions } from './draw';
|
|
7
7
|
import type { PropAction } from './script';
|
|
8
8
|
/**
|
|
9
9
|
* A prop: what it is, its rig, what it can do and how it acts. Families
|
|
@@ -92,7 +92,11 @@ export interface PropTarget extends CustomTarget {
|
|
|
92
92
|
/** px per metre */
|
|
93
93
|
readonly propScale: number;
|
|
94
94
|
readonly propDraw: Omit<PropDrawOptions, 'time' | 'rider'>;
|
|
95
|
+
/** Parts that have come loose as pieces (`propSurface().piece`): the piece's key in its props, by part id */
|
|
96
|
+
readonly loose?: Map<string, number>;
|
|
95
97
|
}
|
|
98
|
+
/** Where the loose parts have gone in this frame, from the `piece.K.*` values, by part id. */
|
|
99
|
+
export declare function loosePartsOf(target: PropTarget, values: Record<string, number>): Record<string, LoosePart> | undefined;
|
|
96
100
|
/** Every control a prop has, described: the common ones and its own. */
|
|
97
101
|
export declare function propControls(prop: Prop): Record<string, PropertyInfo & {
|
|
98
102
|
default?: number;
|
|
@@ -20,6 +20,8 @@ import type { BodyPlan, Pose } from '../rig/body-plan';
|
|
|
20
20
|
* - the face: `mouth`, `smile`, `mouthWidth`, `blink`, `eye.left`, `eye.right`,
|
|
21
21
|
* `brow.left`, `brow.right`, `browTilt`, `lookX`, `lookY` (as the v1 stick figure),
|
|
22
22
|
* and marks that fade in from 0 to 1: `blush` (cheeks), `tears`, `sweat` (a bead at the temple)
|
|
23
|
+
* - hair in motion: `hair.swing` (round the head toward its left +, degrees), `hair.trail`
|
|
24
|
+
* (streaming back +, head radii), `hair.lift` (up +, head radii); `hairFollow` keys them
|
|
23
25
|
* - `held.left`, `held.right`, `held.both`: whether what the character holds
|
|
24
26
|
* there shows (1, the default) or has been let go (below 0.5)
|
|
25
27
|
*
|
|
@@ -36,7 +36,7 @@ import { type SurfaceBox } from './surface/surface-box';
|
|
|
36
36
|
* `mark.ID.draw`, `strike.K.draw`, `piece.K.x`…) and written out by
|
|
37
37
|
* `tracks()`.
|
|
38
38
|
*/
|
|
39
|
-
export type BoardThemeName = 'whiteboard' | 'chalkboard';
|
|
39
|
+
export type BoardThemeName = 'whiteboard' | 'chalkboard' | 'lines';
|
|
40
40
|
export interface BoardTheme {
|
|
41
41
|
background: string;
|
|
42
42
|
frame: string;
|
|
@@ -49,6 +49,12 @@ export interface BoardTheme {
|
|
|
49
49
|
stroke: number;
|
|
50
50
|
/** Ink opacity (chalk is a little see-through) */
|
|
51
51
|
opacity: number;
|
|
52
|
+
/** Ruled paper: the lines' colour, their spacing (em of the font size) and a margin line's colour */
|
|
53
|
+
rule?: {
|
|
54
|
+
color: string;
|
|
55
|
+
spacing?: number;
|
|
56
|
+
margin?: string;
|
|
57
|
+
};
|
|
52
58
|
}
|
|
53
59
|
export declare const BOARD_THEMES: Record<BoardThemeName, BoardTheme>;
|
|
54
60
|
/** The marks a board can draw. */
|
|
@@ -76,6 +82,12 @@ export interface BoardMark {
|
|
|
76
82
|
/** `arrow`: from one place to another */
|
|
77
83
|
from?: string;
|
|
78
84
|
to?: string;
|
|
85
|
+
/**
|
|
86
|
+
* `arrow`: how far it bows, as a fraction of its length (+ bows to the left of
|
|
87
|
+
* the way it points, − to the right). Default: a slight hand-drawn bow, or
|
|
88
|
+
* round any text it would cross.
|
|
89
|
+
*/
|
|
90
|
+
bend?: number;
|
|
79
91
|
color?: string;
|
|
80
92
|
/** Start undrawn, to be drawn in with the `draw` edit */
|
|
81
93
|
hidden?: boolean;
|