@margoengine/cutscene 0.0.0-stage → 1.0.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 +773 -2
- package/dist/curve-editor.d.ts +79 -0
- package/dist/curve-editor.js +293 -0
- package/dist/cutscene-WWP9-stS.js +527 -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-CbKMbpyN.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 +122 -4
package/dist/vfx.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Cutscene, CutsceneState, CutsceneTrackType } from './cutscene.js';
|
|
2
|
+
import type { ClipBase } from './document.js';
|
|
3
|
+
/** A burst of particles inside a clip. */
|
|
4
|
+
export interface VfxBurst {
|
|
5
|
+
/** Seconds from the start of the clip. */
|
|
6
|
+
time: number;
|
|
7
|
+
/** Particles to add, a whole number from 1. */
|
|
8
|
+
count: number;
|
|
9
|
+
}
|
|
10
|
+
/** A span of an effect running. */
|
|
11
|
+
export interface VfxClip extends ClipBase {
|
|
12
|
+
/** Births per second while it runs (default the rate of the effect when the director took it over). */
|
|
13
|
+
rate?: number;
|
|
14
|
+
/** Bursts, sorted by time. */
|
|
15
|
+
bursts?: VfxBurst[];
|
|
16
|
+
}
|
|
17
|
+
/** An effect on the timeline. */
|
|
18
|
+
export interface VfxTrack {
|
|
19
|
+
type: 'vfx';
|
|
20
|
+
id: string;
|
|
21
|
+
/** The effect's name in the director. */
|
|
22
|
+
target: string;
|
|
23
|
+
clips: VfxClip[];
|
|
24
|
+
muted?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Spans an object shows. */
|
|
27
|
+
export interface ActivationTrack {
|
|
28
|
+
type: 'activation';
|
|
29
|
+
id: string;
|
|
30
|
+
/** The object's name. */
|
|
31
|
+
target: string;
|
|
32
|
+
clips: ClipBase[];
|
|
33
|
+
/** Hide the object during the spans instead of showing it (default false). */
|
|
34
|
+
invert?: boolean;
|
|
35
|
+
muted?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** An effect's state at a time. */
|
|
38
|
+
export interface VfxState {
|
|
39
|
+
/** True inside a clip. */
|
|
40
|
+
running: boolean;
|
|
41
|
+
/** Which clip of the track, or the last one before this time; -1 before the first. */
|
|
42
|
+
clip: number;
|
|
43
|
+
/** Seconds into that clip, when running. */
|
|
44
|
+
time: number;
|
|
45
|
+
/** Births per second the clip asks for; absent keeps the effect's own. */
|
|
46
|
+
rate?: number;
|
|
47
|
+
}
|
|
48
|
+
/** The `vfx` track type: pass it in the `tracks` option. Read a state with {@link effectsOf}. */
|
|
49
|
+
export declare function vfxTrack(): CutsceneTrackType;
|
|
50
|
+
/** The `activation` track type: pass it in the `tracks` option. Read a state with {@link activeOf}. */
|
|
51
|
+
export declare function activationTrack(): CutsceneTrackType;
|
|
52
|
+
/** What each effect does at this state's time, by effect name. */
|
|
53
|
+
export declare function effectsOf(state: CutsceneState): Record<string, VfxState>;
|
|
54
|
+
/** Whether each object shows at this state's time, by object name. */
|
|
55
|
+
export declare function activeOf(state: CutsceneState): Record<string, boolean>;
|
|
56
|
+
/** Sets `visible` on the objects a state names; a `Mesh` fits. Objects you do not pass are left alone. */
|
|
57
|
+
export declare function applyActivation(state: CutsceneState, objects: Readonly<Record<string, {
|
|
58
|
+
visible: boolean;
|
|
59
|
+
}>>): void;
|
|
60
|
+
/** What the director drives; `VFX` of `@margoengine/vfx` fits. */
|
|
61
|
+
export interface DirectedEffect {
|
|
62
|
+
options: {
|
|
63
|
+
rate?: number;
|
|
64
|
+
lifetime?: readonly [number, number];
|
|
65
|
+
};
|
|
66
|
+
burst(count: number): unknown;
|
|
67
|
+
reset(): unknown;
|
|
68
|
+
}
|
|
69
|
+
/** Options of {@link VfxDirector}. */
|
|
70
|
+
export interface VfxDirectorOptions {
|
|
71
|
+
/** Draws one step of the given seconds, for the replay of a seek: `(delta) => engine.render({ delta })`. Required. */
|
|
72
|
+
step: (delta: number) => unknown;
|
|
73
|
+
/** Seconds of one replay step. Match your frame time, as the same steps give the same particles (default 1/60). */
|
|
74
|
+
stepSize?: number;
|
|
75
|
+
/** Longest replay, seconds. A seek replays at most this much before its time (default 10). */
|
|
76
|
+
longest?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Applies a cutscene's particle state to live effects, once per frame, before you draw. Playing forward starts and
|
|
80
|
+
* stops them and fires bursts as their times pass. Anything else, a seek, a step backward or a leap, wipes the effects
|
|
81
|
+
* and runs the same frames again from the moment they last had nothing alive, so a scrub lands on what playing there
|
|
82
|
+
* shows, leftovers of earlier clips included. An effect starts fresh whenever a clip finds it empty, so its random
|
|
83
|
+
* numbers depend on the cutscene alone.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* const director = new VfxDirector(cutscene, { sparks }, { step: (delta) => engine.render({ delta }) });
|
|
87
|
+
* director.apply(player.state); // each frame, before engine.render({ delta })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare class VfxDirector {
|
|
91
|
+
private readonly cutscene;
|
|
92
|
+
private readonly effects;
|
|
93
|
+
private readonly step;
|
|
94
|
+
private readonly stepSize;
|
|
95
|
+
private readonly longest;
|
|
96
|
+
/** The time last applied; below 0 before the first. */
|
|
97
|
+
private clock;
|
|
98
|
+
constructor(cutscene: Cutscene, effects: Readonly<Record<string, DirectedEffect>>, options: VfxDirectorOptions);
|
|
99
|
+
/** Makes the effects match a state of this cutscene. Call once per frame, before drawing. */
|
|
100
|
+
apply(state: CutsceneState): void;
|
|
101
|
+
/** One frame of playing: what every frame does, live or in a replay. */
|
|
102
|
+
private forward;
|
|
103
|
+
/** The earliest time something alive at `time` began, within `longest`; `time` when nothing is alive. */
|
|
104
|
+
private cause;
|
|
105
|
+
private seek;
|
|
106
|
+
}
|
package/dist/vfx.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
function e(e, t) {
|
|
2
|
+
let { add: n } = t;
|
|
3
|
+
t.target(), t.clips((e, r) => {
|
|
4
|
+
if (t.positive(e, "rate", r), !("bursts" in e)) return;
|
|
5
|
+
let i = t.list(e.bursts, `${r}.bursts`);
|
|
6
|
+
i?.forEach((t, i) => {
|
|
7
|
+
let a = `${r}.bursts[${i}]`;
|
|
8
|
+
typeof t.time == "number" && t.time >= 0 && t.time <= e.duration || n(`${a}.time`, "must be seconds inside the clip"), (!Number.isInteger(t.count) || t.count < 1) && n(`${a}.count`, "must be a whole number from 1");
|
|
9
|
+
}), i && t.ordered(i, `${r}.bursts`, "time");
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function t(e, t) {
|
|
13
|
+
t.target(), "invert" in e && typeof e.invert != "boolean" && t.add(`${t.path}.invert`, "must be true or false"), t.clips(() => {});
|
|
14
|
+
}
|
|
15
|
+
var n = (e) => {
|
|
16
|
+
let { clips: t, target: n } = e;
|
|
17
|
+
return t.flatMap((e) => [{
|
|
18
|
+
time: e.start,
|
|
19
|
+
kind: "enter",
|
|
20
|
+
name: n,
|
|
21
|
+
clip: e
|
|
22
|
+
}, {
|
|
23
|
+
time: e.start + e.duration,
|
|
24
|
+
kind: "exit",
|
|
25
|
+
name: n,
|
|
26
|
+
clip: e
|
|
27
|
+
}]);
|
|
28
|
+
};
|
|
29
|
+
function r() {
|
|
30
|
+
return {
|
|
31
|
+
type: "vfx",
|
|
32
|
+
validate: e,
|
|
33
|
+
instants(e) {
|
|
34
|
+
let { clips: t, target: r } = e, i = t.flatMap((e) => (e.bursts ?? []).map((t) => ({
|
|
35
|
+
time: e.start + t.time,
|
|
36
|
+
kind: "event",
|
|
37
|
+
name: r + ":burst",
|
|
38
|
+
data: { count: t.count }
|
|
39
|
+
})));
|
|
40
|
+
return [...n(e), ...i];
|
|
41
|
+
},
|
|
42
|
+
evaluate(e, t, n) {
|
|
43
|
+
let { clips: r, target: i } = e, a = (n.extras ??= {}).vfx ??= {}, o = -1;
|
|
44
|
+
for (; o + 1 < r.length && r[o + 1].start <= t;) o++;
|
|
45
|
+
let s = r[o], c = !!s && t < s.start + s.duration;
|
|
46
|
+
a[i]?.running || (a[i] = c ? {
|
|
47
|
+
running: c,
|
|
48
|
+
clip: o,
|
|
49
|
+
time: t - s.start,
|
|
50
|
+
...s.rate === void 0 ? {} : { rate: s.rate }
|
|
51
|
+
} : {
|
|
52
|
+
running: c,
|
|
53
|
+
clip: o,
|
|
54
|
+
time: 0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function i() {
|
|
60
|
+
return {
|
|
61
|
+
type: "activation",
|
|
62
|
+
validate: t,
|
|
63
|
+
instants: n,
|
|
64
|
+
evaluate(e, t, n) {
|
|
65
|
+
let { clips: r, target: i, invert: a } = e, o = (n.extras ??= {}).active ??= {};
|
|
66
|
+
o[i] = r.some((e) => t >= e.start && t < e.start + e.duration) !== (a === !0);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function a(e) {
|
|
71
|
+
return e.extras?.vfx ?? {};
|
|
72
|
+
}
|
|
73
|
+
function o(e) {
|
|
74
|
+
return e.extras?.active ?? {};
|
|
75
|
+
}
|
|
76
|
+
function s(e, t) {
|
|
77
|
+
for (let [n, r] of Object.entries(o(e))) Object.hasOwn(t, n) && (t[n].visible = r);
|
|
78
|
+
}
|
|
79
|
+
var c = 8, l = 3, u = 1e-6, d = (e) => e.options.lifetime?.[1] ?? l, f = class {
|
|
80
|
+
constructor(e, t, n) {
|
|
81
|
+
this.cutscene = e, this.clock = -1;
|
|
82
|
+
let { step: r, stepSize: i = 1 / 60, longest: a = 10 } = n ?? {};
|
|
83
|
+
if (typeof e?.evaluate != "function") throw TypeError("VfxDirector needs the Cutscene as its first argument");
|
|
84
|
+
if (typeof r != "function") throw TypeError("VfxDirector needs step(delta), which draws one frame");
|
|
85
|
+
if (!(i > 0) || !Number.isFinite(i)) throw RangeError("VfxDirector stepSize must be above 0");
|
|
86
|
+
if (!(a >= 0) || !Number.isFinite(a)) throw RangeError("VfxDirector longest must be 0 or more");
|
|
87
|
+
this.step = r, this.stepSize = i, this.longest = a, this.effects = new Map(Object.entries(t).map(([e, t]) => {
|
|
88
|
+
let n = t.options.rate;
|
|
89
|
+
return t.options.rate = 0, [e, {
|
|
90
|
+
effect: t,
|
|
91
|
+
rate: n,
|
|
92
|
+
running: !1,
|
|
93
|
+
on: -Infinity
|
|
94
|
+
}];
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
apply(e) {
|
|
98
|
+
let { time: t } = e, n = t - Math.max(0, this.clock);
|
|
99
|
+
n >= 0 && n <= this.stepSize * c ? this.forward(t) : this.seek(t);
|
|
100
|
+
}
|
|
101
|
+
forward(e) {
|
|
102
|
+
let t = a(this.cutscene.evaluate(e + u));
|
|
103
|
+
for (let [n, r] of this.effects) {
|
|
104
|
+
let i = t[n], { effect: a } = r;
|
|
105
|
+
i?.running ? (!r.running && e - r.on > d(a) && a.reset(), a.options.rate = i.rate ?? r.rate, r.running = !0, r.on = e) : (a.options.rate = 0, r.running = !1);
|
|
106
|
+
}
|
|
107
|
+
for (let t of this.cutscene.eventsBetween(this.clock + u, e + u)) t.type === "vfx" && t.kind === "event" && this.effects.get(t.name.slice(0, -6))?.effect.burst(t.data.count);
|
|
108
|
+
this.clock = e;
|
|
109
|
+
}
|
|
110
|
+
cause(e) {
|
|
111
|
+
let t = /* @__PURE__ */ new Map(), n = Math.floor(Math.min(e, this.longest) / this.stepSize + u), r = e;
|
|
112
|
+
for (let i = 0; i <= n; i++) {
|
|
113
|
+
let n = e - i * this.stepSize, o = a(this.cutscene.evaluate(n + u));
|
|
114
|
+
for (let [i, { effect: a }] of this.effects) {
|
|
115
|
+
let s = t.get(i) ?? e;
|
|
116
|
+
!o[i]?.running || s - n > d(a) || (t.set(i, n), r = Math.min(r, n));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return r;
|
|
120
|
+
}
|
|
121
|
+
seek(e) {
|
|
122
|
+
let t = this.stepSize, n = Math.ceil((e - this.cause(e)) / t - u);
|
|
123
|
+
for (let e of this.effects.values()) e.effect.reset(), e.effect.options.rate = 0, e.running = !1, e.on = -Infinity;
|
|
124
|
+
this.clock = e - (n + 1) * t;
|
|
125
|
+
for (let r = n; r > 0; r--) this.forward(Math.max(0, e - r * t)), this.step(t);
|
|
126
|
+
this.forward(e);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
export { f as VfxDirector, i as activationTrack, o as activeOf, s as applyActivation, a as effectsOf, r as vfxTrack };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
2
|
+
import type { EngineKernel, Mesh } from '@margoengine/core';
|
|
3
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
4
|
+
import type { Inspector } from '@margoengine/inspector';
|
|
5
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
6
|
+
import type { InspectorGizmo, InspectorGizmoOptions } from '@margoengine/inspector/gizmo';
|
|
7
|
+
import type { TransformKey } from './document.js';
|
|
8
|
+
import type { ItemRef, TimelineEditor, TimelineModel } from './editor.js';
|
|
9
|
+
/** Inserts or replaces a transform key at its exact time, creating its track when absent. One validated undo step. */
|
|
10
|
+
export declare function keyTransform(model: TimelineModel, track: string, target: string, key: TransformKey): ItemRef;
|
|
11
|
+
/** Options for selecting and keying meshes with the inspector gizmo. */
|
|
12
|
+
export interface ViewportKeyingOptions {
|
|
13
|
+
/** Borrow an existing inspector gizmo; default attach one owned by this tool. */
|
|
14
|
+
gizmo?: InspectorGizmo;
|
|
15
|
+
/** Options of an owned gizmo; ignored when gizmo is supplied. */
|
|
16
|
+
gizmoOptions?: InspectorGizmoOptions;
|
|
17
|
+
/** Map a mesh to saved track id and target. Default its nonempty name, otherwise mesh-<runtime id>. */
|
|
18
|
+
binding?: (mesh: Mesh) => {
|
|
19
|
+
track: string;
|
|
20
|
+
target: string;
|
|
21
|
+
};
|
|
22
|
+
/** Key after a completed gizmo drag that changed the pose. Default false. */
|
|
23
|
+
autoKey?: boolean;
|
|
24
|
+
/** Where the key button and auto-key toggle go. Default the timeline panel. */
|
|
25
|
+
parent?: HTMLElement | ShadowRoot;
|
|
26
|
+
/** Dispose on abort. An already aborted signal throws before attachment. */
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
/** Picks through an attached Inspector, manipulates with its gizmo and keys local transforms at the editor playhead. */
|
|
30
|
+
export declare class ViewportKeying {
|
|
31
|
+
readonly engine: EngineKernel;
|
|
32
|
+
readonly editor: TimelineEditor;
|
|
33
|
+
readonly inspector: Inspector;
|
|
34
|
+
private readonly options;
|
|
35
|
+
readonly gizmo: InspectorGizmo;
|
|
36
|
+
readonly element: HTMLFieldSetElement;
|
|
37
|
+
/** Whether the end of each changed drag records a transform key. Default false. */
|
|
38
|
+
autoKey: boolean;
|
|
39
|
+
private before?;
|
|
40
|
+
private disposed;
|
|
41
|
+
private readonly abort;
|
|
42
|
+
/** Loads the inspector gizmo only when attaching. An aborted signal leaves no owned tool behind. */
|
|
43
|
+
static attach(engine: EngineKernel, editor: TimelineEditor, inspector: Inspector, options?: ViewportKeyingOptions): Promise<ViewportKeying>;
|
|
44
|
+
private constructor();
|
|
45
|
+
/** Records the current selection. Replaces an existing key at the playhead, preserving its easing. */
|
|
46
|
+
key(): ItemRef;
|
|
47
|
+
private readonly start;
|
|
48
|
+
private readonly end;
|
|
49
|
+
private readonly shortcut;
|
|
50
|
+
/** Removes keying UI/listeners and disposes only an owned gizmo. The editor, inspector and scene are borrowed. */
|
|
51
|
+
dispose(): void;
|
|
52
|
+
[Symbol.dispose](): void;
|
|
53
|
+
}
|
package/dist/viewport.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
|
|
4
|
+
import { MargoError as e } from "@margoengine/math/errors";
|
|
5
|
+
import { meshRuntime as t } from "@margoengine/core/extension";
|
|
6
|
+
//#region src/viewport.ts
|
|
7
|
+
function n(e, t, n, r) {
|
|
8
|
+
let i = e.document.tracks.find((e) => e.id === t);
|
|
9
|
+
if (!i) return e.addTrack({
|
|
10
|
+
type: "transform",
|
|
11
|
+
id: t,
|
|
12
|
+
target: n,
|
|
13
|
+
keys: [r]
|
|
14
|
+
}), {
|
|
15
|
+
track: t,
|
|
16
|
+
index: 0
|
|
17
|
+
};
|
|
18
|
+
if (i.type !== "transform" || i.target !== n) throw RangeError("Viewport track must transform this target; choose a matching track id");
|
|
19
|
+
let a = i.keys.findIndex((e) => e.time === r.time);
|
|
20
|
+
if (a < 0) return e.addItem(t, r);
|
|
21
|
+
let o = e.updateItem({
|
|
22
|
+
track: t,
|
|
23
|
+
index: a
|
|
24
|
+
}, r);
|
|
25
|
+
if (!o) throw RangeError("Transform key was refused; pass finite transforms and a unit quaternion");
|
|
26
|
+
return o;
|
|
27
|
+
}
|
|
28
|
+
var r = (e) => {
|
|
29
|
+
e.check();
|
|
30
|
+
let n = t(e), r = n.engine.store.transforms, i = n.id;
|
|
31
|
+
return [
|
|
32
|
+
"x",
|
|
33
|
+
"y",
|
|
34
|
+
"z",
|
|
35
|
+
"qx",
|
|
36
|
+
"qy",
|
|
37
|
+
"qz",
|
|
38
|
+
"qw",
|
|
39
|
+
"sx",
|
|
40
|
+
"sy",
|
|
41
|
+
"sz"
|
|
42
|
+
].map((e) => r[e][i]);
|
|
43
|
+
}, i = class i {
|
|
44
|
+
static async attach(e, t, n, r = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
45
|
+
r.signal?.throwIfAborted();
|
|
46
|
+
let a = r.gizmo ? void 0 : await import("@margoengine/inspector/gizmo");
|
|
47
|
+
r.signal?.throwIfAborted();
|
|
48
|
+
let o = r.gizmo ?? a.InspectorGizmo.attach(e, n, r.gizmoOptions);
|
|
49
|
+
try {
|
|
50
|
+
return new i(e, t, n, r, o);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
throw r.gizmo || o.dispose(), e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
constructor(e, t, n, i, a) {
|
|
56
|
+
if (this.engine = e, this.editor = t, this.inspector = n, this.options = i, this.disposed = !1, this.abort = new AbortController(), this.start = () => {
|
|
57
|
+
let e = this.inspector.selected;
|
|
58
|
+
this.before = e ? {
|
|
59
|
+
mesh: e,
|
|
60
|
+
values: r(e)
|
|
61
|
+
} : void 0;
|
|
62
|
+
}, this.end = () => {
|
|
63
|
+
let e = this.before;
|
|
64
|
+
this.before = void 0, this.autoKey && e && e.mesh === this.inspector.selected && r(e.mesh).some((t, n) => t !== e.values[n]) && this.key();
|
|
65
|
+
}, this.shortcut = (e) => {
|
|
66
|
+
e.key.toLowerCase() !== "k" || e.ctrlKey || e.metaKey || e.altKey || !this.inspector.selected || (e.preventDefault(), this.key());
|
|
67
|
+
}, this.dispose = this.dispose.bind(this), i.signal?.throwIfAborted(), i.gizmo && (i.gizmo.engine !== e || i.gizmo.inspector !== n)) throw RangeError("Viewport gizmo must belong to this engine and inspector; pass their gizmo");
|
|
68
|
+
this.gizmo = a, this.autoKey = i.autoKey ?? !1;
|
|
69
|
+
let o = t.element.ownerDocument;
|
|
70
|
+
this.element = o.createElement("fieldset");
|
|
71
|
+
let s = o.createElement("legend");
|
|
72
|
+
s.textContent = "Viewport keying", this.element.append(s);
|
|
73
|
+
let c = o.createElement("button");
|
|
74
|
+
c.type = "button", c.textContent = "Key transform", c.addEventListener("click", () => this.key(), { signal: this.abort.signal }), this.element.append(c);
|
|
75
|
+
let l = o.createElement("label"), u = o.createElement("input");
|
|
76
|
+
u.type = "checkbox", u.checked = this.autoKey, u.addEventListener("change", () => {
|
|
77
|
+
this.autoKey = u.checked;
|
|
78
|
+
}, { signal: this.abort.signal }), l.append(u, " Auto key"), this.element.append(l), (i.parent ?? t.element).append(this.element), this.gizmo.controls.addEventListener("mouseDown", this.start), this.gizmo.controls.addEventListener("mouseUp", this.end), e.canvas.addEventListener("keydown", this.shortcut, { signal: this.abort.signal }), i.signal?.addEventListener("abort", this.dispose, { once: !0 });
|
|
79
|
+
}
|
|
80
|
+
key() {
|
|
81
|
+
if (this.disposed) throw new e("disposed", "Viewport keying is disposed; attach a new tool");
|
|
82
|
+
let i = this.inspector.selected;
|
|
83
|
+
if (!i) throw new e("state", "Select a scene object before keying its transform");
|
|
84
|
+
let a = r(i), o = i.name || `mesh-${t(i).id}`, { track: s, target: c } = this.options.binding?.(i) ?? {
|
|
85
|
+
track: o,
|
|
86
|
+
target: o
|
|
87
|
+
}, l = n(this.editor.model, s, c, {
|
|
88
|
+
time: this.editor.time,
|
|
89
|
+
position: a.slice(0, 3),
|
|
90
|
+
rotation: a.slice(3, 7),
|
|
91
|
+
scale: a.slice(7, 10)
|
|
92
|
+
});
|
|
93
|
+
return this.editor.selection = [l], l;
|
|
94
|
+
}
|
|
95
|
+
dispose() {
|
|
96
|
+
this.disposed || (this.disposed = !0, this.abort.abort(), this.options.signal?.removeEventListener("abort", this.dispose), this.gizmo.controls.removeEventListener("mouseDown", this.start), this.gizmo.controls.removeEventListener("mouseUp", this.end), this.options.gizmo || this.gizmo.dispose(), this.element.remove(), this.before = void 0);
|
|
97
|
+
}
|
|
98
|
+
[Symbol.dispose]() {
|
|
99
|
+
this.dispose();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { i as ViewportKeying, n as keyTransform };
|
package/package.json
CHANGED
|
@@ -1,6 +1,124 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@margoengine/cutscene",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cutscene timelines: camera, transform, property, animation, audio, subtitle and event tracks, nested timelines, scrubbing, a player that fires events in order, virtual camera shots with blends, rendering to a video file, a take recorder, dialogue with lip sync, and particle and activation tracks, and a timeline editor panel.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"cutscene",
|
|
10
|
+
"timeline",
|
|
11
|
+
"sequencer",
|
|
12
|
+
"cinematics",
|
|
13
|
+
"keyframes"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://margoengine.com",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
22
|
+
"directory": "packages/cutscene"
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"author": "Scott Campbell",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./shots": {
|
|
34
|
+
"types": "./dist/shots.d.ts",
|
|
35
|
+
"import": "./dist/shots.js"
|
|
36
|
+
},
|
|
37
|
+
"./render": {
|
|
38
|
+
"types": "./dist/render.d.ts",
|
|
39
|
+
"import": "./dist/render.js"
|
|
40
|
+
},
|
|
41
|
+
"./record": {
|
|
42
|
+
"types": "./dist/record.d.ts",
|
|
43
|
+
"import": "./dist/record.js"
|
|
44
|
+
},
|
|
45
|
+
"./lipsync": {
|
|
46
|
+
"types": "./dist/lipsync.d.ts",
|
|
47
|
+
"import": "./dist/lipsync.js"
|
|
48
|
+
},
|
|
49
|
+
"./vfx": {
|
|
50
|
+
"types": "./dist/vfx.d.ts",
|
|
51
|
+
"import": "./dist/vfx.js"
|
|
52
|
+
},
|
|
53
|
+
"./editor": {
|
|
54
|
+
"types": "./dist/editor.d.ts",
|
|
55
|
+
"import": "./dist/editor.js"
|
|
56
|
+
},
|
|
57
|
+
"./curve-editor": {
|
|
58
|
+
"types": "./dist/curve-editor.d.ts",
|
|
59
|
+
"import": "./dist/curve-editor.js"
|
|
60
|
+
},
|
|
61
|
+
"./viewport": {
|
|
62
|
+
"types": "./dist/viewport.d.ts",
|
|
63
|
+
"import": "./dist/viewport.js"
|
|
64
|
+
},
|
|
65
|
+
"./nested-editor": {
|
|
66
|
+
"types": "./dist/nested-editor.d.ts",
|
|
67
|
+
"import": "./dist/nested-editor.js"
|
|
68
|
+
},
|
|
69
|
+
"./scroll": {
|
|
70
|
+
"types": "./dist/scroll.d.ts",
|
|
71
|
+
"import": "./dist/scroll.js"
|
|
72
|
+
},
|
|
73
|
+
"./seek": {
|
|
74
|
+
"types": "./dist/seek.d.ts",
|
|
75
|
+
"import": "./dist/seek.js"
|
|
76
|
+
},
|
|
77
|
+
"./film-titles": {
|
|
78
|
+
"types": "./dist/film-titles.d.ts",
|
|
79
|
+
"import": "./dist/film-titles.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"files": [
|
|
83
|
+
"dist",
|
|
84
|
+
"LICENSE",
|
|
85
|
+
"NOTICE"
|
|
86
|
+
],
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
},
|
|
90
|
+
"dependencies": {
|
|
91
|
+
"@margoengine/math": "^1.0.0",
|
|
92
|
+
"@margoengine/tween": "^1.0.0"
|
|
93
|
+
},
|
|
94
|
+
"scripts": {
|
|
95
|
+
"build": "node ../../scripts/build-optional.js cutscene",
|
|
96
|
+
"test": "npm run build && node --test tests/*.test.js",
|
|
97
|
+
"test:gpu": "npm run build && cd ../.. && node packages/cutscene/tests/render-browser.mjs && node packages/cutscene/tests/vfx-browser.mjs && node packages/cutscene/tests/editor-browser.mjs && node packages/cutscene/tests/curve-browser.mjs && node packages/cutscene/tests/viewport-browser.mjs && node packages/cutscene/tests/nested-browser.mjs && node packages/cutscene/tests/scroll-browser.mjs",
|
|
98
|
+
"prepack": "npm run build"
|
|
99
|
+
},
|
|
100
|
+
"peerDependencies": {
|
|
101
|
+
"@margoengine/core": "^1.0.0",
|
|
102
|
+
"@margoengine/headless": "^1.0.0",
|
|
103
|
+
"@margoengine/input": "^1.0.0",
|
|
104
|
+
"@margoengine/inspector": "^1.0.0",
|
|
105
|
+
"@margoengine/ui": "^1.0.0"
|
|
106
|
+
},
|
|
107
|
+
"peerDependenciesMeta": {
|
|
108
|
+
"@margoengine/core": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@margoengine/headless": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@margoengine/input": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"@margoengine/inspector": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"@margoengine/ui": {
|
|
121
|
+
"optional": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|