@margoengine/cutscene 0.1.0 → 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 -201
- package/NOTICE +4 -4
- package/README.md +774 -774
- package/dist/{cutscene-DAWl8liP.js → cutscene-WWP9-stS.js} +162 -131
- package/dist/editor.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{player-DtIkr2sQ.js → player-CbKMbpyN.js} +1 -1
- package/dist/render.js +2 -2
- package/dist/shots.js +1 -1
- package/dist/viewport.js +2 -2
- package/package.json +124 -124
|
@@ -1,186 +1,217 @@
|
|
|
1
1
|
import { interpolateQuaternions as e } from "@margoengine/math/quat";
|
|
2
|
-
import
|
|
2
|
+
import { cubicBezier as t, easeInBack as n, easeInBounce as r, easeInCirc as i, easeInCubic as a, easeInElastic as o, easeInExpo as s, easeInOutBack as c, easeInOutBounce as l, easeInOutCirc as u, easeInOutCubic as d, easeInOutExpo as f, easeInOutQuad as p, easeInOutQuart as m, easeInOutQuint as h, easeInOutSine as g, easeInQuad as _, easeInQuart as v, easeInQuint as y, easeInSine as b, easeOutBack as x, easeOutBounce as S, easeOutCirc as C, easeOutCubic as w, easeOutElastic as ee, easeOutExpo as te, easeOutQuad as ne, easeOutQuart as T, easeOutQuint as E, easeOutSine as D, easeSmoothstep as O, linear as k } from "@margoengine/tween";
|
|
3
3
|
//#region src/document.ts
|
|
4
|
-
var
|
|
4
|
+
var A = 16, j = 1e6, M = (e) => typeof e == "object" && !!e && !Array.isArray(e), N = (e) => typeof e == "number" && Number.isFinite(e), P = (e, t) => Array.isArray(e) && e.length === t && e.every(N), F = [
|
|
5
5
|
"linear",
|
|
6
6
|
"step",
|
|
7
7
|
"smoothstep"
|
|
8
8
|
];
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
|
|
9
|
+
function I(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map()) {
|
|
10
|
+
let r = [], i = (e, t) => {
|
|
11
|
+
r.length < 1e3 && r.push({
|
|
12
12
|
path: e,
|
|
13
13
|
message: t
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
if (!
|
|
17
|
-
e.format !== "margo-cutscene" &&
|
|
18
|
-
let
|
|
19
|
-
"timelines" in e && !
|
|
20
|
-
let
|
|
21
|
-
e !== void 0 && (typeof e == "string" ? !
|
|
22
|
-
},
|
|
23
|
-
let
|
|
24
|
-
if (!
|
|
25
|
-
|
|
16
|
+
if (!M(e)) return i("", "must be a cutscene document {format: \"margo-cutscene\", version: 1, duration, tracks}"), r;
|
|
17
|
+
e.format !== "margo-cutscene" && i("format", "must be 'margo-cutscene'; this is not a cutscene document"), e.version !== 1 && i("version", "must be 1; this file is from a newer version, update @margoengine/cutscene");
|
|
18
|
+
let a = 0, o = M(e.timelines) ? e.timelines : {};
|
|
19
|
+
"timelines" in e && !M(e.timelines) && i("timelines", "must be an object of name: timeline");
|
|
20
|
+
let s = (e, n) => {
|
|
21
|
+
e !== void 0 && (typeof e == "string" ? !F.includes(e) && !t.has(e) && i(n, `unknown easing '${e}'; use linear, step, smoothstep, an ease* name of @margoengine/tween or [x1, y1, x2, y2]`) : (!P(e, 4) || e[0] < 0 || e[0] > 1 || e[2] < 0 || e[2] > 1) && i(n, "must be an easing name or cubic-bezier [x1, y1, x2, y2] with x1 and x2 in [0, 1]"));
|
|
22
|
+
}, c = (e, t) => {
|
|
23
|
+
let r = (e) => t ? `${t}.${e}` : e;
|
|
24
|
+
if (!M(e)) {
|
|
25
|
+
i(t, "must be a timeline {duration, tracks}");
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
let c = e.duration,
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
for (let r = 1; r < e.length; r++)
|
|
32
|
-
},
|
|
33
|
-
if (!Array.isArray(e)) return
|
|
34
|
-
if (
|
|
28
|
+
let c = e.duration, l = N(c) && c > 0;
|
|
29
|
+
l || i(r("duration"), "must be a finite number of seconds above 0");
|
|
30
|
+
let u = l ? c : Infinity, d = (e, t) => !N(e) || e < 0 || e > u ? (i(t, `must be a time in seconds from 0 to the duration (${l ? c : "duration"})`), !1) : !0, f = (e, t, n) => {
|
|
31
|
+
for (let r = 1; r < e.length; r++) N(e[r][n]) && N(e[r - 1][n]) && e[r][n] < e[r - 1][n] && i(`${t}[${r}].${n}`, `is earlier than the one before; sort the list by ${n}`);
|
|
32
|
+
}, p = (e, t) => {
|
|
33
|
+
if (!Array.isArray(e)) return i(t, "must be an array"), null;
|
|
34
|
+
if (a += e.length, a > 1e6) return i(t, `the document has more than ${j} keys, clips and events; split it`), null;
|
|
35
35
|
let n = [];
|
|
36
36
|
return e.forEach((e, r) => {
|
|
37
|
-
|
|
37
|
+
M(e) ? n.push(e) : i(`${t}[${r}]`, "must be an object");
|
|
38
38
|
}), n.length === e.length ? n : null;
|
|
39
39
|
};
|
|
40
40
|
if ("markers" in e) {
|
|
41
|
-
let t =
|
|
41
|
+
let t = p(e.markers, r("markers"));
|
|
42
42
|
t?.forEach((e, t) => {
|
|
43
|
-
|
|
44
|
-
}), t &&
|
|
43
|
+
d(e.time, r(`markers[${t}].time`)), (typeof e.name != "string" || !e.name) && i(r(`markers[${t}].name`), "must be a non-empty string");
|
|
44
|
+
}), t && f(t, r("markers"), "time");
|
|
45
45
|
}
|
|
46
|
-
let
|
|
47
|
-
let n =
|
|
48
|
-
n && !n.length &&
|
|
46
|
+
let m = (e, t) => {
|
|
47
|
+
let n = p(e, t);
|
|
48
|
+
n && !n.length && i(t, "must hold at least one key"), n?.forEach((e, n) => {
|
|
49
49
|
let r = `${t}[${n}]`;
|
|
50
|
-
|
|
51
|
-
}), n &&
|
|
52
|
-
},
|
|
53
|
-
if (!
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
let
|
|
57
|
-
typeof e.id != "string" || !e.id ?
|
|
58
|
-
let
|
|
59
|
-
(typeof e.target != "string" || !e.target) &&
|
|
60
|
-
},
|
|
61
|
-
let n =
|
|
50
|
+
d(e.time, `${r}.time`), P(e.position, 3) || i(`${r}.position`, "must be [x, y, z] with finite numbers"), P(e.target, 3) || i(`${r}.target`, "must be [x, y, z] with finite numbers"), "fov" in e && !(N(e.fov) && e.fov > 0 && e.fov < 180) && i(`${r}.fov`, "must be degrees between 0 and 180"), "roll" in e && !N(e.roll) && i(`${r}.roll`, "must be a finite number of radians"), "cut" in e && typeof e.cut != "boolean" && i(`${r}.cut`, "must be true or false"), s(e.ease, `${r}.ease`);
|
|
51
|
+
}), n && f(n, t, "time");
|
|
52
|
+
}, h = p(e.tracks, r("tracks"));
|
|
53
|
+
if (!h) return;
|
|
54
|
+
let g = /* @__PURE__ */ new Set();
|
|
55
|
+
h.forEach((e, t) => {
|
|
56
|
+
let a = r(`tracks[${t}]`);
|
|
57
|
+
typeof e.id != "string" || !e.id ? i(`${a}.id`, "must be a non-empty string") : g.has(e.id) ? i(`${a}.id`, `'${e.id}' is used by another track; give each track its own id`) : g.add(e.id), "muted" in e && typeof e.muted != "boolean" && i(`${a}.muted`, "must be true or false");
|
|
58
|
+
let c = () => {
|
|
59
|
+
(typeof e.target != "string" || !e.target) && i(`${a}.target`, "must name the object, a non-empty string");
|
|
60
|
+
}, l = (t) => {
|
|
61
|
+
let n = p(e.clips, `${a}.clips`);
|
|
62
62
|
return n?.forEach((e, n) => {
|
|
63
|
-
let
|
|
64
|
-
!
|
|
65
|
-
}), n &&
|
|
66
|
-
},
|
|
67
|
-
t in e && !(
|
|
63
|
+
let r = `${a}.clips[${n}]`, o = d(e.start, `${r}.start`);
|
|
64
|
+
!N(e.duration) || e.duration <= 0 ? i(`${r}.duration`, "must be a finite number of seconds above 0") : o && e.start + e.duration > u + 1e-9 && i(`${r}.duration`, "runs past the end of its timeline; shorten it or raise the duration"), t(e, r);
|
|
65
|
+
}), n && f(n, `${a}.clips`, "start"), n;
|
|
66
|
+
}, h = (e, t, n, r = !0) => {
|
|
67
|
+
t in e && !(N(e[t]) && (r ? e[t] >= 0 : e[t] > 0)) && i(`${n}.${t}`, `must be a finite number ${r ? "of 0 or more" : "above 0"}`);
|
|
68
68
|
};
|
|
69
69
|
switch (e.type) {
|
|
70
70
|
case "camera":
|
|
71
|
-
"path" in e && e.path !== "catmull-rom" && e.path !== "linear" &&
|
|
71
|
+
"path" in e && e.path !== "catmull-rom" && e.path !== "linear" && i(`${a}.path`, "must be 'catmull-rom' or 'linear'"), m(e.keys, `${a}.keys`);
|
|
72
72
|
break;
|
|
73
73
|
case "transform": {
|
|
74
|
-
|
|
75
|
-
let t =
|
|
76
|
-
t && !t.length &&
|
|
77
|
-
let n = `${
|
|
78
|
-
|
|
79
|
-
}), t &&
|
|
74
|
+
c();
|
|
75
|
+
let t = p(e.keys, `${a}.keys`);
|
|
76
|
+
t && !t.length && i(`${a}.keys`, "must hold at least one key"), t?.forEach((e, t) => {
|
|
77
|
+
let n = `${a}.keys[${t}]`;
|
|
78
|
+
d(e.time, `${n}.time`), !("position" in e) && !("rotation" in e) && !("scale" in e) && i(n, "must set position, rotation or scale"), "position" in e && !P(e.position, 3) && i(`${n}.position`, "must be [x, y, z] with finite numbers"), "scale" in e && !P(e.scale, 3) && i(`${n}.scale`, "must be [x, y, z] with finite numbers"), "rotation" in e && (!P(e.rotation, 4) || Math.hypot(...e.rotation) < 1e-6) && i(`${n}.rotation`, "must be a unit quaternion [x, y, z, w]"), s(e.ease, `${n}.ease`);
|
|
79
|
+
}), t && f(t, `${a}.keys`, "time");
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
case "property": {
|
|
83
|
-
|
|
84
|
-
let t =
|
|
85
|
-
t && !t.length &&
|
|
83
|
+
c(), (typeof e.property != "string" || !e.property) && i(`${a}.property`, "must name the property, a non-empty string");
|
|
84
|
+
let t = p(e.keys, `${a}.keys`);
|
|
85
|
+
t && !t.length && i(`${a}.keys`, "must hold at least one key");
|
|
86
86
|
let n = -2;
|
|
87
87
|
t?.forEach((e, t) => {
|
|
88
|
-
let
|
|
89
|
-
|
|
90
|
-
let o = e.value,
|
|
91
|
-
|
|
92
|
-
}), t &&
|
|
88
|
+
let r = `${a}.keys[${t}]`;
|
|
89
|
+
d(e.time, `${r}.time`);
|
|
90
|
+
let o = e.value, c = N(o) ? -1 : Array.isArray(o) && o.length && o.every(N) ? o.length : -3;
|
|
91
|
+
c === -3 ? i(`${r}.value`, "must be a finite number or a non-empty array of finite numbers") : n !== -2 && c !== n ? i(`${r}.value`, "must have the same shape as the first key (a number, or an array of the same length)") : n = c, s(e.ease, `${r}.ease`);
|
|
92
|
+
}), t && f(t, `${a}.keys`, "time");
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
case "animation":
|
|
96
|
-
|
|
97
|
-
(typeof e.clip != "string" || !e.clip) &&
|
|
96
|
+
c(), l((e, t) => {
|
|
97
|
+
(typeof e.clip != "string" || !e.clip) && i(`${t}.clip`, "must name the animation clip"), h(e, "speed", t, !1), h(e, "offset", t), h(e, "blendIn", t), h(e, "blendOut", t), "loop" in e && typeof e.loop != "boolean" && i(`${t}.loop`, "must be true or false"), e.loop === !0 && !(N(e.length) && e.length > 0) ? i(`${t}.length`, "must be the clip length in seconds (above 0) when loop is true") : h(e, "length", t, !1);
|
|
98
98
|
});
|
|
99
99
|
break;
|
|
100
100
|
case "audio":
|
|
101
|
-
|
|
102
|
-
(typeof e.sound != "string" || !e.sound) &&
|
|
101
|
+
l((e, t) => {
|
|
102
|
+
(typeof e.sound != "string" || !e.sound) && i(`${t}.sound`, "must name the sound"), h(e, "volume", t), h(e, "offset", t), h(e, "fadeIn", t), h(e, "fadeOut", t);
|
|
103
103
|
});
|
|
104
104
|
break;
|
|
105
105
|
case "subtitle":
|
|
106
|
-
|
|
107
|
-
typeof e.text != "string" &&
|
|
106
|
+
l((e, t) => {
|
|
107
|
+
typeof e.text != "string" && i(`${t}.text`, "must be a string"), "speaker" in e && typeof e.speaker != "string" && i(`${t}.speaker`, "must be a string");
|
|
108
108
|
});
|
|
109
109
|
break;
|
|
110
110
|
case "event": {
|
|
111
|
-
let t =
|
|
111
|
+
let t = p(e.events, `${a}.events`);
|
|
112
112
|
t?.forEach((e, t) => {
|
|
113
|
-
|
|
114
|
-
}), t &&
|
|
113
|
+
d(e.time, `${a}.events[${t}].time`), (typeof e.name != "string" || !e.name) && i(`${a}.events[${t}].name`, "must be a non-empty string");
|
|
114
|
+
}), t && f(t, `${a}.events`, "time");
|
|
115
115
|
break;
|
|
116
116
|
}
|
|
117
117
|
case "timeline":
|
|
118
|
-
|
|
119
|
-
(typeof e.timeline != "string" || !Object.hasOwn(
|
|
118
|
+
l((e, t) => {
|
|
119
|
+
(typeof e.timeline != "string" || !Object.hasOwn(o, e.timeline)) && i(`${t}.timeline`, `must name a timeline in the document's timelines (${Object.keys(o).join(", ") || "none defined"})`), h(e, "speed", t, !1), h(e, "offset", t);
|
|
120
120
|
});
|
|
121
121
|
break;
|
|
122
122
|
default: {
|
|
123
123
|
let t = typeof e.type == "string" ? n.get(e.type) : void 0;
|
|
124
124
|
t ? t.validate(e, {
|
|
125
|
-
path:
|
|
126
|
-
end:
|
|
127
|
-
add:
|
|
128
|
-
time:
|
|
129
|
-
ease:
|
|
130
|
-
list:
|
|
131
|
-
ordered:
|
|
132
|
-
target:
|
|
133
|
-
clips:
|
|
134
|
-
positive:
|
|
135
|
-
cameraKeys:
|
|
136
|
-
}) :
|
|
125
|
+
path: a,
|
|
126
|
+
end: u,
|
|
127
|
+
add: i,
|
|
128
|
+
time: d,
|
|
129
|
+
ease: s,
|
|
130
|
+
list: p,
|
|
131
|
+
ordered: f,
|
|
132
|
+
target: c,
|
|
133
|
+
clips: l,
|
|
134
|
+
positive: h,
|
|
135
|
+
cameraKeys: m
|
|
136
|
+
}) : i(`${a}.type`, `unknown track type ${JSON.stringify(e.type)}; use camera, transform, property, animation, audio, subtitle, event or timeline, or pass its custom track type in the tracks option`);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
|
-
|
|
142
|
-
for (let [e, t] of Object.entries(
|
|
143
|
-
let
|
|
144
|
-
let t =
|
|
145
|
-
return !
|
|
146
|
-
},
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
|
|
141
|
+
c(e, "");
|
|
142
|
+
for (let [e, t] of Object.entries(o)) c(t, `timelines.${e}`);
|
|
143
|
+
let l = (e) => {
|
|
144
|
+
let t = o[e];
|
|
145
|
+
return !M(t) || !Array.isArray(t.tracks) ? [] : t.tracks.flatMap((e) => M(e) && e.type === "timeline" && Array.isArray(e.clips) ? e.clips.flatMap((e) => M(e) && typeof e.timeline == "string" && Object.hasOwn(o, e.timeline) ? [e.timeline] : []) : []);
|
|
146
|
+
}, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = (e, t) => {
|
|
147
|
+
if (u.get(e) === 2) return d.get(e);
|
|
148
|
+
if (u.get(e) === 1) return i(`timelines.${e}`, `nests itself (${[...t, e].join(" > ")}); remove the cycle`), 0;
|
|
149
|
+
u.set(e, 1);
|
|
150
150
|
let n = 0;
|
|
151
|
-
for (let r of
|
|
152
|
-
return
|
|
151
|
+
for (let r of l(e)) n = Math.max(n, 1 + f(r, [...t, e]));
|
|
152
|
+
return u.set(e, 2), d.set(e, n), n;
|
|
153
153
|
};
|
|
154
|
-
for (let e of Object.keys(
|
|
155
|
-
return
|
|
154
|
+
for (let e of Object.keys(o)) f(e, []) + 1 > 16 && i(`timelines.${e}`, "nests deeper than 16 levels; flatten it");
|
|
155
|
+
return r;
|
|
156
156
|
}
|
|
157
|
-
var
|
|
157
|
+
var L = (e) => {
|
|
158
158
|
if (e && typeof e == "object" && !Object.isFrozen(e)) {
|
|
159
159
|
Object.freeze(e);
|
|
160
|
-
for (let t of Object.values(e))
|
|
160
|
+
for (let t of Object.values(e)) L(t);
|
|
161
161
|
}
|
|
162
162
|
return e;
|
|
163
163
|
};
|
|
164
|
-
function
|
|
164
|
+
function R(e, t, n) {
|
|
165
165
|
let r;
|
|
166
166
|
try {
|
|
167
167
|
r = JSON.parse(typeof e == "string" ? e : JSON.stringify(e));
|
|
168
168
|
} catch (e) {
|
|
169
169
|
throw TypeError(`Cutscene is not valid JSON (${e.message}); save it with JSON.stringify(document)`);
|
|
170
170
|
}
|
|
171
|
-
let i =
|
|
171
|
+
let i = I(r, t, n);
|
|
172
172
|
if (i.length) throw TypeError(`Invalid cutscene; fix ${i[0].path || "the document"}: ${i[0].message}${i.length > 1 ? ` (and ${i.length - 1} more; see validateCutscene)` : ""}`);
|
|
173
|
-
return
|
|
173
|
+
return L(r);
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
176
|
//#region src/cutscene.ts
|
|
177
|
-
var
|
|
177
|
+
var z = {
|
|
178
|
+
easeInBack: n,
|
|
179
|
+
easeInBounce: r,
|
|
180
|
+
easeInCirc: i,
|
|
181
|
+
easeInCubic: a,
|
|
182
|
+
easeInElastic: o,
|
|
183
|
+
easeInExpo: s,
|
|
184
|
+
easeInOutBack: c,
|
|
185
|
+
easeInOutBounce: l,
|
|
186
|
+
easeInOutCirc: u,
|
|
187
|
+
easeInOutCubic: d,
|
|
188
|
+
easeInOutExpo: f,
|
|
189
|
+
easeInOutQuad: p,
|
|
190
|
+
easeInOutQuart: m,
|
|
191
|
+
easeInOutQuint: h,
|
|
192
|
+
easeInOutSine: g,
|
|
193
|
+
easeInQuad: _,
|
|
194
|
+
easeInQuart: v,
|
|
195
|
+
easeInQuint: y,
|
|
196
|
+
easeInSine: b,
|
|
197
|
+
easeOutBack: x,
|
|
198
|
+
easeOutBounce: S,
|
|
199
|
+
easeOutCirc: C,
|
|
200
|
+
easeOutCubic: w,
|
|
201
|
+
easeOutElastic: ee,
|
|
202
|
+
easeOutExpo: te,
|
|
203
|
+
easeOutQuad: ne,
|
|
204
|
+
easeOutQuart: T,
|
|
205
|
+
easeOutQuint: E,
|
|
206
|
+
easeOutSine: D,
|
|
207
|
+
easeSmoothstep: O
|
|
208
|
+
}, B = /* @__PURE__ */ new Set(/* @__PURE__ */ F.concat(/* @__PURE__ */ Object.keys(z))), V = (e) => e < 1 ? 0 : 1, H = (e) => e === void 0 || e === "linear" ? k : e === "step" ? V : e === "smoothstep" ? O : typeof e == "string" ? z[e] : t(e[0], e[1], e[2], e[3]), U = {
|
|
178
209
|
exit: 0,
|
|
179
210
|
marker: 1,
|
|
180
211
|
event: 2,
|
|
181
212
|
enter: 3
|
|
182
213
|
};
|
|
183
|
-
function
|
|
214
|
+
function W(e, t) {
|
|
184
215
|
let n = 0, r = e.length - 1, i = -1;
|
|
185
216
|
for (; n <= r;) {
|
|
186
217
|
let a = n + r >> 1;
|
|
@@ -188,8 +219,8 @@ function h(e, t) {
|
|
|
188
219
|
}
|
|
189
220
|
return i;
|
|
190
221
|
}
|
|
191
|
-
function
|
|
192
|
-
let r =
|
|
222
|
+
function G(e, t, n) {
|
|
223
|
+
let r = W(e, n);
|
|
193
224
|
if (r < 0) return {
|
|
194
225
|
i: 0,
|
|
195
226
|
j: 0,
|
|
@@ -213,11 +244,11 @@ function g(e, t, n) {
|
|
|
213
244
|
u: o > 0 ? t[r + 1](Math.min(1, Math.max(0, (n - i.time) / o))) : 1
|
|
214
245
|
};
|
|
215
246
|
}
|
|
216
|
-
var
|
|
247
|
+
var K = (e, t, n) => e.map((e, r) => e + (t[r] - e) * n), q = (e, t, n, r, i) => {
|
|
217
248
|
let a = i * i, o = a * i;
|
|
218
249
|
return t.map((s, c) => .5 * (2 * t[c] + (-e[c] + n[c]) * i + (2 * e[c] - 5 * t[c] + 4 * n[c] - r[c]) * a + (-e[c] + 3 * t[c] - 3 * n[c] + r[c]) * o));
|
|
219
250
|
};
|
|
220
|
-
function
|
|
251
|
+
function J(e, t, n) {
|
|
221
252
|
let r = t[0] - e[0], i = t[1] - e[1], a = t[2] - e[2], o = Math.hypot(r, i, a);
|
|
222
253
|
if (o < 1e-12) return [
|
|
223
254
|
0,
|
|
@@ -242,7 +273,7 @@ function y(e, t, n) {
|
|
|
242
273
|
l * f + g * p
|
|
243
274
|
];
|
|
244
275
|
}
|
|
245
|
-
function
|
|
276
|
+
function Y(e, t) {
|
|
246
277
|
let n = /* @__PURE__ */ new Map(), r = (e) => {
|
|
247
278
|
let t = n.get(e);
|
|
248
279
|
if (t) return t;
|
|
@@ -252,7 +283,7 @@ function b(e, t) {
|
|
|
252
283
|
channels: /* @__PURE__ */ new Map(),
|
|
253
284
|
instants: []
|
|
254
285
|
}, n.set(e, t);
|
|
255
|
-
for (let n of e.tracks) if ((n.type === "camera" || n.type === "transform" || n.type === "property") && t.eases.set(n, n.keys.map((e) =>
|
|
286
|
+
for (let n of e.tracks) if ((n.type === "camera" || n.type === "transform" || n.type === "property") && t.eases.set(n, n.keys.map((e) => H(e.ease))), n.type === "transform") {
|
|
256
287
|
let e = (e) => n.keys.flatMap((t, n) => t[e] ? [n] : []);
|
|
257
288
|
t.channels.set(n, {
|
|
258
289
|
position: e("position"),
|
|
@@ -333,18 +364,18 @@ function b(e, t) {
|
|
|
333
364
|
return a.instants = i(e, "").map(({ span: e, ...t }, n) => ({
|
|
334
365
|
...t,
|
|
335
366
|
order: n
|
|
336
|
-
})).sort((e, t) => e.time - t.time ||
|
|
367
|
+
})).sort((e, t) => e.time - t.time || U[e.kind] - U[t.kind] || e.order - t.order).map((e, t) => Object.freeze({
|
|
337
368
|
...e,
|
|
338
369
|
order: t
|
|
339
370
|
})), n;
|
|
340
371
|
}
|
|
341
|
-
function
|
|
342
|
-
let { i: a, j: o, u: s } =
|
|
372
|
+
function X(e, t, n, r, i) {
|
|
373
|
+
let { i: a, j: o, u: s } = G(e, t, r), c = e[a], l = e[o], u, d;
|
|
343
374
|
if (a === o) u = [...c.position], d = [...c.target];
|
|
344
|
-
else if (n === "linear") u =
|
|
375
|
+
else if (n === "linear") u = K(c.position, l.position, s), d = K(c.target, l.target, s);
|
|
345
376
|
else {
|
|
346
377
|
let t = a > 0 && !c.cut ? e[a - 1] : c, n = o + 1 < e.length && !e[o + 1].cut ? e[o + 1] : l;
|
|
347
|
-
u =
|
|
378
|
+
u = q(t.position, c.position, l.position, n.position, s), d = q(t.target, c.target, l.target, n.target, s);
|
|
348
379
|
}
|
|
349
380
|
let f = c.fov ?? 60, p = l.fov ?? 60, m = c.roll ?? 0, h = m + ((l.roll ?? 0) - m) * s;
|
|
350
381
|
return {
|
|
@@ -352,11 +383,11 @@ function x(e, t, n, r, i) {
|
|
|
352
383
|
target: d,
|
|
353
384
|
fov: f + (p - f) * s,
|
|
354
385
|
roll: h,
|
|
355
|
-
up:
|
|
386
|
+
up: J(u, d, h),
|
|
356
387
|
track: i
|
|
357
388
|
};
|
|
358
389
|
}
|
|
359
|
-
function
|
|
390
|
+
function Z(e, t, n) {
|
|
360
391
|
Object.defineProperty(e, t, {
|
|
361
392
|
value: n,
|
|
362
393
|
writable: !0,
|
|
@@ -364,14 +395,14 @@ function S(e, t, n) {
|
|
|
364
395
|
configurable: !0
|
|
365
396
|
});
|
|
366
397
|
}
|
|
367
|
-
function
|
|
398
|
+
function Q(e, t) {
|
|
368
399
|
if (Object.hasOwn(e, t)) return e[t];
|
|
369
400
|
let n = {};
|
|
370
|
-
return
|
|
401
|
+
return Z(e, t, n), n;
|
|
371
402
|
}
|
|
372
|
-
var
|
|
403
|
+
var $ = class {
|
|
373
404
|
constructor(e, t = {}) {
|
|
374
|
-
this.types = new Map((t.tracks ?? []).map((e) => [e.type, e])), this.document =
|
|
405
|
+
this.types = new Map((t.tracks ?? []).map((e) => [e.type, e])), this.document = R(e, B, this.types), this.compiled = Y(this.document, this.types), this.instants = Object.freeze(this.compiled.get(this.document).instants);
|
|
375
406
|
}
|
|
376
407
|
get duration() {
|
|
377
408
|
return this.document.duration;
|
|
@@ -387,7 +418,7 @@ var w = class {
|
|
|
387
418
|
audio: [],
|
|
388
419
|
subtitles: [],
|
|
389
420
|
marker: null
|
|
390
|
-
}, r = this.document.markers ?? [], i =
|
|
421
|
+
}, r = this.document.markers ?? [], i = W(r, t);
|
|
391
422
|
i >= 0 && (n.marker = r[i].name);
|
|
392
423
|
let a = [];
|
|
393
424
|
this.timeline(this.document, t, "", n, a);
|
|
@@ -406,10 +437,10 @@ var w = class {
|
|
|
406
437
|
let t = r + s.id;
|
|
407
438
|
switch (s.type) {
|
|
408
439
|
case "camera":
|
|
409
|
-
i.camera ||=
|
|
440
|
+
i.camera ||= X(s.keys, o.eases.get(s), s.path ?? "catmull-rom", n, t);
|
|
410
441
|
break;
|
|
411
442
|
case "transform": {
|
|
412
|
-
let t = o.channels.get(s), r = o.eases.get(s), a =
|
|
443
|
+
let t = o.channels.get(s), r = o.eases.get(s), a = Q(i.transforms, s.target);
|
|
413
444
|
for (let i of [
|
|
414
445
|
"position",
|
|
415
446
|
"rotation",
|
|
@@ -417,7 +448,7 @@ var w = class {
|
|
|
417
448
|
]) {
|
|
418
449
|
let o = t[i];
|
|
419
450
|
if (!o.length) continue;
|
|
420
|
-
let c = o.map((e) => s.keys[e]), { i: l, j: u, u: d } =
|
|
451
|
+
let c = o.map((e) => s.keys[e]), { i: l, j: u, u: d } = G(c, o.map((e) => r[e]), n), f = c[l][i], p = c[u][i];
|
|
421
452
|
if (i === "rotation") {
|
|
422
453
|
let t = l === u ? [...f] : e(f, p, d, .9995), n = Math.hypot(t[0], t[1], t[2], t[3]);
|
|
423
454
|
a.rotation = [
|
|
@@ -426,13 +457,13 @@ var w = class {
|
|
|
426
457
|
t[2] / n,
|
|
427
458
|
t[3] / n
|
|
428
459
|
];
|
|
429
|
-
} else a[i] =
|
|
460
|
+
} else a[i] = K(f, p, d);
|
|
430
461
|
}
|
|
431
462
|
break;
|
|
432
463
|
}
|
|
433
464
|
case "property": {
|
|
434
|
-
let { i: e, j: t, u: r } =
|
|
435
|
-
|
|
465
|
+
let { i: e, j: t, u: r } = G(s.keys, o.eases.get(s), n), a = s.keys[e].value, c = s.keys[t].value;
|
|
466
|
+
Z(Q(i.properties, s.target), s.property, typeof a == "number" ? a + (c - a) * r : K(a, c, r));
|
|
436
467
|
break;
|
|
437
468
|
}
|
|
438
469
|
case "animation":
|
|
@@ -489,8 +520,8 @@ var w = class {
|
|
|
489
520
|
}
|
|
490
521
|
}
|
|
491
522
|
};
|
|
492
|
-
function
|
|
493
|
-
return new
|
|
523
|
+
function re(e, t, n) {
|
|
524
|
+
return new $(e, n).evaluate(t);
|
|
494
525
|
}
|
|
495
526
|
//#endregion
|
|
496
|
-
export {
|
|
527
|
+
export { re as a, j as c, I as d, H as i, A as l, B as n, J as o, X as r, F as s, $ as t, R as u };
|
package/dist/editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as e, n as t, t as n } from "./cutscene-
|
|
1
|
+
import { d as e, n as t, t as n } from "./cutscene-WWP9-stS.js";
|
|
2
2
|
import { MargoError as r } from "@margoengine/math/errors";
|
|
3
3
|
import { EditHistory as i } from "@margoengine/inspector/history";
|
|
4
4
|
//#region src/editor.ts
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, l as r, n as i, s as a, t as o, u as s } from "./cutscene-
|
|
2
|
-
import { t as c } from "./player-
|
|
1
|
+
import { a as e, c as t, d as n, l as r, n as i, s as a, t as o, u as s } from "./cutscene-WWP9-stS.js";
|
|
2
|
+
import { t as c } from "./player-CbKMbpyN.js";
|
|
3
3
|
export { a as BASIC_EASINGS, o as Cutscene, c as CutscenePlayer, i as EASING_NAMES, t as MAX_CUTSCENE_ITEMS, r as MAX_TIMELINE_DEPTH, e as evaluate, s as parseCutscene, n as validateCutscene };
|
package/dist/render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "./cutscene-
|
|
2
|
-
import { t } from "./player-
|
|
1
|
+
import { t as e } from "./cutscene-WWP9-stS.js";
|
|
2
|
+
import { t } from "./player-CbKMbpyN.js";
|
|
3
3
|
import { seek as n, seekSync as r } from "./seek.js";
|
|
4
4
|
//#region src/render.ts
|
|
5
5
|
var i = 128, a = (e, t = 0, n = e.duration) => {
|
package/dist/shots.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, o as t, r as n } from "./cutscene-
|
|
1
|
+
import { i as e, o as t, r as n } from "./cutscene-WWP9-stS.js";
|
|
2
2
|
import { rotateByQuaternion as r } from "@margoengine/math/quat";
|
|
3
3
|
//#region src/shots.ts
|
|
4
4
|
var i = (e) => Array.isArray(e) && e.length === 3 && e.every((e) => Number.isFinite(e));
|
package/dist/viewport.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { MargoError as e } from "@margoengine/math/errors";
|
|
@@ -41,7 +41,7 @@ var r = (e) => {
|
|
|
41
41
|
"sz"
|
|
42
42
|
].map((e) => r[e][i]);
|
|
43
43
|
}, i = class i {
|
|
44
|
-
static async attach(e, t, n, r = {}) {__margoAssertCore(e,__margoCoreRequirement("
|
|
44
|
+
static async attach(e, t, n, r = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
45
45
|
r.signal?.throwIfAborted();
|
|
46
46
|
let a = r.gizmo ? void 0 : await import("@margoengine/inspector/gizmo");
|
|
47
47
|
r.signal?.throwIfAborted();
|