@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.
@@ -1,186 +1,217 @@
1
1
  import { interpolateQuaternions as e } from "@margoengine/math/quat";
2
- import * as t from "@margoengine/tween";
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 n = 16, r = 1e6, i = (e) => typeof e == "object" && !!e && !Array.isArray(e), a = (e) => typeof e == "number" && Number.isFinite(e), o = (e, t) => Array.isArray(e) && e.length === t && e.every(a), s = [
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 c(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map()) {
10
- let c = [], l = (e, t) => {
11
- c.length < 1e3 && c.push({
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 (!i(e)) return l("", "must be a cutscene document {format: \"margo-cutscene\", version: 1, duration, tracks}"), c;
17
- e.format !== "margo-cutscene" && l("format", "must be 'margo-cutscene'; this is not a cutscene document"), e.version !== 1 && l("version", "must be 1; this file is from a newer version, update @margoengine/cutscene");
18
- let u = 0, d = i(e.timelines) ? e.timelines : {};
19
- "timelines" in e && !i(e.timelines) && l("timelines", "must be an object of name: timeline");
20
- let f = (e, n) => {
21
- e !== void 0 && (typeof e == "string" ? !s.includes(e) && !t.has(e) && l(n, `unknown easing '${e}'; use linear, step, smoothstep, an ease* name of @margoengine/tween or [x1, y1, x2, y2]`) : (!o(e, 4) || e[0] < 0 || e[0] > 1 || e[2] < 0 || e[2] > 1) && l(n, "must be an easing name or cubic-bezier [x1, y1, x2, y2] with x1 and x2 in [0, 1]"));
22
- }, p = (e, t) => {
23
- let s = (e) => t ? `${t}.${e}` : e;
24
- if (!i(e)) {
25
- l(t, "must be a timeline {duration, tracks}");
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, p = a(c) && c > 0;
29
- p || l(s("duration"), "must be a finite number of seconds above 0");
30
- let m = p ? c : Infinity, h = (e, t) => !a(e) || e < 0 || e > m ? (l(t, `must be a time in seconds from 0 to the duration (${p ? c : "duration"})`), !1) : !0, g = (e, t, n) => {
31
- for (let r = 1; r < e.length; r++) a(e[r][n]) && a(e[r - 1][n]) && e[r][n] < e[r - 1][n] && l(`${t}[${r}].${n}`, `is earlier than the one before; sort the list by ${n}`);
32
- }, _ = (e, t) => {
33
- if (!Array.isArray(e)) return l(t, "must be an array"), null;
34
- if (u += e.length, u > 1e6) return l(t, `the document has more than ${r} keys, clips and events; split it`), null;
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
- i(e) ? n.push(e) : l(`${t}[${r}]`, "must be an object");
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 = _(e.markers, s("markers"));
41
+ let t = p(e.markers, r("markers"));
42
42
  t?.forEach((e, t) => {
43
- h(e.time, s(`markers[${t}].time`)), (typeof e.name != "string" || !e.name) && l(s(`markers[${t}].name`), "must be a non-empty string");
44
- }), t && g(t, s("markers"), "time");
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 v = (e, t) => {
47
- let n = _(e, t);
48
- n && !n.length && l(t, "must hold at least one key"), n?.forEach((e, n) => {
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
- h(e.time, `${r}.time`), o(e.position, 3) || l(`${r}.position`, "must be [x, y, z] with finite numbers"), o(e.target, 3) || l(`${r}.target`, "must be [x, y, z] with finite numbers"), "fov" in e && !(a(e.fov) && e.fov > 0 && e.fov < 180) && l(`${r}.fov`, "must be degrees between 0 and 180"), "roll" in e && !a(e.roll) && l(`${r}.roll`, "must be a finite number of radians"), "cut" in e && typeof e.cut != "boolean" && l(`${r}.cut`, "must be true or false"), f(e.ease, `${r}.ease`);
51
- }), n && g(n, t, "time");
52
- }, y = _(e.tracks, s("tracks"));
53
- if (!y) return;
54
- let b = /* @__PURE__ */ new Set();
55
- y.forEach((e, t) => {
56
- let r = s(`tracks[${t}]`);
57
- typeof e.id != "string" || !e.id ? l(`${r}.id`, "must be a non-empty string") : b.has(e.id) ? l(`${r}.id`, `'${e.id}' is used by another track; give each track its own id`) : b.add(e.id), "muted" in e && typeof e.muted != "boolean" && l(`${r}.muted`, "must be true or false");
58
- let i = () => {
59
- (typeof e.target != "string" || !e.target) && l(`${r}.target`, "must name the object, a non-empty string");
60
- }, c = (t) => {
61
- let n = _(e.clips, `${r}.clips`);
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 i = `${r}.clips[${n}]`, o = h(e.start, `${i}.start`);
64
- !a(e.duration) || e.duration <= 0 ? l(`${i}.duration`, "must be a finite number of seconds above 0") : o && e.start + e.duration > m + 1e-9 && l(`${i}.duration`, "runs past the end of its timeline; shorten it or raise the duration"), t(e, i);
65
- }), n && g(n, `${r}.clips`, "start"), n;
66
- }, u = (e, t, n, r = !0) => {
67
- t in e && !(a(e[t]) && (r ? e[t] >= 0 : e[t] > 0)) && l(`${n}.${t}`, `must be a finite number ${r ? "of 0 or more" : "above 0"}`);
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" && l(`${r}.path`, "must be 'catmull-rom' or 'linear'"), v(e.keys, `${r}.keys`);
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
- i();
75
- let t = _(e.keys, `${r}.keys`);
76
- t && !t.length && l(`${r}.keys`, "must hold at least one key"), t?.forEach((e, t) => {
77
- let n = `${r}.keys[${t}]`;
78
- h(e.time, `${n}.time`), !("position" in e) && !("rotation" in e) && !("scale" in e) && l(n, "must set position, rotation or scale"), "position" in e && !o(e.position, 3) && l(`${n}.position`, "must be [x, y, z] with finite numbers"), "scale" in e && !o(e.scale, 3) && l(`${n}.scale`, "must be [x, y, z] with finite numbers"), "rotation" in e && (!o(e.rotation, 4) || Math.hypot(...e.rotation) < 1e-6) && l(`${n}.rotation`, "must be a unit quaternion [x, y, z, w]"), f(e.ease, `${n}.ease`);
79
- }), t && g(t, `${r}.keys`, "time");
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
- i(), (typeof e.property != "string" || !e.property) && l(`${r}.property`, "must name the property, a non-empty string");
84
- let t = _(e.keys, `${r}.keys`);
85
- t && !t.length && l(`${r}.keys`, "must hold at least one key");
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 i = `${r}.keys[${t}]`;
89
- h(e.time, `${i}.time`);
90
- let o = e.value, s = a(o) ? -1 : Array.isArray(o) && o.length && o.every(a) ? o.length : -3;
91
- s === -3 ? l(`${i}.value`, "must be a finite number or a non-empty array of finite numbers") : n !== -2 && s !== n ? l(`${i}.value`, "must have the same shape as the first key (a number, or an array of the same length)") : n = s, f(e.ease, `${i}.ease`);
92
- }), t && g(t, `${r}.keys`, "time");
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
- i(), c((e, t) => {
97
- (typeof e.clip != "string" || !e.clip) && l(`${t}.clip`, "must name the animation clip"), u(e, "speed", t, !1), u(e, "offset", t), u(e, "blendIn", t), u(e, "blendOut", t), "loop" in e && typeof e.loop != "boolean" && l(`${t}.loop`, "must be true or false"), e.loop === !0 && !(a(e.length) && e.length > 0) ? l(`${t}.length`, "must be the clip length in seconds (above 0) when loop is true") : u(e, "length", t, !1);
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
- c((e, t) => {
102
- (typeof e.sound != "string" || !e.sound) && l(`${t}.sound`, "must name the sound"), u(e, "volume", t), u(e, "offset", t), u(e, "fadeIn", t), u(e, "fadeOut", t);
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
- c((e, t) => {
107
- typeof e.text != "string" && l(`${t}.text`, "must be a string"), "speaker" in e && typeof e.speaker != "string" && l(`${t}.speaker`, "must be a 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 = _(e.events, `${r}.events`);
111
+ let t = p(e.events, `${a}.events`);
112
112
  t?.forEach((e, t) => {
113
- h(e.time, `${r}.events[${t}].time`), (typeof e.name != "string" || !e.name) && l(`${r}.events[${t}].name`, "must be a non-empty string");
114
- }), t && g(t, `${r}.events`, "time");
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
- c((e, t) => {
119
- (typeof e.timeline != "string" || !Object.hasOwn(d, e.timeline)) && l(`${t}.timeline`, `must name a timeline in the document's timelines (${Object.keys(d).join(", ") || "none defined"})`), u(e, "speed", t, !1), u(e, "offset", t);
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: r,
126
- end: m,
127
- add: l,
128
- time: h,
129
- ease: f,
130
- list: _,
131
- ordered: g,
132
- target: i,
133
- clips: c,
134
- positive: u,
135
- cameraKeys: v
136
- }) : l(`${r}.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`);
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
- p(e, "");
142
- for (let [e, t] of Object.entries(d)) p(t, `timelines.${e}`);
143
- let m = (e) => {
144
- let t = d[e];
145
- return !i(t) || !Array.isArray(t.tracks) ? [] : t.tracks.flatMap((e) => i(e) && e.type === "timeline" && Array.isArray(e.clips) ? e.clips.flatMap((e) => i(e) && typeof e.timeline == "string" && Object.hasOwn(d, e.timeline) ? [e.timeline] : []) : []);
146
- }, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = (e, t) => {
147
- if (h.get(e) === 2) return g.get(e);
148
- if (h.get(e) === 1) return l(`timelines.${e}`, `nests itself (${[...t, e].join(" > ")}); remove the cycle`), 0;
149
- h.set(e, 1);
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 m(e)) n = Math.max(n, 1 + _(r, [...t, e]));
152
- return h.set(e, 2), g.set(e, n), n;
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(d)) _(e, []) + 1 > 16 && l(`timelines.${e}`, "nests deeper than 16 levels; flatten it");
155
- return c;
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 l = (e) => {
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)) l(t);
160
+ for (let t of Object.values(e)) L(t);
161
161
  }
162
162
  return e;
163
163
  };
164
- function u(e, t, n) {
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 = c(r, t, n);
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 l(r);
173
+ return L(r);
174
174
  }
175
175
  //#endregion
176
176
  //#region src/cutscene.ts
177
- var d = /* @__PURE__ */ new Set([...s, ...Object.keys(t).filter((e) => /^ease[A-Z]/.test(e) && typeof t[e] == "function")]), f = (e) => e < 1 ? 0 : 1, p = (e) => e === void 0 || e === "linear" ? t.linear : e === "step" ? f : e === "smoothstep" ? t.easeSmoothstep : typeof e == "string" ? t[e] : t.cubicBezier(e[0], e[1], e[2], e[3]), m = {
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 h(e, t) {
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 g(e, t, n) {
192
- let r = h(e, n);
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 _ = (e, t, n) => e.map((e, r) => e + (t[r] - e) * n), v = (e, t, n, r, i) => {
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 y(e, t, n) {
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 b(e, t) {
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) => p(e.ease))), n.type === "transform") {
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 || m[e.kind] - m[t.kind] || e.order - t.order).map((e, t) => Object.freeze({
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 x(e, t, n, r, i) {
342
- let { i: a, j: o, u: s } = g(e, t, r), c = e[a], l = e[o], u, d;
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 = _(c.position, l.position, s), d = _(c.target, l.target, s);
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 = v(t.position, c.position, l.position, n.position, s), d = v(t.target, c.target, l.target, n.target, s);
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: y(u, d, h),
386
+ up: J(u, d, h),
356
387
  track: i
357
388
  };
358
389
  }
359
- function S(e, t, n) {
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 C(e, t) {
398
+ function Q(e, t) {
368
399
  if (Object.hasOwn(e, t)) return e[t];
369
400
  let n = {};
370
- return S(e, t, n), n;
401
+ return Z(e, t, n), n;
371
402
  }
372
- var w = class {
403
+ var $ = class {
373
404
  constructor(e, t = {}) {
374
- this.types = new Map((t.tracks ?? []).map((e) => [e.type, e])), this.document = u(e, d, this.types), this.compiled = b(this.document, this.types), this.instants = Object.freeze(this.compiled.get(this.document).instants);
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 = h(r, t);
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 ||= x(s.keys, o.eases.get(s), s.path ?? "catmull-rom", n, t);
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 = C(i.transforms, s.target);
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 } = g(c, o.map((e) => r[e]), n), f = c[l][i], p = c[u][i];
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] = _(f, p, d);
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 } = g(s.keys, o.eases.get(s), n), a = s.keys[e].value, c = s.keys[t].value;
435
- S(C(i.properties, s.target), s.property, typeof a == "number" ? a + (c - a) * r : _(a, c, r));
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 T(e, t, n) {
493
- return new w(e, n).evaluate(t);
523
+ function re(e, t, n) {
524
+ return new $(e, n).evaluate(t);
494
525
  }
495
526
  //#endregion
496
- export { T as a, r as c, c as d, p as i, n as l, d as n, y as o, x as r, s, w as t, u };
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-DAWl8liP.js";
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-DAWl8liP.js";
2
- import { t as c } from "./player-DtIkr2sQ.js";
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 };
@@ -1,4 +1,4 @@
1
- import { t as e } from "./cutscene-DAWl8liP.js";
1
+ import { t as e } from "./cutscene-WWP9-stS.js";
2
2
  import { MargoError as t } from "@margoengine/math/errors";
3
3
  //#region src/player.ts
4
4
  var n = 100, r = class {
package/dist/render.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as e } from "./cutscene-DAWl8liP.js";
2
- import { t } from "./player-DtIkr2sQ.js";
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-DAWl8liP.js";
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 0.1.0
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("0.1.0",import.meta.url));
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();