@margoengine/cutscene 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +774 -3
- package/dist/curve-editor.d.ts +79 -0
- package/dist/curve-editor.js +293 -0
- package/dist/cutscene-DAWl8liP.js +496 -0
- package/dist/cutscene.d.ts +157 -0
- package/dist/document.d.ts +234 -0
- package/dist/editor.d.ts +254 -0
- package/dist/editor.js +514 -0
- package/dist/film-titles.d.ts +162 -0
- package/dist/film-titles.js +229 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lipsync.d.ts +72 -0
- package/dist/lipsync.js +377 -0
- package/dist/nested-editor.d.ts +69 -0
- package/dist/nested-editor.js +217 -0
- package/dist/player-DtIkr2sQ.js +143 -0
- package/dist/player.d.ts +94 -0
- package/dist/record.d.ts +143 -0
- package/dist/record.js +300 -0
- package/dist/render.d.ts +100 -0
- package/dist/render.js +124 -0
- package/dist/scroll.d.ts +103 -0
- package/dist/scroll.js +135 -0
- package/dist/seek.d.ts +86 -0
- package/dist/seek.js +76 -0
- package/dist/shots.d.ts +98 -0
- package/dist/shots.js +220 -0
- package/dist/vfx.d.ts +106 -0
- package/dist/vfx.js +130 -0
- package/dist/viewport.d.ts +53 -0
- package/dist/viewport.js +103 -0
- package/package.json +124 -6
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import type { Quat, Vec3 } from '@margoengine/math';
|
|
2
|
+
export type { Quat, Vec3 };
|
|
3
|
+
/**
|
|
4
|
+
* Easing into a key from the previous one: a name (`'linear'`, `'step'`, `'smoothstep'` or any `ease*` easing of
|
|
5
|
+
* `@margoengine/tween`, e.g. `'easeInOutCubic'`), or CSS cubic-bezier control points `[x1, y1, x2, y2]`.
|
|
6
|
+
*/
|
|
7
|
+
export type EaseSpec = string | readonly [number, number, number, number];
|
|
8
|
+
/** A camera key: where the camera is and looks at a time. */
|
|
9
|
+
export interface CameraKey {
|
|
10
|
+
/** Seconds from the start of the timeline. */
|
|
11
|
+
time: number;
|
|
12
|
+
position: Vec3;
|
|
13
|
+
/** The point looked at. */
|
|
14
|
+
target: Vec3;
|
|
15
|
+
/** Vertical field of view, degrees (default 60, as core's Camera). */
|
|
16
|
+
fov?: number;
|
|
17
|
+
/** Roll about the view direction, radians (default 0). */
|
|
18
|
+
roll?: number;
|
|
19
|
+
/** Easing from the previous key into this one (default `'linear'`). */
|
|
20
|
+
ease?: EaseSpec;
|
|
21
|
+
/** A camera cut: jump to this key instead of moving from the previous one (default false). */
|
|
22
|
+
cut?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Camera moves: keys interpolated along a path, with cuts. */
|
|
25
|
+
export interface CameraTrack {
|
|
26
|
+
type: 'camera';
|
|
27
|
+
id: string;
|
|
28
|
+
keys: CameraKey[];
|
|
29
|
+
/** Path through the key positions and targets: a Catmull-Rom spline through every key (default) or straight lines. */
|
|
30
|
+
path?: 'catmull-rom' | 'linear';
|
|
31
|
+
/** Ignored while true (default false). */
|
|
32
|
+
muted?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** A transform key; each channel present is interpolated among the keys that have it. */
|
|
35
|
+
export interface TransformKey {
|
|
36
|
+
time: number;
|
|
37
|
+
position?: Vec3;
|
|
38
|
+
/** Unit quaternion `[x, y, z, w]`, interpolated by spherical linear interpolation. */
|
|
39
|
+
rotation?: Quat;
|
|
40
|
+
scale?: Vec3;
|
|
41
|
+
ease?: EaseSpec;
|
|
42
|
+
}
|
|
43
|
+
/** Moves one object, named by `target`. */
|
|
44
|
+
export interface TransformTrack {
|
|
45
|
+
type: 'transform';
|
|
46
|
+
id: string;
|
|
47
|
+
/** The object's name in your scene. */
|
|
48
|
+
target: string;
|
|
49
|
+
keys: TransformKey[];
|
|
50
|
+
muted?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** A property key: a number or a numeric array (a colour, a vector). */
|
|
53
|
+
export interface PropertyKey {
|
|
54
|
+
time: number;
|
|
55
|
+
value: number | number[];
|
|
56
|
+
ease?: EaseSpec;
|
|
57
|
+
}
|
|
58
|
+
/** Animates one property of one object (`'material.opacity'`, `'light.intensity'`). */
|
|
59
|
+
export interface PropertyTrack {
|
|
60
|
+
type: 'property';
|
|
61
|
+
id: string;
|
|
62
|
+
target: string;
|
|
63
|
+
property: string;
|
|
64
|
+
keys: PropertyKey[];
|
|
65
|
+
muted?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** A span of time on a clip track. */
|
|
68
|
+
export interface ClipBase {
|
|
69
|
+
/** Seconds from the start of the timeline. */
|
|
70
|
+
start: number;
|
|
71
|
+
/** Seconds; above 0. */
|
|
72
|
+
duration: number;
|
|
73
|
+
}
|
|
74
|
+
/** Plays an animation clip on an object (for your animation mixer). */
|
|
75
|
+
export interface AnimationClip extends ClipBase {
|
|
76
|
+
/** The clip's name (as in the glTF file). */
|
|
77
|
+
clip: string;
|
|
78
|
+
/** Playback rate (default 1). */
|
|
79
|
+
speed?: number;
|
|
80
|
+
/** Clip time at the start of the span, seconds (default 0). */
|
|
81
|
+
offset?: number;
|
|
82
|
+
/** Wrap the clip time at `length` instead of holding the last frame (default false). */
|
|
83
|
+
loop?: boolean;
|
|
84
|
+
/** Clip length for `loop`, seconds. */
|
|
85
|
+
length?: number;
|
|
86
|
+
/** Seconds to fade the weight in from 0 and out to 0 (default 0). */
|
|
87
|
+
blendIn?: number;
|
|
88
|
+
blendOut?: number;
|
|
89
|
+
}
|
|
90
|
+
/** Animation clip triggers for one object. */
|
|
91
|
+
export interface AnimationTrack {
|
|
92
|
+
type: 'animation';
|
|
93
|
+
id: string;
|
|
94
|
+
target: string;
|
|
95
|
+
clips: AnimationClip[];
|
|
96
|
+
muted?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/** An audio cue. */
|
|
99
|
+
export interface AudioClip extends ClipBase {
|
|
100
|
+
/** The sound's name in your audio bank. */
|
|
101
|
+
sound: string;
|
|
102
|
+
/** Gain (default 1). */
|
|
103
|
+
volume?: number;
|
|
104
|
+
/** Seconds into the sound at the start of the span (default 0). */
|
|
105
|
+
offset?: number;
|
|
106
|
+
/** Seconds of linear fade in and out (default 0). */
|
|
107
|
+
fadeIn?: number;
|
|
108
|
+
fadeOut?: number;
|
|
109
|
+
}
|
|
110
|
+
/** Audio cues. */
|
|
111
|
+
export interface AudioTrack {
|
|
112
|
+
type: 'audio';
|
|
113
|
+
id: string;
|
|
114
|
+
clips: AudioClip[];
|
|
115
|
+
muted?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** A subtitle or caption line. */
|
|
118
|
+
export interface SubtitleClip extends ClipBase {
|
|
119
|
+
text: string;
|
|
120
|
+
speaker?: string;
|
|
121
|
+
}
|
|
122
|
+
/** Subtitles and on-screen text. */
|
|
123
|
+
export interface SubtitleTrack {
|
|
124
|
+
type: 'subtitle';
|
|
125
|
+
id: string;
|
|
126
|
+
clips: SubtitleClip[];
|
|
127
|
+
muted?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/** A named instant with optional JSON data. */
|
|
130
|
+
export interface CueEvent {
|
|
131
|
+
time: number;
|
|
132
|
+
name: string;
|
|
133
|
+
data?: unknown;
|
|
134
|
+
}
|
|
135
|
+
/** Custom events: the player fires them in order, also when skipping. */
|
|
136
|
+
export interface EventTrack {
|
|
137
|
+
type: 'event';
|
|
138
|
+
id: string;
|
|
139
|
+
events: CueEvent[];
|
|
140
|
+
muted?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** Plays a nested timeline from `timelines`. */
|
|
143
|
+
export interface TimelineClip extends ClipBase {
|
|
144
|
+
/** Key of the nested timeline in the document's `timelines`. */
|
|
145
|
+
timeline: string;
|
|
146
|
+
/** Playback rate (default 1). */
|
|
147
|
+
speed?: number;
|
|
148
|
+
/** Nested time at the start of the span, seconds (default 0). */
|
|
149
|
+
offset?: number;
|
|
150
|
+
}
|
|
151
|
+
/** Nested timelines, placed on the parent's time. */
|
|
152
|
+
export interface TimelineTrack {
|
|
153
|
+
type: 'timeline';
|
|
154
|
+
id: string;
|
|
155
|
+
clips: TimelineClip[];
|
|
156
|
+
muted?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/** Optional entries extend this map with their track interfaces, without loading their runtime into the root. */
|
|
159
|
+
export interface CustomTrackTypes {
|
|
160
|
+
}
|
|
161
|
+
/** Any built-in track or a type registered by an imported optional entry. */
|
|
162
|
+
export type Track = CameraTrack | TransformTrack | PropertyTrack | AnimationTrack | AudioTrack | SubtitleTrack | EventTrack | TimelineTrack | CustomTrackTypes[keyof CustomTrackTypes];
|
|
163
|
+
/** A named point in time (a chapter, a beat); the player reports markers it passes. */
|
|
164
|
+
export interface Marker {
|
|
165
|
+
time: number;
|
|
166
|
+
name: string;
|
|
167
|
+
}
|
|
168
|
+
/** A timeline: tracks over `duration` seconds. */
|
|
169
|
+
export interface TimelineSpec {
|
|
170
|
+
/** Seconds; above 0. */
|
|
171
|
+
duration: number;
|
|
172
|
+
tracks: Track[];
|
|
173
|
+
markers?: Marker[];
|
|
174
|
+
}
|
|
175
|
+
/** A saved cutscene: `JSON.stringify` it to store it, {@link parseCutscene} to read it back. */
|
|
176
|
+
export interface CutsceneDocument extends TimelineSpec {
|
|
177
|
+
format: 'margo-cutscene';
|
|
178
|
+
version: 1;
|
|
179
|
+
/** Nested timelines by key, for timeline tracks. They may nest further, without cycles. */
|
|
180
|
+
timelines?: Record<string, TimelineSpec>;
|
|
181
|
+
}
|
|
182
|
+
/** What a custom track type's `validate` gets: the helpers the built-in tracks are checked with. */
|
|
183
|
+
export interface TrackCheck {
|
|
184
|
+
/** The track's path in the document (`tracks[2]`). */
|
|
185
|
+
path: string;
|
|
186
|
+
/** Length of the timeline holding the track, seconds. */
|
|
187
|
+
end: number;
|
|
188
|
+
/** Report a problem at `path`, with its fix. */
|
|
189
|
+
add(path: string, message: string): void;
|
|
190
|
+
/** Check a time on this timeline; false when it was reported. */
|
|
191
|
+
time(value: unknown, path: string): boolean;
|
|
192
|
+
/** Check an {@link EaseSpec}; `undefined` passes. */
|
|
193
|
+
ease(value: unknown, path: string): void;
|
|
194
|
+
/** Check that a list holds objects, and count them against {@link MAX_CUTSCENE_ITEMS}; null when it was reported. */
|
|
195
|
+
list(value: unknown, path: string): Record<string, unknown>[] | null;
|
|
196
|
+
/** Check that a list is sorted by `field`. */
|
|
197
|
+
ordered(list: Record<string, unknown>[], path: string, field: string): void;
|
|
198
|
+
/** Check `track.target`. */
|
|
199
|
+
target(): void;
|
|
200
|
+
/** Check `track.clips` as spans of the timeline, calling `check` on each; returns them, or null when reported. */
|
|
201
|
+
clips(check: (clip: Record<string, unknown>, path: string) => void): Record<string, unknown>[] | null;
|
|
202
|
+
/** Check an optional number on a clip: above 0, or 0 and above when `zero` (default true). */
|
|
203
|
+
positive(clip: Record<string, unknown>, key: string, path: string, zero?: boolean): void;
|
|
204
|
+
/** Check a list of {@link CameraKey}s and that it is not empty. */
|
|
205
|
+
cameraKeys(value: unknown, path: string): void;
|
|
206
|
+
}
|
|
207
|
+
/** One problem found by {@link validateCutscene}: where (`tracks[2].keys[0].time`) and what to change. */
|
|
208
|
+
export interface CutsceneIssue {
|
|
209
|
+
path: string;
|
|
210
|
+
message: string;
|
|
211
|
+
}
|
|
212
|
+
/** Deepest nesting of timelines accepted. */
|
|
213
|
+
export declare const MAX_TIMELINE_DEPTH = 16;
|
|
214
|
+
/** Most keys, clips, events and markers accepted in one document. */
|
|
215
|
+
export declare const MAX_CUTSCENE_ITEMS = 1000000;
|
|
216
|
+
/** Names accepted for {@link EaseSpec} besides the `ease*` names of `@margoengine/tween`. */
|
|
217
|
+
export declare const BASIC_EASINGS: readonly ['linear', 'step', 'smoothstep'];
|
|
218
|
+
/** The part of a custom track type the validator uses. */
|
|
219
|
+
export interface TrackValidator {
|
|
220
|
+
validate(track: Record<string, unknown>, check: TrackCheck): void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Check a cutscene document without building it. Returns every problem found, each with its path and the fix; an
|
|
224
|
+
* empty array means it is valid. `easings` lists the extra easing names allowed (the player passes tween's), and
|
|
225
|
+
* `types` the custom track types allowed, by their `type`.
|
|
226
|
+
* Never throws, whatever the input.
|
|
227
|
+
*/
|
|
228
|
+
export declare function validateCutscene(input: unknown, easings?: ReadonlySet<string>, types?: ReadonlyMap<string, TrackValidator>): CutsceneIssue[];
|
|
229
|
+
/**
|
|
230
|
+
* Read a cutscene: JSON text or an object, checked with {@link validateCutscene}. Returns a deep-frozen copy, so the
|
|
231
|
+
* document cannot change under a player and `evaluate` stays a pure function of it and the time.
|
|
232
|
+
* @throws TypeError naming the first problem's path and fix, or for text that is not JSON.
|
|
233
|
+
*/
|
|
234
|
+
export declare function parseCutscene(input: string | unknown, easings?: ReadonlySet<string>, types?: ReadonlyMap<string, TrackValidator>): CutsceneDocument;
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
2
|
+
import { EditHistory } from '@margoengine/inspector/history';
|
|
3
|
+
import { Cutscene, type CutsceneTrackType } from './cutscene.js';
|
|
4
|
+
import { type CutsceneDocument, type TimelineSpec, type Track } from './document.js';
|
|
5
|
+
/** The `track` of the row that holds the document's markers. */
|
|
6
|
+
export declare const MARKERS = "@markers";
|
|
7
|
+
/** An item of a row: a place in its track's list. Moves and deletes give new refs, as lists stay sorted. */
|
|
8
|
+
export interface ItemRef {
|
|
9
|
+
track: string;
|
|
10
|
+
index: number;
|
|
11
|
+
}
|
|
12
|
+
/** Something on a row. */
|
|
13
|
+
export interface TimelineItem extends ItemRef {
|
|
14
|
+
kind: 'key' | 'event' | 'clip' | 'marker';
|
|
15
|
+
/** Seconds; a clip's start. */
|
|
16
|
+
time: number;
|
|
17
|
+
/** Seconds; 0 for all but clips. */
|
|
18
|
+
duration: number;
|
|
19
|
+
/** What it shows: an event's name, a clip's text, sound or camera. */
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
/** A track as the panel shows it. */
|
|
23
|
+
export interface TimelineRow {
|
|
24
|
+
track: string;
|
|
25
|
+
type: string;
|
|
26
|
+
/** The track's target or id. */
|
|
27
|
+
label: string;
|
|
28
|
+
items: TimelineItem[];
|
|
29
|
+
/** True when {@link TimelineModel.addKey} can add here with no fields. */
|
|
30
|
+
keyable: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Options of {@link TimelineModel}. */
|
|
33
|
+
export interface TimelineModelOptions {
|
|
34
|
+
/** Custom track types the document uses, as for `Cutscene`. Default none. */
|
|
35
|
+
tracks?: readonly CutsceneTrackType[];
|
|
36
|
+
/** Undo stack, to share with the rest of your tool. Default a new one. */
|
|
37
|
+
history?: EditHistory;
|
|
38
|
+
}
|
|
39
|
+
/** Options of {@link TimelineModel.snap}. */
|
|
40
|
+
export interface SnapOptions {
|
|
41
|
+
/** Grid in seconds; 0 turns it off. Default 0.1. */
|
|
42
|
+
step?: number;
|
|
43
|
+
/** Pulls to other items and to these times within this many seconds; 0 turns it off. Default 0.05. */
|
|
44
|
+
reach?: number;
|
|
45
|
+
/** Items that do not pull: the ones being dragged. */
|
|
46
|
+
ignore?: readonly ItemRef[];
|
|
47
|
+
/** More times that pull, such as the playhead. */
|
|
48
|
+
times?: readonly number[];
|
|
49
|
+
}
|
|
50
|
+
type Listener = (label: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* A cutscene document being edited: add, move and delete keys, events, clips and markers with undo and redo. Every
|
|
53
|
+
* edit leaves a valid document: one that would break it, such as two shots overlapping, is refused and changes nothing.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* const model = new TimelineModel(document);
|
|
57
|
+
* const key = model.addKey('door', 1.5);
|
|
58
|
+
* model.moveItems([key], 0.25);
|
|
59
|
+
* model.undo();
|
|
60
|
+
* const text = model.save();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class TimelineModel {
|
|
64
|
+
/** The undo stack. */
|
|
65
|
+
readonly history: EditHistory;
|
|
66
|
+
private data;
|
|
67
|
+
private root?;
|
|
68
|
+
private scopeName?;
|
|
69
|
+
private get doc();
|
|
70
|
+
private set doc(value);
|
|
71
|
+
private readonly types;
|
|
72
|
+
private readonly checks;
|
|
73
|
+
private readonly listeners;
|
|
74
|
+
private open;
|
|
75
|
+
/** @throws TypeError naming the first problem of a document that is not valid. */
|
|
76
|
+
constructor(document: CutsceneDocument | string | unknown, _arg0?: TimelineModelOptions);
|
|
77
|
+
/** Length of the timeline, seconds. */
|
|
78
|
+
get duration(): number;
|
|
79
|
+
/** A copy of the document as it stands. */
|
|
80
|
+
get document(): CutsceneDocument;
|
|
81
|
+
/** The document as it stands, for `JSON.stringify`. */
|
|
82
|
+
toJSON(): CutsceneDocument;
|
|
83
|
+
/** The document as JSON text, for a file; `new Cutscene(text)` reads it. */
|
|
84
|
+
save(): string;
|
|
85
|
+
/** A `Cutscene` of the document as it stands, to play or render. */
|
|
86
|
+
cutscene(): Cutscene;
|
|
87
|
+
/** Calls `listener` with the edit's label after every change, undo and redo included. Returns an unsubscribe function. */
|
|
88
|
+
on(event: 'change', listener: Listener): () => void;
|
|
89
|
+
/** A live editing view of a named nested definition. It shares root validation, subscriptions and undo history. */
|
|
90
|
+
nested(name: string): TimelineModel;
|
|
91
|
+
/** Sets a named definition atomically, validating all its placements and refusing cycles. */
|
|
92
|
+
setTimeline(name: string, timeline: TimelineSpec): boolean;
|
|
93
|
+
/** Every top-level track, then the markers. A timeline clip moves as one clip; what is inside it is not shown. */
|
|
94
|
+
get rows(): TimelineRow[];
|
|
95
|
+
/**
|
|
96
|
+
* Adds a key at `time` on a key track, holding what the track gives there, so the value at that time stays as it
|
|
97
|
+
* was until you edit it; `fields` set or replace parts of it. On an event track or the marker row it adds one named
|
|
98
|
+
* `fields.name`.
|
|
99
|
+
* @returns the new item.
|
|
100
|
+
* @throws RangeError for an unknown track, a time outside the timeline, or a clip track: use {@link addItem}.
|
|
101
|
+
*/
|
|
102
|
+
addKey(track: string, time: number, fields?: Record<string, unknown>): ItemRef;
|
|
103
|
+
/**
|
|
104
|
+
* Adds a whole key, event, marker or clip: `{ time, ... }`, or `{ start, duration, ... }` for a clip.
|
|
105
|
+
* @returns the new item.
|
|
106
|
+
* @throws RangeError for an unknown track or fields the document refuses.
|
|
107
|
+
*/
|
|
108
|
+
addItem(track: string, item: Record<string, unknown>): ItemRef;
|
|
109
|
+
/** Adds a whole track as one validated undo step. Duplicate ids or invalid fields throw without changing the document. */
|
|
110
|
+
addTrack(track: Track): void;
|
|
111
|
+
/**
|
|
112
|
+
* Moves items together by `delta` seconds, stopping at the ends of the timeline as a group.
|
|
113
|
+
* @returns the items where they are now. A move the document refuses changes nothing, and gives them back as they were.
|
|
114
|
+
*/
|
|
115
|
+
moveItems(items: readonly ItemRef[], delta: number): ItemRef[];
|
|
116
|
+
/**
|
|
117
|
+
* Changes fields of an item: a key's `value` or `ease`, an event's `name`, a clip's `duration`. Pass `undefined` to
|
|
118
|
+
* remove a field. Use {@link moveItems} for its time.
|
|
119
|
+
* @returns true, or false when the document refuses the change, which then does not happen.
|
|
120
|
+
*/
|
|
121
|
+
setItem(ref: ItemRef, fields: Record<string, unknown>): boolean;
|
|
122
|
+
/** Atomically edits and sorts an item, including its time. Returns its new ref, or undefined if validation refuses it. */
|
|
123
|
+
updateItem(ref: ItemRef, fields: Record<string, unknown>): ItemRef | undefined;
|
|
124
|
+
/** Deletes items. A delete the document refuses, such as a track's last key, changes nothing and gives false. */
|
|
125
|
+
deleteItems(items: readonly ItemRef[]): boolean;
|
|
126
|
+
/** Sets the length of the timeline. False when something would fall outside it, which is then not done. */
|
|
127
|
+
setDuration(seconds: number): boolean;
|
|
128
|
+
/** Starts a run of edits that undo as one, such as a drag; {@link commit} ends it. */
|
|
129
|
+
begin(label: string): void;
|
|
130
|
+
/** Ends the run {@link begin} started. A run that changed nothing leaves no undo step. */
|
|
131
|
+
commit(): void;
|
|
132
|
+
/** Takes back the last edit, if any. */
|
|
133
|
+
undo(): void;
|
|
134
|
+
/** Does the last undone edit again, if any. */
|
|
135
|
+
redo(): void;
|
|
136
|
+
/** The time to use for `time`: on another item or a given time if one is near, else on the grid, else as it is. */
|
|
137
|
+
snap(time: number, _arg1?: SnapOptions): number;
|
|
138
|
+
private track;
|
|
139
|
+
private list;
|
|
140
|
+
private item;
|
|
141
|
+
private sampled;
|
|
142
|
+
private snapshot;
|
|
143
|
+
private restore;
|
|
144
|
+
private changed;
|
|
145
|
+
private remember;
|
|
146
|
+
/** Runs one change; keeps it only if the document stays valid. `strict` reports a refusal as a RangeError. */
|
|
147
|
+
private edit;
|
|
148
|
+
}
|
|
149
|
+
/** Options of {@link TimelineEditor}. */
|
|
150
|
+
export interface TimelineEditorOptions extends TimelineModelOptions {
|
|
151
|
+
/** Where the panel goes. Default none: place `element` yourself. */
|
|
152
|
+
parent?: HTMLElement;
|
|
153
|
+
/** Pixels a second, from 10 to 2000. Default 100. */
|
|
154
|
+
zoom?: number;
|
|
155
|
+
/** Grid in seconds, also what an arrow key moves. Default 0.1. */
|
|
156
|
+
step?: number;
|
|
157
|
+
/** Snap while dragging and scrubbing. Default true. */
|
|
158
|
+
snap?: boolean;
|
|
159
|
+
/** File name of the Export button. Default `'cutscene.json'`. */
|
|
160
|
+
fileName?: string;
|
|
161
|
+
}
|
|
162
|
+
/** What {@link TimelineEditor.on} listens for, with what each gives. */
|
|
163
|
+
export interface TimelineEditorEvents {
|
|
164
|
+
/** The playhead moved: seconds. */
|
|
165
|
+
seek: number;
|
|
166
|
+
/** The selection changed. */
|
|
167
|
+
select: readonly ItemRef[];
|
|
168
|
+
/** The document changed: the edit's label. */
|
|
169
|
+
change: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The timeline panel: rows of keys, clips and events under a ruler. Drag the ruler to scrub, drag items to move them,
|
|
173
|
+
* and `on('seek' | 'select' | 'change', listener)` to follow along.
|
|
174
|
+
*
|
|
175
|
+
* | Key | Does |
|
|
176
|
+
* | --- | --- |
|
|
177
|
+
* | Left, Right | Moves the selection a step, or the playhead with nothing selected; Shift makes it ten |
|
|
178
|
+
* | Home, End | Playhead to the ends |
|
|
179
|
+
* | K | Adds a key at the playhead on the current row |
|
|
180
|
+
* | Delete, Backspace | Deletes the selection |
|
|
181
|
+
* | Ctrl+Z, Ctrl+Shift+Z, Ctrl+Y | Undo, redo (Cmd too) |
|
|
182
|
+
* | +, - | Zoom |
|
|
183
|
+
* | Escape | Clears the selection |
|
|
184
|
+
*
|
|
185
|
+
* @throws TypeError for a document that is not valid, RangeError for options out of range.
|
|
186
|
+
*/
|
|
187
|
+
export declare class TimelineEditor {
|
|
188
|
+
/** The panel. */
|
|
189
|
+
readonly element: HTMLDivElement;
|
|
190
|
+
/** The document being edited. */
|
|
191
|
+
readonly model: TimelineModel;
|
|
192
|
+
private readonly bar;
|
|
193
|
+
private readonly names;
|
|
194
|
+
private readonly scroll;
|
|
195
|
+
private readonly inner;
|
|
196
|
+
private readonly ruler;
|
|
197
|
+
private readonly lanes;
|
|
198
|
+
private readonly head;
|
|
199
|
+
private readonly listeners;
|
|
200
|
+
private readonly fileName;
|
|
201
|
+
private readonly step;
|
|
202
|
+
private readonly unsubscribe;
|
|
203
|
+
private pixels;
|
|
204
|
+
private snapping;
|
|
205
|
+
private playhead;
|
|
206
|
+
private picked;
|
|
207
|
+
private row;
|
|
208
|
+
private drag;
|
|
209
|
+
/** True while a move is under way: the rows wait for the selection's new places. */
|
|
210
|
+
private holding;
|
|
211
|
+
private disposed;
|
|
212
|
+
/** Aborted at dispose: removes every listener the panel added. */
|
|
213
|
+
private readonly abort;
|
|
214
|
+
constructor(document: CutsceneDocument | string | unknown, options?: TimelineEditorOptions);
|
|
215
|
+
/** Playhead, seconds. Setting it moves the playhead and fires no event. */
|
|
216
|
+
get time(): number;
|
|
217
|
+
set time(seconds: number);
|
|
218
|
+
/** Pixels a second. */
|
|
219
|
+
get zoom(): number;
|
|
220
|
+
set zoom(value: number);
|
|
221
|
+
/** Selected items. */
|
|
222
|
+
get selection(): readonly ItemRef[];
|
|
223
|
+
set selection(items: readonly ItemRef[]);
|
|
224
|
+
/** Calls `listener` on an event. Returns an unsubscribe function. */
|
|
225
|
+
on<K extends keyof TimelineEditorEvents>(event: K, listener: (value: TimelineEditorEvents[K]) => void): () => void;
|
|
226
|
+
/** Removes the panel and its listeners. */
|
|
227
|
+
dispose(): void;
|
|
228
|
+
[Symbol.dispose](): void;
|
|
229
|
+
private emit;
|
|
230
|
+
private toolbar;
|
|
231
|
+
/** Moves what follows the time, without rebuilding the rows. */
|
|
232
|
+
private place;
|
|
233
|
+
private draw;
|
|
234
|
+
private itemElement;
|
|
235
|
+
/** Seconds under a pointer. */
|
|
236
|
+
private timeAt;
|
|
237
|
+
private snapped;
|
|
238
|
+
/** Seeks the playhead and emits seek, as a ruler gesture does. Setting time alone emits no event. */
|
|
239
|
+
seek(time: number): void;
|
|
240
|
+
private press;
|
|
241
|
+
private grab;
|
|
242
|
+
private pointerMove;
|
|
243
|
+
/** Moves the selection and gives how far it went: less at the ends of the timeline, 0 when the document refuses. */
|
|
244
|
+
private shift;
|
|
245
|
+
private release;
|
|
246
|
+
/** Undo and redo put older lists back, so refs of the selection mean nothing there. */
|
|
247
|
+
private history;
|
|
248
|
+
private addKey;
|
|
249
|
+
private nudge;
|
|
250
|
+
private key;
|
|
251
|
+
private wheel;
|
|
252
|
+
private download;
|
|
253
|
+
}
|
|
254
|
+
export {};
|