@fxi/zartigl 0.10.4 → 0.11.1
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/dist/{backdrop-DctkJ45Q.js → backdrop-Dceb4d8E.js} +6 -6
- package/dist/catalog.js +1 -1
- package/dist/{geovideo-index-BqOLqzgA.js → engine-BBxJ6x3s.js} +706 -329
- package/dist/engine.d.ts +78 -2
- package/dist/engine.js +54 -107
- package/dist/{index-CNtMu8AU.js → index-DKYFuzyw.js} +2 -2
- package/dist/zartigl.js +67 -67
- package/package.json +1 -1
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import "./backdrop-Dceb4d8E.js";
|
|
2
|
+
const Te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, be = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, we = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ye = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, _e = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, Re = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, xe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ve = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, ke = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, Ae = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, Fe = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, Se = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, Ue = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, Me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Pe = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, De = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Ge = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, Ne = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, Ie = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, Le = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, Ce = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, Ve = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, he = {
|
|
3
|
+
thermal: Te,
|
|
3
4
|
"thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
|
|
4
|
-
haline:
|
|
5
|
-
solar:
|
|
6
|
-
ice:
|
|
7
|
-
deep:
|
|
8
|
-
rdylbu:
|
|
9
|
-
dense:
|
|
10
|
-
algae:
|
|
11
|
-
oxygen:
|
|
12
|
-
matter:
|
|
13
|
-
viridis:
|
|
14
|
-
plasma:
|
|
15
|
-
cyclic:
|
|
16
|
-
tempo:
|
|
17
|
-
turbid:
|
|
18
|
-
speed:
|
|
19
|
-
amp:
|
|
20
|
-
heat:
|
|
5
|
+
haline: be,
|
|
6
|
+
solar: we,
|
|
7
|
+
ice: ye,
|
|
8
|
+
deep: _e,
|
|
9
|
+
rdylbu: Re,
|
|
10
|
+
dense: xe,
|
|
11
|
+
algae: ve,
|
|
12
|
+
oxygen: ke,
|
|
13
|
+
matter: Ae,
|
|
14
|
+
viridis: Fe,
|
|
15
|
+
plasma: Se,
|
|
16
|
+
cyclic: Ue,
|
|
17
|
+
tempo: Me,
|
|
18
|
+
turbid: Pe,
|
|
19
|
+
speed: De,
|
|
20
|
+
amp: Ge,
|
|
21
|
+
heat: Ne,
|
|
21
22
|
"heat-alert": { label: "Heat Alert", tags: ["sequential", "alpha", "deprecated"], colors: ["#fde72500", "#fde725cc", "#f8961e", "#e63946", "#9d0208", "#3a0007"] },
|
|
22
|
-
balance:
|
|
23
|
-
delta:
|
|
24
|
-
curl:
|
|
23
|
+
balance: Ie,
|
|
24
|
+
delta: Le,
|
|
25
|
+
curl: Ce,
|
|
25
26
|
"mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
|
|
26
27
|
"mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
|
|
27
28
|
"mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
|
|
28
|
-
gray:
|
|
29
|
-
},
|
|
29
|
+
gray: Ve
|
|
30
|
+
}, ie = 64, Oe = {
|
|
30
31
|
linear: (t) => t,
|
|
31
32
|
// Rises fast: values just inside the zone already show.
|
|
32
33
|
log: (t) => Math.log10(1 + 9 * t),
|
|
33
34
|
// Stays faint longer: codec noise at the end of the range stays hidden.
|
|
34
35
|
exp: (t) => (10 ** t - 1) / 9
|
|
35
36
|
};
|
|
36
|
-
function
|
|
37
|
-
const i =
|
|
37
|
+
function Be(t, e) {
|
|
38
|
+
const i = Oe[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
|
|
38
39
|
let s = 1;
|
|
39
40
|
return r > 0 && t < r && (s = Math.min(s, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (s = Math.min(s, i(Math.max(1 - t, 0) / n))), s;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function Xe(t) {
|
|
42
43
|
let e = t.replace("#", "");
|
|
43
44
|
(e.length === 3 || e.length === 4) && (e = [...e].map((r) => r + r).join(""));
|
|
44
45
|
const i = (r) => parseInt(e.slice(r, r + 2), 16);
|
|
@@ -49,12 +50,12 @@ function Ae(t) {
|
|
|
49
50
|
e.length === 8 ? i(6) : 255
|
|
50
51
|
];
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function qe([t, e, i, r]) {
|
|
53
54
|
return `#${[t, e, i, r].map(
|
|
54
55
|
(n) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, "0")
|
|
55
56
|
).join("")}`;
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function $e(t, e) {
|
|
58
59
|
if (e <= t[0][0])
|
|
59
60
|
return t[0][1];
|
|
60
61
|
for (let i = 1; i < t.length; i++) {
|
|
@@ -66,29 +67,29 @@ function Fe(t, e) {
|
|
|
66
67
|
}
|
|
67
68
|
return t[t.length - 1][1];
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function We(t, e) {
|
|
70
71
|
const i = Object.entries(t).map(
|
|
71
|
-
([n, s]) => [Number(n),
|
|
72
|
+
([n, s]) => [Number(n), Xe(s)]
|
|
72
73
|
).sort((n, s) => n[0] - s[0]), r = {};
|
|
73
|
-
for (let n = 0; n <=
|
|
74
|
-
const s = n /
|
|
75
|
-
r[s] =
|
|
74
|
+
for (let n = 0; n <= ie; n++) {
|
|
75
|
+
const s = n / ie, [o, a, d, c] = $e(i, s);
|
|
76
|
+
r[s] = qe([o, a, d, c * Be(s, e)]);
|
|
76
77
|
}
|
|
77
78
|
return r;
|
|
78
79
|
}
|
|
79
|
-
const
|
|
80
|
-
function
|
|
80
|
+
const He = (t) => !!t && ((t.low ?? 0) > 0 || (t.high ?? 0) > 0);
|
|
81
|
+
function re(t) {
|
|
81
82
|
const e = {}, i = t.length - 1;
|
|
82
83
|
return t.forEach((r, n) => {
|
|
83
84
|
e[i === 0 ? 0 : n / i] = r;
|
|
84
85
|
}), e;
|
|
85
86
|
}
|
|
86
|
-
function
|
|
87
|
-
const i =
|
|
88
|
-
return
|
|
87
|
+
function ze(t, e) {
|
|
88
|
+
const i = Ye(t, e?.reverse ?? !1);
|
|
89
|
+
return He(e?.alphaFade) ? We(i, e.alphaFade) : i;
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
const i =
|
|
91
|
+
function Ye(t, e) {
|
|
92
|
+
const i = he;
|
|
92
93
|
if (typeof t == "string") {
|
|
93
94
|
const r = i[t];
|
|
94
95
|
if (!r)
|
|
@@ -98,22 +99,22 @@ function Pe(t, e) {
|
|
|
98
99
|
).join(", ")}`
|
|
99
100
|
);
|
|
100
101
|
const n = e ? [...r.colors].reverse() : r.colors;
|
|
101
|
-
return
|
|
102
|
+
return re(n);
|
|
102
103
|
}
|
|
103
104
|
if (Array.isArray(t)) {
|
|
104
105
|
const r = e ? [...t].reverse() : t;
|
|
105
|
-
return
|
|
106
|
+
return re(r);
|
|
106
107
|
}
|
|
107
108
|
return e ? Object.fromEntries(
|
|
108
109
|
Object.entries(t).map(([r, n]) => [1 - Number(r), n])
|
|
109
110
|
) : t;
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
-
return Object.entries(
|
|
112
|
+
function jt(t = {}) {
|
|
113
|
+
return Object.entries(he).map(([i, r]) => ({ id: i, ...r })).filter(
|
|
113
114
|
(i) => t.includeDeprecated || !i.tags.includes("deprecated")
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function ne(t, e, i) {
|
|
117
118
|
const r = t.createShader(e);
|
|
118
119
|
if (!r)
|
|
119
120
|
throw new Error("Failed to create shader");
|
|
@@ -123,18 +124,18 @@ function O(t, e, i) {
|
|
|
123
124
|
}
|
|
124
125
|
return r;
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
+
function Kt(t, e, i) {
|
|
127
128
|
const r = t.createProgram();
|
|
128
129
|
if (!r)
|
|
129
130
|
throw new Error("Failed to create program");
|
|
130
|
-
const n =
|
|
131
|
+
const n = ne(t, t.VERTEX_SHADER, e), s = ne(t, t.FRAGMENT_SHADER, i);
|
|
131
132
|
if (t.attachShader(r, n), t.attachShader(r, s), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
|
|
132
133
|
const o = t.getProgramInfoLog(r);
|
|
133
134
|
throw t.deleteProgram(r), new Error(`Program link error: ${o}`);
|
|
134
135
|
}
|
|
135
136
|
return t.deleteShader(n), t.deleteShader(s), r;
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
+
function Qt(t, e, i, r, n) {
|
|
138
139
|
const s = t.createTexture();
|
|
139
140
|
if (!s)
|
|
140
141
|
throw new Error("Failed to create texture");
|
|
@@ -150,7 +151,7 @@ function yt(t, e, i, r, n) {
|
|
|
150
151
|
i
|
|
151
152
|
), t.bindTexture(t.TEXTURE_2D, null), s;
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
+
function je(t, e, i) {
|
|
154
155
|
const r = t.getParameter(
|
|
155
156
|
t.TEXTURE_BINDING_2D
|
|
156
157
|
), n = t.getParameter(
|
|
@@ -182,19 +183,19 @@ function De(t, e, i) {
|
|
|
182
183
|
}
|
|
183
184
|
return a;
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function Ke(t) {
|
|
186
187
|
return {
|
|
187
188
|
kind: "rgba8-packed",
|
|
188
189
|
internalFormat: t.RGBA,
|
|
189
190
|
type: t.UNSIGNED_BYTE
|
|
190
191
|
};
|
|
191
192
|
}
|
|
192
|
-
function
|
|
193
|
+
function Zt(t) {
|
|
193
194
|
if (typeof WebGL2RenderingContext > "u" || !(t instanceof WebGL2RenderingContext))
|
|
194
195
|
throw new Error("zartigl requires WebGL2");
|
|
195
196
|
return t;
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
+
function Jt(t) {
|
|
198
199
|
const e = [];
|
|
199
200
|
t.getExtension("EXT_color_buffer_float") ? e.push(
|
|
200
201
|
{ kind: "float32", internalFormat: t.RGBA32F, type: t.FLOAT },
|
|
@@ -205,15 +206,15 @@ function At(t) {
|
|
|
205
206
|
type: t.HALF_FLOAT
|
|
206
207
|
});
|
|
207
208
|
for (const i of e)
|
|
208
|
-
if (
|
|
209
|
+
if (je(
|
|
209
210
|
t,
|
|
210
211
|
i.internalFormat,
|
|
211
212
|
i.type
|
|
212
213
|
))
|
|
213
214
|
return i;
|
|
214
|
-
return
|
|
215
|
+
return Ke(t);
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
+
function ei(t, e, i, r, n, s, o) {
|
|
217
218
|
const a = t.createTexture();
|
|
218
219
|
if (!a)
|
|
219
220
|
throw new Error("Failed to create texture");
|
|
@@ -229,10 +230,10 @@ function kt(t, e, i, r, n, s, o) {
|
|
|
229
230
|
i
|
|
230
231
|
), t.bindTexture(t.TEXTURE_2D, null), a;
|
|
231
232
|
}
|
|
232
|
-
function
|
|
233
|
+
function ti(t, e, i) {
|
|
233
234
|
t.activeTexture(t.TEXTURE0 + i), t.bindTexture(t.TEXTURE_2D, e);
|
|
234
235
|
}
|
|
235
|
-
function
|
|
236
|
+
function ii(t, e) {
|
|
236
237
|
const i = t.createFramebuffer();
|
|
237
238
|
if (!i)
|
|
238
239
|
throw new Error("Failed to create framebuffer");
|
|
@@ -244,7 +245,7 @@ function vt(t, e) {
|
|
|
244
245
|
0
|
|
245
246
|
), t.bindFramebuffer(t.FRAMEBUFFER, null), i;
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
+
function ri(t) {
|
|
248
249
|
const e = t.createBuffer();
|
|
249
250
|
if (!e)
|
|
250
251
|
throw new Error("Failed to create buffer");
|
|
@@ -254,7 +255,7 @@ function St(t) {
|
|
|
254
255
|
t.STATIC_DRAW
|
|
255
256
|
), e;
|
|
256
257
|
}
|
|
257
|
-
const
|
|
258
|
+
const Qe = {
|
|
258
259
|
0: "#3288bd",
|
|
259
260
|
0.1: "#66c2a5",
|
|
260
261
|
0.2: "#abdda4",
|
|
@@ -264,8 +265,8 @@ const Ne = {
|
|
|
264
265
|
0.6: "#f46d43",
|
|
265
266
|
1: "#d53e4f"
|
|
266
267
|
};
|
|
267
|
-
function
|
|
268
|
-
const r =
|
|
268
|
+
function ni(t, e, i) {
|
|
269
|
+
const r = ze(e ?? Qe, i), n = document.createElement("canvas");
|
|
269
270
|
n.width = 256, n.height = 1;
|
|
270
271
|
const s = n.getContext("2d"), o = s.createLinearGradient(0, 0, 256, 0);
|
|
271
272
|
for (const [d, c] of Object.entries(r))
|
|
@@ -276,7 +277,7 @@ function Ut(t, e, i) {
|
|
|
276
277
|
throw new Error("Failed to create color ramp texture");
|
|
277
278
|
return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), a;
|
|
278
279
|
}
|
|
279
|
-
function
|
|
280
|
+
function si(t) {
|
|
280
281
|
const e = t.getExtension("WEBGL_debug_renderer_info");
|
|
281
282
|
return {
|
|
282
283
|
vendor: String(t.getParameter(t.VENDOR) ?? ""),
|
|
@@ -286,7 +287,7 @@ function Pt(t) {
|
|
|
286
287
|
version: String(t.getParameter(t.VERSION) ?? "")
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
+
function ai(t) {
|
|
290
291
|
return {
|
|
291
292
|
program: t.getParameter(t.CURRENT_PROGRAM),
|
|
292
293
|
activeTexture: t.getParameter(t.ACTIVE_TEXTURE),
|
|
@@ -303,10 +304,10 @@ function Dt(t) {
|
|
|
303
304
|
]
|
|
304
305
|
};
|
|
305
306
|
}
|
|
306
|
-
function
|
|
307
|
+
function oi(t, e) {
|
|
307
308
|
t.useProgram(e.program), t.activeTexture(e.activeTexture), t.bindBuffer(t.ARRAY_BUFFER, e.arrayBuffer), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.elementBuffer), t.bindFramebuffer(t.FRAMEBUFFER, e.framebuffer), e.blend ? t.enable(t.BLEND) : t.disable(t.BLEND), e.depthTest ? t.enable(t.DEPTH_TEST) : t.disable(t.DEPTH_TEST), e.stencilTest ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), t.viewport(e.viewport[0], e.viewport[1], e.viewport[2], e.viewport[3]), t.blendFunc(e.blendFunc[0], e.blendFunc[1]);
|
|
308
309
|
}
|
|
309
|
-
const
|
|
310
|
+
const Ze = {
|
|
310
311
|
degrees_c: "°C",
|
|
311
312
|
degc: "°C",
|
|
312
313
|
degrees_celsius: "°C",
|
|
@@ -322,7 +323,7 @@ const Ie = {
|
|
|
322
323
|
"0.001": "PSU",
|
|
323
324
|
psu: "PSU",
|
|
324
325
|
stress_level: ""
|
|
325
|
-
},
|
|
326
|
+
}, Je = {
|
|
326
327
|
meter: "m",
|
|
327
328
|
meters: "m",
|
|
328
329
|
metre: "m",
|
|
@@ -345,12 +346,12 @@ const Ie = {
|
|
|
345
346
|
newton: "N",
|
|
346
347
|
pascal: "Pa",
|
|
347
348
|
kelvin: "K"
|
|
348
|
-
},
|
|
349
|
-
function
|
|
350
|
-
return t === 1 ? "" : [...String(t)].map((e) =>
|
|
349
|
+
}, et = "⁰¹²³⁴⁵⁶⁷⁸⁹";
|
|
350
|
+
function se(t) {
|
|
351
|
+
return t === 1 ? "" : [...String(t)].map((e) => et[Number(e)]).join("");
|
|
351
352
|
}
|
|
352
|
-
function
|
|
353
|
-
const e = t?.trim() ?? "", i =
|
|
353
|
+
function ci(t) {
|
|
354
|
+
const e = t?.trim() ?? "", i = Ze[e.toLowerCase()];
|
|
354
355
|
if (i != null)
|
|
355
356
|
return i;
|
|
356
357
|
if (e.includes("/"))
|
|
@@ -360,21 +361,21 @@ function Nt(t) {
|
|
|
360
361
|
const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(s);
|
|
361
362
|
if (!o)
|
|
362
363
|
return e.replace(/_/g, " ");
|
|
363
|
-
const a =
|
|
364
|
-
d < 0 ? n.push(a +
|
|
364
|
+
const a = Je[o[1]] ?? o[1], d = Number(o[2] ?? 1);
|
|
365
|
+
d < 0 ? n.push(a + se(-d)) : r.push(a + se(d));
|
|
365
366
|
}
|
|
366
367
|
return [r.join(" ") || "1", ...n].join("/");
|
|
367
368
|
}
|
|
368
|
-
const
|
|
369
|
-
function
|
|
369
|
+
const ae = 20, tt = 600;
|
|
370
|
+
function it(t) {
|
|
370
371
|
const e = Math.max(0, Math.min(1, t));
|
|
371
|
-
return
|
|
372
|
+
return ae * Math.pow(tt / ae, e);
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
-
return Math.exp(-1 /
|
|
374
|
+
function di(t) {
|
|
375
|
+
return Math.exp(-1 / it(t));
|
|
375
376
|
}
|
|
376
|
-
const
|
|
377
|
-
class
|
|
377
|
+
const rt = 0.8, nt = 120, st = 300;
|
|
378
|
+
class li {
|
|
378
379
|
constructor(e) {
|
|
379
380
|
this.base = e, this.moving = !1, this.start = 0, this.duration = 0, this.from = e, this.to = e;
|
|
380
381
|
}
|
|
@@ -383,7 +384,7 @@ class Gt {
|
|
|
383
384
|
this.base = e, this.moving || (this.from = e, this.to = e, this.duration = 0);
|
|
384
385
|
}
|
|
385
386
|
setMoving(e, i) {
|
|
386
|
-
e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ?
|
|
387
|
+
e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? rt : this.base, this.start = i, this.duration = e ? nt : st);
|
|
387
388
|
}
|
|
388
389
|
value(e) {
|
|
389
390
|
if (this.duration === 0)
|
|
@@ -392,7 +393,91 @@ class Gt {
|
|
|
392
393
|
return i === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * i * i * (3 - 2 * i);
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
|
-
|
|
396
|
+
var at = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physical) {
|
|
397
|
+
if (physical > 0.5) return texel.xyz;
|
|
398
|
+
return vec3(mix(minimum, maximum, texel.rg), texel.a);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
vec3 blendVelocity(vec3 a, vec3 b, float fraction) {
|
|
402
|
+
if (fraction <= 0.0) return a;
|
|
403
|
+
return mix(a, b, fraction);
|
|
404
|
+
}`, ot = `vec3 applyVibrance(vec3 c, float v) {
|
|
405
|
+
float mx = max(c.r, max(c.g, c.b));
|
|
406
|
+
float mn = min(c.r, min(c.g, c.b));
|
|
407
|
+
float boost = v * (1.0 - (mx - mn));
|
|
408
|
+
float luma = dot(c, vec3(0.299, 0.587, 0.114));
|
|
409
|
+
return mix(vec3(luma), c, 1.0 + boost);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
vec3 gradeColor(vec3 c, vec4 g) {
|
|
413
|
+
float m = max(c.r, max(c.g, c.b));
|
|
414
|
+
if (m > 0.0) {
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
float e = g.x > 1e-3 ? (1.0 - exp(-g.x * m)) / (1.0 - exp(-g.x)) : m;
|
|
418
|
+
|
|
419
|
+
e += g.w * smoothstep(0.5, 1.0, e) * (1.0 - e);
|
|
420
|
+
c *= e / m;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
|
|
424
|
+
return clamp(applyVibrance(c, g.z), 0.0, 1.0);
|
|
425
|
+
}`, ct = `uniform vec2 u_code_range;
|
|
426
|
+
uniform vec2 u_value_range;
|
|
427
|
+
uniform float u_scalar_transfer;
|
|
428
|
+
|
|
429
|
+
float geoVideoScalarCode(float r) {
|
|
430
|
+
return clamp((r - u_code_range.x) / (u_code_range.y - u_code_range.x), 0.0, 1.0);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
float geoVideoScalarValue(float r) {
|
|
434
|
+
float code = geoVideoScalarCode(r);
|
|
435
|
+
float t = mix(code, (pow(10.0, code) - 1.0) / 9.0, u_scalar_transfer);
|
|
436
|
+
return mix(u_value_range.x, u_value_range.y, t);
|
|
437
|
+
}`, dt = `uint pcg(uint v) {
|
|
438
|
+
uint state = v * 747796405u + 2891336453u;
|
|
439
|
+
uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
|
440
|
+
return (word >> 22u) ^ word;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
float random(uvec3 v) {
|
|
444
|
+
return float(pcg(v.x ^ pcg(v.y ^ pcg(v.z))) >> 8u) * (1.0 / 16777216.0);
|
|
445
|
+
}`, lt = `vec3 applyVibrance(vec3 c, float v) {
|
|
446
|
+
float mx = max(c.r, max(c.g, c.b));
|
|
447
|
+
float mn = min(c.r, min(c.g, c.b));
|
|
448
|
+
float boost = v * (1.0 - (mx - mn));
|
|
449
|
+
float luma = dot(c, vec3(0.299, 0.587, 0.114));
|
|
450
|
+
return mix(vec3(luma), c, 1.0 + boost);
|
|
451
|
+
}`, ht = `#define GLOW_SCALE 4
|
|
452
|
+
|
|
453
|
+
vec4 glowGather(sampler2D trails, ivec2 texel) {
|
|
454
|
+
ivec2 last = textureSize(trails, 0) - 1;
|
|
455
|
+
ivec2 origin = texel * GLOW_SCALE;
|
|
456
|
+
vec4 sum = vec4(0.0);
|
|
457
|
+
for (int y = 0; y < GLOW_SCALE; y++) {
|
|
458
|
+
for (int x = 0; x < GLOW_SCALE; x++) {
|
|
459
|
+
vec4 c = texelFetch(trails, min(origin + ivec2(x, y), last), 0);
|
|
460
|
+
sum += vec4(c.rgb * c.a, c.a);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return sum / float(GLOW_SCALE * GLOW_SCALE);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
|
|
467
|
+
vec2 d = 1.0 / vec2(textureSize(glowTex, 0));
|
|
468
|
+
vec4 glow = 0.25 * (
|
|
469
|
+
texture(glowTex, uv + vec2(-d.x, -d.y)) +
|
|
470
|
+
texture(glowTex, uv + vec2(d.x, -d.y)) +
|
|
471
|
+
texture(glowTex, uv + vec2(-d.x, d.y)) +
|
|
472
|
+
texture(glowTex, uv + vec2(d.x, d.y)));
|
|
473
|
+
glow = min(glow * gain, vec4(1.0));
|
|
474
|
+
float under = 1.0 - trail.a;
|
|
475
|
+
float alpha = trail.a + glow.a * under;
|
|
476
|
+
vec3 rgb = (trail.rgb * trail.a + glow.rgb * under) / max(alpha, 1e-4);
|
|
477
|
+
return vec4(rgb, alpha);
|
|
478
|
+
}`;
|
|
479
|
+
const hi = lt, ui = ot, fi = dt, mi = ct, pi = at, Ei = ht, gi = 4, Ti = 1.2;
|
|
480
|
+
function bi(t) {
|
|
396
481
|
if (t == null)
|
|
397
482
|
return null;
|
|
398
483
|
if (!Number.isFinite(t[0]) || !Number.isFinite(t[1]) || t[0] >= t[1])
|
|
@@ -401,12 +486,12 @@ function Lt(t) {
|
|
|
401
486
|
);
|
|
402
487
|
return [t[0], t[1]];
|
|
403
488
|
}
|
|
404
|
-
function
|
|
489
|
+
function x(t, e) {
|
|
405
490
|
if (typeof t != "number" || !Number.isFinite(t))
|
|
406
491
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
407
492
|
return t;
|
|
408
493
|
}
|
|
409
|
-
function
|
|
494
|
+
function B(t, e) {
|
|
410
495
|
if (typeof t != "string")
|
|
411
496
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
412
497
|
const i = new Date(t).getTime();
|
|
@@ -414,12 +499,12 @@ function A(t, e) {
|
|
|
414
499
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
415
500
|
return i;
|
|
416
501
|
}
|
|
417
|
-
function
|
|
502
|
+
function Y(t) {
|
|
418
503
|
return typeof t == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
|
|
419
504
|
t
|
|
420
505
|
);
|
|
421
506
|
}
|
|
422
|
-
function
|
|
507
|
+
function oe(t) {
|
|
423
508
|
if (!t || typeof t != "object")
|
|
424
509
|
throw new Error("Invalid GeoVideo manifest");
|
|
425
510
|
const e = t;
|
|
@@ -432,78 +517,78 @@ function W(t) {
|
|
|
432
517
|
if (!Array.isArray(e.bounds) || e.bounds.length !== 4)
|
|
433
518
|
throw new Error("Invalid GeoVideo manifest bounds");
|
|
434
519
|
const [i, r, n, s] = e.bounds.map(
|
|
435
|
-
(
|
|
520
|
+
(m, E) => x(m, `bounds[${E}]`)
|
|
436
521
|
);
|
|
437
522
|
if (r < -90 || s > 90 || r >= s || i === n)
|
|
438
523
|
throw new Error("Invalid GeoVideo geographic bounds");
|
|
439
524
|
const o = e.media;
|
|
440
525
|
if (!o || typeof o.url != "string" || !o.url)
|
|
441
526
|
throw new Error("Invalid GeoVideo media");
|
|
442
|
-
for (const
|
|
443
|
-
if (
|
|
444
|
-
throw new Error(`Invalid GeoVideo media.${
|
|
527
|
+
for (const m of ["width", "height", "fps", "durationSeconds"])
|
|
528
|
+
if (x(o[m], `media.${m}`) <= 0)
|
|
529
|
+
throw new Error(`Invalid GeoVideo media.${m}`);
|
|
445
530
|
const a = e.encoding;
|
|
446
531
|
if (!a || a.bits !== 8 || a.colorSpace !== "bt709" || a.colorRange !== "limited" && a.colorRange !== "full")
|
|
447
532
|
throw new Error("Invalid GeoVideo encoding");
|
|
448
|
-
const d =
|
|
533
|
+
const d = x(a.codeMin, "encoding.codeMin"), c = x(a.codeMax, "encoding.codeMax");
|
|
449
534
|
if (d < 0 || c > 255 || d >= c)
|
|
450
535
|
throw new Error("Invalid GeoVideo code range");
|
|
451
536
|
let l = o.height;
|
|
452
537
|
if (a.kind === "scalar-luma") {
|
|
453
|
-
if (a.transfer !== "linear" && a.transfer !== "log10-1p9" ||
|
|
538
|
+
if (a.transfer !== "linear" && a.transfer !== "log10-1p9" || x(a.valueMin, "encoding.valueMin") >= x(a.valueMax, "encoding.valueMax"))
|
|
454
539
|
throw new Error("Invalid GeoVideo scalar-luma encoding");
|
|
455
540
|
} else if (a.kind === "vector-luma") {
|
|
456
|
-
if (a.transfer !== "linear" && a.transfer !== "sqrt" || a.layout !== "stacked-uv" ||
|
|
541
|
+
if (a.transfer !== "linear" && a.transfer !== "sqrt" || a.layout !== "stacked-uv" || x(a.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
|
|
457
542
|
throw new Error("Invalid GeoVideo vector-luma encoding");
|
|
458
543
|
l = o.height / 2;
|
|
459
544
|
} else
|
|
460
545
|
throw new Error("Unsupported GeoVideo encoding");
|
|
461
546
|
const h = e.mask;
|
|
462
|
-
if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url ||
|
|
547
|
+
if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || x(h.width, "mask.width") !== o.width || x(h.height, "mask.height") !== l || x(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
|
|
463
548
|
throw new Error("Invalid GeoVideo static mask");
|
|
464
549
|
if (e.timeline?.kind === "range") {
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
550
|
+
const m = B(e.timeline.dateStart, "timeline.dateStart");
|
|
551
|
+
if (B(e.timeline.dateEnd, "timeline.dateEnd") <= m)
|
|
467
552
|
throw new Error("GeoVideo timeline end must follow start");
|
|
468
553
|
if (e.timeline.interpolation !== "linear" && e.timeline.interpolation !== "nearest")
|
|
469
554
|
throw new Error("Invalid GeoVideo interpolation");
|
|
470
555
|
} else if (e.timeline?.kind === "snapshot-loop")
|
|
471
|
-
|
|
556
|
+
B(e.timeline.date, "timeline.date");
|
|
472
557
|
else if (e.timeline?.kind === "sample-sequence") {
|
|
473
558
|
if (!Array.isArray(e.timeline.values) || e.timeline.values.length === 0)
|
|
474
559
|
throw new Error("GeoVideo sample sequence must contain values");
|
|
475
|
-
const
|
|
476
|
-
(
|
|
560
|
+
const m = e.timeline.values.map(
|
|
561
|
+
(E, w) => B(E, `timeline.values[${w}]`)
|
|
477
562
|
);
|
|
478
|
-
if (
|
|
563
|
+
if (m.some((E, w) => w > 0 && E <= m[w - 1]))
|
|
479
564
|
throw new Error(
|
|
480
565
|
"GeoVideo sample sequence values must be strictly increasing"
|
|
481
566
|
);
|
|
482
567
|
} else
|
|
483
568
|
throw new Error("Invalid GeoVideo timeline");
|
|
484
|
-
const
|
|
485
|
-
if (!Array.isArray(
|
|
569
|
+
const p = e.style?.colorDomain;
|
|
570
|
+
if (!Array.isArray(p) || p.length !== 2 || !p.every(Number.isFinite) || p[0] >= p[1])
|
|
486
571
|
throw new Error("Invalid GeoVideo color domain");
|
|
487
|
-
if (!
|
|
572
|
+
if (!Y(e.id) || !e.provenance || !Y(e.provenance.catalogEntryId) || !Y(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
|
|
488
573
|
throw new Error("Invalid GeoVideo provenance");
|
|
489
574
|
return { ...e, bounds: [i, r, n, s] };
|
|
490
575
|
}
|
|
491
|
-
async function
|
|
576
|
+
async function ut(t, e) {
|
|
492
577
|
if (typeof t != "string")
|
|
493
|
-
return
|
|
578
|
+
return oe(t);
|
|
494
579
|
const i = await fetch(t, { signal: e });
|
|
495
580
|
if (!i.ok)
|
|
496
581
|
throw new Error(
|
|
497
582
|
`GeoVideo manifest request failed (${i.status}): ${t}`
|
|
498
583
|
);
|
|
499
|
-
const r = await i.json(), n =
|
|
584
|
+
const r = await i.json(), n = oe(r), s = typeof document < "u" ? new URL(t, document.baseURI).href : t;
|
|
500
585
|
return {
|
|
501
586
|
...n,
|
|
502
587
|
media: { ...n.media, url: new URL(n.media.url, s).href },
|
|
503
588
|
mask: { ...n.mask, url: new URL(n.mask.url, s).href }
|
|
504
589
|
};
|
|
505
590
|
}
|
|
506
|
-
function
|
|
591
|
+
function M(t) {
|
|
507
592
|
if (t.timeline.kind === "snapshot-loop")
|
|
508
593
|
return [new Date(t.timeline.date).getTime()];
|
|
509
594
|
if (t.timeline.kind === "sample-sequence")
|
|
@@ -517,17 +602,17 @@ function w(t) {
|
|
|
517
602
|
(n, s) => e + (i - e) * s / (r - 1)
|
|
518
603
|
);
|
|
519
604
|
}
|
|
520
|
-
function
|
|
605
|
+
function ue(t) {
|
|
521
606
|
return t.timeline.kind === "sample-sequence" ? t.timeline.values.length / t.media.durationSeconds : t.media.fps;
|
|
522
607
|
}
|
|
523
|
-
function
|
|
524
|
-
return e /
|
|
608
|
+
function wi(t, e) {
|
|
609
|
+
return e / ue(t);
|
|
525
610
|
}
|
|
526
|
-
function
|
|
611
|
+
function ft(t, e) {
|
|
527
612
|
if (t.timeline.kind === "snapshot-loop")
|
|
528
613
|
return 0;
|
|
529
614
|
if (t.timeline.kind === "sample-sequence") {
|
|
530
|
-
const s =
|
|
615
|
+
const s = M(t);
|
|
531
616
|
let o = 0;
|
|
532
617
|
for (let d = 1; d < s.length; d += 1)
|
|
533
618
|
Math.abs(s[d] - e) < Math.abs(s[o] - e) && (o = d);
|
|
@@ -535,22 +620,22 @@ function $e(t, e) {
|
|
|
535
620
|
return o * a + Math.min(a / 2, 0.5 / t.media.fps);
|
|
536
621
|
}
|
|
537
622
|
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime();
|
|
538
|
-
return Math.max(0, Math.min(1, (e - i) / (r - i))) *
|
|
623
|
+
return Math.max(0, Math.min(1, (e - i) / (r - i))) * fe(t);
|
|
539
624
|
}
|
|
540
|
-
function
|
|
625
|
+
function yi(t, e) {
|
|
541
626
|
if (t.timeline.kind === "snapshot-loop")
|
|
542
627
|
return new Date(t.timeline.date).getTime();
|
|
543
628
|
if (t.timeline.kind === "sample-sequence") {
|
|
544
|
-
const o =
|
|
629
|
+
const o = M(t), a = t.media.durationSeconds / o.length, d = Math.floor((e + 0.25 / t.media.fps) / a);
|
|
545
630
|
return o[Math.max(0, Math.min(o.length - 1, d))];
|
|
546
631
|
}
|
|
547
|
-
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n =
|
|
632
|
+
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = fe(t), s = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
|
|
548
633
|
return i + (r - i) * s;
|
|
549
634
|
}
|
|
550
|
-
function
|
|
635
|
+
function fe(t) {
|
|
551
636
|
return Math.max(0, t.media.durationSeconds - 1 / t.media.fps);
|
|
552
637
|
}
|
|
553
|
-
function
|
|
638
|
+
function mt(t, e) {
|
|
554
639
|
const i = new Uint8Array(t.length / 4);
|
|
555
640
|
for (let r = 0; r < i.length; r++) {
|
|
556
641
|
const n = t[r * 4];
|
|
@@ -558,7 +643,7 @@ function We(t, e) {
|
|
|
558
643
|
}
|
|
559
644
|
return i;
|
|
560
645
|
}
|
|
561
|
-
class
|
|
646
|
+
class pt {
|
|
562
647
|
constructor() {
|
|
563
648
|
this.gl = null, this.texture = null, this.framebuffer = null;
|
|
564
649
|
}
|
|
@@ -589,44 +674,44 @@ class He {
|
|
|
589
674
|
return this.gl = r, this.texture = r.createTexture(), this.framebuffer = r.createFramebuffer(), r;
|
|
590
675
|
}
|
|
591
676
|
}
|
|
592
|
-
function
|
|
677
|
+
function ce(t) {
|
|
593
678
|
const e = Math.max(4, Math.floor(t.length / 4 / 997) * 4);
|
|
594
679
|
for (let i = 3; i < t.length; i += e)
|
|
595
680
|
if (t[i] !== 0)
|
|
596
681
|
return !1;
|
|
597
682
|
return !0;
|
|
598
683
|
}
|
|
599
|
-
function
|
|
684
|
+
function g() {
|
|
600
685
|
return new DOMException("GeoVideo frame request was cancelled", "AbortError");
|
|
601
686
|
}
|
|
602
|
-
function
|
|
687
|
+
function G(t, e, i) {
|
|
603
688
|
return e ? e.aborted ? (t.catch(() => {
|
|
604
|
-
}), i?.(), Promise.reject(
|
|
689
|
+
}), i?.(), Promise.reject(g())) : new Promise((r, n) => {
|
|
605
690
|
const s = () => {
|
|
606
|
-
i?.(), n(
|
|
691
|
+
i?.(), n(g());
|
|
607
692
|
};
|
|
608
693
|
e.addEventListener("abort", s, { once: !0 }), t.then(r, n).finally(() => {
|
|
609
694
|
e.removeEventListener("abort", s);
|
|
610
695
|
});
|
|
611
696
|
}) : t;
|
|
612
697
|
}
|
|
613
|
-
function
|
|
698
|
+
function j(t, e) {
|
|
614
699
|
return new Promise(
|
|
615
700
|
(i) => t.addEventListener(e, () => i(), { once: !0 })
|
|
616
701
|
);
|
|
617
702
|
}
|
|
618
|
-
const
|
|
619
|
-
function
|
|
703
|
+
const Et = 250;
|
|
704
|
+
function gt(t) {
|
|
620
705
|
return "requestVideoFrameCallback" in t ? Promise.race([
|
|
621
706
|
new Promise(
|
|
622
707
|
(e) => t.requestVideoFrameCallback(() => e())
|
|
623
708
|
),
|
|
624
|
-
new Promise((e) => setTimeout(e,
|
|
709
|
+
new Promise((e) => setTimeout(e, Et))
|
|
625
710
|
]) : Promise.resolve();
|
|
626
711
|
}
|
|
627
|
-
class
|
|
712
|
+
class me {
|
|
628
713
|
constructor(e, i, r = {}) {
|
|
629
|
-
this.reader = new
|
|
714
|
+
this.reader = new pt(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(M(e));
|
|
630
715
|
}
|
|
631
716
|
/** Static validity, one 8-bit value per grid cell; null before init(). */
|
|
632
717
|
get mask() {
|
|
@@ -635,11 +720,11 @@ class J {
|
|
|
635
720
|
/** Luma codes of the presented frame, or null when it is blank. */
|
|
636
721
|
readCodes(e, i) {
|
|
637
722
|
const r = this.reader.read(e, this.width, i);
|
|
638
|
-
return
|
|
723
|
+
return ce(r) ? null : mt(r, this.manifest.encoding.colorRange);
|
|
639
724
|
}
|
|
640
725
|
/** True when the decoder exposed no pixels; reads back one row only. */
|
|
641
726
|
isBlank(e) {
|
|
642
|
-
return
|
|
727
|
+
return ce(this.reader.read(e, this.width, 1));
|
|
643
728
|
}
|
|
644
729
|
init() {
|
|
645
730
|
return this.initPromise ??= this.load().catch((e) => {
|
|
@@ -663,23 +748,23 @@ class J {
|
|
|
663
748
|
frame(e, i = {}) {
|
|
664
749
|
const { signal: r } = i;
|
|
665
750
|
if (r?.aborted)
|
|
666
|
-
return Promise.reject(
|
|
751
|
+
return Promise.reject(g());
|
|
667
752
|
let n = this.frames.get(e);
|
|
668
753
|
if (n ? (this.frames.delete(e), this.frames.set(e, n)) : n = this.enqueue(e), n.settled)
|
|
669
754
|
return n.promise;
|
|
670
755
|
const s = n;
|
|
671
|
-
return s.waiters++,
|
|
756
|
+
return s.waiters++, G(s.promise, r, () => this.leave(s));
|
|
672
757
|
}
|
|
673
758
|
enqueue(e) {
|
|
674
759
|
const i = new AbortController(), r = this.queue.then(
|
|
675
|
-
() => i.signal.aborted ? Promise.reject(
|
|
760
|
+
() => i.signal.aborted ? Promise.reject(g()) : this.decode(e, i.signal)
|
|
676
761
|
);
|
|
677
762
|
this.queue = r.catch(() => {
|
|
678
763
|
});
|
|
679
764
|
const n = {
|
|
680
765
|
index: e,
|
|
681
766
|
controller: i,
|
|
682
|
-
promise:
|
|
767
|
+
promise: G(r, i.signal),
|
|
683
768
|
waiters: 0,
|
|
684
769
|
settled: !1
|
|
685
770
|
};
|
|
@@ -702,7 +787,7 @@ class J {
|
|
|
702
787
|
e.controller.abort(), this.pending.delete(e), this.frames.get(e.index) === e && this.frames.delete(e.index);
|
|
703
788
|
}
|
|
704
789
|
async load() {
|
|
705
|
-
const [e] = await Promise.all([this.loadMask(), this.
|
|
790
|
+
const [e] = await Promise.all([this.loadMask(), this.loadMedia()]);
|
|
706
791
|
this.maskCodes = e;
|
|
707
792
|
}
|
|
708
793
|
async loadMask() {
|
|
@@ -722,7 +807,8 @@ class J {
|
|
|
722
807
|
o[a] = s[a * 4];
|
|
723
808
|
return o;
|
|
724
809
|
}
|
|
725
|
-
|
|
810
|
+
/** Open the media; the default reads frames by seeking a video element. */
|
|
811
|
+
async loadMedia() {
|
|
726
812
|
const e = document.createElement("video");
|
|
727
813
|
if (e.crossOrigin = "anonymous", e.muted = !0, e.playsInline = !0, e.preload = "metadata", e.src = this.manifest.media.url, this.video = e, await new Promise((i, r) => {
|
|
728
814
|
e.addEventListener("loadedmetadata", () => i(), {
|
|
@@ -745,8 +831,8 @@ class J {
|
|
|
745
831
|
async presentFrame(e, i) {
|
|
746
832
|
if (this.presented && Math.abs(e.currentTime - i) <= 1e-3 && !e.seeking)
|
|
747
833
|
return;
|
|
748
|
-
const r =
|
|
749
|
-
e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([
|
|
834
|
+
const r = gt(e), n = j(e, "seeked");
|
|
835
|
+
e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([j(e, "loadeddata"), j(e, "canplay")]), await r, this.presented = !0;
|
|
750
836
|
}
|
|
751
837
|
/**
|
|
752
838
|
* Some mobile browsers expose no decoded pixels to WebGL until playback
|
|
@@ -761,25 +847,29 @@ class J {
|
|
|
761
847
|
}
|
|
762
848
|
e.pause(), this.presented = !1;
|
|
763
849
|
}
|
|
850
|
+
/** Media time inside the video frame showing step `index`. */
|
|
851
|
+
stepSeconds(e) {
|
|
852
|
+
return this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : ft(this.manifest, this.times[e]);
|
|
853
|
+
}
|
|
764
854
|
/**
|
|
765
855
|
* Seek and capture one step. `signal` aborts it between steps; a seek
|
|
766
856
|
* already started completes first, keeping the queue serial.
|
|
767
857
|
*/
|
|
768
858
|
async decode(e, i) {
|
|
769
859
|
if (i.aborted)
|
|
770
|
-
throw
|
|
860
|
+
throw g();
|
|
771
861
|
await this.init();
|
|
772
862
|
const r = this.video, n = this.maskCodes;
|
|
773
863
|
if (i.aborted || !r || !n)
|
|
774
|
-
throw
|
|
775
|
-
const s = this.
|
|
864
|
+
throw g();
|
|
865
|
+
const s = this.stepSeconds(e);
|
|
776
866
|
if (await this.presentFrame(r, s), i.aborted || r !== this.video)
|
|
777
|
-
throw
|
|
867
|
+
throw g();
|
|
778
868
|
const o = this.height * this.planes;
|
|
779
869
|
let a = await this.capture(r, o, n);
|
|
780
870
|
if (a === null && !this.primed) {
|
|
781
871
|
if (await this.primeDecoder(r), await this.presentFrame(r, s), i.aborted || r !== this.video)
|
|
782
|
-
throw
|
|
872
|
+
throw g();
|
|
783
873
|
a = await this.capture(r, o, n);
|
|
784
874
|
}
|
|
785
875
|
if (a === null)
|
|
@@ -787,14 +877,14 @@ class J {
|
|
|
787
877
|
return a;
|
|
788
878
|
}
|
|
789
879
|
}
|
|
790
|
-
function
|
|
880
|
+
function Tt(t) {
|
|
791
881
|
return {
|
|
792
882
|
codeRange: [t.codeMin / 255, t.codeMax / 255],
|
|
793
883
|
valueRange: [t.valueMin, t.valueMax],
|
|
794
884
|
transfer: t.transfer === "log10-1p9" ? 1 : 0
|
|
795
885
|
};
|
|
796
886
|
}
|
|
797
|
-
class
|
|
887
|
+
class bt extends me {
|
|
798
888
|
constructor(e, i = {}) {
|
|
799
889
|
if (e.encoding.kind !== "scalar-luma")
|
|
800
890
|
throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
|
|
@@ -807,7 +897,7 @@ class ze extends J {
|
|
|
807
897
|
});
|
|
808
898
|
}
|
|
809
899
|
}
|
|
810
|
-
function
|
|
900
|
+
function v(t, e) {
|
|
811
901
|
if (e <= t[0])
|
|
812
902
|
return { index: 0, fraction: 0 };
|
|
813
903
|
const i = t.length - 1;
|
|
@@ -820,19 +910,274 @@ function R(t, e) {
|
|
|
820
910
|
}
|
|
821
911
|
return { index: r, fraction: (e - t[r]) / (t[n] - t[r]) };
|
|
822
912
|
}
|
|
823
|
-
function
|
|
824
|
-
const { index: i, fraction: r } =
|
|
913
|
+
function K(t, e) {
|
|
914
|
+
const { index: i, fraction: r } = v(t, e);
|
|
825
915
|
return i + r;
|
|
826
916
|
}
|
|
827
|
-
function
|
|
917
|
+
function wt(t, e) {
|
|
828
918
|
const i = Math.max(0, Math.min(t.length - 1, Math.floor(e))), r = Math.min(i + 1, t.length - 1);
|
|
829
919
|
return t[i] + (t[r] - t[i]) * Math.max(0, e - i);
|
|
830
920
|
}
|
|
831
|
-
function
|
|
921
|
+
function $(t, e, i) {
|
|
922
|
+
const r = [];
|
|
923
|
+
let n = e;
|
|
924
|
+
for (; n + 8 <= i; ) {
|
|
925
|
+
let s = t.getUint32(n);
|
|
926
|
+
const o = String.fromCharCode(
|
|
927
|
+
t.getUint8(n + 4),
|
|
928
|
+
t.getUint8(n + 5),
|
|
929
|
+
t.getUint8(n + 6),
|
|
930
|
+
t.getUint8(n + 7)
|
|
931
|
+
);
|
|
932
|
+
let a = 8;
|
|
933
|
+
if (s === 1 ? (s = Number(t.getBigUint64(n + 8)), a = 16) : s === 0 && (s = i - n), s < a || n + s > i)
|
|
934
|
+
throw new Error(`Malformed MP4 box ${o}`);
|
|
935
|
+
r.push({ type: o, start: n + a, end: n + s }), n += s;
|
|
936
|
+
}
|
|
937
|
+
return r;
|
|
938
|
+
}
|
|
939
|
+
function b(t, e, i) {
|
|
940
|
+
const r = $(t, e.start, e.end).find(
|
|
941
|
+
(n) => n.type === i
|
|
942
|
+
);
|
|
943
|
+
if (!r)
|
|
944
|
+
throw new Error(`MP4 box ${i} not found in ${e.type}`);
|
|
945
|
+
return r;
|
|
946
|
+
}
|
|
947
|
+
function V(t, e, i) {
|
|
948
|
+
return $(t, e.start, e.end).find((r) => r.type === i) ?? null;
|
|
949
|
+
}
|
|
950
|
+
function D(t, e) {
|
|
951
|
+
return { at: e.start + 8, count: t.getUint32(e.start + 4) };
|
|
952
|
+
}
|
|
953
|
+
function yt(t, e, i) {
|
|
954
|
+
const r = V(t, e, "edts"), n = r && V(t, r, "elst");
|
|
955
|
+
if (!n)
|
|
956
|
+
return;
|
|
957
|
+
const { at: s, count: o } = D(t, n), a = t.getUint8(n.start) === 1 ? Number(t.getBigInt64(s + 8)) : t.getInt32(s + 4);
|
|
958
|
+
if (o !== 1 || a !== i)
|
|
959
|
+
throw new Error("Unsupported MP4 edit list");
|
|
960
|
+
}
|
|
961
|
+
function _t(t) {
|
|
962
|
+
const e = new DataView(t), i = { type: "file", start: 0, end: t.byteLength }, r = b(e, i, "moov"), n = $(e, r.start, r.end).find((f) => {
|
|
963
|
+
if (f.type !== "trak")
|
|
964
|
+
return !1;
|
|
965
|
+
const u = b(e, b(e, f, "mdia"), "hdlr");
|
|
966
|
+
return String.fromCharCode(...new Uint8Array(t, u.start + 8, 4)) === "vide";
|
|
967
|
+
});
|
|
968
|
+
if (!n)
|
|
969
|
+
throw new Error("MP4 has no video track");
|
|
970
|
+
const s = b(
|
|
971
|
+
e,
|
|
972
|
+
b(e, b(e, n, "mdia"), "minf"),
|
|
973
|
+
"stbl"
|
|
974
|
+
), o = b(e, s, "stsd"), [a] = $(e, o.start + 8, o.end);
|
|
975
|
+
if (!a || a.type !== "avc1" && a.type !== "avc3")
|
|
976
|
+
throw new Error(`Unsupported MP4 sample entry ${a?.type}`);
|
|
977
|
+
const d = e.getUint16(a.start + 24), c = e.getUint16(a.start + 26), l = b(e, { ...a, start: a.start + 78 }, "avcC"), h = new Uint8Array(t.slice(l.start, l.end)), p = (f) => h[f].toString(16).padStart(2, "0"), m = `avc1.${p(1)}${p(2)}${p(3)}`, E = b(e, s, "stsz"), w = e.getUint32(E.start + 4), y = e.getUint32(E.start + 8), A = Array.from(
|
|
978
|
+
{ length: y },
|
|
979
|
+
(f, u) => w || e.getUint32(E.start + 12 + u * 4)
|
|
980
|
+
), N = V(e, s, "co64"), O = N ?? b(e, s, "stco"), U = D(e, O), T = Array.from(
|
|
981
|
+
{ length: U.count },
|
|
982
|
+
(f, u) => N ? Number(e.getBigUint64(U.at + u * 8)) : e.getUint32(U.at + u * 4)
|
|
983
|
+
), _ = D(e, b(e, s, "stsc")), F = [];
|
|
984
|
+
for (let f = 0; f < _.count; f++) {
|
|
985
|
+
const u = _.at + f * 12, I = e.getUint32(u) - 1, R = e.getUint32(u + 4), z = f + 1 < _.count ? e.getUint32(u + 12) - 1 : T.length;
|
|
986
|
+
for (let L = I; L < z; L++) {
|
|
987
|
+
let C = T[L];
|
|
988
|
+
for (let te = 0; te < R && F.length < y; te++)
|
|
989
|
+
F.push(C), C += A[F.length - 1];
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const S = D(e, b(e, s, "stts")), k = [];
|
|
993
|
+
let P = 0;
|
|
994
|
+
for (let f = 0; f < S.count; f++) {
|
|
995
|
+
const u = e.getUint32(S.at + f * 8), I = e.getUint32(S.at + f * 8 + 4);
|
|
996
|
+
for (let R = 0; R < u; R++)
|
|
997
|
+
k.push(P), P += I;
|
|
998
|
+
}
|
|
999
|
+
const W = V(e, s, "ctts");
|
|
1000
|
+
if (W) {
|
|
1001
|
+
const f = e.getUint8(W.start) === 1, u = D(e, W);
|
|
1002
|
+
let I = 0;
|
|
1003
|
+
for (let R = 0; R < u.count; R++) {
|
|
1004
|
+
const z = e.getUint32(u.at + R * 8), L = f ? e.getInt32(u.at + R * 8 + 4) : e.getUint32(u.at + R * 8 + 4);
|
|
1005
|
+
for (let C = 0; C < z; C++)
|
|
1006
|
+
k[I++] += L;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
yt(e, n, Math.min(...k.slice(0, y)));
|
|
1010
|
+
const ge = k.slice(0, y).map((f, u) => [f, u]).sort((f, u) => f[0] - u[0]), J = new Array(y);
|
|
1011
|
+
ge.forEach(([, f], u) => J[f] = u);
|
|
1012
|
+
const H = V(e, s, "stss"), ee = /* @__PURE__ */ new Set();
|
|
1013
|
+
if (H) {
|
|
1014
|
+
const f = D(e, H);
|
|
1015
|
+
for (let u = 0; u < f.count; u++)
|
|
1016
|
+
ee.add(e.getUint32(f.at + u * 4) - 1);
|
|
1017
|
+
}
|
|
1018
|
+
if (F.length !== y || k.length < y)
|
|
1019
|
+
throw new Error("Inconsistent MP4 sample tables");
|
|
1020
|
+
return {
|
|
1021
|
+
codec: m,
|
|
1022
|
+
description: h,
|
|
1023
|
+
width: d,
|
|
1024
|
+
height: c,
|
|
1025
|
+
samples: A.map((f, u) => ({
|
|
1026
|
+
offset: F[u],
|
|
1027
|
+
size: f,
|
|
1028
|
+
frame: J[u],
|
|
1029
|
+
key: H ? ee.has(u) : !0
|
|
1030
|
+
}))
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
const Rt = 50;
|
|
1034
|
+
class xt extends bt {
|
|
1035
|
+
constructor() {
|
|
1036
|
+
super(...arguments), this.track = null, this.data = null, this.sampleOfFrame = [], this.decoder = null, this.fed = -1, this.taken = -1, this.outputs = /* @__PURE__ */ new Map(), this.progress = null, this.failure = null, this.loading = null;
|
|
1037
|
+
}
|
|
1038
|
+
/** True once the media decodes through WebCodecs. */
|
|
1039
|
+
get usesWebCodecs() {
|
|
1040
|
+
return this.track !== null;
|
|
1041
|
+
}
|
|
1042
|
+
async loadMedia() {
|
|
1043
|
+
if (typeof VideoDecoder > "u" || typeof fetch > "u")
|
|
1044
|
+
return super.loadMedia();
|
|
1045
|
+
const e = new AbortController();
|
|
1046
|
+
this.loading = e;
|
|
1047
|
+
const i = await fetch(this.manifest.media.url, {
|
|
1048
|
+
signal: e.signal
|
|
1049
|
+
});
|
|
1050
|
+
if (!i.ok)
|
|
1051
|
+
throw new Error(
|
|
1052
|
+
`Failed to load GeoVideo media: ${this.manifest.media.url}`
|
|
1053
|
+
);
|
|
1054
|
+
const r = await i.arrayBuffer();
|
|
1055
|
+
let n;
|
|
1056
|
+
try {
|
|
1057
|
+
n = _t(r);
|
|
1058
|
+
} catch {
|
|
1059
|
+
return this.loading === e ? super.loadMedia() : void 0;
|
|
1060
|
+
}
|
|
1061
|
+
if (n.width !== this.manifest.media.width || n.height !== this.manifest.media.height)
|
|
1062
|
+
throw new Error(
|
|
1063
|
+
`GeoVideo media dimensions ${n.width}x${n.height} do not match manifest ${this.manifest.media.width}x${this.manifest.media.height}`
|
|
1064
|
+
);
|
|
1065
|
+
const { supported: s } = await VideoDecoder.isConfigSupported(
|
|
1066
|
+
this.config(n)
|
|
1067
|
+
).catch(() => ({ supported: !1 }));
|
|
1068
|
+
if (this.loading !== e)
|
|
1069
|
+
throw g();
|
|
1070
|
+
if (this.loading = null, !s)
|
|
1071
|
+
return super.loadMedia();
|
|
1072
|
+
this.sampleOfFrame = [], n.samples.forEach(
|
|
1073
|
+
(o, a) => this.sampleOfFrame[o.frame] = a
|
|
1074
|
+
), this.data = r, this.track = n;
|
|
1075
|
+
}
|
|
1076
|
+
release() {
|
|
1077
|
+
this.loading?.abort(), this.loading = null, this.closeDecoder(), this.track = null, this.data = null, super.release();
|
|
1078
|
+
}
|
|
1079
|
+
async decode(e, i) {
|
|
1080
|
+
if (await this.init(), !this.track)
|
|
1081
|
+
return super.decode(e, i);
|
|
1082
|
+
if (i.aborted)
|
|
1083
|
+
throw g();
|
|
1084
|
+
const r = Math.min(
|
|
1085
|
+
this.track.samples.length - 1,
|
|
1086
|
+
Math.floor(this.stepSeconds(e) * this.manifest.media.fps + 1e-6)
|
|
1087
|
+
), n = await this.decodeFrame(r, i);
|
|
1088
|
+
try {
|
|
1089
|
+
return await createImageBitmap(n, {
|
|
1090
|
+
premultiplyAlpha: "none",
|
|
1091
|
+
colorSpaceConversion: "none"
|
|
1092
|
+
});
|
|
1093
|
+
} finally {
|
|
1094
|
+
n.close();
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
config(e) {
|
|
1098
|
+
return {
|
|
1099
|
+
codec: e.codec,
|
|
1100
|
+
description: e.description,
|
|
1101
|
+
codedWidth: e.width,
|
|
1102
|
+
codedHeight: e.height,
|
|
1103
|
+
optimizeForLatency: !0
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
/** Video frame `frame`, owned by the caller. */
|
|
1107
|
+
async decodeFrame(e, i) {
|
|
1108
|
+
const r = this.track, n = this.sampleOfFrame[e], s = this.keySample(n);
|
|
1109
|
+
for ((this.fed < 0 || e <= this.taken || s > this.fed) && this.restart(s), this.taken = e - 1, this.dropOutputsBefore(e); !this.outputs.has(e); ) {
|
|
1110
|
+
if (this.failure)
|
|
1111
|
+
throw this.failure;
|
|
1112
|
+
if (i.aborted)
|
|
1113
|
+
throw g();
|
|
1114
|
+
const a = this.decoder;
|
|
1115
|
+
this.fed < r.samples.length && a.decodeQueueSize < 2 && (this.feed(this.fed++), this.fed === r.samples.length && a.flush().catch(() => {
|
|
1116
|
+
})), await this.waitProgress();
|
|
1117
|
+
}
|
|
1118
|
+
const o = this.outputs.get(e);
|
|
1119
|
+
return this.outputs.delete(e), this.taken = e, o;
|
|
1120
|
+
}
|
|
1121
|
+
dropOutputsBefore(e) {
|
|
1122
|
+
for (const [i, r] of this.outputs)
|
|
1123
|
+
i < e && (r.close(), this.outputs.delete(i));
|
|
1124
|
+
}
|
|
1125
|
+
keySample(e) {
|
|
1126
|
+
const { samples: i } = this.track;
|
|
1127
|
+
let r = e;
|
|
1128
|
+
for (; r > 0 && !i[r].key; )
|
|
1129
|
+
r--;
|
|
1130
|
+
return r;
|
|
1131
|
+
}
|
|
1132
|
+
restart(e) {
|
|
1133
|
+
this.closeDecoder(), this.failure = null;
|
|
1134
|
+
const i = new VideoDecoder({
|
|
1135
|
+
output: (r) => {
|
|
1136
|
+
this.decoder !== i || r.timestamp <= this.taken ? r.close() : this.outputs.set(r.timestamp, r), this.notify();
|
|
1137
|
+
},
|
|
1138
|
+
error: (r) => {
|
|
1139
|
+
this.decoder === i && (this.failure = r, this.fed = -1), this.notify();
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
i.addEventListener("dequeue", () => this.notify()), i.configure(this.config(this.track)), this.decoder = i, this.fed = e, this.taken = this.track.samples[e].frame - 1;
|
|
1143
|
+
}
|
|
1144
|
+
feed(e) {
|
|
1145
|
+
const i = this.track.samples[e];
|
|
1146
|
+
this.decoder.decode(
|
|
1147
|
+
new EncodedVideoChunk({
|
|
1148
|
+
type: i.key ? "key" : "delta",
|
|
1149
|
+
// Video frame numbers: outputs carry them back in display order.
|
|
1150
|
+
timestamp: i.frame,
|
|
1151
|
+
data: new Uint8Array(this.data, i.offset, i.size)
|
|
1152
|
+
})
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
/** Next output, dequeue or error; a timer for decoders without events. */
|
|
1156
|
+
waitProgress() {
|
|
1157
|
+
return new Promise((e) => {
|
|
1158
|
+
const i = setTimeout(r, Rt);
|
|
1159
|
+
function r() {
|
|
1160
|
+
clearTimeout(i), e();
|
|
1161
|
+
}
|
|
1162
|
+
this.progress = r;
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
notify() {
|
|
1166
|
+
const e = this.progress;
|
|
1167
|
+
this.progress = null, e?.();
|
|
1168
|
+
}
|
|
1169
|
+
closeDecoder() {
|
|
1170
|
+
this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null, this.fed = -1;
|
|
1171
|
+
for (const e of this.outputs.values())
|
|
1172
|
+
e.close();
|
|
1173
|
+
this.outputs.clear();
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function vt(t, e) {
|
|
832
1177
|
let i = (t - e.codeMin) / (e.codeMax - e.codeMin) * 2 - 1;
|
|
833
1178
|
return i = Math.max(-1, Math.min(1, i)), e.transfer === "sqrt" && (i = Math.sign(i) * i * i), i * e.valueDomain;
|
|
834
1179
|
}
|
|
835
|
-
function
|
|
1180
|
+
function kt(t, e, i, r) {
|
|
836
1181
|
const n = e.length;
|
|
837
1182
|
if (t.length !== 2 * n)
|
|
838
1183
|
throw new Error(
|
|
@@ -840,7 +1185,7 @@ function Qe(t, e, i, r) {
|
|
|
840
1185
|
);
|
|
841
1186
|
const s = new Float32Array(256);
|
|
842
1187
|
for (let c = 0; c < 256; c++)
|
|
843
|
-
s[c] =
|
|
1188
|
+
s[c] = vt(c, r);
|
|
844
1189
|
const o = i * 255, a = new Float32Array(n), d = new Float32Array(n);
|
|
845
1190
|
for (let c = 0; c < n; c++) {
|
|
846
1191
|
const l = e[c] >= o;
|
|
@@ -848,7 +1193,7 @@ function Qe(t, e, i, r) {
|
|
|
848
1193
|
}
|
|
849
1194
|
return { u: a, v: d };
|
|
850
1195
|
}
|
|
851
|
-
class
|
|
1196
|
+
class At extends me {
|
|
852
1197
|
constructor(e, i = {}) {
|
|
853
1198
|
if (e.encoding.kind !== "vector-luma")
|
|
854
1199
|
throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
|
|
@@ -915,7 +1260,7 @@ class et extends J {
|
|
|
915
1260
|
/** u/v codes are written into luma: read back, then decoded on the CPU. */
|
|
916
1261
|
async capture(e, i, r) {
|
|
917
1262
|
const n = this.readCodes(e, i);
|
|
918
|
-
return n ?
|
|
1263
|
+
return n ? kt(
|
|
919
1264
|
n,
|
|
920
1265
|
r,
|
|
921
1266
|
this.manifest.mask.threshold,
|
|
@@ -923,7 +1268,7 @@ class et extends J {
|
|
|
923
1268
|
) : null;
|
|
924
1269
|
}
|
|
925
1270
|
}
|
|
926
|
-
function
|
|
1271
|
+
function Ft(t, e, i = {}) {
|
|
927
1272
|
const [r, n] = i.range ?? [-1 / 0, 1 / 0], s = [...t].sort((a, d) => a.start - d.start), o = s.find(
|
|
928
1273
|
(a) => a.start > e && a.start <= n
|
|
929
1274
|
) ?? (i.loop ? s.find(
|
|
@@ -931,7 +1276,7 @@ function tt(t, e, i = {}) {
|
|
|
931
1276
|
) : void 0);
|
|
932
1277
|
return o ? { chunk: o, time: Math.max(o.start, r) } : null;
|
|
933
1278
|
}
|
|
934
|
-
function
|
|
1279
|
+
function St(t, e) {
|
|
935
1280
|
let i = null, r = -1 / 0;
|
|
936
1281
|
for (const n of e) {
|
|
937
1282
|
const s = Math.min(t.end, n.end) - Math.max(t.start, n.start);
|
|
@@ -939,7 +1284,7 @@ function it(t, e) {
|
|
|
939
1284
|
}
|
|
940
1285
|
return i;
|
|
941
1286
|
}
|
|
942
|
-
function
|
|
1287
|
+
function Ut(t) {
|
|
943
1288
|
return {
|
|
944
1289
|
width: t.mask.width,
|
|
945
1290
|
height: t.mask.height,
|
|
@@ -947,11 +1292,11 @@ function rt(t) {
|
|
|
947
1292
|
rowOrder: "north-to-south"
|
|
948
1293
|
};
|
|
949
1294
|
}
|
|
950
|
-
function
|
|
951
|
-
return t.encoding.kind === "vector-luma" ? new
|
|
1295
|
+
function pe(t, e = {}) {
|
|
1296
|
+
return t.encoding.kind === "vector-luma" ? new At(t, e) : new xt(t, e);
|
|
952
1297
|
}
|
|
953
|
-
const
|
|
954
|
-
function
|
|
1298
|
+
const Mt = 3, Pt = 3, Dt = 0.6, Gt = 1.5;
|
|
1299
|
+
function Nt(t) {
|
|
955
1300
|
const e = new AbortController();
|
|
956
1301
|
if (!t)
|
|
957
1302
|
return { controller: e, unlink: () => {
|
|
@@ -962,14 +1307,14 @@ function ct(t) {
|
|
|
962
1307
|
unlink: () => t.removeEventListener("abort", i)
|
|
963
1308
|
};
|
|
964
1309
|
}
|
|
965
|
-
class
|
|
1310
|
+
class _i {
|
|
966
1311
|
constructor(e) {
|
|
967
1312
|
this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = e.id, this.chunks = e.chunks.filter(
|
|
968
1313
|
(i) => Number.isFinite(i.start) && Number.isFinite(i.end) && i.end >= i.start
|
|
969
|
-
).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ??
|
|
1314
|
+
).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? Mt), this.frameCacheSize = Math.max(
|
|
970
1315
|
1,
|
|
971
|
-
e.frameCacheSize ??
|
|
972
|
-
), this.prefetchAt = e.prefetchAt ??
|
|
1316
|
+
e.frameCacheSize ?? Pt
|
|
1317
|
+
), this.prefetchAt = e.prefetchAt ?? Dt, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? ut, this.createFrameSource = e.createFrameSource ?? ((i, r) => pe(
|
|
973
1318
|
i,
|
|
974
1319
|
r
|
|
975
1320
|
));
|
|
@@ -987,12 +1332,12 @@ class Bt {
|
|
|
987
1332
|
/** Every step time of the archive; loads all chunk manifests. */
|
|
988
1333
|
async steps(e = {}) {
|
|
989
1334
|
if (e.signal?.aborted)
|
|
990
|
-
throw
|
|
991
|
-
const i = await
|
|
1335
|
+
throw g();
|
|
1336
|
+
const i = await G(
|
|
992
1337
|
Promise.all(this.chunks.map((r) => this.manifest(r))),
|
|
993
1338
|
e.signal
|
|
994
1339
|
);
|
|
995
|
-
return Float64Array.from(i.flatMap(
|
|
1340
|
+
return Float64Array.from(i.flatMap(M));
|
|
996
1341
|
}
|
|
997
1342
|
/**
|
|
998
1343
|
* The frames bracketing `time`, decoded; null out of coverage (before the
|
|
@@ -1001,39 +1346,39 @@ class Bt {
|
|
|
1001
1346
|
async sample(e, i = {}) {
|
|
1002
1347
|
const { signal: r } = i, n = i.mode ?? "interpolate";
|
|
1003
1348
|
if (r?.aborted)
|
|
1004
|
-
throw
|
|
1349
|
+
throw g();
|
|
1005
1350
|
const s = this.chunkIndexAt(e);
|
|
1006
1351
|
if (s < 0)
|
|
1007
1352
|
return null;
|
|
1008
|
-
const o = [], { controller: a, unlink: d } =
|
|
1353
|
+
const o = [], { controller: a, unlink: d } = Nt(r);
|
|
1009
1354
|
try {
|
|
1010
|
-
const c = this.acquire(this.chunks[s], o), l = await
|
|
1011
|
-
let
|
|
1355
|
+
const c = this.acquire(this.chunks[s], o), l = await G(c.ready, a.signal), { times: h } = l;
|
|
1356
|
+
let p;
|
|
1012
1357
|
if (e <= h[h.length - 1]) {
|
|
1013
|
-
const { index:
|
|
1014
|
-
|
|
1358
|
+
const { index: T, fraction: _ } = v(h, e);
|
|
1359
|
+
p = n === "discrete" || _ === 0 ? [c, T, c, T, 0] : [c, T, c, T + 1, _];
|
|
1015
1360
|
} else {
|
|
1016
|
-
const
|
|
1017
|
-
if (!
|
|
1361
|
+
const T = this.chunks[s + 1];
|
|
1362
|
+
if (!T)
|
|
1018
1363
|
return null;
|
|
1019
|
-
const
|
|
1020
|
-
if (P -
|
|
1364
|
+
const _ = this.acquire(T, o), F = await G(_.ready, a.signal), S = h.length - 1, k = h[S], P = F.times[0];
|
|
1365
|
+
if (P - k > this.gapLimit(h, F.times))
|
|
1021
1366
|
return null;
|
|
1022
|
-
|
|
1367
|
+
p = n === "discrete" ? [c, S, c, S, 0] : e >= P ? [_, 0, _, 0, 0] : [c, S, _, 0, (e - k) / (P - k)];
|
|
1023
1368
|
}
|
|
1024
|
-
const [
|
|
1025
|
-
|
|
1026
|
-
let
|
|
1369
|
+
const [m, E, w, y, A] = p, N = m === w && E === y, O = [this.frame(m, E, a.signal)];
|
|
1370
|
+
N || O.push(this.frame(w, y, a.signal));
|
|
1371
|
+
let U;
|
|
1027
1372
|
try {
|
|
1028
|
-
|
|
1029
|
-
} catch (
|
|
1030
|
-
throw a.abort(),
|
|
1373
|
+
U = await Promise.all(O);
|
|
1374
|
+
} catch (T) {
|
|
1375
|
+
throw a.abort(), T;
|
|
1031
1376
|
}
|
|
1032
1377
|
return this.prefetchAfter(s, e), {
|
|
1033
1378
|
time: e,
|
|
1034
|
-
a:
|
|
1035
|
-
b:
|
|
1036
|
-
mix:
|
|
1379
|
+
a: U[0],
|
|
1380
|
+
b: U[N ? 0 : 1],
|
|
1381
|
+
mix: A
|
|
1037
1382
|
};
|
|
1038
1383
|
} finally {
|
|
1039
1384
|
d();
|
|
@@ -1072,7 +1417,7 @@ class Bt {
|
|
|
1072
1417
|
e.length > 1 ? e[e.length - 1] - e[e.length - 2] : 0,
|
|
1073
1418
|
i.length > 1 ? i[1] - i[0] : 0
|
|
1074
1419
|
], n = Math.max(...r);
|
|
1075
|
-
return n > 0 ? n *
|
|
1420
|
+
return n > 0 ? n * Gt : -1 / 0;
|
|
1076
1421
|
}
|
|
1077
1422
|
prefetchAfter(e, i) {
|
|
1078
1423
|
const r = this.chunks[e], n = this.chunks[e + 1], s = r.end - r.start, o = s > 0 ? (i - r.start) / s : 1;
|
|
@@ -1105,11 +1450,11 @@ class Bt {
|
|
|
1105
1450
|
};
|
|
1106
1451
|
r.ready = this.manifest(e).then((n) => {
|
|
1107
1452
|
if (r.released)
|
|
1108
|
-
throw
|
|
1453
|
+
throw g();
|
|
1109
1454
|
return r.opened = {
|
|
1110
1455
|
manifest: n,
|
|
1111
|
-
times: Float64Array.from(
|
|
1112
|
-
grid:
|
|
1456
|
+
times: Float64Array.from(M(n)),
|
|
1457
|
+
grid: Ut(n),
|
|
1113
1458
|
source: this.createFrameSource(n, {
|
|
1114
1459
|
cacheSize: this.frameCacheSize
|
|
1115
1460
|
})
|
|
@@ -1121,12 +1466,12 @@ class Bt {
|
|
|
1121
1466
|
return this.open.set(e.key, i), i;
|
|
1122
1467
|
}
|
|
1123
1468
|
async frame(e, i, r) {
|
|
1124
|
-
const { manifest: n, times: s, grid: o, source: a } = await
|
|
1469
|
+
const { manifest: n, times: s, grid: o, source: a } = await G(
|
|
1125
1470
|
e.ready,
|
|
1126
1471
|
r
|
|
1127
1472
|
);
|
|
1128
1473
|
if (e.released)
|
|
1129
|
-
throw
|
|
1474
|
+
throw g();
|
|
1130
1475
|
const d = await a.frame(i, { signal: r });
|
|
1131
1476
|
return {
|
|
1132
1477
|
key: `${this.id}/${e.chunk.key}/${i}`,
|
|
@@ -1151,18 +1496,18 @@ class Bt {
|
|
|
1151
1496
|
e.released = !0, e.prefetch?.abort(), e.prefetch = null, e.opened?.source.release(), e.opened = null, this.open.get(e.chunk.key) === e && this.open.delete(e.chunk.key);
|
|
1152
1497
|
}
|
|
1153
1498
|
}
|
|
1154
|
-
const
|
|
1499
|
+
const It = {
|
|
1155
1500
|
a: "u_vel0",
|
|
1156
1501
|
b: "u_vel1",
|
|
1157
1502
|
mix: "u_vel_mix",
|
|
1158
1503
|
bounds: "u_bounds"
|
|
1159
|
-
},
|
|
1504
|
+
}, Lt = {
|
|
1160
1505
|
a: "u_tint0",
|
|
1161
1506
|
b: "u_tint1",
|
|
1162
1507
|
mix: "u_tint_mix",
|
|
1163
1508
|
bounds: "u_tint_bounds"
|
|
1164
1509
|
};
|
|
1165
|
-
function
|
|
1510
|
+
function Ct(t) {
|
|
1166
1511
|
const e = new Float32Array(t.u.length * 4);
|
|
1167
1512
|
for (let i = 0; i < t.u.length; i++) {
|
|
1168
1513
|
const r = t.u[i], n = t.v[i];
|
|
@@ -1170,10 +1515,10 @@ function ht(t) {
|
|
|
1170
1515
|
}
|
|
1171
1516
|
return e;
|
|
1172
1517
|
}
|
|
1173
|
-
class
|
|
1518
|
+
class Vt {
|
|
1174
1519
|
constructor(e, i, r = {}) {
|
|
1175
|
-
this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source =
|
|
1176
|
-
const n =
|
|
1520
|
+
this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = pe(i, { cacheSize: 2 }), this.uniforms = this.vector ? It : Lt;
|
|
1521
|
+
const n = M(i);
|
|
1177
1522
|
this.times = r.animateSnapshot && i.timeline.kind === "snapshot-loop" ? Array.from(
|
|
1178
1523
|
{
|
|
1179
1524
|
length: Math.max(
|
|
@@ -1198,12 +1543,16 @@ class ut {
|
|
|
1198
1543
|
}
|
|
1199
1544
|
/** Resolves once the step at `ms` is uploaded. */
|
|
1200
1545
|
async prime(e) {
|
|
1201
|
-
const { index: i } =
|
|
1546
|
+
const { index: i } = v(this.times, e);
|
|
1202
1547
|
await this.request(i);
|
|
1203
1548
|
}
|
|
1549
|
+
/** The uploaded texture of the step at `ms`, or null. */
|
|
1550
|
+
texture(e) {
|
|
1551
|
+
return this.textures.get(v(this.times, e).index) ?? null;
|
|
1552
|
+
}
|
|
1204
1553
|
/** True once the frames interpolated at `ms` are uploaded. */
|
|
1205
1554
|
ready(e) {
|
|
1206
|
-
const { index: i, fraction: r } =
|
|
1555
|
+
const { index: i, fraction: r } = v(this.times, e);
|
|
1207
1556
|
return this.textures.has(i) && (r === 0 || this.textures.has(i + 1));
|
|
1208
1557
|
}
|
|
1209
1558
|
/**
|
|
@@ -1211,7 +1560,7 @@ class ut {
|
|
|
1211
1560
|
* `ms`, then request those first.
|
|
1212
1561
|
*/
|
|
1213
1562
|
focus(e) {
|
|
1214
|
-
const { index: i } =
|
|
1563
|
+
const { index: i } = v(this.times, e), r = Math.min(i + 1, this.times.length - 1);
|
|
1215
1564
|
[...this.pending.keys()].some(
|
|
1216
1565
|
(s) => s !== i && s !== r
|
|
1217
1566
|
) && (this.source.cancelAll(), this.pending.clear());
|
|
@@ -1224,7 +1573,7 @@ class ut {
|
|
|
1224
1573
|
* while a requested frame decodes.
|
|
1225
1574
|
*/
|
|
1226
1575
|
sample(e, i = !0) {
|
|
1227
|
-
const { index: r, fraction: n } =
|
|
1576
|
+
const { index: r, fraction: n } = v(this.times, e), s = Math.min(r + 1, this.times.length - 1);
|
|
1228
1577
|
[...this.pending.keys()].some((c) => c < r || c > s + 1) && (this.source.cancelAll(), this.pending.clear());
|
|
1229
1578
|
for (const c of [r, s, s + 1])
|
|
1230
1579
|
c < this.times.length && this.request(c).catch(() => {
|
|
@@ -1263,7 +1612,7 @@ class ut {
|
|
|
1263
1612
|
return !1;
|
|
1264
1613
|
const n = this.uniforms;
|
|
1265
1614
|
if (e.texture(n.a, r, this.pair[0]), e.texture(n.b, r + 1, this.pair[1]), e.float(n.mix, this.pair[2]), e.vec4(n.bounds, this.bounds), this.mask && this.manifest.encoding.kind === "scalar-luma") {
|
|
1266
|
-
const { codeRange: s, valueRange: o, transfer: a } =
|
|
1615
|
+
const { codeRange: s, valueRange: o, transfer: a } = Tt(
|
|
1267
1616
|
this.manifest.encoding
|
|
1268
1617
|
);
|
|
1269
1618
|
e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...s), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", a);
|
|
@@ -1320,7 +1669,7 @@ class ut {
|
|
|
1320
1669
|
0,
|
|
1321
1670
|
i.RGBA,
|
|
1322
1671
|
i.FLOAT,
|
|
1323
|
-
|
|
1672
|
+
Ct(e)
|
|
1324
1673
|
) : (i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, i.NONE), i.texImage2D(
|
|
1325
1674
|
i.TEXTURE_2D,
|
|
1326
1675
|
0,
|
|
@@ -1373,7 +1722,7 @@ class ut {
|
|
|
1373
1722
|
}
|
|
1374
1723
|
}
|
|
1375
1724
|
}
|
|
1376
|
-
class
|
|
1725
|
+
class Ot {
|
|
1377
1726
|
constructor(e, i) {
|
|
1378
1727
|
this.onPlaying = i, this.time = 0, this.endFraction = 0, this.held = !1, this.playingValue = e;
|
|
1379
1728
|
}
|
|
@@ -1384,6 +1733,10 @@ class ft {
|
|
|
1384
1733
|
set ms(e) {
|
|
1385
1734
|
this.time = e, this.endFraction = 0;
|
|
1386
1735
|
}
|
|
1736
|
+
/** Progress through the final sample's held step, 0 elsewhere. */
|
|
1737
|
+
get holdFraction() {
|
|
1738
|
+
return this.endFraction;
|
|
1739
|
+
}
|
|
1387
1740
|
get playing() {
|
|
1388
1741
|
return this.playingValue;
|
|
1389
1742
|
}
|
|
@@ -1401,34 +1754,34 @@ class ft {
|
|
|
1401
1754
|
advance(e, i, r, n = [i[0], i[i.length - 1]], s = !1, o = !1) {
|
|
1402
1755
|
if (!this.advancing || !i.length)
|
|
1403
1756
|
return !1;
|
|
1404
|
-
const a =
|
|
1405
|
-
let l = Math.max(a,
|
|
1757
|
+
const a = K(i, n[0]), d = K(i, n[1]), c = d + (o ? 1 : 0);
|
|
1758
|
+
let l = Math.max(a, K(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
|
|
1406
1759
|
const h = o ? l >= c : l > c;
|
|
1407
|
-
return h && s && c > a ? l = a + (l - a) % (c - a) : l = Math.min(c, l), this.time =
|
|
1760
|
+
return h && s && c > a ? l = a + (l - a) % (c - a) : l = Math.min(c, l), this.time = wt(i, Math.min(d, l)), this.endFraction = Math.max(0, l - d), h && !s;
|
|
1408
1761
|
}
|
|
1409
1762
|
}
|
|
1410
|
-
function
|
|
1411
|
-
const e =
|
|
1763
|
+
function X(t) {
|
|
1764
|
+
const e = M(t);
|
|
1412
1765
|
return [e[0], e[e.length - 1]];
|
|
1413
1766
|
}
|
|
1414
|
-
function
|
|
1767
|
+
function Q(t, e) {
|
|
1415
1768
|
return e ? [Math.max(t[0], e[0]), Math.min(t[1], e[1])] : t;
|
|
1416
1769
|
}
|
|
1417
|
-
function
|
|
1770
|
+
function q([t, e], i) {
|
|
1418
1771
|
return Math.max(t, Math.min(e, i));
|
|
1419
1772
|
}
|
|
1420
|
-
class
|
|
1773
|
+
class Ri {
|
|
1421
1774
|
constructor(e, i, r) {
|
|
1422
1775
|
this.repaint = i, this.emit = r, this.field = null, this.manifest = null, this.gl = null, this.pendingField = null, this.standby = null, this.awaitingNext = !1, this.timeRange = null, this.lastTick = null, this.lastStepTime = null, this.seekId = 0, this.seeking = !1, this.failed = !1, this.exactTime = 0, this.endEmitted = !1, this.destroyed = !1, this.resumePlayback = !1, this.playOnReady = e.autoplay ?? !0, this.loop = e.loop ?? !0, this.playbackRate = e.playbackRate ?? 1, this.stepsPerSecond = e.stepsPerSecond;
|
|
1423
1776
|
const n = typeof e.time == "string" ? Date.parse(e.time) : e.time;
|
|
1424
|
-
this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new
|
|
1777
|
+
this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new Ot(
|
|
1425
1778
|
!1,
|
|
1426
1779
|
(s) => this.emit("playbackChange", s)
|
|
1427
1780
|
);
|
|
1428
1781
|
}
|
|
1429
1782
|
async load(e, i) {
|
|
1430
|
-
if (this.gl = e, this.manifest = i, this.timeRange =
|
|
1431
|
-
|
|
1783
|
+
if (this.gl = e, this.manifest = i, this.timeRange = Q(
|
|
1784
|
+
X(i),
|
|
1432
1785
|
this.requestedTimeRange
|
|
1433
1786
|
), this.timeRange[0] > this.timeRange[1])
|
|
1434
1787
|
throw new Error(
|
|
@@ -1437,10 +1790,25 @@ class Xt {
|
|
|
1437
1790
|
this.pendingField = this.createField(i), await this.prepare(this.pendingField);
|
|
1438
1791
|
}
|
|
1439
1792
|
sample(e) {
|
|
1440
|
-
|
|
1793
|
+
if (this.tick(e), !this.field)
|
|
1794
|
+
return null;
|
|
1795
|
+
const i = this.pendingField || this.seeking ? this.field.currentPair : this.field.sample(
|
|
1441
1796
|
this.clock.advancing ? this.clock.ms : this.exactTime,
|
|
1442
1797
|
this.clock.advancing && !this.awaitingNext
|
|
1443
|
-
)
|
|
1798
|
+
);
|
|
1799
|
+
return this.handoff(i) ?? i;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Through the final step of a chunk followed by a decoded one, the last
|
|
1803
|
+
* frame blends into the next chunk's first, as steps do within a chunk:
|
|
1804
|
+
* the chunk swap then lands on the frame already shown.
|
|
1805
|
+
*/
|
|
1806
|
+
handoff(e) {
|
|
1807
|
+
const i = this.clock.holdFraction, r = this.pendingField ?? this.standby?.field, n = this.pendingField ? this.requestedTime : this.standby?.time;
|
|
1808
|
+
if (!e || i <= 0 || !r || n == null)
|
|
1809
|
+
return null;
|
|
1810
|
+
const s = r.texture(n);
|
|
1811
|
+
return s ? [e[0], s, Math.min(1, i)] : null;
|
|
1444
1812
|
}
|
|
1445
1813
|
get time() {
|
|
1446
1814
|
return this.clock.ms;
|
|
@@ -1472,11 +1840,11 @@ class Xt {
|
|
|
1472
1840
|
const r = this.clock.advance(
|
|
1473
1841
|
i,
|
|
1474
1842
|
this.field.times,
|
|
1475
|
-
this.stepsPerSecond ?? this.playbackRate *
|
|
1843
|
+
this.stepsPerSecond ?? this.playbackRate * ue(this.field.manifest),
|
|
1476
1844
|
this.playbackRange(this.field),
|
|
1477
1845
|
this.loop,
|
|
1478
1846
|
!0
|
|
1479
|
-
), { index: n } =
|
|
1847
|
+
), { index: n } = v(this.field.times, this.clock.ms), s = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : q(this.timeRange, this.field.times[n]);
|
|
1480
1848
|
s !== this.lastStepTime && (this.lastStepTime = s, this.emit("timeChange", s)), r ? this.reachEnd() : this.repaint();
|
|
1481
1849
|
}
|
|
1482
1850
|
setTime(e) {
|
|
@@ -1490,7 +1858,7 @@ class Xt {
|
|
|
1490
1858
|
/** Load the requested step first; stale seeks and swaps cannot replace it. */
|
|
1491
1859
|
async prepare(e, i) {
|
|
1492
1860
|
this.failed = !1;
|
|
1493
|
-
const r = ++this.seekId, n = this.timeRange ??
|
|
1861
|
+
const r = ++this.seekId, n = this.timeRange ?? X(e.manifest), s = i ?? q(n, this.requestedTime ?? n[0]), o = v(e.times, s), a = Math.min(
|
|
1494
1862
|
e.times.length - 1,
|
|
1495
1863
|
o.index + (o.fraction > 0.5 ? 1 : 0)
|
|
1496
1864
|
), d = e.times[a];
|
|
@@ -1505,7 +1873,7 @@ class Xt {
|
|
|
1505
1873
|
if (r !== this.seekId || this.destroyed)
|
|
1506
1874
|
return;
|
|
1507
1875
|
const c = this.pendingField === e;
|
|
1508
|
-
if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = d, this.clock.ms =
|
|
1876
|
+
if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = d, this.clock.ms = q(this.playbackRange(e), d), e.sample(d, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
|
|
1509
1877
|
const l = e.manifest;
|
|
1510
1878
|
if (this.emit("loaded", {
|
|
1511
1879
|
min: l.style.colorDomain[0],
|
|
@@ -1535,10 +1903,10 @@ class Xt {
|
|
|
1535
1903
|
const r = this.replacementTimeRange(e, i);
|
|
1536
1904
|
if (!r || !this.gl || e.media.url === this.manifest?.media.url)
|
|
1537
1905
|
return !1;
|
|
1538
|
-
const n =
|
|
1906
|
+
const n = q(r, i.time ?? r[0]);
|
|
1539
1907
|
this.standby?.field.manifest.media.url !== e.media.url && (this.discardStandby(), this.standby = { field: this.createField(e), time: n });
|
|
1540
1908
|
const s = this.standby;
|
|
1541
|
-
return s.time = n, s.field.prime(n).catch(() => {
|
|
1909
|
+
return s.time = n, s.field.focus(n), s.field.prime(n).catch(() => {
|
|
1542
1910
|
this.standby === s && this.discardStandby();
|
|
1543
1911
|
}), !0;
|
|
1544
1912
|
}
|
|
@@ -1550,8 +1918,8 @@ class Xt {
|
|
|
1550
1918
|
const r = this.manifest;
|
|
1551
1919
|
if (!r || e.encoding.kind !== r.encoding.kind || e.media.width !== r.media.width || e.media.height !== r.media.height || e.mask.width !== r.mask.width || e.mask.height !== r.mask.height)
|
|
1552
1920
|
return null;
|
|
1553
|
-
const n =
|
|
1554
|
-
|
|
1921
|
+
const n = Q(
|
|
1922
|
+
X(e),
|
|
1555
1923
|
i.timeRange
|
|
1556
1924
|
);
|
|
1557
1925
|
return n[0] <= n[1] ? n : null;
|
|
@@ -1572,7 +1940,7 @@ class Xt {
|
|
|
1572
1940
|
pause() {
|
|
1573
1941
|
const e = this.playOnReady && !this.clock.playing;
|
|
1574
1942
|
if (this.playOnReady = !1, this.awaitingNext = !1, this.clock.setPlaying(!1), this.field && !this.pendingField && !this.seeking && !this.endEmitted) {
|
|
1575
|
-
const { index: i } =
|
|
1943
|
+
const { index: i } = v(this.field.times, this.clock.ms);
|
|
1576
1944
|
this.prepare(this.field, this.field.times[i]).catch(
|
|
1577
1945
|
(r) => this.reportError(r)
|
|
1578
1946
|
);
|
|
@@ -1596,8 +1964,8 @@ class Xt {
|
|
|
1596
1964
|
setTimeRange(e) {
|
|
1597
1965
|
if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] > e[1])
|
|
1598
1966
|
throw new Error("Invalid GeoVideo time range");
|
|
1599
|
-
const i =
|
|
1600
|
-
this.manifest ?
|
|
1967
|
+
const i = Q(
|
|
1968
|
+
this.manifest ? X(this.manifest) : e,
|
|
1601
1969
|
e
|
|
1602
1970
|
);
|
|
1603
1971
|
if (i[0] > i[1])
|
|
@@ -1615,7 +1983,7 @@ class Xt {
|
|
|
1615
1983
|
];
|
|
1616
1984
|
}
|
|
1617
1985
|
createField(e) {
|
|
1618
|
-
const i = new
|
|
1986
|
+
const i = new Vt(this.gl, e, {
|
|
1619
1987
|
repeatLongitude: !1,
|
|
1620
1988
|
animateSnapshot: !0,
|
|
1621
1989
|
onError: (r) => {
|
|
@@ -1630,7 +1998,7 @@ class Xt {
|
|
|
1630
1998
|
i.name === "AbortError" || this.destroyed || (this.playOnReady = !1, this.awaitingNext = !1, this.failed = !0, this.seeking = !0, this.clock.setPlaying(!1), this.emit("status", { phase: "error", error: i }), this.emit("error", i));
|
|
1631
1999
|
}
|
|
1632
2000
|
}
|
|
1633
|
-
function
|
|
2001
|
+
function Z(t) {
|
|
1634
2002
|
const { start: e, end: i } = t.temporal ?? {};
|
|
1635
2003
|
return {
|
|
1636
2004
|
source: t,
|
|
@@ -1638,54 +2006,54 @@ function G(t) {
|
|
|
1638
2006
|
end: Date.parse(i ?? e ?? "")
|
|
1639
2007
|
};
|
|
1640
2008
|
}
|
|
1641
|
-
function
|
|
1642
|
-
const r = t.filter((s) => s.id === e.id && s.temporal?.start != null).map(
|
|
2009
|
+
function xi(t, e, i = {}) {
|
|
2010
|
+
const r = t.filter((s) => s.id === e.id && s.temporal?.start != null).map(Z), n = Ft(
|
|
1643
2011
|
r,
|
|
1644
2012
|
Date.parse(e.temporal?.end ?? ""),
|
|
1645
2013
|
i
|
|
1646
2014
|
);
|
|
1647
2015
|
return n ? { source: n.chunk.source, time: n.time } : null;
|
|
1648
2016
|
}
|
|
1649
|
-
function
|
|
1650
|
-
return
|
|
2017
|
+
function vi(t, e) {
|
|
2018
|
+
return St(Z(t), e.map(Z))?.source ?? null;
|
|
1651
2019
|
}
|
|
1652
|
-
const
|
|
1653
|
-
function
|
|
2020
|
+
const Bt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
2021
|
+
function Xt(t) {
|
|
1654
2022
|
return t instanceof Date ? t.getTime() : typeof t == "number" ? t : new Date(t).getTime();
|
|
1655
2023
|
}
|
|
1656
|
-
function
|
|
1657
|
-
const i =
|
|
2024
|
+
function de(t, e) {
|
|
2025
|
+
const i = Xt(t);
|
|
1658
2026
|
if (!Number.isFinite(i))
|
|
1659
2027
|
throw new Error(`Invalid ${e}`);
|
|
1660
2028
|
return i;
|
|
1661
2029
|
}
|
|
1662
|
-
function
|
|
1663
|
-
const i = e.match(
|
|
2030
|
+
function Ee(t, e) {
|
|
2031
|
+
const i = e.match(Bt);
|
|
1664
2032
|
if (!i)
|
|
1665
2033
|
throw new Error(`Invalid trailing time duration: ${e}`);
|
|
1666
|
-
const r = i.slice(1).map((
|
|
1667
|
-
if (!r.some((
|
|
2034
|
+
const r = i.slice(1).map((A) => Number(A ?? 0));
|
|
2035
|
+
if (!r.some((A) => A > 0))
|
|
1668
2036
|
throw new Error("Trailing time duration must be positive");
|
|
1669
|
-
const [n, s, o, a, d, c, l] = r, h = new Date(t),
|
|
2037
|
+
const [n, s, o, a, d, c, l] = r, h = new Date(t), p = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - s, m = Math.floor(p / 12), E = (p % 12 + 12) % 12, w = new Date(Date.UTC(m, E + 1, 0)).getUTCDate();
|
|
1670
2038
|
return Date.UTC(
|
|
1671
|
-
u,
|
|
1672
2039
|
m,
|
|
1673
|
-
|
|
2040
|
+
E,
|
|
2041
|
+
Math.min(h.getUTCDate(), w),
|
|
1674
2042
|
h.getUTCHours(),
|
|
1675
2043
|
h.getUTCMinutes(),
|
|
1676
2044
|
h.getUTCSeconds(),
|
|
1677
2045
|
h.getUTCMilliseconds()
|
|
1678
2046
|
) - (((o * 7 + a) * 24 + d) * 60 + c) * 6e4 - l * 1e3;
|
|
1679
2047
|
}
|
|
1680
|
-
function
|
|
2048
|
+
function ki(t, [e, i]) {
|
|
1681
2049
|
let r = e, n = i;
|
|
1682
|
-
if (typeof t.trailing == "string" ? r =
|
|
2050
|
+
if (typeof t.trailing == "string" ? r = Ee(i, t.trailing) : (t.start != null && (r = de(t.start, "time range start")), t.end != null && (n = de(t.end, "time range end"))), r > n)
|
|
1683
2051
|
throw new Error("Time range start must not follow its end");
|
|
1684
2052
|
return [Math.max(e, r), Math.min(i, n)];
|
|
1685
2053
|
}
|
|
1686
|
-
const
|
|
1687
|
-
function
|
|
1688
|
-
if (!
|
|
2054
|
+
const qt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
|
|
2055
|
+
function Ai(t, e) {
|
|
2056
|
+
if (!qt(t))
|
|
1689
2057
|
throw new Error(`${e} must be an object`);
|
|
1690
2058
|
for (const s of Object.keys(t))
|
|
1691
2059
|
if (s !== "start" && s !== "end" && s !== "trailing")
|
|
@@ -1695,7 +2063,7 @@ function Wt(t, e) {
|
|
|
1695
2063
|
throw new Error(`${e}.trailing excludes start and end`);
|
|
1696
2064
|
if (typeof t.trailing != "string")
|
|
1697
2065
|
throw new Error(`${e}.trailing must be an ISO 8601 duration`);
|
|
1698
|
-
return
|
|
2066
|
+
return Ee(0, t.trailing), { trailing: t.trailing };
|
|
1699
2067
|
}
|
|
1700
2068
|
const i = (s) => {
|
|
1701
2069
|
const o = t[s];
|
|
@@ -1712,37 +2080,37 @@ function Wt(t, e) {
|
|
|
1712
2080
|
...n !== void 0 && { end: n }
|
|
1713
2081
|
};
|
|
1714
2082
|
}
|
|
1715
|
-
function
|
|
2083
|
+
function Fi(t) {
|
|
1716
2084
|
return t.type === "geovideo" && typeof t.indexUrl == "string";
|
|
1717
2085
|
}
|
|
1718
|
-
function
|
|
2086
|
+
function Si(t, e) {
|
|
1719
2087
|
return t.id === e.id && (t.type !== "geovideo" || e.type !== "geovideo" || t.manifestUrl === e.manifestUrl);
|
|
1720
2088
|
}
|
|
1721
|
-
function
|
|
2089
|
+
function le(t) {
|
|
1722
2090
|
return typeof t == "string" && Number.isFinite(Date.parse(t));
|
|
1723
2091
|
}
|
|
1724
|
-
function
|
|
2092
|
+
function $t(t) {
|
|
1725
2093
|
const e = t;
|
|
1726
2094
|
if (!e || e.schemaVersion !== 1 || e.type !== "geovideo-index" || !Array.isArray(e.chunks))
|
|
1727
2095
|
throw new Error("Unsupported GeoVideo index");
|
|
1728
2096
|
for (const i of e.chunks)
|
|
1729
|
-
if (!
|
|
2097
|
+
if (!le(i?.start) || !le(i.end) || Date.parse(i.end) < Date.parse(i.start) || typeof i.manifestUrl != "string")
|
|
1730
2098
|
throw new Error("Invalid GeoVideo index chunk");
|
|
1731
2099
|
return e;
|
|
1732
2100
|
}
|
|
1733
|
-
async function
|
|
2101
|
+
async function Ui(t, e) {
|
|
1734
2102
|
const i = await fetch(t, { signal: e });
|
|
1735
2103
|
if (!i.ok)
|
|
1736
2104
|
throw new Error(
|
|
1737
2105
|
`GeoVideo index request failed (${i.status}): ${t}`
|
|
1738
2106
|
);
|
|
1739
|
-
return
|
|
2107
|
+
return $t(await i.json());
|
|
1740
2108
|
}
|
|
1741
|
-
function
|
|
2109
|
+
function Wt(t) {
|
|
1742
2110
|
return typeof document < "u" ? new URL(t, document.baseURI).href : t;
|
|
1743
2111
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const i =
|
|
2112
|
+
function Ht(t, e) {
|
|
2113
|
+
const i = Wt(e);
|
|
1746
2114
|
return t.chunks.map((r) => ({
|
|
1747
2115
|
key: r.key,
|
|
1748
2116
|
manifestUrl: new URL(r.manifestUrl, i).href,
|
|
@@ -1752,15 +2120,15 @@ function Rt(t, e) {
|
|
|
1752
2120
|
...r.provisional ? { provisional: !0 } : {}
|
|
1753
2121
|
}));
|
|
1754
2122
|
}
|
|
1755
|
-
function
|
|
2123
|
+
function zt(t, e, i) {
|
|
1756
2124
|
if (e.sourceId !== t.id || e.catalogEntryId !== i.id)
|
|
1757
2125
|
throw new Error(
|
|
1758
2126
|
`GeoVideo index identity does not match catalog entry/source: ${t.id}`
|
|
1759
2127
|
);
|
|
1760
2128
|
}
|
|
1761
|
-
function
|
|
1762
|
-
|
|
1763
|
-
const r =
|
|
2129
|
+
function Mi(t, e, i) {
|
|
2130
|
+
zt(t, e, i);
|
|
2131
|
+
const r = Ht(e, t.indexUrl);
|
|
1764
2132
|
return e.chunks.map(
|
|
1765
2133
|
(n, s) => ({
|
|
1766
2134
|
id: t.id,
|
|
@@ -1778,62 +2146,71 @@ function Kt(t, e, i) {
|
|
|
1778
2146
|
);
|
|
1779
2147
|
}
|
|
1780
2148
|
export {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
Q,
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
2149
|
+
ne as $,
|
|
2150
|
+
ue as A,
|
|
2151
|
+
ci as B,
|
|
2152
|
+
Fi as C,
|
|
2153
|
+
xi as D,
|
|
2154
|
+
Ui as E,
|
|
2155
|
+
Mi as F,
|
|
2156
|
+
Ti as G,
|
|
2157
|
+
ki as H,
|
|
2158
|
+
yi as I,
|
|
2159
|
+
oe as J,
|
|
2160
|
+
ui as K,
|
|
2161
|
+
mi as L,
|
|
2162
|
+
Ei as M,
|
|
2163
|
+
_i as N,
|
|
2164
|
+
Ot as O,
|
|
2165
|
+
xt as P,
|
|
2166
|
+
Vt as Q,
|
|
2167
|
+
me as R,
|
|
2168
|
+
bt as S,
|
|
2169
|
+
li as T,
|
|
2170
|
+
At as U,
|
|
2171
|
+
fi as V,
|
|
2172
|
+
pi as W,
|
|
2173
|
+
hi as X,
|
|
2174
|
+
Be as Y,
|
|
2175
|
+
zt as Z,
|
|
2176
|
+
pe as _,
|
|
2177
|
+
ri as a,
|
|
2178
|
+
it as a0,
|
|
2179
|
+
Ut as a1,
|
|
2180
|
+
Ht as a2,
|
|
2181
|
+
Ft as a3,
|
|
2182
|
+
vi as a4,
|
|
2183
|
+
St as a5,
|
|
2184
|
+
Ai as a6,
|
|
2185
|
+
wt as a7,
|
|
2186
|
+
Ee as a8,
|
|
2187
|
+
v as a9,
|
|
2188
|
+
K as aa,
|
|
2189
|
+
$t as ab,
|
|
2190
|
+
Ct as ac,
|
|
2191
|
+
ni as b,
|
|
2192
|
+
Kt as c,
|
|
2193
|
+
Jt as d,
|
|
2194
|
+
ei as e,
|
|
2195
|
+
ii as f,
|
|
2196
|
+
si as g,
|
|
2197
|
+
Qt as h,
|
|
2198
|
+
ti as i,
|
|
2199
|
+
gi as j,
|
|
2200
|
+
Zt as k,
|
|
2201
|
+
oi as l,
|
|
2202
|
+
Ri as m,
|
|
2203
|
+
di as n,
|
|
2204
|
+
ut as o,
|
|
2205
|
+
Tt as p,
|
|
2206
|
+
ze as q,
|
|
2207
|
+
Ke as r,
|
|
2208
|
+
ai as s,
|
|
2209
|
+
ft as t,
|
|
2210
|
+
jt as u,
|
|
2211
|
+
bi as v,
|
|
2212
|
+
de as w,
|
|
2213
|
+
M as x,
|
|
2214
|
+
Si as y,
|
|
2215
|
+
wi as z
|
|
1839
2216
|
};
|