filens-preview 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -24
- package/dist/all-in-one/filens.js +24667 -22367
- package/dist/index.d.ts +4 -0
- package/dist/split/assets/iwork-worker-DiTOJG8f.js +27 -0
- package/dist/split/chunks/{archive-Drem4a-o.js → archive-_cUUL2-3.js} +2 -2
- package/dist/split/chunks/{cad-CsU3TiHK.js → cad-Cyh8aipO.js} +1 -1
- package/dist/split/chunks/{core-BvtuMqS1.js → core-gp02JQ3r.js} +1493 -1459
- package/dist/split/chunks/{diagram-BxRNHzmO.js → diagram-rxvArV-1.js} +2 -2
- package/dist/split/chunks/{docx-Ch1AvEUX.js → docx-ecvZsSWm.js} +2 -2
- package/dist/split/chunks/{ebook-P42eILp5.js → ebook-5FyKWZ8s.js} +2 -2
- package/dist/split/chunks/{iwork-HnghW_EB.js → iwork-DlaehzuR.js} +63 -63
- package/dist/split/chunks/{media-runtime-kbzoW8bd.js → media-runtime-DwW7eq4g.js} +2 -2
- package/dist/split/chunks/{mindmap-vFlOJSIq.js → mindmap-D9lNNDoa.js} +2 -2
- package/dist/split/chunks/{model3d-DoNu7iyY.js → model3d-BtFT01ZH.js} +3 -3
- package/dist/split/chunks/{panorama-Bw_8HQsv.js → panorama-Ci6DK6sa.js} +989 -985
- package/dist/split/chunks/{vendor-Cv2Fxtsf.js → vendor-DvWhw-zP.js} +6883 -7216
- package/dist/split/chunks/{xlsx-ypLtJxeq.js → xlsx-VJTu9XNS.js} +2 -2
- package/dist/split/converter-core.wasm +0 -0
- package/dist/split/converter-office.wasm +0 -0
- package/dist/split/filens.js +3814 -1213
- package/package.json +1 -1
- package/dist/split/assets/iwork-worker-D64s_rsm.js +0 -34
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var A = (t, e, i) =>
|
|
4
|
-
import { m as
|
|
5
|
-
import { S as
|
|
1
|
+
var ko = Object.defineProperty;
|
|
2
|
+
var Ro = (t, e, i) => e in t ? ko(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var A = (t, e, i) => Ro(t, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { m as kn, c as Po, n as Ao } from "./core-gp02JQ3r.js";
|
|
5
|
+
import { S as Ji, ab as Ft, ac as Ta, ad as ka, ae as Ra, af as Ki, h as Zi, ag as Lo, ah as Pa, ai as Rn, l as _o, n as Uo, a8 as Eo, aj as Yr, v as Co } from "./vendor-DvWhw-zP.js";
|
|
6
6
|
function Se(t) {
|
|
7
|
-
if (t != null && t.aborted) throw
|
|
7
|
+
if (t != null && t.aborted) throw Pn();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function Pn() {
|
|
10
10
|
return Object.assign(new Error("The conversion was aborted."), { name: "AbortError" });
|
|
11
11
|
}
|
|
12
12
|
function wt(t, e) {
|
|
13
13
|
return e ? new Promise((i, n) => {
|
|
14
|
-
const r = () => n(
|
|
14
|
+
const r = () => n(Pn());
|
|
15
15
|
t.then(
|
|
16
16
|
(o) => {
|
|
17
17
|
e.removeEventListener("abort", r), i(o);
|
|
@@ -22,7 +22,7 @@ function wt(t, e) {
|
|
|
22
22
|
), e.aborted ? r() : e.addEventListener("abort", r, { once: !0 });
|
|
23
23
|
}) : t;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Aa(t) {
|
|
26
26
|
let e;
|
|
27
27
|
return () => {
|
|
28
28
|
if (!e) {
|
|
@@ -34,28 +34,28 @@ function Pa(t) {
|
|
|
34
34
|
return e;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function Io(t) {
|
|
38
38
|
return /^(?:https?:|blob:|\/|\.{1,2}\/)/i.test(t);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function zo(t) {
|
|
41
41
|
return t.trimStart().toLowerCase().startsWith("data:");
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Bo(t) {
|
|
44
44
|
const e = atob(t), i = new Uint8Array(e.length);
|
|
45
45
|
for (let n = 0; n < i.length; n++) i[n] = e.charCodeAt(n);
|
|
46
46
|
return i;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function jo(t) {
|
|
49
49
|
var c;
|
|
50
50
|
const e = t.trimStart(), i = e.indexOf(",");
|
|
51
51
|
if (i < 0) throw new Error("Conversion data URL is missing its payload separator.");
|
|
52
52
|
const n = e.slice(0, i), r = e.slice(i + 1), o = (c = n.match(/^data:([^;,]+)/i)) == null ? void 0 : c[1];
|
|
53
|
-
if (/;base64$/i.test(n)) return { bytes:
|
|
53
|
+
if (/;base64$/i.test(n)) return { bytes: Bo(r), contentType: o };
|
|
54
54
|
const s = new TextEncoder().encode(r);
|
|
55
55
|
let a = 0;
|
|
56
56
|
for (let l = 0; l < s.length; l++) {
|
|
57
57
|
if (s[l] === 37) {
|
|
58
|
-
const u =
|
|
58
|
+
const u = Qr(s[l + 1]), f = Qr(s[l + 2]);
|
|
59
59
|
if (u >= 0 && f >= 0) {
|
|
60
60
|
s[a++] = u << 4 | f, l += 2;
|
|
61
61
|
continue;
|
|
@@ -65,22 +65,22 @@ function Bo(t) {
|
|
|
65
65
|
}
|
|
66
66
|
return { bytes: s.subarray(0, a), contentType: o };
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Qr(t) {
|
|
69
69
|
if (t >= 48 && t <= 57) return t - 48;
|
|
70
70
|
const e = t | 32;
|
|
71
71
|
return e >= 97 && e <= 102 ? e - 87 : -1;
|
|
72
72
|
}
|
|
73
|
-
async function
|
|
74
|
-
if (
|
|
73
|
+
async function An(t, e = globalThis.fetch, i) {
|
|
74
|
+
if (No(t))
|
|
75
75
|
return new Uint8Array(await wt(t.arrayBuffer(), i));
|
|
76
76
|
if (t instanceof ArrayBuffer)
|
|
77
77
|
return new Uint8Array(t);
|
|
78
78
|
if (ArrayBuffer.isView(t))
|
|
79
79
|
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
80
80
|
if (typeof t == "string") {
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
83
|
-
if (
|
|
81
|
+
if (zo(t))
|
|
82
|
+
return jo(t).bytes;
|
|
83
|
+
if (Io(t)) {
|
|
84
84
|
if (!e) throw new Error("A fetch implementation is required to load a conversion source URL.");
|
|
85
85
|
const n = await wt(e(t, { signal: i }), i);
|
|
86
86
|
if (Se(i), !n.ok)
|
|
@@ -91,15 +91,15 @@ async function Rn(t, e = globalThis.fetch, i) {
|
|
|
91
91
|
}
|
|
92
92
|
throw new Error("Unsupported conversion source type.");
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function No(t) {
|
|
95
95
|
return typeof t == "object" && t !== null && "arrayBuffer" in t && typeof t.arrayBuffer == "function";
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const e =
|
|
97
|
+
function wi(t) {
|
|
98
|
+
const e = Aa(() => Ln(t.wasm, t.fetch));
|
|
99
99
|
return async (i) => {
|
|
100
100
|
const n = i.signal;
|
|
101
101
|
Se(n);
|
|
102
|
-
const r = new
|
|
102
|
+
const r = new En({
|
|
103
103
|
args: i.args,
|
|
104
104
|
files: i.files,
|
|
105
105
|
captureStdio: i.captureStdio
|
|
@@ -113,7 +113,7 @@ function $i(t) {
|
|
|
113
113
|
try {
|
|
114
114
|
s.exports._start();
|
|
115
115
|
} catch (c) {
|
|
116
|
-
if (c instanceof
|
|
116
|
+
if (c instanceof _n)
|
|
117
117
|
a = c.code;
|
|
118
118
|
else
|
|
119
119
|
throw c;
|
|
@@ -128,32 +128,32 @@ function $i(t) {
|
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
async function
|
|
131
|
+
async function Ln(t, e = globalThis.fetch) {
|
|
132
132
|
const i = typeof t == "function" ? await t() : await t;
|
|
133
133
|
if (i instanceof WebAssembly.Module)
|
|
134
134
|
return i;
|
|
135
|
-
if (typeof i == "string" ||
|
|
135
|
+
if (typeof i == "string" || Oo(i)) {
|
|
136
136
|
if (!e)
|
|
137
137
|
throw new Error("A fetch implementation is required to load converter WASM from a URL.");
|
|
138
|
-
return
|
|
138
|
+
return Hr(await e(String(i)));
|
|
139
139
|
}
|
|
140
|
-
return typeof Response < "u" && i instanceof Response ?
|
|
140
|
+
return typeof Response < "u" && i instanceof Response ? Hr(i) : WebAssembly.compile(i);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function Oo(t) {
|
|
143
143
|
return typeof URL < "u" && t instanceof URL;
|
|
144
144
|
}
|
|
145
|
-
async function
|
|
145
|
+
async function Hr(t) {
|
|
146
146
|
if (!t.ok)
|
|
147
147
|
throw new Error(`Failed to fetch converter WASM: ${t.status} ${t.statusText}`.trim());
|
|
148
148
|
return WebAssembly.compile(await t.arrayBuffer());
|
|
149
149
|
}
|
|
150
|
-
class
|
|
150
|
+
class _n extends Error {
|
|
151
151
|
constructor(e) {
|
|
152
152
|
super(`WASI exited with code ${e}`), this.code = e;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
const Q = 0, ge = 8,
|
|
156
|
-
class
|
|
155
|
+
const Q = 0, ge = 8, Vo = 20, Jr = 28, hi = 31, mi = 44, Kr = 54, pa = 55, Un = 2, ba = 3, wa = 4, Zr = 1, Wo = 2, qo = 4, Go = 8, en = 1;
|
|
156
|
+
class En {
|
|
157
157
|
constructor(e) {
|
|
158
158
|
A(this, "imports", {
|
|
159
159
|
args_get: (e, i) => this.argsGet(e, i),
|
|
@@ -179,7 +179,7 @@ class _n {
|
|
|
179
179
|
path_unlink_file: (e, i, n) => this.pathUnlinkFile(e, i, n),
|
|
180
180
|
poll_oneoff: (e, i, n, r) => this.pollOneoff(r),
|
|
181
181
|
proc_exit: (e) => {
|
|
182
|
-
throw new
|
|
182
|
+
throw new _n(e);
|
|
183
183
|
},
|
|
184
184
|
random_get: (e, i) => this.randomGet(e, i),
|
|
185
185
|
sched_yield: () => Q
|
|
@@ -208,14 +208,14 @@ class _n {
|
|
|
208
208
|
return new TextDecoder().decode(new Uint8Array(this.stdio[e]));
|
|
209
209
|
}
|
|
210
210
|
readFile(e) {
|
|
211
|
-
const i = this.files.get(
|
|
211
|
+
const i = this.files.get(qt(e));
|
|
212
212
|
if (!i)
|
|
213
213
|
throw new Error(`WASM file was not written: ${e}`);
|
|
214
214
|
const n = new Uint8Array(i.byteLength);
|
|
215
215
|
return n.set(i), n;
|
|
216
216
|
}
|
|
217
217
|
readFileIfPresent(e) {
|
|
218
|
-
return this.files.has(
|
|
218
|
+
return this.files.has(qt(e)) ? this.readFile(e) : void 0;
|
|
219
219
|
}
|
|
220
220
|
get memory() {
|
|
221
221
|
var i;
|
|
@@ -231,7 +231,7 @@ class _n {
|
|
|
231
231
|
return new DataView(this.memory.buffer);
|
|
232
232
|
}
|
|
233
233
|
argsSizesGet(e, i) {
|
|
234
|
-
return this.view.setUint32(e, this.args.length, !0), this.view.setUint32(i,
|
|
234
|
+
return this.view.setUint32(e, this.args.length, !0), this.view.setUint32(i, Xo(this.args), !0), Q;
|
|
235
235
|
}
|
|
236
236
|
argsGet(e, i) {
|
|
237
237
|
return this.writeStringList(this.args, e, i);
|
|
@@ -247,12 +247,12 @@ class _n {
|
|
|
247
247
|
}
|
|
248
248
|
fdFdstatGet(e, i) {
|
|
249
249
|
const n = this.fds.get(e);
|
|
250
|
-
return n ? (this.bytes.fill(0, i, i + 24), this.bytes[i] =
|
|
250
|
+
return n ? (this.bytes.fill(0, i, i + 24), this.bytes[i] = $o(n), this.view.setBigUint64(i + 8, 0xffffffffffffffffn, !0), this.view.setBigUint64(i + 16, 0xffffffffffffffffn, !0), Q) : ge;
|
|
251
251
|
}
|
|
252
252
|
fdFilestatGet(e, i) {
|
|
253
253
|
var r;
|
|
254
254
|
const n = this.fds.get(e);
|
|
255
|
-
return n ? n.kind === "file" ? (this.writeFilestat(i,
|
|
255
|
+
return n ? n.kind === "file" ? (this.writeFilestat(i, wa, ((r = this.files.get(n.path)) == null ? void 0 : r.byteLength) ?? 0), Q) : n.kind === "dir" ? (this.writeFilestat(i, ba, 0), Q) : (this.writeFilestat(i, Un, 0), Q) : ge;
|
|
256
256
|
}
|
|
257
257
|
fdPrestatGet(e, i) {
|
|
258
258
|
const n = this.fds.get(e);
|
|
@@ -285,9 +285,9 @@ class _n {
|
|
|
285
285
|
const o = this.fds.get(e);
|
|
286
286
|
if (!o || o.kind !== "file")
|
|
287
287
|
return (o == null ? void 0 : o.kind) === "dir" ? hi : ge;
|
|
288
|
-
if (n !== 0 && n !== 1 && n !== 2) return
|
|
288
|
+
if (n !== 0 && n !== 1 && n !== 2) return Jr;
|
|
289
289
|
const a = (n === 0 ? 0 : n === 1 ? o.position : n === 2 ? ((c = this.files.get(o.path)) == null ? void 0 : c.byteLength) ?? 0 : -1) + Number(i);
|
|
290
|
-
return !Number.isSafeInteger(a) || a < 0 ?
|
|
290
|
+
return !Number.isSafeInteger(a) || a < 0 ? Jr : (o.position = a, this.view.setBigUint64(r, BigInt(a), !0), Q);
|
|
291
291
|
}
|
|
292
292
|
fdTell(e, i) {
|
|
293
293
|
const n = this.fds.get(e);
|
|
@@ -319,26 +319,26 @@ class _n {
|
|
|
319
319
|
}
|
|
320
320
|
pathCreateDirectory(e, i, n) {
|
|
321
321
|
const r = this.readPath(e, i, n);
|
|
322
|
-
return r ? (this.ensureParentDir(r), this.files.has(r) ?
|
|
322
|
+
return r ? (this.ensureParentDir(r), this.files.has(r) ? Kr : (this.dirs.add(r), Q)) : ge;
|
|
323
323
|
}
|
|
324
324
|
pathFilestatGet(e, i, n, r) {
|
|
325
325
|
var s;
|
|
326
326
|
const o = this.readPath(e, i, n);
|
|
327
|
-
return o ? this.files.has(o) ? (this.writeFilestat(r,
|
|
327
|
+
return o ? this.files.has(o) ? (this.writeFilestat(r, wa, ((s = this.files.get(o)) == null ? void 0 : s.byteLength) ?? 0), Q) : this.dirs.has(o) ? (this.writeFilestat(r, ba, 0), Q) : mi : ge;
|
|
328
328
|
}
|
|
329
329
|
pathOpen(e, i, n, r, o, s) {
|
|
330
330
|
var l;
|
|
331
331
|
const a = this.readPath(e, i, n);
|
|
332
332
|
if (!a)
|
|
333
333
|
return ge;
|
|
334
|
-
if (r &
|
|
335
|
-
return
|
|
336
|
-
if (!!(r &
|
|
337
|
-
return this.dirs.has(a) ? this.openDescriptor({ kind: "dir", path: a, position: 0 }, s) : this.files.has(a) ?
|
|
334
|
+
if (r & Zr && r & qo && (this.files.has(a) || this.dirs.has(a)))
|
|
335
|
+
return Vo;
|
|
336
|
+
if (!!(r & Wo))
|
|
337
|
+
return this.dirs.has(a) ? this.openDescriptor({ kind: "dir", path: a, position: 0 }, s) : this.files.has(a) ? Kr : mi;
|
|
338
338
|
if (this.files.has(a))
|
|
339
339
|
r & Go && this.files.set(a, new Uint8Array());
|
|
340
340
|
else {
|
|
341
|
-
if (!(r &
|
|
341
|
+
if (!(r & Zr))
|
|
342
342
|
return this.dirs.has(a) ? hi : mi;
|
|
343
343
|
this.ensureParentDir(a), this.files.set(a, new Uint8Array());
|
|
344
344
|
}
|
|
@@ -346,8 +346,8 @@ class _n {
|
|
|
346
346
|
{
|
|
347
347
|
kind: "file",
|
|
348
348
|
path: a,
|
|
349
|
-
position: o &
|
|
350
|
-
append: !!(o &
|
|
349
|
+
position: o & en ? ((l = this.files.get(a)) == null ? void 0 : l.byteLength) ?? 0 : 0,
|
|
350
|
+
append: !!(o & en)
|
|
351
351
|
},
|
|
352
352
|
s
|
|
353
353
|
);
|
|
@@ -357,13 +357,13 @@ class _n {
|
|
|
357
357
|
if (!r)
|
|
358
358
|
return ge;
|
|
359
359
|
if (r === "/" || r === "/work")
|
|
360
|
-
return
|
|
360
|
+
return pa;
|
|
361
361
|
for (const o of this.dirs)
|
|
362
|
-
if (o !== r &&
|
|
363
|
-
return
|
|
362
|
+
if (o !== r && ya(o) === r)
|
|
363
|
+
return pa;
|
|
364
364
|
for (const o of this.files.keys())
|
|
365
|
-
if (
|
|
366
|
-
return
|
|
365
|
+
if (ya(o) === r)
|
|
366
|
+
return pa;
|
|
367
367
|
return this.dirs.delete(r) ? Q : mi;
|
|
368
368
|
}
|
|
369
369
|
pathUnlinkFile(e, i, n) {
|
|
@@ -403,7 +403,7 @@ class _n {
|
|
|
403
403
|
if (!r || r.kind !== "dir")
|
|
404
404
|
return null;
|
|
405
405
|
const o = new TextDecoder().decode(this.bytes.subarray(i, i + n));
|
|
406
|
-
return
|
|
406
|
+
return Yo(r.path, o);
|
|
407
407
|
}
|
|
408
408
|
openDescriptor(e, i) {
|
|
409
409
|
const n = this.nextFd++;
|
|
@@ -413,13 +413,13 @@ class _n {
|
|
|
413
413
|
this.bytes.fill(0, e, e + 64), this.bytes[e + 16] = i, this.view.setBigUint64(e + 24, 1n, !0), this.view.setBigUint64(e + 32, BigInt(n), !0);
|
|
414
414
|
}
|
|
415
415
|
writeInitialFile(e, i) {
|
|
416
|
-
const n =
|
|
416
|
+
const n = qt(e);
|
|
417
417
|
this.ensureParentDir(n);
|
|
418
418
|
const r = new Uint8Array(i.byteLength);
|
|
419
419
|
r.set(i), this.files.set(n, r);
|
|
420
420
|
}
|
|
421
421
|
ensureParentDir(e) {
|
|
422
|
-
const i =
|
|
422
|
+
const i = ya(e);
|
|
423
423
|
i === e || this.dirs.has(i) || (this.ensureParentDir(i), this.dirs.add(i));
|
|
424
424
|
}
|
|
425
425
|
writeFileChunk(e, i) {
|
|
@@ -435,23 +435,23 @@ class _n {
|
|
|
435
435
|
s.set(i, r), this.files.set(e.path, s), e.position = r + i.byteLength;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function Xo(t) {
|
|
439
439
|
return t.reduce((e, i) => e + new TextEncoder().encode(i).byteLength + 1, 0);
|
|
440
440
|
}
|
|
441
|
-
function
|
|
441
|
+
function $o(t) {
|
|
442
442
|
switch (t.kind) {
|
|
443
443
|
case "dir":
|
|
444
|
-
return xa;
|
|
445
|
-
case "file":
|
|
446
444
|
return ba;
|
|
445
|
+
case "file":
|
|
446
|
+
return wa;
|
|
447
447
|
default:
|
|
448
|
-
return
|
|
448
|
+
return Un;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
function
|
|
452
|
-
return e.startsWith("/") ?
|
|
451
|
+
function Yo(t, e) {
|
|
452
|
+
return e.startsWith("/") ? qt(e) : qt(`${t}/${e}`);
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function qt(t) {
|
|
455
455
|
const e = [];
|
|
456
456
|
for (const i of t.replace(/\\/g, "/").split("/"))
|
|
457
457
|
if (!(!i || i === ".")) {
|
|
@@ -463,14 +463,14 @@ function Gt(t) {
|
|
|
463
463
|
}
|
|
464
464
|
return `/${e.join("/")}`;
|
|
465
465
|
}
|
|
466
|
-
function
|
|
467
|
-
const e =
|
|
466
|
+
function ya(t) {
|
|
467
|
+
const e = qt(t);
|
|
468
468
|
if (e === "/")
|
|
469
469
|
return "/";
|
|
470
470
|
const i = e.lastIndexOf("/");
|
|
471
471
|
return i <= 0 ? "/" : e.slice(0, i);
|
|
472
472
|
}
|
|
473
|
-
const
|
|
473
|
+
const Qo = [
|
|
474
474
|
{
|
|
475
475
|
sourceFormat: "dng",
|
|
476
476
|
targetFormat: "jpg"
|
|
@@ -563,85 +563,89 @@ const Yo = [
|
|
|
563
563
|
sourceFormat: "icns",
|
|
564
564
|
targetFormat: "png"
|
|
565
565
|
}
|
|
566
|
-
],
|
|
567
|
-
|
|
568
|
-
),
|
|
569
|
-
|
|
566
|
+
], Ho = new Set(
|
|
567
|
+
kn.map((t) => ut(t.sourceFormat))
|
|
568
|
+
), Jo = new Set(
|
|
569
|
+
kn.map(
|
|
570
570
|
(t) => `${ut(t.sourceFormat)}->${ut(t.targetFormat)}`
|
|
571
571
|
)
|
|
572
|
-
),
|
|
573
|
-
|
|
572
|
+
), Ko = new Set(
|
|
573
|
+
Qo.map(
|
|
574
574
|
(t) => `${ut(t.sourceFormat)}->${ut(t.targetFormat)}`
|
|
575
575
|
)
|
|
576
576
|
);
|
|
577
|
-
class
|
|
577
|
+
class Qi extends Error {
|
|
578
578
|
constructor(e) {
|
|
579
579
|
super(e.errorMessage || e.errorCode || "WASM conversion failed."), this.result = e, this.name = "WasmConversionError";
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
const e =
|
|
582
|
+
function Xc(t) {
|
|
583
|
+
const e = wi(t), i = t.officeWasm ? wi({ wasm: t.officeWasm, fetch: t.fetch }) : void 0, n = t.imageWasm ? Aa(() => Ln(t.imageWasm, t.fetch)) : void 0, r = t.imageWasm ? wi({ wasm: n, fetch: t.fetch }) : void 0, o = n ? Zo(n) : void 0;
|
|
584
584
|
return {
|
|
585
|
-
async convert(
|
|
586
|
-
Se(
|
|
587
|
-
const
|
|
588
|
-
Se(
|
|
589
|
-
const
|
|
590
|
-
...
|
|
591
|
-
...
|
|
592
|
-
}),
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
if (Se(
|
|
585
|
+
async convert(s, a) {
|
|
586
|
+
Se(a.signal);
|
|
587
|
+
const c = ut(s.sourceFormat), l = ut(s.targetFormat), u = es(c, l), f = `/work/input.${c}`, y = `/work/output.${l}`, p = "/work/options.json", h = "/work/result.json", d = await An(s.source, t.fetch, a.signal);
|
|
588
|
+
Se(a.signal);
|
|
589
|
+
const m = JSON.stringify({
|
|
590
|
+
...s.password ? { password: s.password } : {},
|
|
591
|
+
...s.locale ? { locale: s.locale } : {}
|
|
592
|
+
}), g = !!(r && Ko.has(u));
|
|
593
|
+
if (g && l === "jpg" && o) {
|
|
594
|
+
const D = await o(d, a.signal);
|
|
595
|
+
if (Se(a.signal), D) return D;
|
|
596
596
|
}
|
|
597
|
-
const b =
|
|
597
|
+
const b = g ? r : e, x = (D, F) => D({
|
|
598
598
|
args: [
|
|
599
|
-
|
|
599
|
+
g ? "converter-image" : "converter-core",
|
|
600
600
|
"--input",
|
|
601
|
-
u,
|
|
602
|
-
"--output",
|
|
603
601
|
f,
|
|
602
|
+
"--output",
|
|
603
|
+
y,
|
|
604
604
|
"--source",
|
|
605
|
-
a,
|
|
606
|
-
"--target",
|
|
607
605
|
c,
|
|
606
|
+
"--target",
|
|
607
|
+
l,
|
|
608
608
|
"--options",
|
|
609
|
-
|
|
609
|
+
p,
|
|
610
610
|
"--result",
|
|
611
|
-
|
|
611
|
+
h
|
|
612
612
|
],
|
|
613
613
|
files: {
|
|
614
|
-
[
|
|
615
|
-
[
|
|
614
|
+
[f]: F,
|
|
615
|
+
[p]: new TextEncoder().encode(m)
|
|
616
616
|
},
|
|
617
|
-
readFiles: [
|
|
618
|
-
signal:
|
|
617
|
+
readFiles: [h, y],
|
|
618
|
+
signal: a.signal
|
|
619
619
|
});
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
});
|
|
631
|
-
return {
|
|
632
|
-
source: b.files[f],
|
|
633
|
-
format: ut(x.targetFormat || c),
|
|
634
|
-
contentType: x.contentType,
|
|
635
|
-
warnings: x.warnings
|
|
620
|
+
let v = await x(b, d), w = $i(v.files[h]);
|
|
621
|
+
if (!w.ok && w.errorCode === "engine_unavailable" && w.requiredModule === "office" && i) {
|
|
622
|
+
const D = await x(i, d);
|
|
623
|
+
tn($i(D.files[h]), D.exitCode), v = await x(e, D.files[y]), w = $i(v.files[h]);
|
|
624
|
+
}
|
|
625
|
+
return Se(a.signal), tn(w, v.exitCode), {
|
|
626
|
+
source: v.files[y],
|
|
627
|
+
format: ut(w.targetFormat || l),
|
|
628
|
+
contentType: w.contentType,
|
|
629
|
+
warnings: w.warnings
|
|
636
630
|
};
|
|
637
631
|
}
|
|
638
632
|
};
|
|
639
633
|
}
|
|
640
|
-
function
|
|
641
|
-
|
|
634
|
+
function tn(t, e) {
|
|
635
|
+
if (!t.ok) throw new Qi(t);
|
|
636
|
+
if (e !== 0)
|
|
637
|
+
throw new Qi({
|
|
638
|
+
...t,
|
|
639
|
+
ok: !1,
|
|
640
|
+
errorCode: t.errorCode || "conversion_failed",
|
|
641
|
+
errorMessage: t.errorMessage || `converter WASM exited with code ${e}`
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function Zo(t) {
|
|
645
|
+
const e = Aa(async () => {
|
|
642
646
|
const i = await t(), n = new Set(WebAssembly.Module.exports(i).map((s) => s.name));
|
|
643
647
|
if (!["filens_image_alloc", "filens_image_free", "filens_image_preview", "memory"].every((s) => n.has(s))) return null;
|
|
644
|
-
const r = new
|
|
648
|
+
const r = new En({ args: ["converter-image"], files: {} }), o = await WebAssembly.instantiate(i, { wasi_snapshot_preview1: r.imports });
|
|
645
649
|
return r.setInstance(o), o.exports;
|
|
646
650
|
});
|
|
647
651
|
return async (i, n) => {
|
|
@@ -655,20 +659,20 @@ function Ko(t) {
|
|
|
655
659
|
if (s = Number(c & 0xffffffffn), a = Number(c >> 32n), !s || a < 4 || s + a > r.memory.buffer.byteLength) throw new Error("Image core returned an invalid preview buffer.");
|
|
656
660
|
const l = new Uint8Array(r.memory.buffer, s, a), u = new DataView(l.buffer, l.byteOffset, 4).getUint32(0, !0);
|
|
657
661
|
if (u > l.length - 4) throw new Error("Image core returned invalid preview metadata.");
|
|
658
|
-
const f =
|
|
659
|
-
if (!f.ok) throw new
|
|
662
|
+
const f = $i(l.subarray(4, 4 + u));
|
|
663
|
+
if (!f.ok) throw new Qi(f);
|
|
660
664
|
return { source: l.slice(4 + u), format: "jpg", contentType: f.contentType, warnings: f.warnings };
|
|
661
665
|
} finally {
|
|
662
666
|
s && a && r.filens_image_free(s, a), o && r.filens_image_free(o, i.length);
|
|
663
667
|
}
|
|
664
668
|
};
|
|
665
669
|
}
|
|
666
|
-
function
|
|
670
|
+
function es(t, e) {
|
|
667
671
|
const i = `${t}->${e}`;
|
|
668
|
-
if (
|
|
672
|
+
if (Jo.has(i))
|
|
669
673
|
return i;
|
|
670
|
-
const n =
|
|
671
|
-
throw new
|
|
674
|
+
const n = Ho.has(t) ? `unsupported conversion pair: ${t} -> ${e}` : `unsupported source format: ${t}`;
|
|
675
|
+
throw new Qi({
|
|
672
676
|
ok: !1,
|
|
673
677
|
sourceFormat: t,
|
|
674
678
|
targetFormat: e,
|
|
@@ -678,7 +682,7 @@ function Zo(t, e) {
|
|
|
678
682
|
metrics: {}
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
|
-
function
|
|
685
|
+
function $i(t) {
|
|
682
686
|
const e = new TextDecoder().decode(t), i = JSON.parse(e);
|
|
683
687
|
return {
|
|
684
688
|
...i,
|
|
@@ -688,16 +692,16 @@ function Un(t) {
|
|
|
688
692
|
function ut(t) {
|
|
689
693
|
return t.trim().replace(/^\./, "").toLowerCase();
|
|
690
694
|
}
|
|
691
|
-
function
|
|
695
|
+
function $c() {
|
|
692
696
|
return {
|
|
693
697
|
async convert(t, e) {
|
|
694
698
|
const i = t.sourceFormat.replace(/^\./, "").toLowerCase(), n = t.targetFormat.replace(/^\./, "").toLowerCase();
|
|
695
699
|
if (!(["heic", "heif"].includes(i) && n === "png"))
|
|
696
700
|
throw new Error(`Unsupported media conversion: ${i} -> ${n}.`);
|
|
697
701
|
Se(e.signal);
|
|
698
|
-
const r = ArrayBuffer.isView(t.source) ? t.source.slice() : t.source instanceof ArrayBuffer ? t.source.slice(0) : t.source, o = await
|
|
702
|
+
const r = ArrayBuffer.isView(t.source) ? t.source.slice() : t.source instanceof ArrayBuffer ? t.source.slice(0) : t.source, o = await An(r, globalThis.fetch, e.signal);
|
|
699
703
|
Se(e.signal);
|
|
700
|
-
const s = await wt(import("./media-runtime-
|
|
704
|
+
const s = await wt(import("./media-runtime-DwW7eq4g.js"), e.signal);
|
|
701
705
|
return Se(e.signal), s.convertMedia(o, i, e.signal);
|
|
702
706
|
}
|
|
703
707
|
};
|
|
@@ -715,7 +719,7 @@ function le(t, e, i) {
|
|
|
715
719
|
});
|
|
716
720
|
});
|
|
717
721
|
}
|
|
718
|
-
function
|
|
722
|
+
function ts(t, e) {
|
|
719
723
|
const i = (n) => (H(e), le(n(), e));
|
|
720
724
|
return {
|
|
721
725
|
open: (n, r) => i(() => t.open(n, { ...r, signal: e })),
|
|
@@ -733,14 +737,14 @@ function es(t, e) {
|
|
|
733
737
|
}
|
|
734
738
|
};
|
|
735
739
|
}
|
|
736
|
-
const
|
|
740
|
+
const an = 8, Mi = 64 << 20, is = 128 << 20, rn = 120, as = 8 << 20;
|
|
737
741
|
class B extends Error {
|
|
738
742
|
constructor(e, i) {
|
|
739
743
|
super(i), this.code = e, this.name = "PanoramaProcessorError";
|
|
740
744
|
}
|
|
741
745
|
}
|
|
742
|
-
function
|
|
743
|
-
const e = t.fetch ?? globalThis.fetch, i =
|
|
746
|
+
function rs(t) {
|
|
747
|
+
const e = t.fetch ?? globalThis.fetch, i = wi({ wasm: t.wasm, fetch: e }), n = t.imageWasm ? wi({ wasm: t.imageWasm, fetch: e }) : void 0, r = (l) => {
|
|
744
748
|
const u = new AbortController(), f = pi(u.signal, l);
|
|
745
749
|
return { controller: u, ...f, companionTrackIds: /* @__PURE__ */ new Map() };
|
|
746
750
|
};
|
|
@@ -759,16 +763,16 @@ function as(t) {
|
|
|
759
763
|
const v = await l.companionProcessor.readSample(p, f, y);
|
|
760
764
|
return ie(y), { ...v, trackId: u };
|
|
761
765
|
}
|
|
762
|
-
const { reader:
|
|
763
|
-
if (!
|
|
764
|
-
const
|
|
765
|
-
if (!
|
|
766
|
-
const b = await
|
|
767
|
-
return { ...g, trackId: u, timescale:
|
|
766
|
+
const { reader: h, manifest: d } = l;
|
|
767
|
+
if (!h || !d) throw new B("invalid_manifest", "Open a panorama source before reading samples.");
|
|
768
|
+
const m = d.tracks.find((v) => v.id === u) ?? (((x = d.metadataTrack) == null ? void 0 : x.id) === u ? d.metadataTrack : void 0), g = m == null ? void 0 : m.samples[f];
|
|
769
|
+
if (!m || !g) throw new RangeError(`Unknown panorama sample ${u}:${f}.`);
|
|
770
|
+
const b = await h.read(g.offset, g.size, y);
|
|
771
|
+
return { ...g, trackId: u, timescale: m.timescale, data: b };
|
|
768
772
|
};
|
|
769
773
|
return {
|
|
770
774
|
async open(l, u) {
|
|
771
|
-
var
|
|
775
|
+
var h;
|
|
772
776
|
const f = r(u.signal), y = o;
|
|
773
777
|
o = f, s(y);
|
|
774
778
|
const p = f.signal;
|
|
@@ -776,12 +780,12 @@ function as(t) {
|
|
|
776
780
|
ie(p);
|
|
777
781
|
const d = await le(bt.open(l, e, p), p, (S) => S.close());
|
|
778
782
|
ie(p), f.reader = d;
|
|
779
|
-
let
|
|
783
|
+
let m;
|
|
780
784
|
const g = /* @__PURE__ */ new Map(), b = u.format === "insp" ? 1 << 20 : 65536, x = u.format === "insp" ? 65536 : 1 << 20, v = [
|
|
781
785
|
{ offset: 0, length: Math.min(b, d.size) },
|
|
782
786
|
{ offset: Math.max(0, d.size - x), length: Math.min(x, d.size) }
|
|
783
787
|
];
|
|
784
|
-
await
|
|
788
|
+
await on(d, g, v, p);
|
|
785
789
|
let w;
|
|
786
790
|
if (u.sidecar) {
|
|
787
791
|
const S = await bt.open(u.sidecar, e, p);
|
|
@@ -792,7 +796,7 @@ function as(t) {
|
|
|
792
796
|
S.close();
|
|
793
797
|
}
|
|
794
798
|
}
|
|
795
|
-
for (let S = 0; S <
|
|
799
|
+
for (let S = 0; S < an; S += 1) {
|
|
796
800
|
ie(p);
|
|
797
801
|
const D = [...g.values()].map((P, E) => ({
|
|
798
802
|
offset: P.offset,
|
|
@@ -818,42 +822,42 @@ function as(t) {
|
|
|
818
822
|
if (!_) throw new B("invalid_manifest", "Panorama inspector did not return a result.");
|
|
819
823
|
const k = JSON.parse(new TextDecoder().decode(_));
|
|
820
824
|
if (k.ok && k.payload) {
|
|
821
|
-
if (
|
|
822
|
-
f.companionProcessor =
|
|
825
|
+
if (m = os(k.payload), u.companion) {
|
|
826
|
+
f.companionProcessor = rs(t);
|
|
823
827
|
const P = await f.companionProcessor.open(u.companion, {
|
|
824
828
|
format: u.format,
|
|
825
829
|
sidecar: u.sidecar,
|
|
826
830
|
signal: p
|
|
827
831
|
});
|
|
828
832
|
ie(p);
|
|
829
|
-
const E = new Set(
|
|
833
|
+
const E = new Set(m.tracks.map((J) => J.id)), j = /* @__PURE__ */ new Map(), q = P.tracks.map((J) => {
|
|
830
834
|
let Z = J.id;
|
|
831
835
|
for (; E.has(Z); ) Z += 1e6;
|
|
832
836
|
return E.add(Z), f.companionTrackIds.set(Z, J.id), j.set(J.id, Z), { ...J, id: Z };
|
|
833
|
-
}),
|
|
837
|
+
}), G = P.lenses.map((J) => ({
|
|
834
838
|
...J,
|
|
835
839
|
sourceTrackId: J.sourceTrackId === void 0 ? void 0 : j.get(J.sourceTrackId)
|
|
836
|
-
})), te = [...
|
|
837
|
-
|
|
838
|
-
...
|
|
839
|
-
cameraModel:
|
|
840
|
-
firmware:
|
|
841
|
-
textureOrigin:
|
|
842
|
-
projection:
|
|
843
|
-
calibrationSource:
|
|
844
|
-
confidence:
|
|
840
|
+
})), te = [...m.tracks, ...q], ne = ls(cs(m.lenses, G), te), ue = [...m.warnings, ...P.warnings];
|
|
841
|
+
m = {
|
|
842
|
+
...m,
|
|
843
|
+
cameraModel: m.cameraModel || P.cameraModel,
|
|
844
|
+
firmware: m.firmware || P.firmware,
|
|
845
|
+
textureOrigin: m.textureOrigin || P.textureOrigin,
|
|
846
|
+
projection: m.projection.kind === "unknown" ? P.projection : m.projection,
|
|
847
|
+
calibrationSource: m.calibrationSource === "unavailable" ? P.calibrationSource : m.calibrationSource,
|
|
848
|
+
confidence: m.confidence === "low" ? P.confidence : m.confidence,
|
|
845
849
|
tracks: te,
|
|
846
850
|
lenses: ne,
|
|
847
851
|
warnings: ne.length >= 2 ? ue.filter((J) => !J.includes("matching companion file") && !J.startsWith("INSV calibration was not found")) : ue
|
|
848
852
|
};
|
|
849
853
|
}
|
|
850
|
-
return f.manifest =
|
|
854
|
+
return f.manifest = m, m;
|
|
851
855
|
}
|
|
852
|
-
if (k.errorCode !== "need_ranges" || !((
|
|
853
|
-
throw
|
|
854
|
-
await
|
|
856
|
+
if (k.errorCode !== "need_ranges" || !((h = k.requiredRanges) != null && h.length))
|
|
857
|
+
throw ga(k.errorCode, k.errorMessage);
|
|
858
|
+
await on(d, g, k.requiredRanges, p);
|
|
855
859
|
}
|
|
856
|
-
throw new B("resource_limit", `Panorama inspection exceeded ${
|
|
860
|
+
throw new B("resource_limit", `Panorama inspection exceeded ${an} range iterations.`);
|
|
857
861
|
} catch (d) {
|
|
858
862
|
throw o === f && (o = r()), s(f), d;
|
|
859
863
|
}
|
|
@@ -863,19 +867,19 @@ function as(t) {
|
|
|
863
867
|
const u = o, f = pi(u.signal, l), y = f.signal;
|
|
864
868
|
try {
|
|
865
869
|
ie(y);
|
|
866
|
-
const
|
|
867
|
-
if (!
|
|
870
|
+
const h = u.reader, d = u.manifest;
|
|
871
|
+
if (!h || (d == null ? void 0 : d.format) !== "dng") throw new B("invalid_manifest", "Open a DNG before developing its RAW preview.");
|
|
868
872
|
if (!n) throw new B("codec_unsupported", "Calibrated DNG preview requires converter-image.wasm (imageWasm).");
|
|
869
|
-
if (
|
|
870
|
-
const
|
|
871
|
-
for (let w = 0; w <
|
|
872
|
-
const S = Math.min(
|
|
873
|
+
if (h.size > 256 * 1024 * 1024) throw new B("resource_limit", "RAW preview input exceeds 256 MiB.");
|
|
874
|
+
const m = new Uint8Array(h.size);
|
|
875
|
+
for (let w = 0; w < m.length; w += Mi) {
|
|
876
|
+
const S = Math.min(Mi, m.length - w), D = await h.read(w, S, y);
|
|
873
877
|
if (ie(y), D.length !== S) throw new B("range_unavailable", "DNG source returned an incomplete byte range.");
|
|
874
|
-
|
|
878
|
+
m.set(D, w);
|
|
875
879
|
}
|
|
876
880
|
const g = "/work/result.json", b = "/work/preview.jpg", x = await n({
|
|
877
881
|
args: ["converter-image", "--source", "dng", "--target", "jpg", "--input", "/work/input.dng", "--output", b, "--options", "/work/options.json", "--result", g],
|
|
878
|
-
files: { "/work/input.dng":
|
|
882
|
+
files: { "/work/input.dng": m, "/work/options.json": new TextEncoder().encode(JSON.stringify({ preserveSensorGeometry: !0 })) },
|
|
879
883
|
readFiles: [g, b],
|
|
880
884
|
signal: y
|
|
881
885
|
});
|
|
@@ -897,19 +901,19 @@ function as(t) {
|
|
|
897
901
|
}
|
|
898
902
|
},
|
|
899
903
|
async readImuWindow(l, u, f) {
|
|
900
|
-
var
|
|
904
|
+
var h;
|
|
901
905
|
const y = o, p = pi(y.signal, f);
|
|
902
906
|
try {
|
|
903
907
|
ie(p.signal);
|
|
904
908
|
const d = y.manifest;
|
|
905
909
|
if (!(d != null && d.metadataTrack)) return [];
|
|
906
|
-
if (!Number.isSafeInteger(l) || !Number.isSafeInteger(u) || l < 0 || u < 0 || u >
|
|
907
|
-
throw new B("resource_limit", `Panorama metadata windows are limited to ${
|
|
908
|
-
const
|
|
909
|
-
if (g.reduce((T, L) => T + L.size, 0) >
|
|
910
|
+
if (!Number.isSafeInteger(l) || !Number.isSafeInteger(u) || l < 0 || u < 0 || u > rn)
|
|
911
|
+
throw new B("resource_limit", `Panorama metadata windows are limited to ${rn} samples.`);
|
|
912
|
+
const m = d.metadataTrack, g = m.samples.slice(l, l + u);
|
|
913
|
+
if (g.reduce((T, L) => T + L.size, 0) > as) throw new B("resource_limit", "Panorama metadata window exceeds 8 MiB.");
|
|
910
914
|
const x = {}, v = [];
|
|
911
915
|
for (let T = 0; T < g.length; T += 1) {
|
|
912
|
-
const L = await c(y,
|
|
916
|
+
const L = await c(y, m.id, l + T, p.signal), _ = `/work/metadata-${T}.bin`;
|
|
913
917
|
x[_] = L.data, v.push({ path: _, pts: L.pts, timescale: L.timescale });
|
|
914
918
|
}
|
|
915
919
|
const w = "/work/result.json";
|
|
@@ -924,7 +928,7 @@ function as(t) {
|
|
|
924
928
|
const D = S.files[w];
|
|
925
929
|
if (!D) throw new B("invalid_manifest", "Panorama metadata decoder did not return a result.");
|
|
926
930
|
const F = JSON.parse(new TextDecoder().decode(D));
|
|
927
|
-
if (!F.ok || !Array.isArray((
|
|
931
|
+
if (!F.ok || !Array.isArray((h = F.payload) == null ? void 0 : h.samples)) throw ga(F.errorCode, F.errorMessage);
|
|
928
932
|
return F.payload.samples;
|
|
929
933
|
} finally {
|
|
930
934
|
p.release();
|
|
@@ -932,7 +936,7 @@ function as(t) {
|
|
|
932
936
|
},
|
|
933
937
|
seek(l) {
|
|
934
938
|
const u = o.manifest;
|
|
935
|
-
return u ? Object.fromEntries(u.tracks.map((f) => [f.id,
|
|
939
|
+
return u ? Object.fromEntries(u.tracks.map((f) => [f.id, ss(f, l)])) : {};
|
|
936
940
|
},
|
|
937
941
|
async computeSeam(l, u) {
|
|
938
942
|
const f = pi(o.signal, u);
|
|
@@ -954,13 +958,13 @@ function as(t) {
|
|
|
954
958
|
signal: f.signal
|
|
955
959
|
});
|
|
956
960
|
ie(f.signal);
|
|
957
|
-
const
|
|
958
|
-
if (!
|
|
959
|
-
const d = JSON.parse(new TextDecoder().decode(
|
|
960
|
-
if (!d.ok || !d.payload) throw
|
|
961
|
-
const
|
|
962
|
-
if (!Array.isArray(
|
|
963
|
-
return
|
|
961
|
+
const h = p.files[y];
|
|
962
|
+
if (!h) throw new B("invalid_manifest", "Panorama seam solver did not return a result.");
|
|
963
|
+
const d = JSON.parse(new TextDecoder().decode(h));
|
|
964
|
+
if (!d.ok || !d.payload) throw ga(d.errorCode, d.errorMessage);
|
|
965
|
+
const m = d.payload;
|
|
966
|
+
if (!Array.isArray(m.seam) || !Number.isFinite(m.cost)) throw new B("invalid_manifest", "Panorama seam solver returned an invalid path.");
|
|
967
|
+
return m;
|
|
964
968
|
} finally {
|
|
965
969
|
f.release();
|
|
966
970
|
}
|
|
@@ -970,16 +974,16 @@ function as(t) {
|
|
|
970
974
|
getManifest: () => o.manifest
|
|
971
975
|
};
|
|
972
976
|
}
|
|
973
|
-
function
|
|
977
|
+
function Cn(t) {
|
|
974
978
|
return {
|
|
975
|
-
codec:
|
|
979
|
+
codec: us(t),
|
|
976
980
|
codedWidth: t.width,
|
|
977
981
|
codedHeight: t.height,
|
|
978
|
-
description:
|
|
982
|
+
description: In(t.decoderConfig),
|
|
979
983
|
optimizeForLatency: !0
|
|
980
984
|
};
|
|
981
985
|
}
|
|
982
|
-
function
|
|
986
|
+
function ns(t) {
|
|
983
987
|
return new EncodedVideoChunk({
|
|
984
988
|
type: t.key ? "key" : "delta",
|
|
985
989
|
timestamp: Math.round(t.pts * 1e6 / t.timescale),
|
|
@@ -987,7 +991,7 @@ function rs(t) {
|
|
|
987
991
|
data: t.data
|
|
988
992
|
});
|
|
989
993
|
}
|
|
990
|
-
function
|
|
994
|
+
function os(t) {
|
|
991
995
|
var r;
|
|
992
996
|
if (!t || !Array.isArray(t.tracks) || !Array.isArray(t.lenses))
|
|
993
997
|
throw new B("invalid_manifest", "Panorama inspector returned an invalid manifest.");
|
|
@@ -997,7 +1001,7 @@ function ns(t) {
|
|
|
997
1001
|
}));
|
|
998
1002
|
return { ...t, projection: i, lenses: n };
|
|
999
1003
|
}
|
|
1000
|
-
function
|
|
1004
|
+
function ss(t, e) {
|
|
1001
1005
|
const i = Math.max(0, e) * t.timescale;
|
|
1002
1006
|
let n = 0;
|
|
1003
1007
|
for (let r = 0; r < t.samples.length; r += 1) {
|
|
@@ -1007,24 +1011,24 @@ function os(t, e) {
|
|
|
1007
1011
|
}
|
|
1008
1012
|
return n;
|
|
1009
1013
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const i = t.slice(0, 2), n = new Set(i.map(
|
|
1014
|
+
function cs(t, e) {
|
|
1015
|
+
const i = t.slice(0, 2), n = new Set(i.map(nn));
|
|
1012
1016
|
for (const r of e) {
|
|
1013
1017
|
if (i.length === 2) break;
|
|
1014
|
-
const o =
|
|
1018
|
+
const o = nn(r);
|
|
1015
1019
|
n.has(o) || (i.push(r), n.add(o));
|
|
1016
1020
|
}
|
|
1017
1021
|
return i;
|
|
1018
1022
|
}
|
|
1019
|
-
function
|
|
1023
|
+
function ls(t, e) {
|
|
1020
1024
|
return e.length < t.length ? t : t.map((i, n) => i.sourceTrackId === void 0 ? { ...i, sourceTrackId: e[n].id } : i);
|
|
1021
1025
|
}
|
|
1022
|
-
function
|
|
1026
|
+
function nn(t) {
|
|
1023
1027
|
const e = { ...t };
|
|
1024
1028
|
return delete e.sourceTrackId, delete e.sourceRect, JSON.stringify(e);
|
|
1025
1029
|
}
|
|
1026
|
-
function
|
|
1027
|
-
const e =
|
|
1030
|
+
function us(t) {
|
|
1031
|
+
const e = In(t.decoderConfig);
|
|
1028
1032
|
if ((t.codec === "avc1" || t.codec === "avc3") && e.length >= 4)
|
|
1029
1033
|
return `${t.codec}.${[...e.slice(1, 4)].map((i) => i.toString(16).padStart(2, "0")).join("")}`;
|
|
1030
1034
|
if ((t.codec === "hvc1" || t.codec === "hev1") && e.length >= 13) {
|
|
@@ -1039,19 +1043,19 @@ function ls(t) {
|
|
|
1039
1043
|
}
|
|
1040
1044
|
return t.codec;
|
|
1041
1045
|
}
|
|
1042
|
-
function
|
|
1046
|
+
function In(t) {
|
|
1043
1047
|
return t ? Uint8Array.from(t.match(/.{1,2}/g) ?? [], (e) => Number.parseInt(e, 16)) : new Uint8Array();
|
|
1044
1048
|
}
|
|
1045
|
-
async function
|
|
1049
|
+
async function on(t, e, i, n) {
|
|
1046
1050
|
for (const r of i) {
|
|
1047
1051
|
const o = r.offset + r.length;
|
|
1048
|
-
if (!Number.isSafeInteger(r.offset) || !Number.isSafeInteger(r.length) || !Number.isSafeInteger(o) || r.offset < 0 || r.length <= 0 || r.length >
|
|
1052
|
+
if (!Number.isSafeInteger(r.offset) || !Number.isSafeInteger(r.length) || !Number.isSafeInteger(o) || r.offset < 0 || r.length <= 0 || r.length > Mi || o > t.size)
|
|
1049
1053
|
throw new B("resource_limit", "Panorama inspector requested an invalid source range.");
|
|
1050
1054
|
const s = [...e.values()].sort((u, f) => u.offset - f.offset), a = [];
|
|
1051
1055
|
let c = r.offset;
|
|
1052
1056
|
for (const u of s)
|
|
1053
1057
|
if (u.offset > c && a.push({ offset: c, length: Math.min(u.offset, o) - c }), c = Math.max(c, u.offset + u.bytes.length), c >= o) break;
|
|
1054
|
-
if (c < o && a.push({ offset: c, length: o - c }), s.reduce((u, f) => u + f.bytes.length, 0) + a.reduce((u, f) => u + f.length, 0) >
|
|
1058
|
+
if (c < o && a.push({ offset: c, length: o - c }), s.reduce((u, f) => u + f.bytes.length, 0) + a.reduce((u, f) => u + f.length, 0) > is)
|
|
1055
1059
|
throw new B("resource_limit", "Panorama inspection exceeded its 128 MiB range budget.");
|
|
1056
1060
|
for (const u of a) {
|
|
1057
1061
|
const f = await t.read(u.offset, u.length, n);
|
|
@@ -1076,21 +1080,21 @@ class bt {
|
|
|
1076
1080
|
if (o.status === 206) {
|
|
1077
1081
|
const u = s == null ? void 0 : s.match(/^bytes 0-0\/(\d+)$/i), f = Number(u == null ? void 0 : u[1]);
|
|
1078
1082
|
if (gi(o), !Number.isSafeInteger(f) || f <= 0) throw new B("range_unavailable", "Remote panorama size is unavailable.");
|
|
1079
|
-
return new bt(f, async (y, p,
|
|
1080
|
-
var
|
|
1081
|
-
const d = await yi(i(r, { headers: { Range: `bytes=${y}-${y + p - 1}` }, signal:
|
|
1082
|
-
if (ie(
|
|
1083
|
+
return new bt(f, async (y, p, h) => {
|
|
1084
|
+
var m;
|
|
1085
|
+
const d = await yi(i(r, { headers: { Range: `bytes=${y}-${y + p - 1}` }, signal: h }), h, gi);
|
|
1086
|
+
if (ie(h), d.status !== 206 || ((m = d.headers.get("content-range")) == null ? void 0 : m.toLowerCase()) !== `bytes ${y}-${y + p - 1}/${f}`)
|
|
1083
1087
|
throw gi(d), new B("range_unavailable", "Remote server returned an inconsistent panorama byte range.");
|
|
1084
|
-
return new Uint8Array(await yi(d.arrayBuffer(),
|
|
1088
|
+
return new Uint8Array(await yi(d.arrayBuffer(), h));
|
|
1085
1089
|
});
|
|
1086
1090
|
}
|
|
1087
1091
|
const a = Number(o.headers.get("content-length"));
|
|
1088
|
-
if (!o.ok || !Number.isSafeInteger(a) || a <= 0 || a >
|
|
1092
|
+
if (!o.ok || !Number.isSafeInteger(a) || a <= 0 || a > Mi)
|
|
1089
1093
|
throw gi(o), new B("range_unavailable", "Remote server must support HTTP byte ranges for large panorama files.");
|
|
1090
1094
|
const c = new Uint8Array(await yi(o.arrayBuffer(), n));
|
|
1091
1095
|
ie(n);
|
|
1092
1096
|
const l = o.headers.get("content-encoding");
|
|
1093
|
-
if (!c.length || c.length >
|
|
1097
|
+
if (!c.length || c.length > Mi || (!l || l.toLowerCase() === "identity") && c.length !== a)
|
|
1094
1098
|
throw new B("range_unavailable", "Remote panorama body does not match its declared length or size limit.");
|
|
1095
1099
|
return new bt(c.byteLength, async (u, f) => c.slice(u, u + f));
|
|
1096
1100
|
}
|
|
@@ -1107,7 +1111,7 @@ class bt {
|
|
|
1107
1111
|
(e = this.cleanup) == null || e.call(this);
|
|
1108
1112
|
}
|
|
1109
1113
|
}
|
|
1110
|
-
function
|
|
1114
|
+
function ga(t, e) {
|
|
1111
1115
|
const i = {
|
|
1112
1116
|
range_unavailable: "range_unavailable",
|
|
1113
1117
|
resource_limit: "resource_limit",
|
|
@@ -1154,26 +1158,26 @@ function ie(t) {
|
|
|
1154
1158
|
if (t != null && t.aborted)
|
|
1155
1159
|
throw t.reason instanceof Error ? t.reason : new DOMException("The panorama operation was aborted.", "AbortError");
|
|
1156
1160
|
}
|
|
1157
|
-
async function
|
|
1158
|
-
var y, p,
|
|
1159
|
-
if (e.projection.kind !== "mei-extended" || !
|
|
1161
|
+
async function ds(t, e, i) {
|
|
1162
|
+
var y, p, h, d;
|
|
1163
|
+
if (e.projection.kind !== "mei-extended" || !ea(e))
|
|
1160
1164
|
throw new B("calibration_missing", "This INSP does not contain two supported calibrated panorama lenses.");
|
|
1161
|
-
const n = e.width ?? Number(((y = i.image) == null ? void 0 : y.naturalWidth) ?? ((p = i.image) == null ? void 0 : p.width)), r = e.height ?? Number(((
|
|
1165
|
+
const n = e.width ?? Number(((y = i.image) == null ? void 0 : y.naturalWidth) ?? ((p = i.image) == null ? void 0 : p.width)), r = e.height ?? Number(((h = i.image) == null ? void 0 : h.naturalHeight) ?? ((d = i.image) == null ? void 0 : d.height));
|
|
1162
1166
|
if (!(n > 0) || !(r > 0)) throw new B("invalid_manifest", "The calibrated INSP image dimensions are unavailable.");
|
|
1163
|
-
const o = { id: 0, codec: "jpeg", decoderConfig: "", width: n, height: r, timescale: 1, samples: [] }, s = e.lenses.slice(0, 2).map((
|
|
1167
|
+
const o = { id: 0, codec: "jpeg", decoderConfig: "", width: n, height: r, timescale: 1, samples: [] }, s = e.lenses.slice(0, 2).map((m) => ({
|
|
1164
1168
|
track: o,
|
|
1165
|
-
rect:
|
|
1169
|
+
rect: m.sourceRect ?? { x: 0, y: 0, width: 1, height: 1 }
|
|
1166
1170
|
}));
|
|
1167
|
-
if (!s.every((
|
|
1171
|
+
if (!s.every((m) => zn(m.rect)))
|
|
1168
1172
|
throw new B("invalid_manifest", "The calibrated INSP lenses are not bound to valid image regions.");
|
|
1169
|
-
i.flipY =
|
|
1170
|
-
const a = new
|
|
1173
|
+
i.flipY = _a(e.textureOrigin), i.colorSpace = Ji, i.minFilter = Ft, i.generateMipmaps = !1, i.needsUpdate = !0;
|
|
1174
|
+
const a = new Ta(new Uint8Array(128 * 64).fill(128), 128, 64, ka, Ra);
|
|
1171
1175
|
a.needsUpdate = !0, a.minFilter = Ft;
|
|
1172
|
-
const c =
|
|
1173
|
-
|
|
1174
|
-
const l = new
|
|
1176
|
+
const c = fs(e, s, i, a);
|
|
1177
|
+
Ua(c, e.lenses);
|
|
1178
|
+
const l = new Ki(500, 96, 64);
|
|
1175
1179
|
l.scale(-1, 1, 1);
|
|
1176
|
-
const u = new
|
|
1180
|
+
const u = new Zi(l, c), f = new jn(t, e, s, c, a);
|
|
1177
1181
|
return await f.acceptImage(i.image), {
|
|
1178
1182
|
mesh: u,
|
|
1179
1183
|
update: () => {
|
|
@@ -1200,9 +1204,9 @@ async function us(t, e, i) {
|
|
|
1200
1204
|
setStabilization: () => "off"
|
|
1201
1205
|
};
|
|
1202
1206
|
}
|
|
1203
|
-
function
|
|
1207
|
+
function fs(t, e, i, n) {
|
|
1204
1208
|
const r = t.lenses.slice(0, 2);
|
|
1205
|
-
return new
|
|
1209
|
+
return new Pa({
|
|
1206
1210
|
uniforms: {
|
|
1207
1211
|
lens0: { value: i },
|
|
1208
1212
|
lens1: { value: i },
|
|
@@ -1343,29 +1347,29 @@ function ds(t, e, i, n) {
|
|
|
1343
1347
|
`
|
|
1344
1348
|
});
|
|
1345
1349
|
}
|
|
1346
|
-
async function
|
|
1350
|
+
async function hs(t, e) {
|
|
1347
1351
|
if (!["dji-fisheye-lut", "mei-extended"].includes(e.projection.kind) || e.lenses.length < 2)
|
|
1348
1352
|
throw new B("calibration_missing", "This source does not contain two supported calibrated panorama lenses.");
|
|
1349
|
-
if (!
|
|
1353
|
+
if (!ea(e))
|
|
1350
1354
|
throw new B("calibration_missing", "The two panorama lenses do not contain complete, distinct calibration.");
|
|
1351
1355
|
if (typeof VideoDecoder > "u" || typeof EncodedVideoChunk > "u")
|
|
1352
1356
|
throw new B("codec_unsupported", "This browser does not expose WebCodecs video decoding.");
|
|
1353
|
-
const i =
|
|
1357
|
+
const i = ta(e);
|
|
1354
1358
|
if (!i)
|
|
1355
1359
|
throw new B("invalid_manifest", "The panorama lenses are not bound to valid source tracks and frame regions.");
|
|
1356
|
-
const n = [...new Map(i.map((
|
|
1357
|
-
if (n.some((
|
|
1360
|
+
const n = [...new Map(i.map((m) => [m.track.id, m.track])).values()];
|
|
1361
|
+
if (n.some((m) => m.timescale <= 0 || !m.samples.length))
|
|
1358
1362
|
throw new B("invalid_manifest", "The calibrated panorama tracks do not contain a playable sample timeline.");
|
|
1359
|
-
const r = n.map(
|
|
1360
|
-
if ((await Promise.all(r.map((
|
|
1361
|
-
throw new B("codec_unsupported", `This browser cannot decode the ${[...new Set(n.map((
|
|
1362
|
-
const s = n.map(() => new
|
|
1363
|
-
s.forEach((
|
|
1364
|
-
|
|
1363
|
+
const r = n.map(Cn);
|
|
1364
|
+
if ((await Promise.all(r.map((m) => VideoDecoder.isConfigSupported(m)))).some((m) => !m.supported))
|
|
1365
|
+
throw new B("codec_unsupported", `This browser cannot decode the ${[...new Set(n.map((m) => m.codec.toUpperCase()))].join("/")} panorama tracks.`);
|
|
1366
|
+
const s = n.map(() => new Lo());
|
|
1367
|
+
s.forEach((m) => {
|
|
1368
|
+
m.flipY = _a(e.textureOrigin), m.colorSpace = Ji, m.minFilter = Ft;
|
|
1365
1369
|
});
|
|
1366
|
-
const a = new
|
|
1370
|
+
const a = new Ta(new Uint8Array(128 * 64).fill(128), 128, 64, ka, Ra);
|
|
1367
1371
|
a.needsUpdate = !0, a.minFilter = Ft;
|
|
1368
|
-
const c = e.lenses.slice(0, 2), l = i.map((
|
|
1372
|
+
const c = e.lenses.slice(0, 2), l = i.map((m) => s[n.indexOf(m.track)]), u = new Pa({
|
|
1369
1373
|
uniforms: {
|
|
1370
1374
|
lens0: { value: l[0] },
|
|
1371
1375
|
lens1: { value: l[1] },
|
|
@@ -1539,22 +1543,22 @@ async function fs(t, e) {
|
|
|
1539
1543
|
}
|
|
1540
1544
|
`
|
|
1541
1545
|
});
|
|
1542
|
-
|
|
1543
|
-
const f = new
|
|
1546
|
+
Ua(u, e.lenses);
|
|
1547
|
+
const f = new Ki(500, 96, 64);
|
|
1544
1548
|
f.scale(-1, 1, 1);
|
|
1545
|
-
const y = new
|
|
1546
|
-
|
|
1547
|
-
}, (
|
|
1548
|
-
p.reset(),
|
|
1549
|
+
const y = new Zi(f, u), p = new jn(t, e, i, u, a), h = new Fs(t, e, u), d = new Bn(t, n, s, r, (m, g) => {
|
|
1550
|
+
h.apply(m.timestamp / 1e6), p.accept(m, g);
|
|
1551
|
+
}, (m) => h.prepare(m), () => {
|
|
1552
|
+
p.reset(), h.reset();
|
|
1549
1553
|
});
|
|
1550
1554
|
return d.start(), {
|
|
1551
1555
|
mesh: y,
|
|
1552
1556
|
update: () => d.update(),
|
|
1553
1557
|
play: () => d.play(),
|
|
1554
1558
|
pause: () => d.pause(),
|
|
1555
|
-
seek: (
|
|
1559
|
+
seek: (m) => d.seek(m),
|
|
1556
1560
|
close: () => {
|
|
1557
|
-
d.close(), p.close(), s.forEach((
|
|
1561
|
+
d.close(), p.close(), s.forEach((m) => m.dispose()), a.dispose(), f.dispose(), u.dispose();
|
|
1558
1562
|
},
|
|
1559
1563
|
get streamSyncMs() {
|
|
1560
1564
|
return d.streamSyncMs;
|
|
@@ -1572,23 +1576,23 @@ async function fs(t, e) {
|
|
|
1572
1576
|
return d.paused;
|
|
1573
1577
|
},
|
|
1574
1578
|
get stabilizationAvailable() {
|
|
1575
|
-
return
|
|
1579
|
+
return h.available;
|
|
1576
1580
|
},
|
|
1577
1581
|
get stabilizationMode() {
|
|
1578
|
-
return
|
|
1582
|
+
return h.mode;
|
|
1579
1583
|
},
|
|
1580
1584
|
get error() {
|
|
1581
1585
|
return d.error;
|
|
1582
1586
|
},
|
|
1583
|
-
setStabilization: (
|
|
1587
|
+
setStabilization: (m) => h.setMode(m)
|
|
1584
1588
|
};
|
|
1585
1589
|
}
|
|
1586
|
-
async function
|
|
1590
|
+
async function ms(t, e, i) {
|
|
1587
1591
|
if (!["dji-fisheye-lut", "mei-extended"].includes(t.projection.kind) || t.lenses.length < 2)
|
|
1588
1592
|
throw new B("calibration_missing", "This source does not contain two supported calibrated panorama lenses.");
|
|
1589
|
-
if (!
|
|
1593
|
+
if (!ea(t))
|
|
1590
1594
|
throw new B("calibration_missing", "The two panorama lenses do not contain complete, distinct calibration.");
|
|
1591
|
-
const n =
|
|
1595
|
+
const n = ta(t);
|
|
1592
1596
|
if (!n)
|
|
1593
1597
|
throw new B("invalid_manifest", "The panorama lenses are not bound to valid source tracks and frame regions.");
|
|
1594
1598
|
const r = [...new Map(n.map((d) => [d.track.id, d.track])).values()];
|
|
@@ -1597,41 +1601,41 @@ async function hs(t, e, i) {
|
|
|
1597
1601
|
const o = /* @__PURE__ */ new Map();
|
|
1598
1602
|
for (const d of n)
|
|
1599
1603
|
o.has(d.track.id) || o.set(d.track.id, o.size === 0 || !i ? e : i);
|
|
1600
|
-
const s = r.map((d) =>
|
|
1604
|
+
const s = r.map((d) => ps(o.get(d.id) ?? e));
|
|
1601
1605
|
try {
|
|
1602
|
-
await Promise.all(s.map((d) =>
|
|
1606
|
+
await Promise.all(s.map((d) => gs(d)));
|
|
1603
1607
|
} catch (d) {
|
|
1604
|
-
throw s.forEach((
|
|
1608
|
+
throw s.forEach((m) => m.remove()), s.forEach((m) => sn(m)), new B("codec_unsupported", d instanceof Error ? d.message : String(d));
|
|
1605
1609
|
}
|
|
1606
1610
|
const a = s.map((d) => {
|
|
1607
|
-
const
|
|
1608
|
-
return
|
|
1609
|
-
}), c = new
|
|
1611
|
+
const m = new Rn(d);
|
|
1612
|
+
return m.flipY = _a(t.textureOrigin), m.colorSpace = Ji, m.minFilter = Ft, m;
|
|
1613
|
+
}), c = new Ta(new Uint8Array(128 * 64).fill(128), 128, 64, ka, Ra);
|
|
1610
1614
|
c.needsUpdate = !0, c.minFilter = Ft;
|
|
1611
|
-
const l = t.lenses.slice(0, 2), u = n.map((d) => a[r.indexOf(d.track)]), f =
|
|
1612
|
-
|
|
1613
|
-
const y = new
|
|
1615
|
+
const l = t.lenses.slice(0, 2), u = n.map((d) => a[r.indexOf(d.track)]), f = vs(t, l, n, u, c);
|
|
1616
|
+
Ua(f, t.lenses);
|
|
1617
|
+
const y = new Ki(500, 96, 64);
|
|
1614
1618
|
y.scale(-1, 1, 1);
|
|
1615
|
-
const p = new
|
|
1616
|
-
return
|
|
1619
|
+
const p = new Zi(y, f), h = new xs(s, a);
|
|
1620
|
+
return h.play(), {
|
|
1617
1621
|
mesh: p,
|
|
1618
|
-
update: () =>
|
|
1619
|
-
play: () =>
|
|
1620
|
-
pause: () =>
|
|
1621
|
-
seek: (d) =>
|
|
1622
|
+
update: () => h.update(),
|
|
1623
|
+
play: () => h.play(),
|
|
1624
|
+
pause: () => h.pause(),
|
|
1625
|
+
seek: (d) => h.seek(d),
|
|
1622
1626
|
close: () => {
|
|
1623
|
-
|
|
1624
|
-
d.remove(),
|
|
1627
|
+
h.close(), c.dispose(), a.forEach((d) => d.dispose()), y.dispose(), f.dispose(), s.forEach((d) => {
|
|
1628
|
+
d.remove(), sn(d);
|
|
1625
1629
|
});
|
|
1626
1630
|
},
|
|
1627
1631
|
get duration() {
|
|
1628
|
-
return
|
|
1632
|
+
return h.duration;
|
|
1629
1633
|
},
|
|
1630
1634
|
get currentTime() {
|
|
1631
|
-
return
|
|
1635
|
+
return h.currentTime;
|
|
1632
1636
|
},
|
|
1633
1637
|
get paused() {
|
|
1634
|
-
return
|
|
1638
|
+
return h.paused;
|
|
1635
1639
|
},
|
|
1636
1640
|
streamSyncMs: 0,
|
|
1637
1641
|
dynamicSeam: !1,
|
|
@@ -1641,34 +1645,34 @@ async function hs(t, e, i) {
|
|
|
1641
1645
|
setStabilization: () => "off"
|
|
1642
1646
|
};
|
|
1643
1647
|
}
|
|
1644
|
-
function
|
|
1648
|
+
function ps(t) {
|
|
1645
1649
|
var i;
|
|
1646
1650
|
const e = document.createElement("video");
|
|
1647
1651
|
if (e.preload = "auto", e.muted = !0, e.loop = !0, e.playsInline = !0, e.crossOrigin = "anonymous", e.setAttribute("aria-hidden", "true"), e.style.display = "none", typeof t == "string" || t instanceof URL)
|
|
1648
1652
|
e.src = String(t);
|
|
1649
1653
|
else {
|
|
1650
|
-
const n = t instanceof Blob ? t : new Blob([
|
|
1651
|
-
|
|
1654
|
+
const n = t instanceof Blob ? t : new Blob([ys(t)], { type: "video/mp4" }), r = URL.createObjectURL(n);
|
|
1655
|
+
Fa.set(e, r), e.src = r;
|
|
1652
1656
|
}
|
|
1653
1657
|
return (i = document.body) == null || i.append(e), e.load(), e;
|
|
1654
1658
|
}
|
|
1655
|
-
function
|
|
1659
|
+
function ys(t) {
|
|
1656
1660
|
if (t instanceof ArrayBuffer) return t;
|
|
1657
1661
|
const e = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), i = new Uint8Array(e.byteLength);
|
|
1658
1662
|
return i.set(e), i.buffer;
|
|
1659
1663
|
}
|
|
1660
|
-
const
|
|
1661
|
-
function
|
|
1664
|
+
const Fa = /* @__PURE__ */ new WeakMap();
|
|
1665
|
+
function gs(t) {
|
|
1662
1666
|
return t.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA ? Promise.resolve() : new Promise((e, i) => {
|
|
1663
1667
|
t.addEventListener("loadeddata", () => e(), { once: !0 }), t.addEventListener("error", () => i(new Error("The browser could not decode the calibrated INSV video track.")), { once: !0 });
|
|
1664
1668
|
});
|
|
1665
1669
|
}
|
|
1666
|
-
function
|
|
1667
|
-
const e =
|
|
1668
|
-
e && (URL.revokeObjectURL(e),
|
|
1670
|
+
function sn(t) {
|
|
1671
|
+
const e = Fa.get(t);
|
|
1672
|
+
e && (URL.revokeObjectURL(e), Fa.delete(t));
|
|
1669
1673
|
}
|
|
1670
|
-
function
|
|
1671
|
-
return new
|
|
1674
|
+
function vs(t, e, i, n, r) {
|
|
1675
|
+
return new Pa({
|
|
1672
1676
|
uniforms: {
|
|
1673
1677
|
lens0: { value: n[0] },
|
|
1674
1678
|
lens1: { value: n[1] },
|
|
@@ -1835,7 +1839,7 @@ function gs(t, e, i, n, r) {
|
|
|
1835
1839
|
`
|
|
1836
1840
|
});
|
|
1837
1841
|
}
|
|
1838
|
-
class
|
|
1842
|
+
class xs {
|
|
1839
1843
|
constructor(e, i) {
|
|
1840
1844
|
A(this, "isClosed", !1);
|
|
1841
1845
|
this.videos = e, this.textures = i;
|
|
@@ -1882,52 +1886,52 @@ class vs {
|
|
|
1882
1886
|
this.isClosed || (this.isClosed = !0, this.pause());
|
|
1883
1887
|
}
|
|
1884
1888
|
}
|
|
1885
|
-
function
|
|
1889
|
+
function ea(t) {
|
|
1886
1890
|
const e = t.lenses.slice(0, 2);
|
|
1887
|
-
if (e.length < 2 || !e.every((a) =>
|
|
1888
|
-
const n =
|
|
1891
|
+
if (e.length < 2 || !e.every((a) => ws(a, t.projection.kind)) || (t.cameraModel || "").replace(/^Insta360\s+/i, "").trim().toUpperCase() === "X5" && (!["embedded", "sidecar"].includes(t.calibrationSource) || !e.every((a) => a.distortionModel === "radtan_pro" ? Ke(a.distortionCoeffs, 13) : Ke(a.thinPrism, 4) && Ke(a.sensorTilt, 2)))) return !1;
|
|
1892
|
+
const n = Fi(e[0].extrinsicQuaternion), r = Fi(e[1].extrinsicQuaternion);
|
|
1889
1893
|
if (Math.abs(n.reduce((a, c, l) => a + c * r[l], 0)) >= 0.999) return !1;
|
|
1890
|
-
const o =
|
|
1894
|
+
const o = cn(e[0], t.projection.kind), s = cn(e[1], t.projection.kind);
|
|
1891
1895
|
return o.reduce((a, c, l) => a + c * s[l], 0) < -0.8;
|
|
1892
1896
|
}
|
|
1893
|
-
function
|
|
1897
|
+
function ta(t) {
|
|
1894
1898
|
const e = t.lenses.slice(0, 2);
|
|
1895
1899
|
if (e.length < 2) return;
|
|
1896
1900
|
const i = e.map((n, r) => {
|
|
1897
1901
|
const o = n.sourceTrackId === void 0 ? t.tracks.length >= 2 ? t.tracks[r] : void 0 : t.tracks.find((a) => a.id === n.sourceTrackId), s = n.sourceRect ?? { x: 0, y: 0, width: 1, height: 1 };
|
|
1898
|
-
return o &&
|
|
1902
|
+
return o && zn(s) ? { track: o, rect: s } : void 0;
|
|
1899
1903
|
});
|
|
1900
1904
|
if (!(!i[0] || !i[1]) && !(i[0].track.id === i[1].track.id && !e.every((n) => n.sourceRect)))
|
|
1901
1905
|
return i;
|
|
1902
1906
|
}
|
|
1903
|
-
function
|
|
1907
|
+
function bs(t, e, i, n) {
|
|
1904
1908
|
return [
|
|
1905
1909
|
i.rect.x + t * i.rect.width,
|
|
1906
|
-
i.rect.y +
|
|
1910
|
+
i.rect.y + _s(e, n) * i.rect.height
|
|
1907
1911
|
];
|
|
1908
1912
|
}
|
|
1909
1913
|
function Xt(t, e) {
|
|
1910
1914
|
const { x: i, y: n, width: r, height: o } = t.rect;
|
|
1911
1915
|
return [i, e === "top-left" ? n : 1 - n - o, r, o];
|
|
1912
1916
|
}
|
|
1913
|
-
function
|
|
1917
|
+
function zn(t) {
|
|
1914
1918
|
return [t.x, t.y, t.width, t.height].every(Number.isFinite) && t.x >= 0 && t.y >= 0 && t.width > 0 && t.height > 0 && t.x + t.width <= 1 && t.y + t.height <= 1;
|
|
1915
1919
|
}
|
|
1916
1920
|
function $t(t, e) {
|
|
1917
1921
|
return [t.width || e.track.width * e.rect.width, t.height || e.track.height * e.rect.height];
|
|
1918
1922
|
}
|
|
1919
|
-
function
|
|
1923
|
+
function cn(t, e) {
|
|
1920
1924
|
const i = dt(t);
|
|
1921
|
-
return
|
|
1925
|
+
return Nn(e === "mei-extended" ? i : La(i), [0, 0, 1]);
|
|
1922
1926
|
}
|
|
1923
|
-
function
|
|
1927
|
+
function ws(t, e) {
|
|
1924
1928
|
const i = [t.width, t.height, t.fx, t.fy, t.cx, t.cy], n = t.extrinsicQuaternion;
|
|
1925
1929
|
return !i.every((r) => typeof r == "number" && Number.isFinite(r)) || ![t.width, t.height, t.fx, t.fy].every((r) => Number(r) > 0) || Number(t.cx) < 0 || Number(t.cx) >= Number(t.width) || Number(t.cy) < 0 || Number(t.cy) >= Number(t.height) || (n == null ? void 0 : n.length) !== 4 || !n.every(Number.isFinite) || Math.hypot(...n) < 0.5 ? !1 : e === "dji-fisheye-lut" ? Ke(t.distortion, 4) && Ke(t.radialLut1, 14) && Ke(t.radialLut2, 14) : t.distortionModel === "radtan_pro" && !Ke(t.distortionCoeffs, 13) ? !1 : e === "mei-extended" && Number.isFinite(t.xi) && Number(t.xi) > 0 && Ke(t.radial, 4) && Ke(t.tangential, 2);
|
|
1926
1930
|
}
|
|
1927
1931
|
function Ke(t, e) {
|
|
1928
1932
|
return !!(t && t.length >= e && t.slice(0, e).every((i) => typeof i == "number" && Number.isFinite(i)));
|
|
1929
1933
|
}
|
|
1930
|
-
class
|
|
1934
|
+
class Bn {
|
|
1931
1935
|
constructor(e, i, n, r, o, s, a) {
|
|
1932
1936
|
A(this, "decoders");
|
|
1933
1937
|
A(this, "queues");
|
|
@@ -1947,7 +1951,7 @@ class zn {
|
|
|
1947
1951
|
A(this, "seekEnd");
|
|
1948
1952
|
A(this, "streamSyncMs", 0);
|
|
1949
1953
|
this.processor = e, this.tracks = i, this.textures = n, this.configs = r, this.onPair = o, this.prepareImu = s, this.onSeek = a, this.queues = i.map(() => []), this.indexes = i.map(() => 0), this.currentFrames = i.map(() => {
|
|
1950
|
-
}), this.duration = Math.min(...i.map(
|
|
1954
|
+
}), this.duration = Math.min(...i.map(qs)), this.seekEnd = Math.min(...i.map((c) => c.samples.at(-1).pts / c.timescale)), this.decoders = [];
|
|
1951
1955
|
try {
|
|
1952
1956
|
r.forEach((c, l) => {
|
|
1953
1957
|
const u = new VideoDecoder({
|
|
@@ -2032,7 +2036,7 @@ class zn {
|
|
|
2032
2036
|
if (!n && c.pts / o.timescale > e || n && s > 0) break;
|
|
2033
2037
|
const l = await this.processor.readSample(o.id, a);
|
|
2034
2038
|
if (this.closed || i !== this.generation) return;
|
|
2035
|
-
this.decoders[r].decode(
|
|
2039
|
+
this.decoders[r].decode(ns(l)), this.indexes[r] += 1, s += 1;
|
|
2036
2040
|
}
|
|
2037
2041
|
}
|
|
2038
2042
|
}
|
|
@@ -2080,7 +2084,7 @@ class zn {
|
|
|
2080
2084
|
(n = this.currentFrames[e]) == null || n.close(), this.currentFrames[e] = i, (r = this.textures[e]) == null || r.setFrame(i);
|
|
2081
2085
|
}
|
|
2082
2086
|
}
|
|
2083
|
-
class
|
|
2087
|
+
class Fs {
|
|
2084
2088
|
constructor(e, i, n) {
|
|
2085
2089
|
A(this, "available");
|
|
2086
2090
|
A(this, "mode");
|
|
@@ -2119,34 +2123,34 @@ class ws {
|
|
|
2119
2123
|
}
|
|
2120
2124
|
apply(e) {
|
|
2121
2125
|
if (!this.available || this.mode !== "horizon-lock") return;
|
|
2122
|
-
const i = this.samples.filter((f) =>
|
|
2126
|
+
const i = this.samples.filter((f) => Ds(f.cameraRotation));
|
|
2123
2127
|
if (!i.length) return;
|
|
2124
2128
|
let n = i.findIndex((f) => f.pts / f.timescale >= e);
|
|
2125
2129
|
n < 0 && (n = i.length - 1);
|
|
2126
|
-
const r = Math.max(0, n - 1), o = i[r], s = i[n], a = o.pts / o.timescale, c = s.pts / s.timescale - a, l =
|
|
2127
|
-
this.material.uniforms.stabilizationQuaternion.value =
|
|
2130
|
+
const r = Math.max(0, n - 1), o = i[r], s = i[n], a = o.pts / o.timescale, c = s.pts / s.timescale - a, l = Ms(o.cameraRotation, s.cameraRotation, c > 0 ? (e - a) / c : 0), u = Math.atan2(2 * (l[0] * l[3] + l[1] * l[2]), 1 - 2 * (l[2] ** 2 + l[3] ** 2));
|
|
2131
|
+
this.material.uniforms.stabilizationQuaternion.value = Ss(La(l), [Math.cos(u / 2), 0, 0, Math.sin(u / 2)]);
|
|
2128
2132
|
}
|
|
2129
2133
|
}
|
|
2130
|
-
function
|
|
2131
|
-
const n =
|
|
2132
|
-
let r =
|
|
2134
|
+
function Ms(t, e, i) {
|
|
2135
|
+
const n = Fi(t);
|
|
2136
|
+
let r = Fi(e), o = n.reduce((l, u, f) => l + u * r[f], 0);
|
|
2133
2137
|
o < 0 && (r = r.map((l) => -l), o = -o);
|
|
2134
2138
|
const s = Math.max(0, Math.min(1, i));
|
|
2135
|
-
if (o > 0.9995) return
|
|
2139
|
+
if (o > 0.9995) return Fi(n.map((l, u) => l + s * (r[u] - l)));
|
|
2136
2140
|
const a = Math.acos(Math.max(-1, Math.min(1, o))), c = Math.sin(a);
|
|
2137
2141
|
return n.map((l, u) => (l * Math.sin((1 - s) * a) + r[u] * Math.sin(s * a)) / c);
|
|
2138
2142
|
}
|
|
2139
|
-
function
|
|
2143
|
+
function Ds(t) {
|
|
2140
2144
|
return (t == null ? void 0 : t.length) === 4 && t.every((e) => typeof e == "number" && Number.isFinite(e));
|
|
2141
2145
|
}
|
|
2142
|
-
function
|
|
2146
|
+
function Fi(t) {
|
|
2143
2147
|
const e = Math.hypot(...t) || 1;
|
|
2144
2148
|
return [0, 1, 2, 3].map((i) => Number(t[i] ?? (i === 0 ? 1 : 0)) / e);
|
|
2145
2149
|
}
|
|
2146
|
-
function
|
|
2150
|
+
function La(t) {
|
|
2147
2151
|
return [t[0], -t[1], -t[2], -t[3]];
|
|
2148
2152
|
}
|
|
2149
|
-
function
|
|
2153
|
+
function Ss(t, e) {
|
|
2150
2154
|
return [
|
|
2151
2155
|
t[0] * e[0] - t[1] * e[1] - t[2] * e[2] - t[3] * e[3],
|
|
2152
2156
|
t[0] * e[1] + t[1] * e[0] + t[2] * e[3] - t[3] * e[2],
|
|
@@ -2155,7 +2159,7 @@ function Ds(t, e) {
|
|
|
2155
2159
|
];
|
|
2156
2160
|
}
|
|
2157
2161
|
const N = 128, ae = 64, Je = 256;
|
|
2158
|
-
class
|
|
2162
|
+
class jn {
|
|
2159
2163
|
constructor(e, i, n, r, o) {
|
|
2160
2164
|
A(this, "lastAnalysis", -1 / 0);
|
|
2161
2165
|
A(this, "busy", !1);
|
|
@@ -2192,17 +2196,17 @@ class Bn {
|
|
|
2192
2196
|
this.generation += 1, this.previousLeft = void 0, this.previousRight = void 0, this.lastAnalysis = -1 / 0, this.material.uniforms.useDynamicSeam.value = 0, this.material.uniforms.exposureGain0.value = [1, 1, 1], this.material.uniforms.exposureGain1.value = [1, 1, 1], this.active = !1;
|
|
2193
2197
|
}
|
|
2194
2198
|
async analyze(e, i) {
|
|
2195
|
-
const n = e.map((x) =>
|
|
2199
|
+
const n = e.map((x) => As(x)), r = [new Uint8Array(N * ae * 3), new Uint8Array(N * ae * 3)], o = [new Float32Array(N * ae), new Float32Array(N * ae)], s = this.manifest.lenses.slice(0, 2);
|
|
2196
2200
|
let a = 0;
|
|
2197
2201
|
const c = [new Float64Array(3), new Float64Array(3)];
|
|
2198
2202
|
for (let x = 0; x < ae; x += 1)
|
|
2199
2203
|
for (let v = 0; v < N; v += 1) {
|
|
2200
|
-
const w =
|
|
2204
|
+
const w = Is((v + 0.5) / N, (x + 0.5) / ae, this.manifest.projection.kind), S = x * N + v;
|
|
2201
2205
|
for (let D = 0; D < 2; D += 1) {
|
|
2202
|
-
const F =
|
|
2206
|
+
const F = Us(w, s[D], this.manifest.projection.kind);
|
|
2203
2207
|
if (!F) continue;
|
|
2204
|
-
const T = S * 3, L = n[D], _ =
|
|
2205
|
-
|
|
2208
|
+
const T = S * 3, L = n[D], _ = bs(F[0], F[1], this.lensSources[D], this.manifest.textureOrigin);
|
|
2209
|
+
Ls(L, Je, _[0], _[1], r[D], T), o[D][S] = F[2] * (this.manifest.projection.kind === "mei-extended" ? zs((v + 0.5) / N, D) : 1);
|
|
2206
2210
|
}
|
|
2207
2211
|
if (o[0][S] > 0 && o[1][S] > 0) {
|
|
2208
2212
|
a += 1;
|
|
@@ -2216,7 +2220,7 @@ class Bn {
|
|
|
2216
2220
|
this.material.uniforms.exposureGain1.value
|
|
2217
2221
|
];
|
|
2218
2222
|
if (a > 64) {
|
|
2219
|
-
const x =
|
|
2223
|
+
const x = Rs(c[0], c[1]);
|
|
2220
2224
|
l = this.active ? x.map((v, w) => v.map((S, D) => l[w][D] * 0.8 + S * 0.2)) : x, this.material.uniforms.exposureGain0.value = l[0], this.material.uniforms.exposureGain1.value = l[1];
|
|
2221
2225
|
}
|
|
2222
2226
|
if (a <= 64) return;
|
|
@@ -2226,115 +2230,115 @@ class Bn {
|
|
|
2226
2230
|
for (let v = 0; v < N; v += 1) {
|
|
2227
2231
|
const w = x * N + v;
|
|
2228
2232
|
if (o[0][w] <= 0 || o[1][w] <= 0) continue;
|
|
2229
|
-
const S = w * 3, D = Math.abs(r[0][S] * l[0][0] - r[1][S] * l[1][0]) + Math.abs(r[0][S + 1] * l[0][1] - r[1][S + 1] * l[1][1]) + Math.abs(r[0][S + 2] * l[0][2] - r[1][S + 2] * l[1][2]), F = v > 0 ? w - 1 : w, T = x > 0 ? w - N : w, L =
|
|
2230
|
-
u[w] = Math.min(65534, D + Math.abs(L - _) * 2 +
|
|
2233
|
+
const S = w * 3, D = Math.abs(r[0][S] * l[0][0] - r[1][S] * l[1][0]) + Math.abs(r[0][S + 1] * l[0][1] - r[1][S + 1] * l[1][1]) + Math.abs(r[0][S + 2] * l[0][2] - r[1][S + 2] * l[1][2]), F = v > 0 ? w - 1 : w, T = x > 0 ? w - N : w, L = fn(r[0], l[0], w, F, T), _ = fn(r[1], l[1], w, F, T);
|
|
2234
|
+
u[w] = Math.min(65534, D + Math.abs(L - _) * 2 + Ps(o[0][w], o[1][w]));
|
|
2231
2235
|
}
|
|
2232
|
-
const f = this.manifest.projection.kind === "dji-fisheye-lut", y = f ?
|
|
2233
|
-
this.processor.computeSeam({ width: p, height: ae, costs:
|
|
2234
|
-
this.processor.computeSeam({ width: p, height: ae, costs:
|
|
2236
|
+
const f = this.manifest.projection.kind === "dji-fisheye-lut", y = f ? Ws(u, N, ae, N / 4) : u, p = N / 2, [h, d] = await Promise.all([
|
|
2237
|
+
this.processor.computeSeam({ width: p, height: ae, costs: hn(y, 0), previous: this.previousLeft, temporalWeight: 3, maxStep: 2 }),
|
|
2238
|
+
this.processor.computeSeam({ width: p, height: ae, costs: hn(y, p), previous: this.previousRight, temporalWeight: 3, maxStep: 2 })
|
|
2235
2239
|
]);
|
|
2236
2240
|
if (this.closed || i !== this.generation) return;
|
|
2237
|
-
if (!
|
|
2241
|
+
if (!ks([h, d], ae)) {
|
|
2238
2242
|
this.material.uniforms.useDynamicSeam.value = 0, this.active = !1;
|
|
2239
2243
|
return;
|
|
2240
2244
|
}
|
|
2241
|
-
const
|
|
2242
|
-
if (!
|
|
2245
|
+
const m = un(ln(h.seam), this.previousLeft), g = un(ln(d.seam), this.previousRight);
|
|
2246
|
+
if (!dn(y, m, 0) || !dn(y, g, p)) {
|
|
2243
2247
|
this.material.uniforms.useDynamicSeam.value = 0, this.active = !1;
|
|
2244
2248
|
return;
|
|
2245
2249
|
}
|
|
2246
|
-
this.previousLeft =
|
|
2247
|
-
const b = f ?
|
|
2250
|
+
this.previousLeft = m, this.previousRight = g;
|
|
2251
|
+
const b = f ? Vs(
|
|
2248
2252
|
o,
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
) :
|
|
2253
|
+
mn(m, N, N / 4),
|
|
2254
|
+
mn(g.map((x) => x + p), N, N / 4)
|
|
2255
|
+
) : Os(o, m, g.map((x) => x + p));
|
|
2252
2256
|
this.seamTexture.image.data.set(b), this.seamTexture.needsUpdate = !0, this.material.uniforms.useDynamicSeam.value = 1, this.active = !0;
|
|
2253
2257
|
}
|
|
2254
2258
|
}
|
|
2255
|
-
function
|
|
2259
|
+
function Ts(t, e) {
|
|
2256
2260
|
if (!(t > 0) || !(e > 0)) return [1, 1];
|
|
2257
2261
|
const i = Math.sqrt(Math.max(0.64, Math.min(1.5625, e / t)));
|
|
2258
2262
|
return [i, 1 / i];
|
|
2259
2263
|
}
|
|
2260
|
-
function
|
|
2264
|
+
function ks(t, e, i = 120) {
|
|
2261
2265
|
return t.length > 0 && t.every((n) => Number.isFinite(n.cost) && n.cost / e <= i);
|
|
2262
2266
|
}
|
|
2263
|
-
function
|
|
2264
|
-
const i = [0, 1, 2].map((n) =>
|
|
2267
|
+
function Rs(t, e) {
|
|
2268
|
+
const i = [0, 1, 2].map((n) => Ts(Number(t[n]), Number(e[n])));
|
|
2265
2269
|
return [i.map((n) => n[0]), i.map((n) => n[1])];
|
|
2266
2270
|
}
|
|
2267
|
-
function
|
|
2271
|
+
function Ps(t, e) {
|
|
2268
2272
|
const i = t + e;
|
|
2269
2273
|
return !(t > 0) || !(e > 0) || !(i > 0) ? 128 : Math.round((1 - 2 * Math.min(t, e) / i) * 128);
|
|
2270
2274
|
}
|
|
2271
|
-
function
|
|
2275
|
+
function ln(t, e = 2) {
|
|
2272
2276
|
if (e <= 0 || t.length <= e * 2) return t.slice();
|
|
2273
2277
|
const i = t.slice();
|
|
2274
2278
|
return i.fill(t[e], 0, e), i.fill(t[t.length - e - 1], t.length - e), i;
|
|
2275
2279
|
}
|
|
2276
|
-
function
|
|
2280
|
+
function un(t, e, i = 4) {
|
|
2277
2281
|
return !e || e.length !== t.length || i < 0 ? t.slice() : t.map((n, r) => Math.max(e[r] - i, Math.min(e[r] + i, n)));
|
|
2278
2282
|
}
|
|
2279
|
-
function
|
|
2283
|
+
function dn(t, e, i = 0, n = N) {
|
|
2280
2284
|
return e.length > 0 && e.every((r, o) => r >= 0 && i + r < n && t[o * n + i + r] < 65535);
|
|
2281
2285
|
}
|
|
2282
|
-
function
|
|
2283
|
-
const o =
|
|
2284
|
-
return Math.abs(o -
|
|
2286
|
+
function fn(t, e, i, n, r) {
|
|
2287
|
+
const o = va(t, e, i);
|
|
2288
|
+
return Math.abs(o - va(t, e, n)) + Math.abs(o - va(t, e, r));
|
|
2285
2289
|
}
|
|
2286
|
-
function
|
|
2290
|
+
function va(t, e, i) {
|
|
2287
2291
|
const n = i * 3;
|
|
2288
2292
|
return (t[n] * e[0] * 77 + t[n + 1] * e[1] * 150 + t[n + 2] * e[2] * 29) / 256;
|
|
2289
2293
|
}
|
|
2290
|
-
function
|
|
2294
|
+
function As(t) {
|
|
2291
2295
|
const i = (typeof OffscreenCanvas < "u" ? new OffscreenCanvas(Je, Je) : Object.assign(document.createElement("canvas"), { width: Je, height: Je })).getContext("2d", { willReadFrequently: !0 });
|
|
2292
2296
|
if (!i) throw new Error("A 2D canvas is required for panorama seam analysis.");
|
|
2293
2297
|
return i.drawImage(t, 0, 0, Je, Je), i.getImageData(0, 0, Je, Je).data;
|
|
2294
2298
|
}
|
|
2295
|
-
function
|
|
2299
|
+
function Ls(t, e, i, n, r = new Uint8Array(3), o = 0) {
|
|
2296
2300
|
const s = Math.max(0, Math.min(e - 1, i * e - 0.5)), a = Math.max(0, Math.min(e - 1, n * e - 0.5)), c = Math.floor(s), l = Math.floor(a), u = Math.min(e - 1, c + 1), f = Math.min(e - 1, l + 1), y = s - c, p = a - l;
|
|
2297
|
-
for (let
|
|
2298
|
-
const d = t[(l * e + c) * 4 +
|
|
2299
|
-
r[o +
|
|
2301
|
+
for (let h = 0; h < 3; h += 1) {
|
|
2302
|
+
const d = t[(l * e + c) * 4 + h] * (1 - y) + t[(l * e + u) * 4 + h] * y, m = t[(f * e + c) * 4 + h] * (1 - y) + t[(f * e + u) * 4 + h] * y;
|
|
2303
|
+
r[o + h] = Math.round(d * (1 - p) + m * p);
|
|
2300
2304
|
}
|
|
2301
2305
|
return r;
|
|
2302
2306
|
}
|
|
2303
|
-
function
|
|
2307
|
+
function _a(t) {
|
|
2304
2308
|
return t !== "top-left";
|
|
2305
2309
|
}
|
|
2306
|
-
function
|
|
2310
|
+
function _s(t, e) {
|
|
2307
2311
|
return e === "top-left" ? t : 1 - t;
|
|
2308
2312
|
}
|
|
2309
|
-
function
|
|
2310
|
-
const n = dt(e), r =
|
|
2313
|
+
function Us(t, e, i) {
|
|
2314
|
+
const n = dt(e), r = Nn(i === "mei-extended" ? La(n) : n, t), o = Math.acos(Math.max(-1, Math.min(1, r[2])));
|
|
2311
2315
|
let s, a;
|
|
2312
2316
|
if (i === "mei-extended") {
|
|
2313
2317
|
const p = r[2] + (e.xi || 0);
|
|
2314
2318
|
if (p <= 1e-6) return;
|
|
2315
|
-
const
|
|
2316
|
-
if (!Number.isFinite(
|
|
2317
|
-
const g =
|
|
2319
|
+
const h = r[0] / p, d = r[1] / p, m = h * h + d * d;
|
|
2320
|
+
if (!Number.isFinite(m) || m > 16) return;
|
|
2321
|
+
const g = m * m, b = Ze(e), x = ve(e.tangential), v = Mt(e.thinPrism), w = 1 + b[0] * m + b[1] * g + b[2] * m * g + b[3] * g * g, S = h * w + 2 * x[0] * h * d + x[1] * (m + 2 * h * h) + v[0] * m + v[1] * g, D = d * w + x[0] * (m + 2 * d * d) + 2 * x[1] * h * d + v[2] * m + v[3] * g, F = e.distortionModel === "radtan_pro" ? Es([h, d], e.distortionCoeffs) : js([S, D], ve(e.sensorTilt));
|
|
2318
2322
|
s = (e.cx || 0) + (e.fx || 1) * F[0], a = (e.cy || 0) + (e.fy || e.fx || 1) * F[1];
|
|
2319
2323
|
} else {
|
|
2320
2324
|
if (o >= 96 * Math.PI / 180) return;
|
|
2321
|
-
const p = Math.max(1e-6, Math.hypot(r[0], r[1])),
|
|
2322
|
-
s = (e.cx || 0) +
|
|
2325
|
+
const p = Math.max(1e-6, Math.hypot(r[0], r[1])), h = Ns(o, e);
|
|
2326
|
+
s = (e.cx || 0) + h * r[0] / p, a = (e.cy || 0) + h * r[1] / p;
|
|
2323
2327
|
}
|
|
2324
2328
|
const c = e.width || 1, l = e.height || 1;
|
|
2325
2329
|
if (!Number.isFinite(s) || !Number.isFinite(a) || s < 0 || s > c - 1 || a < 0 || a > l - 1) return;
|
|
2326
2330
|
const u = (s + 0.5) / c, f = (a + 0.5) / l, y = 0.475 * Math.min(c, l) - Math.hypot(s - (e.cx || 0), a - (e.cy || 0));
|
|
2327
2331
|
if (!(i === "mei-extended" && y <= 0))
|
|
2328
|
-
return [u, f, i === "mei-extended" ? y :
|
|
2332
|
+
return [u, f, i === "mei-extended" ? y : Cs(o)];
|
|
2329
2333
|
}
|
|
2330
|
-
function
|
|
2334
|
+
function Es([t, e], i) {
|
|
2331
2335
|
const n = t * t + e * e, r = n * n, o = 1 + i[0] * n + i[1] * r + i[2] * n * r + i[3] * r * r + i[4] * r * r * n, s = i[5] + i[7] * n, a = i[6] + i[8] * n;
|
|
2332
2336
|
return [
|
|
2333
2337
|
t * o + (n + 2 * t * t) * s + 2 * t * e * a + i[9] * n + i[11] * r,
|
|
2334
2338
|
e * o + (n + 2 * e * e) * a + 2 * t * e * s + i[10] * n + i[12] * r
|
|
2335
2339
|
];
|
|
2336
2340
|
}
|
|
2337
|
-
function
|
|
2341
|
+
function Ua(t, e) {
|
|
2338
2342
|
if (!e.some((r) => r.distortionModel === "radtan_pro")) return;
|
|
2339
2343
|
const n = `${e.slice(0, 2).map((r, o) => {
|
|
2340
2344
|
const s = Array.from({ length: 13 }, (a, c) => {
|
|
@@ -2363,26 +2367,26 @@ function _a(t, e) {
|
|
|
2363
2367
|
t.fragmentShader = t.fragmentShader.replace("precision highp float;", `precision highp float;
|
|
2364
2368
|
${n}`).replace("sampler2D image) {", "sampler2D image, int lensIndex) {").replace("intrinsics.xy * applySensorTilt(distorted, sensorTilt)", "intrinsics.xy * calibratedDistortion(normalized, applySensorTilt(distorted, sensorTilt), lensIndex)").replace("sensorTilt0, lens0);", "sensorTilt0, lens0, 0);").replace("sensorTilt1, lens1);", "sensorTilt1, lens1, 1);");
|
|
2365
2369
|
}
|
|
2366
|
-
function
|
|
2370
|
+
function Cs(t) {
|
|
2367
2371
|
return Math.max(0, Math.min(1, (95 * Math.PI / 180 - t) / (10 * Math.PI / 180)));
|
|
2368
2372
|
}
|
|
2369
|
-
function
|
|
2373
|
+
function Is(t, e, i) {
|
|
2370
2374
|
const n = t * Math.PI * 2 - Math.PI, r = (e - 0.5) * Math.PI, o = Math.cos(r);
|
|
2371
2375
|
return i === "mei-extended" ? [o * Math.sin(n), -Math.sin(r), o * Math.cos(n)] : [o * Math.sin(n + Math.PI / 2), o * Math.cos(n + Math.PI / 2), Math.sin(r)];
|
|
2372
2376
|
}
|
|
2373
|
-
function
|
|
2374
|
-
const i = t * 360 - 180, n = 1 -
|
|
2377
|
+
function zs(t, e) {
|
|
2378
|
+
const i = t * 360 - 180, n = 1 - Bs(75, 105, Math.abs(i));
|
|
2375
2379
|
return e === 0 ? n : 1 - n;
|
|
2376
2380
|
}
|
|
2377
|
-
function
|
|
2381
|
+
function Bs(t, e, i) {
|
|
2378
2382
|
const n = Math.max(0, Math.min(1, (i - t) / (e - t)));
|
|
2379
2383
|
return n * n * (3 - 2 * n);
|
|
2380
2384
|
}
|
|
2381
|
-
function
|
|
2382
|
-
const [i, n] = t, [r, o] = e, s = Math.cos(r), a = Math.sin(r), c = Math.cos(o), l = Math.sin(o), u = c * i + l * a * n - l * s, f = s * n + a, y = l * i - c * a * n + c * s,
|
|
2383
|
-
return [s * (c * u + l * y) *
|
|
2385
|
+
function js(t, e) {
|
|
2386
|
+
const [i, n] = t, [r, o] = e, s = Math.cos(r), a = Math.sin(r), c = Math.cos(o), l = Math.sin(o), u = c * i + l * a * n - l * s, f = s * n + a, y = l * i - c * a * n + c * s, h = 1 / (Math.abs(y) > 1e-6 ? y : y < 0 ? -1e-6 : 1e-6);
|
|
2387
|
+
return [s * (c * u + l * y) * h, (c * s * f - a * y) * h];
|
|
2384
2388
|
}
|
|
2385
|
-
function
|
|
2389
|
+
function Nn(t, e) {
|
|
2386
2390
|
const i = Math.hypot(...t) || 1, [n, r, o, s] = t.map((u) => u / i), a = r * e[0] + o * e[1] + s * e[2], c = [o * e[2] - s * e[1], s * e[0] - r * e[2], r * e[1] - o * e[0]], l = n * n - r * r - o * o - s * s;
|
|
2387
2391
|
return [
|
|
2388
2392
|
2 * a * r + l * e[0] + 2 * n * c[0],
|
|
@@ -2390,25 +2394,25 @@ function jn(t, e) {
|
|
|
2390
2394
|
2 * a * s + l * e[2] + 2 * n * c[2]
|
|
2391
2395
|
];
|
|
2392
2396
|
}
|
|
2393
|
-
function
|
|
2397
|
+
function Ns(t, e) {
|
|
2394
2398
|
const i = 85 * Math.PI / 180, n = Math.min(t, i), r = Ze(e), o = n + r[0] * n ** 3 + r[1] * n ** 5 + r[2] * n ** 7 + r[3] * n ** 9, s = 1 + 3 * r[0] * n ** 2 + 5 * r[1] * n ** 4 + 7 * r[2] * n ** 6 + 9 * r[3] * n ** 8;
|
|
2395
2399
|
return Dt(e) * (e.fx || 1) * (t > i ? o + s * (t - i) : o);
|
|
2396
2400
|
}
|
|
2397
|
-
function
|
|
2401
|
+
function hn(t, e) {
|
|
2398
2402
|
const i = N / 2, n = new Uint16Array(i * ae);
|
|
2399
2403
|
for (let r = 0; r < ae; r += 1) n.set(t.subarray(r * N + e, r * N + e + i), r * i);
|
|
2400
2404
|
return n;
|
|
2401
2405
|
}
|
|
2402
|
-
function
|
|
2406
|
+
function Os(t, e, i) {
|
|
2403
2407
|
const n = new Uint8Array(N * ae);
|
|
2404
2408
|
for (let r = 0; r < ae; r += 1) {
|
|
2405
2409
|
let o = t[1][r * N] > t[0][r * N];
|
|
2406
2410
|
for (let s = 0; s < N; s += 1)
|
|
2407
2411
|
(s === e[r] || s === i[r]) && (o = !o), n[r * N + s] = o ? 255 : 0;
|
|
2408
2412
|
}
|
|
2409
|
-
return
|
|
2413
|
+
return On(n, !1);
|
|
2410
2414
|
}
|
|
2411
|
-
function
|
|
2415
|
+
function Vs(t, e, i) {
|
|
2412
2416
|
const n = new Uint8Array(N * ae), r = N / 4, o = ae / 8;
|
|
2413
2417
|
for (let s = 0; s < ae; s += 1) {
|
|
2414
2418
|
if (s < o || s >= ae - o) {
|
|
@@ -2424,9 +2428,9 @@ function Os(t, e, i) {
|
|
|
2424
2428
|
n[s * N + f] = (y ? u : !u) ? 255 : 0;
|
|
2425
2429
|
}
|
|
2426
2430
|
}
|
|
2427
|
-
return
|
|
2431
|
+
return On(n, !0);
|
|
2428
2432
|
}
|
|
2429
|
-
function
|
|
2433
|
+
function On(t, e) {
|
|
2430
2434
|
const i = t.slice();
|
|
2431
2435
|
for (let n = 0; n < ae; n += 1)
|
|
2432
2436
|
for (let r = 0; r < N; r += 1) {
|
|
@@ -2437,13 +2441,13 @@ function Nn(t, e) {
|
|
|
2437
2441
|
}
|
|
2438
2442
|
return i;
|
|
2439
2443
|
}
|
|
2440
|
-
function
|
|
2444
|
+
function Ws(t, e, i, n) {
|
|
2441
2445
|
const r = new Uint16Array(t.length);
|
|
2442
2446
|
for (let o = 0; o < i; o += 1)
|
|
2443
2447
|
for (let s = 0; s < e; s += 1) r[o * e + (s + n) % e] = t[o * e + s];
|
|
2444
2448
|
return r;
|
|
2445
2449
|
}
|
|
2446
|
-
function
|
|
2450
|
+
function mn(t, e, i) {
|
|
2447
2451
|
return t.map((n) => (n - i + e) % e);
|
|
2448
2452
|
}
|
|
2449
2453
|
function Yt(t) {
|
|
@@ -2463,7 +2467,7 @@ function dt(t) {
|
|
|
2463
2467
|
const e = t.extrinsicQuaternion;
|
|
2464
2468
|
return (e == null ? void 0 : e.length) === 4 && e.every(Number.isFinite) ? e : [1, 0, 0, 0];
|
|
2465
2469
|
}
|
|
2466
|
-
function
|
|
2470
|
+
function qs(t) {
|
|
2467
2471
|
const e = t.samples.at(-1);
|
|
2468
2472
|
return e && t.timescale > 0 ? (e.pts + e.duration) / t.timescale : 0;
|
|
2469
2473
|
}
|
|
@@ -2529,7 +2533,7 @@ const ee = Object.freeze({
|
|
|
2529
2533
|
// 0 = auto
|
|
2530
2534
|
preferredImageWidth: 0,
|
|
2531
2535
|
videoMetadataTimeoutMS: 15e3
|
|
2532
|
-
}),
|
|
2536
|
+
}), pn = [16384, 8192, 4096, 2048];
|
|
2533
2537
|
function O(t, e, i) {
|
|
2534
2538
|
return Math.min(i, Math.max(e, t));
|
|
2535
2539
|
}
|
|
@@ -2543,18 +2547,18 @@ function de(t, e, i = 0) {
|
|
|
2543
2547
|
o.push(me(n && n[s], e[s] ?? 0));
|
|
2544
2548
|
return o;
|
|
2545
2549
|
}
|
|
2546
|
-
function
|
|
2550
|
+
function Ma(t, e) {
|
|
2547
2551
|
const i = de(t, e, 2);
|
|
2548
2552
|
return [Math.max(1, Math.round(i[0])), Math.max(1, Math.round(i[1]))];
|
|
2549
2553
|
}
|
|
2550
|
-
function
|
|
2554
|
+
function Da(t) {
|
|
2551
2555
|
return (me(t, 0) % 360 + 360) % 360;
|
|
2552
2556
|
}
|
|
2553
|
-
function
|
|
2554
|
-
const i = Array.isArray(t) && t.length >= 2 ? t : e, n =
|
|
2557
|
+
function ia(t, e = ee.dualFisheyeSeamLongitudesDeg) {
|
|
2558
|
+
const i = Array.isArray(t) && t.length >= 2 ? t : e, n = Da(i[0]), r = Da(i[1]);
|
|
2555
2559
|
return Math.abs(n - r) < 1e-3 ? e.slice() : [n, r];
|
|
2556
2560
|
}
|
|
2557
|
-
function
|
|
2561
|
+
function yn(t, e) {
|
|
2558
2562
|
if (t instanceof Uint8Array)
|
|
2559
2563
|
return !e || t.length === e ? t : t.length > e ? t.slice(0, e) : null;
|
|
2560
2564
|
if (Array.isArray(t)) {
|
|
@@ -2563,7 +2567,7 @@ function mn(t, e) {
|
|
|
2563
2567
|
}
|
|
2564
2568
|
return null;
|
|
2565
2569
|
}
|
|
2566
|
-
function
|
|
2570
|
+
function Vn(t) {
|
|
2567
2571
|
const e = { ...ee, ...t || {} };
|
|
2568
2572
|
if (e.fovDeg = O(Number(e.fovDeg) || ee.fovDeg, 1, 179), e.maxFovDeg = O(Number(e.maxFovDeg) || ee.maxFovDeg, 1, 179), e.minFovDeg = O(Number(e.minFovDeg) || ee.minFovDeg, 1, 179), e.minFovDeg > e.maxFovDeg) {
|
|
2569
2573
|
const r = e.minFovDeg;
|
|
@@ -2573,7 +2577,7 @@ function On(t) {
|
|
|
2573
2577
|
Number(e.dualFisheyeSeamBlendDeg) || ee.dualFisheyeSeamBlendDeg,
|
|
2574
2578
|
0,
|
|
2575
2579
|
45
|
|
2576
|
-
), e.dualFisheyeSeamLongitudesDeg =
|
|
2580
|
+
), e.dualFisheyeSeamLongitudesDeg = ia(e.dualFisheyeSeamLongitudesDeg), e.dualFisheyeGainFront = Math.max(0.2, Number(e.dualFisheyeGainFront) || ee.dualFisheyeGainFront), e.dualFisheyeGainBack = Math.max(0.2, Number(e.dualFisheyeGainBack) || ee.dualFisheyeGainBack), e.dualFisheyeAutoGain = e.dualFisheyeAutoGain !== !1, e.dualFisheyeRefineFocal = e.dualFisheyeRefineFocal === !0, e.dualFisheyeVideoRegistration = e.dualFisheyeVideoRegistration === !0, e.dualFisheyeCalibration = e.dualFisheyeCalibration && typeof e.dualFisheyeCalibration == "object" ? e.dualFisheyeCalibration : null;
|
|
2577
2581
|
const i = Number(e.dragYawSign);
|
|
2578
2582
|
e.dragYawSign = i === -1 ? -1 : 1;
|
|
2579
2583
|
const n = Number(e.dragPitchSign);
|
|
@@ -2589,14 +2593,14 @@ function fe(t, e) {
|
|
|
2589
2593
|
me(i && i[1], e[1])
|
|
2590
2594
|
];
|
|
2591
2595
|
}
|
|
2592
|
-
function
|
|
2596
|
+
function Sa(t, e) {
|
|
2593
2597
|
const i = Math.max(1e-4, Number(e) || 0);
|
|
2594
2598
|
return [
|
|
2595
2599
|
me(t && t[0], 0) / i,
|
|
2596
2600
|
me(t && t[1], 0) / i
|
|
2597
2601
|
];
|
|
2598
2602
|
}
|
|
2599
|
-
function
|
|
2603
|
+
function Wn(t, e) {
|
|
2600
2604
|
const i = Math.abs(t[0] - e[0]), n = Math.abs(t[1] - e[1]);
|
|
2601
2605
|
return n > i ? [0.475, Math.max(1e-4, n * 0.475)] : [Math.max(1e-4, i * 0.475), 0.475];
|
|
2602
2606
|
}
|
|
@@ -2604,7 +2608,7 @@ function Nt(t, e) {
|
|
|
2604
2608
|
const i = Array.isArray(t) ? t : e, n = me(i && i[0], e[0]), r = me(i && i[1], e[1]), o = me(i && i[2], e[2]), s = Math.hypot(n, r, o);
|
|
2605
2609
|
return s <= 1e-6 ? e.slice() : [n / s, r / s, o / s];
|
|
2606
2610
|
}
|
|
2607
|
-
function
|
|
2611
|
+
function gn(t, e = [1, 0, 0, 0]) {
|
|
2608
2612
|
const i = Array.isArray(t) ? t : e, n = de(i, e, 4), r = Math.hypot(...n) || 1;
|
|
2609
2613
|
return n.map((o) => o / r);
|
|
2610
2614
|
}
|
|
@@ -2646,7 +2650,7 @@ function Gs(t, e) {
|
|
|
2646
2650
|
axis: [0, 0, 1],
|
|
2647
2651
|
right: [-1, 0, 0],
|
|
2648
2652
|
up: [0, 1, 0]
|
|
2649
|
-
}, s = t.front && typeof t.front == "object" ? t.front : {}, a = t.back && typeof t.back == "object" ? t.back : {}, c = t.pipeline && typeof t.pipeline == "object" ? t.pipeline : {}, l =
|
|
2653
|
+
}, s = t.front && typeof t.front == "object" ? t.front : {}, a = t.back && typeof t.back == "object" ? t.back : {}, c = t.pipeline && typeof t.pipeline == "object" ? t.pipeline : {}, l = Xs(t.remap), u = String(t.textureOrigin ?? t.texture_origin ?? "").trim().toLowerCase(), f = Ma(t.imageSize ?? t.image_size, [0, 0]), y = fe(s.center, r.center), p = fe(a.center, o.center), h = Wn(y, p);
|
|
2650
2654
|
return {
|
|
2651
2655
|
textureOrigin: u === "top-left" || u === "bottom-left" ? u : "",
|
|
2652
2656
|
imageSize: f,
|
|
@@ -2654,9 +2658,9 @@ function Gs(t, e) {
|
|
|
2654
2658
|
center: y,
|
|
2655
2659
|
focal: fe(s.focal, r.focal),
|
|
2656
2660
|
principalOffset: fe(s.principalOffset, r.principalOffset),
|
|
2657
|
-
rotationQuat:
|
|
2661
|
+
rotationQuat: gn(s.rotationQuat || s.rotation_quat),
|
|
2658
2662
|
scale: fe(s.scale, r.scale),
|
|
2659
|
-
validRadius: fe(s.validRadius || s.valid_radius,
|
|
2663
|
+
validRadius: fe(s.validRadius || s.valid_radius, h),
|
|
2660
2664
|
radial: de(s.radial, r.radial, 4),
|
|
2661
2665
|
radialLUT1: de(s.radialLUT1 || s.radial_lut_1, r.radialLUT1, 14),
|
|
2662
2666
|
radialLUT2: de(s.radialLUT2 || s.radial_lut_2, r.radialLUT2, 14),
|
|
@@ -2678,9 +2682,9 @@ function Gs(t, e) {
|
|
|
2678
2682
|
center: p,
|
|
2679
2683
|
focal: fe(a.focal, o.focal),
|
|
2680
2684
|
principalOffset: fe(a.principalOffset, o.principalOffset),
|
|
2681
|
-
rotationQuat:
|
|
2685
|
+
rotationQuat: gn(a.rotationQuat || a.rotation_quat),
|
|
2682
2686
|
scale: fe(a.scale, o.scale),
|
|
2683
|
-
validRadius: fe(a.validRadius || a.valid_radius,
|
|
2687
|
+
validRadius: fe(a.validRadius || a.valid_radius, h),
|
|
2684
2688
|
radial: de(a.radial, o.radial, 4),
|
|
2685
2689
|
radialLUT1: de(a.radialLUT1 || a.radial_lut_1, o.radialLUT1, 14),
|
|
2686
2690
|
radialLUT2: de(a.radialLUT2 || a.radial_lut_2, o.radialLUT2, 14),
|
|
@@ -2700,28 +2704,28 @@ function Gs(t, e) {
|
|
|
2700
2704
|
},
|
|
2701
2705
|
pipeline: {
|
|
2702
2706
|
featherWidthPx: Math.max(0, Number(c.featherWidthPx) || 0),
|
|
2703
|
-
seamLongitudesDeg:
|
|
2707
|
+
seamLongitudesDeg: ia(c.seamLongitudesDeg)
|
|
2704
2708
|
},
|
|
2705
2709
|
remap: l
|
|
2706
2710
|
};
|
|
2707
2711
|
}
|
|
2708
|
-
function
|
|
2712
|
+
function Xs(t) {
|
|
2709
2713
|
if (!t || typeof t != "object") return null;
|
|
2710
|
-
const e =
|
|
2714
|
+
const e = Ma([t.width, t.height], [1, 1]), i = e[0], n = e[1], r = i * n * 4, o = yn(t.front, r), s = yn(t.back, r);
|
|
2711
2715
|
return !o || !s ? null : {
|
|
2712
2716
|
strategy: "lut_rgba8",
|
|
2713
2717
|
width: i,
|
|
2714
2718
|
height: n,
|
|
2715
2719
|
front: o,
|
|
2716
2720
|
back: s,
|
|
2717
|
-
meshResolution:
|
|
2721
|
+
meshResolution: Ma(t.meshResolution, [32, 16])
|
|
2718
2722
|
};
|
|
2719
2723
|
}
|
|
2720
|
-
function
|
|
2724
|
+
function $s(t, e) {
|
|
2721
2725
|
const i = Number(t) || 0, n = Number(e) || 0;
|
|
2722
2726
|
return i > 0 && n > i * 1.6 && Math.abs(n / i - 2) <= 0.15;
|
|
2723
2727
|
}
|
|
2724
|
-
function
|
|
2728
|
+
function Ys(t) {
|
|
2725
2729
|
const e = String(t || "").trim();
|
|
2726
2730
|
if (!e) return { r: 0, g: 0, b: 0, a: 1 };
|
|
2727
2731
|
if (e.startsWith("#")) {
|
|
@@ -2751,7 +2755,7 @@ function $s(t) {
|
|
|
2751
2755
|
a: r[4] == null ? 1 : O(Number(r[4]) || 1, 0, 1)
|
|
2752
2756
|
} : { r: 0, g: 0, b: 0, a: 1 };
|
|
2753
2757
|
}
|
|
2754
|
-
function
|
|
2758
|
+
function vn(t, e, i) {
|
|
2755
2759
|
const n = t.createShader(e);
|
|
2756
2760
|
if (!n) throw new Error("createShader failed");
|
|
2757
2761
|
if (t.shaderSource(n, i), t.compileShader(n), !t.getShaderParameter(n, t.COMPILE_STATUS)) {
|
|
@@ -2760,8 +2764,8 @@ function yn(t, e, i) {
|
|
|
2760
2764
|
}
|
|
2761
2765
|
return n;
|
|
2762
2766
|
}
|
|
2763
|
-
function
|
|
2764
|
-
const n =
|
|
2767
|
+
function Qs(t, e, i) {
|
|
2768
|
+
const n = vn(t, t.VERTEX_SHADER, e), r = vn(t, t.FRAGMENT_SHADER, i), o = t.createProgram();
|
|
2765
2769
|
if (!o) throw new Error("createProgram failed");
|
|
2766
2770
|
if (t.attachShader(o, n), t.attachShader(o, r), t.linkProgram(o), t.deleteShader(n), t.deleteShader(r), !t.getProgramParameter(o, t.LINK_STATUS)) {
|
|
2767
2771
|
const s = t.getProgramInfoLog(o) || "";
|
|
@@ -2769,7 +2773,7 @@ function Ys(t, e, i) {
|
|
|
2769
2773
|
}
|
|
2770
2774
|
return o;
|
|
2771
2775
|
}
|
|
2772
|
-
function
|
|
2776
|
+
function Yi(t) {
|
|
2773
2777
|
return t ? t instanceof HTMLVideoElement ? {
|
|
2774
2778
|
width: Math.max(1, t.videoWidth || t.clientWidth || 1),
|
|
2775
2779
|
height: Math.max(1, t.videoHeight || t.clientHeight || 1)
|
|
@@ -2781,14 +2785,14 @@ function Xi(t) {
|
|
|
2781
2785
|
height: Math.max(1, t.height || t.clientHeight || 1)
|
|
2782
2786
|
} : { width: 1, height: 1 };
|
|
2783
2787
|
}
|
|
2784
|
-
const z = 128, X = 64,
|
|
2788
|
+
const z = 128, X = 64, Ea = 256, Be = new Int32Array(new Uint8Array([0, 0, 0, 255]).buffer)[0], qn = /* @__PURE__ */ new WeakSet();
|
|
2785
2789
|
function vi(t, e) {
|
|
2786
2790
|
return t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
|
|
2787
2791
|
}
|
|
2788
|
-
function
|
|
2792
|
+
function Hs(t, e, i = 1) {
|
|
2789
2793
|
return [t[0] - e[0] * i, t[1] - e[1] * i, t[2] - e[2] * i];
|
|
2790
2794
|
}
|
|
2791
|
-
function
|
|
2795
|
+
function xn(t) {
|
|
2792
2796
|
return Math.hypot(t[0], t[1], t[2]);
|
|
2793
2797
|
}
|
|
2794
2798
|
function Gn(t, e, i = !1) {
|
|
@@ -2799,27 +2803,27 @@ function Gn(t, e, i = !1) {
|
|
|
2799
2803
|
(i ? 1 : -1) * o * Math.cos(n)
|
|
2800
2804
|
];
|
|
2801
2805
|
}
|
|
2802
|
-
function
|
|
2806
|
+
function Js(t, e = !1) {
|
|
2803
2807
|
const i = Math.atan2(t[0], e ? t[2] : -t[2]), n = Math.asin(O(e ? -t[1] : t[1], -1, 1));
|
|
2804
2808
|
return [
|
|
2805
2809
|
i / (Math.PI * 2) + 0.5,
|
|
2806
2810
|
e ? n / Math.PI + 0.5 : 0.5 - n / Math.PI
|
|
2807
2811
|
];
|
|
2808
2812
|
}
|
|
2809
|
-
function
|
|
2810
|
-
const a = O(n * e - 0.5, 0, e - 1), c = O(r * i - 0.5, 0, i - 1), l = Math.floor(a), u = Math.floor(c), f = Math.min(e - 1, l + 1), y = Math.min(i - 1, u + 1), p = a - l,
|
|
2813
|
+
function Di(t, e, i, n, r, o, s = 0) {
|
|
2814
|
+
const a = O(n * e - 0.5, 0, e - 1), c = O(r * i - 0.5, 0, i - 1), l = Math.floor(a), u = Math.floor(c), f = Math.min(e - 1, l + 1), y = Math.min(i - 1, u + 1), p = a - l, h = c - u;
|
|
2811
2815
|
for (let d = 0; d < 3; d += 1) {
|
|
2812
|
-
const
|
|
2813
|
-
o[s + d] =
|
|
2816
|
+
const m = t[(u * e + l) * 4 + d] * (1 - p) + t[(u * e + f) * 4 + d] * p, g = t[(y * e + l) * 4 + d] * (1 - p) + t[(y * e + f) * 4 + d] * p;
|
|
2817
|
+
o[s + d] = m * (1 - h) + g * h;
|
|
2814
2818
|
}
|
|
2815
2819
|
return o;
|
|
2816
2820
|
}
|
|
2817
|
-
function
|
|
2821
|
+
function Ks(t, e, i, n = !1) {
|
|
2818
2822
|
var l;
|
|
2819
2823
|
const { pixels: r, width: o, height: s } = t, { uv: a, weights: c } = e;
|
|
2820
2824
|
if (!n) {
|
|
2821
2825
|
for (let u = 0; u < 2; u++) for (let f = 0; f < c[u].length; f++)
|
|
2822
|
-
c[u][f] > 0 &&
|
|
2826
|
+
c[u][f] > 0 && Di(
|
|
2823
2827
|
r,
|
|
2824
2828
|
o,
|
|
2825
2829
|
s,
|
|
@@ -2834,29 +2838,29 @@ function Js(t, e, i, n = !1) {
|
|
|
2834
2838
|
const u = c.map((f, y) => {
|
|
2835
2839
|
let p = 0;
|
|
2836
2840
|
for (let g = 0; g < f.length; g++) f[g] > 0 && p++;
|
|
2837
|
-
const
|
|
2841
|
+
const h = new Uint32Array(p), d = new Uint32Array(p * 4), m = new Float64Array(p * 2);
|
|
2838
2842
|
for (let g = 0, b = 0; g < f.length; g++) {
|
|
2839
2843
|
if (!(f[g] > 0)) continue;
|
|
2840
2844
|
const x = O(a[y][g * 2] * o - 0.5, 0, o - 1), v = O(a[y][g * 2 + 1] * s - 0.5, 0, s - 1), w = Math.floor(x), S = Math.floor(v), D = Math.min(o - 1, w + 1), F = Math.min(s - 1, S + 1);
|
|
2841
|
-
|
|
2845
|
+
h[b] = g * 3, d[b * 4] = (S * o + w) * 4, d[b * 4 + 1] = (S * o + D) * 4, d[b * 4 + 2] = (F * o + w) * 4, d[b * 4 + 3] = (F * o + D) * 4, m[b * 2] = x - w, m[b * 2 + 1] = v - S, b++;
|
|
2842
2846
|
}
|
|
2843
|
-
return { indices:
|
|
2847
|
+
return { indices: h, taps: d, fractions: m };
|
|
2844
2848
|
});
|
|
2845
2849
|
e.sampling = { width: o, height: s, lenses: u };
|
|
2846
2850
|
}
|
|
2847
2851
|
for (let u = 0; u < 2; u++) {
|
|
2848
|
-
const { indices: f, taps: y, fractions: p } = e.sampling.lenses[u],
|
|
2852
|
+
const { indices: f, taps: y, fractions: p } = e.sampling.lenses[u], h = i[u];
|
|
2849
2853
|
for (let d = 0; d < f.length; d++) {
|
|
2850
|
-
const
|
|
2851
|
-
|
|
2852
|
-
const _ = r[
|
|
2853
|
-
|
|
2854
|
-
const P = r[
|
|
2855
|
-
|
|
2854
|
+
const m = y[d * 4], g = y[d * 4 + 1], b = y[d * 4 + 2], x = y[d * 4 + 3], v = f[d], w = p[d * 2], S = p[d * 2 + 1], D = 1 - w, F = 1 - S, T = r[m] * D + r[g] * w, L = r[b] * D + r[x] * w;
|
|
2855
|
+
h[v] = T * F + L * S;
|
|
2856
|
+
const _ = r[m + 1] * D + r[g + 1] * w, k = r[b + 1] * D + r[x + 1] * w;
|
|
2857
|
+
h[v + 1] = _ * F + k * S;
|
|
2858
|
+
const P = r[m + 2] * D + r[g + 2] * w, E = r[b + 2] * D + r[x + 2] * w;
|
|
2859
|
+
h[v + 2] = P * F + E * S;
|
|
2856
2860
|
}
|
|
2857
2861
|
}
|
|
2858
2862
|
}
|
|
2859
|
-
function
|
|
2863
|
+
function Zs(t, e, i) {
|
|
2860
2864
|
if (!t || !(t.front instanceof Uint8Array) || !(t.back instanceof Uint8Array)) return null;
|
|
2861
2865
|
const n = (r) => {
|
|
2862
2866
|
const o = O(Math.round(e * (t.width - 1)), 0, t.width - 1), a = (O(Math.round((1 - i) * (t.height - 1)), 0, t.height - 1) * t.width + o) * 4;
|
|
@@ -2868,62 +2872,62 @@ function Ks(t, e, i) {
|
|
|
2868
2872
|
};
|
|
2869
2873
|
return [n(t.front), n(t.back)];
|
|
2870
2874
|
}
|
|
2871
|
-
function
|
|
2875
|
+
function ec(t, e) {
|
|
2872
2876
|
const i = Math.cos(e[0]), n = Math.sin(e[0]), r = Math.cos(e[1]), o = Math.sin(e[1]), s = r * t[0] + o * n * t[1] - o * i, a = i * t[1] + n, c = o * t[0] - r * n * t[1] + r * i, l = Math.abs(c) > 1e-6 ? c : c < 0 ? -1e-6 : 1e-6;
|
|
2873
2877
|
return [i * (r * s + o * c) / l, (r * i * a - n * c) / l];
|
|
2874
2878
|
}
|
|
2875
2879
|
function St(t, e, i, n, r, o, s = 0) {
|
|
2876
2880
|
var p;
|
|
2877
2881
|
const a = n && Array.isArray(e.rotationQuat) ? (() => {
|
|
2878
|
-
const
|
|
2882
|
+
const h = Ba(
|
|
2879
2883
|
{ w: e.rotationQuat[0], x: -e.rotationQuat[1], y: -e.rotationQuat[2], z: -e.rotationQuat[3] },
|
|
2880
2884
|
t[0],
|
|
2881
2885
|
t[1],
|
|
2882
2886
|
t[2]
|
|
2883
2887
|
);
|
|
2884
|
-
return [
|
|
2888
|
+
return [h.x, h.y, h.z];
|
|
2885
2889
|
})() : [vi(t, e.right), -vi(t, e.up), vi(t, e.axis)];
|
|
2886
2890
|
if (n && s > 0) {
|
|
2887
2891
|
for (let d = 0; d < 3; d += 1) a[d] = a[d] * s + (((p = e.translationM) == null ? void 0 : p[d]) || 0);
|
|
2888
|
-
const
|
|
2889
|
-
if (
|
|
2890
|
-
for (let d = 0; d < 3; d += 1) a[d] /=
|
|
2892
|
+
const h = xn(a);
|
|
2893
|
+
if (h <= 1e-9) return null;
|
|
2894
|
+
for (let d = 0; d < 3; d += 1) a[d] /= h;
|
|
2891
2895
|
}
|
|
2892
2896
|
const c = a[2], l = r ? Math.atan2(Math.hypot(a[0], a[1]), c) : Math.acos(O(c, -1, 1));
|
|
2893
2897
|
if (!n && l > i || r && l >= 96 * Math.PI / 180) return null;
|
|
2894
2898
|
let u;
|
|
2895
2899
|
if (n) {
|
|
2896
|
-
const
|
|
2897
|
-
if (
|
|
2898
|
-
const d = a[0] /
|
|
2900
|
+
const h = a[2] + e.xi;
|
|
2901
|
+
if (h <= 1e-6) return null;
|
|
2902
|
+
const d = a[0] / h, m = a[1] / h, g = d * d + m * m;
|
|
2899
2903
|
if (g > 16) return null;
|
|
2900
|
-
const b = g * g, x = 1 + e.radial[0] * g + e.radial[1] * b + e.radial[2] * g * b + e.radial[3] * b * b, v = e.distortionModel === "radtan_pro" ?
|
|
2901
|
-
d * x + 2 * e.tangential[0] * d *
|
|
2902
|
-
|
|
2904
|
+
const b = g * g, x = 1 + e.radial[0] * g + e.radial[1] * b + e.radial[2] * g * b + e.radial[3] * b * b, v = e.distortionModel === "radtan_pro" ? tc(d, m, e.distortionCoeffs) : ec([
|
|
2905
|
+
d * x + 2 * e.tangential[0] * d * m + e.tangential[1] * (g + 2 * d * d) + e.thinPrism[0] * g + e.thinPrism[1] * b,
|
|
2906
|
+
m * x + e.tangential[0] * (g + 2 * m * m) + 2 * e.tangential[1] * d * m + e.thinPrism[2] * g + e.thinPrism[3] * b
|
|
2903
2907
|
], e.sensorTilt || [0, 0]);
|
|
2904
2908
|
u = [
|
|
2905
2909
|
e.center[0] + e.principalOffset[0] + e.focal[0] * v[0],
|
|
2906
2910
|
e.center[1] + e.principalOffset[1] + e.focal[1] * v[1]
|
|
2907
2911
|
];
|
|
2908
2912
|
} else if (r) {
|
|
2909
|
-
const
|
|
2910
|
-
if (
|
|
2913
|
+
const h = Math.hypot(a[0], a[1]);
|
|
2914
|
+
if (h <= 1e-6)
|
|
2911
2915
|
u = [e.center[0] + e.principalOffset[0], e.center[1] + e.principalOffset[1]];
|
|
2912
2916
|
else if (e.distortionModel === "dji_fisheye_5") {
|
|
2913
|
-
const d = l * l,
|
|
2917
|
+
const d = l * l, m = e.distortionCoeffs, g = l * (1 + d * (m[0] + d * (m[1] + d * (m[2] + d * (m[3] + d * m[4]))))), b = g * a[0] / h, x = g * a[1] / h, v = b * b + x * x, [w, S] = e.tangential;
|
|
2914
2918
|
u = [
|
|
2915
2919
|
e.center[0] + e.principalOffset[0] + e.focal[0] * (b + 2 * w * b * x + S * (v + 2 * b * b)),
|
|
2916
2920
|
e.center[1] + e.principalOffset[1] + e.focal[1] * (x + w * (v + 2 * x * x) + 2 * S * b * x)
|
|
2917
2921
|
];
|
|
2918
2922
|
} else {
|
|
2919
|
-
const d = 85 * Math.PI / 180,
|
|
2923
|
+
const d = 85 * Math.PI / 180, m = Math.min(l, d), g = m * m, b = m * (1 + e.radial[0] * g + e.radial[1] * g * g + e.radial[2] * g * g * g + e.radial[3] * g * g * g * g), x = 1 + 3 * e.radial[0] * g + 5 * e.radial[1] * g * g + 7 * e.radial[2] * g * g * g + 9 * e.radial[3] * g * g * g * g, v = o * (l > d ? b + x * (l - d) : b);
|
|
2920
2924
|
u = [
|
|
2921
|
-
e.center[0] + e.principalOffset[0] + e.focal[0] * v * a[0] /
|
|
2922
|
-
e.center[1] + e.principalOffset[1] + e.focal[1] * v * a[1] /
|
|
2925
|
+
e.center[0] + e.principalOffset[0] + e.focal[0] * v * a[0] / h,
|
|
2926
|
+
e.center[1] + e.principalOffset[1] + e.focal[1] * v * a[1] / h
|
|
2923
2927
|
];
|
|
2924
2928
|
}
|
|
2925
2929
|
} else {
|
|
2926
|
-
const
|
|
2930
|
+
const h = Hs(t, e.axis, c), d = xn(h), m = d > 1e-5 ? [vi(h, e.right) / d, -vi(h, e.up) / d] : [0, 0], g = l * l, b = e.radial || [0, 0, 0, 0], x = l * (1 + b[0] * g + b[1] * g ** 2 + b[2] * g ** 3 + b[3] * g ** 4), v = x * m[0], w = x * m[1], S = v * v + w * w, D = e.tangential || [0, 0], F = e.asymmetric || [0, 0, 0, 0], T = 2 * D[0] * v * w + D[1] * (S + 2 * v * v), L = D[0] * (S + 2 * w * w) + 2 * D[1] * v * w, _ = F[0] * v + F[1] * w, k = F[2] * v + F[3] * w, P = e.focal || Sa(e.scale, i), E = e.principalOffset || [0, 0];
|
|
2927
2931
|
u = [
|
|
2928
2932
|
e.center[0] + E[0] + P[0] * (v + T + _),
|
|
2929
2933
|
e.center[1] + E[1] + P[1] * (w + L + k)
|
|
@@ -2933,23 +2937,23 @@ function St(t, e, i, n, r, o, s = 0) {
|
|
|
2933
2937
|
const f = e.validRadius || [0.475, 0.475], y = Math.max(1 - Math.hypot((u[0] - e.center[0]) / Math.max(1e-4, f[0]), (u[1] - e.center[1]) / Math.max(1e-4, f[1])), 0);
|
|
2934
2938
|
return y <= 0 || u[0] < 0 || u[1] < 0 || u[0] > 1 || u[1] > 1 ? null : { uv: u, confidence: y };
|
|
2935
2939
|
}
|
|
2936
|
-
function
|
|
2940
|
+
function tc(t, e, i) {
|
|
2937
2941
|
const n = t * t + e * e, r = n * n, o = 1 + i[0] * n + i[1] * r + i[2] * n * r + i[3] * r * r + i[4] * r * r * n, s = i[5] + i[7] * n, a = i[6] + i[8] * n;
|
|
2938
2942
|
return [
|
|
2939
2943
|
t * o + (n + 2 * t * t) * s + 2 * t * e * a + i[9] * n + i[11] * r,
|
|
2940
2944
|
e * o + (n + 2 * e * e) * a + 2 * t * e * s + i[10] * n + i[12] * r
|
|
2941
2945
|
];
|
|
2942
2946
|
}
|
|
2943
|
-
function
|
|
2944
|
-
var p,
|
|
2945
|
-
const o = e * i, s = ((p = r == null ? void 0 : r.dp) == null ? void 0 : p.length) === e * 2 ? r.dp : new Float64Array(e * 2), a = ((
|
|
2947
|
+
function Xn(t, e, i, n = 2, r = null) {
|
|
2948
|
+
var p, h;
|
|
2949
|
+
const o = e * i, s = ((p = r == null ? void 0 : r.dp) == null ? void 0 : p.length) === e * 2 ? r.dp : new Float64Array(e * 2), a = ((h = r == null ? void 0 : r.parents) == null ? void 0 : h.length) === o ? r.parents : new Int16Array(o);
|
|
2946
2950
|
r && (r.dp = s, r.parents = a);
|
|
2947
2951
|
let c = 0, l = e;
|
|
2948
2952
|
for (let d = 0; d < e; d += 1) s[d] = t[d] < 65535 ? t[d] : Number.POSITIVE_INFINITY;
|
|
2949
2953
|
for (let d = 1; d < i; d += 1) {
|
|
2950
|
-
const
|
|
2954
|
+
const m = d * e;
|
|
2951
2955
|
for (let b = 0; b < e; b += 1) {
|
|
2952
|
-
const x = t[
|
|
2956
|
+
const x = t[m + b];
|
|
2953
2957
|
if (!Number.isFinite(x) || x >= 65535) {
|
|
2954
2958
|
s[l + b] = Number.POSITIVE_INFINITY;
|
|
2955
2959
|
continue;
|
|
@@ -2960,7 +2964,7 @@ function qn(t, e, i, n = 2, r = null) {
|
|
|
2960
2964
|
const T = s[c + F];
|
|
2961
2965
|
T < v && (v = T, w = F);
|
|
2962
2966
|
}
|
|
2963
|
-
s[l + b] = v + x, w >= 0 && (a[
|
|
2967
|
+
s[l + b] = v + x, w >= 0 && (a[m + b] = w);
|
|
2964
2968
|
}
|
|
2965
2969
|
const g = c;
|
|
2966
2970
|
c = l, l = g;
|
|
@@ -2972,13 +2976,13 @@ function qn(t, e, i, n = 2, r = null) {
|
|
|
2972
2976
|
const y = new Array(i);
|
|
2973
2977
|
y[i - 1] = u;
|
|
2974
2978
|
for (let d = i - 1; d > 0; d -= 1) {
|
|
2975
|
-
const
|
|
2976
|
-
if (
|
|
2977
|
-
y[d - 1] =
|
|
2979
|
+
const m = a[d * e + y[d]];
|
|
2980
|
+
if (m < 0) return null;
|
|
2981
|
+
y[d - 1] = m;
|
|
2978
2982
|
}
|
|
2979
2983
|
return { seam: y, cost: f };
|
|
2980
2984
|
}
|
|
2981
|
-
function
|
|
2985
|
+
function ic(t) {
|
|
2982
2986
|
const e = t.slice();
|
|
2983
2987
|
for (let i = 0; i < X; i += 1)
|
|
2984
2988
|
for (let n = 0; n < z; n += 1) {
|
|
@@ -2989,16 +2993,16 @@ function tc(t) {
|
|
|
2989
2993
|
}
|
|
2990
2994
|
return e;
|
|
2991
2995
|
}
|
|
2992
|
-
function
|
|
2996
|
+
function ac(t, e, i) {
|
|
2993
2997
|
const n = new Uint8Array(z * X);
|
|
2994
2998
|
for (let r = 0; r < X; r += 1) {
|
|
2995
2999
|
let o = t[1][r * z] > t[0][r * z];
|
|
2996
3000
|
for (let s = 0; s < z; s += 1)
|
|
2997
3001
|
(s === e[r] || s === i[r]) && (o = !o), n[r * z + s] = o ? 255 : 0;
|
|
2998
3002
|
}
|
|
2999
|
-
return
|
|
3003
|
+
return ic(n);
|
|
3000
3004
|
}
|
|
3001
|
-
function
|
|
3005
|
+
function rc(t, e, i, n) {
|
|
3002
3006
|
if (!t) return null;
|
|
3003
3007
|
const r = [new Float32Array(t.length), new Float32Array(t.length)];
|
|
3004
3008
|
for (let s = 0; s < X; s += 1) for (let a = 0; a < z; a += 1) {
|
|
@@ -3006,8 +3010,8 @@ function ac(t, e, i, n) {
|
|
|
3006
3010
|
if (i[0][c] <= 0 || i[1][c] <= 0) continue;
|
|
3007
3011
|
const l = i[0][c] > i[1][c] ? 0 : 1, u = 1 - l;
|
|
3008
3012
|
if (i[l][c] < i[u][c] * 1.5) continue;
|
|
3009
|
-
const f = c * 3, y = e[l], p = e[u],
|
|
3010
|
-
if (x < 32 ||
|
|
3013
|
+
const f = c * 3, y = e[l], p = e[u], h = n[l], d = n[u], m = y[f] * h, g = y[f + 1] * h, b = y[f + 2] * h, x = Math.abs(m - p[f] * d) / 3 + Math.abs(g - p[f + 1] * d) / 3 + Math.abs(b - p[f + 2] * d) / 3;
|
|
3014
|
+
if (x < 32 || m * 0.2126 + g * 0.7152 + b * 0.0722 < 24) continue;
|
|
3011
3015
|
const v = (i[l][c] - i[u][c]) * Math.min(1, x / 64);
|
|
3012
3016
|
for (let w = -2; w <= 2; w += 1) {
|
|
3013
3017
|
const S = s + w;
|
|
@@ -3025,8 +3029,8 @@ function ac(t, e, i, n) {
|
|
|
3025
3029
|
if (i[1 - a][s] > 0) {
|
|
3026
3030
|
const c = s * 3, l = e[a], u = n[a], f = l[c] * u * 0.2126 + l[c + 1] * u * 0.7152 + l[c + 2] * u * 0.0722;
|
|
3027
3031
|
if (f < 12) {
|
|
3028
|
-
const y = e[1 - a], p = n[1 - a],
|
|
3029
|
-
if (
|
|
3032
|
+
const y = e[1 - a], p = n[1 - a], h = y[c] * p * 0.2126 + y[c + 1] * p * 0.7152 + y[c + 2] * p * 0.0722;
|
|
3033
|
+
if (h > 24 && f < h * 0.25) continue;
|
|
3030
3034
|
}
|
|
3031
3035
|
}
|
|
3032
3036
|
o[s] = a === 0 ? 0 : 255;
|
|
@@ -3034,7 +3038,7 @@ function ac(t, e, i, n) {
|
|
|
3034
3038
|
}
|
|
3035
3039
|
return o;
|
|
3036
3040
|
}
|
|
3037
|
-
function
|
|
3041
|
+
function nc(t, e, i) {
|
|
3038
3042
|
const n = new Uint8Array(z * X);
|
|
3039
3043
|
for (let r = 0; r < X; r++) for (let o = 0; o < z; o++) {
|
|
3040
3044
|
const s = r * z + o;
|
|
@@ -3057,7 +3061,7 @@ function rc(t, e, i) {
|
|
|
3057
3061
|
}
|
|
3058
3062
|
return n;
|
|
3059
3063
|
}
|
|
3060
|
-
function
|
|
3064
|
+
function oc(t) {
|
|
3061
3065
|
const e = z, i = X, n = new Uint8Array(e * i);
|
|
3062
3066
|
for (let r = 0; r < i; r++) for (let o = 0; o < e; o++) {
|
|
3063
3067
|
const s = r * e + o;
|
|
@@ -3069,23 +3073,23 @@ function nc(t) {
|
|
|
3069
3073
|
}
|
|
3070
3074
|
return n;
|
|
3071
3075
|
}
|
|
3072
|
-
function
|
|
3076
|
+
function sc(t, e, i) {
|
|
3073
3077
|
const n = z, r = X, o = new Float64Array(n * 5), s = new Float64Array(n), a = new Float32Array(n * r);
|
|
3074
3078
|
for (let c = 0; c < r; c++) {
|
|
3075
3079
|
const l = c * n, u = c % 5 * n, f = (c - 2) * n;
|
|
3076
3080
|
let y = 0;
|
|
3077
3081
|
for (let p = -2; p <= 2; p++) {
|
|
3078
|
-
const
|
|
3079
|
-
e[
|
|
3082
|
+
const h = l + (p + n) % n;
|
|
3083
|
+
e[h] > 0 && (y += t[h]);
|
|
3080
3084
|
}
|
|
3081
3085
|
for (let p = 0; p < n; p++) {
|
|
3082
|
-
let
|
|
3083
|
-
if (c >= 5 && (
|
|
3086
|
+
let h = s[p];
|
|
3087
|
+
if (c >= 5 && (h -= o[u + p]), o[u + p] = y, h += y, s[p] = h, c >= 2) {
|
|
3084
3088
|
const g = f + p;
|
|
3085
|
-
e[g] > 0 && (a[g] = Math.abs(t[g] -
|
|
3089
|
+
e[g] > 0 && (a[g] = Math.abs(t[g] - h / Math.max(i[g], 1)));
|
|
3086
3090
|
}
|
|
3087
|
-
const d = l + (p + n - 2) % n,
|
|
3088
|
-
e[d] > 0 && (y -= t[d]), e[
|
|
3091
|
+
const d = l + (p + n - 2) % n, m = l + (p + 3) % n;
|
|
3092
|
+
e[d] > 0 && (y -= t[d]), e[m] > 0 && (y += t[m]);
|
|
3089
3093
|
}
|
|
3090
3094
|
}
|
|
3091
3095
|
for (let c = r - 2; c < r; c++) {
|
|
@@ -3099,68 +3103,68 @@ function oc(t, e, i) {
|
|
|
3099
3103
|
}
|
|
3100
3104
|
return a;
|
|
3101
3105
|
}
|
|
3102
|
-
function
|
|
3103
|
-
if (i) return
|
|
3106
|
+
function cc(t, e, i = null) {
|
|
3107
|
+
if (i) return sc(t, e, i);
|
|
3104
3108
|
const n = z, r = X, o = n * r, s = new Float64Array(n * 5), a = new Uint8Array(n * 5), c = new Float64Array(n), l = new Uint8Array(n), u = new Float32Array(o);
|
|
3105
3109
|
for (let f = 0; f < r; f++) {
|
|
3106
|
-
const y = f * n, p = f % 5 * n,
|
|
3107
|
-
let d = 0,
|
|
3110
|
+
const y = f * n, p = f % 5 * n, h = (f - 2) * n;
|
|
3111
|
+
let d = 0, m = 0;
|
|
3108
3112
|
for (let g = -2; g <= 2; g++) {
|
|
3109
3113
|
const b = y + (g + n) % n;
|
|
3110
|
-
e[b] > 0 && (d += t[b],
|
|
3114
|
+
e[b] > 0 && (d += t[b], m++);
|
|
3111
3115
|
}
|
|
3112
3116
|
for (let g = 0; g < n; g++) {
|
|
3113
3117
|
let b = c[g], x = l[g];
|
|
3114
|
-
if (f >= 5 && (b -= s[p + g], x -= a[p + g]), s[p + g] = d, a[p + g] =
|
|
3115
|
-
const S =
|
|
3118
|
+
if (f >= 5 && (b -= s[p + g], x -= a[p + g]), s[p + g] = d, a[p + g] = m, b += d, x += m, c[g] = b, l[g] = x, f >= 2) {
|
|
3119
|
+
const S = h + g;
|
|
3116
3120
|
e[S] > 0 && (u[S] = Math.abs(t[S] - b / Math.max(x, 1)));
|
|
3117
3121
|
}
|
|
3118
3122
|
const v = y + (g + n - 2) % n, w = y + (g + 3) % n;
|
|
3119
|
-
e[v] > 0 && (d -= t[v],
|
|
3123
|
+
e[v] > 0 && (d -= t[v], m--), e[w] > 0 && (d += t[w], m++);
|
|
3120
3124
|
}
|
|
3121
3125
|
}
|
|
3122
3126
|
for (let f = r - 2; f < r; f++) {
|
|
3123
3127
|
const y = f * n, p = (f - 3) % 5 * n;
|
|
3124
|
-
for (let
|
|
3125
|
-
const d = c[
|
|
3126
|
-
c[
|
|
3127
|
-
const g = y +
|
|
3128
|
-
e[g] > 0 && (u[g] = Math.abs(t[g] - d / Math.max(
|
|
3128
|
+
for (let h = 0; h < n; h++) {
|
|
3129
|
+
const d = c[h] - s[p + h], m = l[h] - a[p + h];
|
|
3130
|
+
c[h] = d, l[h] = m;
|
|
3131
|
+
const g = y + h;
|
|
3132
|
+
e[g] > 0 && (u[g] = Math.abs(t[g] - d / Math.max(m, 1)));
|
|
3129
3133
|
}
|
|
3130
3134
|
}
|
|
3131
3135
|
return u;
|
|
3132
3136
|
}
|
|
3133
|
-
function
|
|
3137
|
+
function lc(t) {
|
|
3134
3138
|
const e = z, i = X, n = e >>> 5, r = new Uint8Array(e * i);
|
|
3135
3139
|
for (let o = 2; o < i - 2; o++) for (let s = 0; s < n; s++) {
|
|
3136
3140
|
const a = (o - 1) * n, c = a + s, l = a + (s + n - 1) % n, u = a + (s + 1) % n, f = t[c] | t[c + n] | t[c + n * 2], y = t[l] | t[l + n] | t[l + n * 2], p = t[u] | t[u + n] | t[u + n * 2];
|
|
3137
|
-
let
|
|
3138
|
-
for (;
|
|
3139
|
-
const d = 31 - Math.clz32(
|
|
3140
|
-
r[o * e + s * 32 + d] = 1,
|
|
3141
|
+
let h = f | f << 1 | f >>> 1 | y >>> 31 | p << 31;
|
|
3142
|
+
for (; h; ) {
|
|
3143
|
+
const d = 31 - Math.clz32(h & -h);
|
|
3144
|
+
r[o * e + s * 32 + d] = 1, h &= h - 1;
|
|
3141
3145
|
}
|
|
3142
3146
|
}
|
|
3143
3147
|
return r;
|
|
3144
3148
|
}
|
|
3145
|
-
function
|
|
3146
|
-
const o = z, s = X, a = o * s, c = e.map((d,
|
|
3147
|
-
const g = new Float32Array(a), b = n[
|
|
3149
|
+
function uc(t, e, i, n, r = null) {
|
|
3150
|
+
const o = z, s = X, a = o * s, c = e.map((d, m) => {
|
|
3151
|
+
const g = new Float32Array(a), b = n[m];
|
|
3148
3152
|
for (let x = 0; x < a; x++) {
|
|
3149
3153
|
const v = x * 3;
|
|
3150
3154
|
g[x] = (d[v] * 0.2126 + d[v + 1] * 0.7152 + d[v + 2] * 0.0722) * b;
|
|
3151
3155
|
}
|
|
3152
3156
|
return g;
|
|
3153
|
-
}), l = r ? r.contrastSampleCounts || (r.contrastSampleCounts = i.map(
|
|
3157
|
+
}), l = r ? r.contrastSampleCounts || (r.contrastSampleCounts = i.map(oc)) : null, u = c.map((d, m) => cc(d, i[m], l == null ? void 0 : l[m])), f = new Uint32Array(a >>> 5);
|
|
3154
3158
|
for (let d = 0; d < a; d++)
|
|
3155
3159
|
i[0][d] <= 0 || i[1][d] <= 0 || Math.abs(c[0][d] - c[1][d]) < 12 || Math.max(u[0][d], u[1][d]) < 12 || (f[d >>> 5] |= 1 << (d & 31));
|
|
3156
|
-
const y =
|
|
3160
|
+
const y = lc(f), p = t.slice(), h = new Int32Array(a);
|
|
3157
3161
|
for (let d = 0; d < a; d++) {
|
|
3158
3162
|
if (y[d] !== 1) continue;
|
|
3159
|
-
let
|
|
3160
|
-
|
|
3163
|
+
let m = 1;
|
|
3164
|
+
h[0] = d, y[d] = 2;
|
|
3161
3165
|
const g = [0, 0];
|
|
3162
|
-
for (let v = 0; v <
|
|
3163
|
-
const w =
|
|
3166
|
+
for (let v = 0; v < m; v++) {
|
|
3167
|
+
const w = h[v], S = w % o, D = Math.floor(w / o);
|
|
3164
3168
|
if (i[0][w] > 0 && i[1][w] > 0 && Math.abs(c[0][w] - c[1][w]) >= 12)
|
|
3165
3169
|
for (let F = 0; F < 2; F++) g[F] += u[F][w] * i[F][w] ** 2;
|
|
3166
3170
|
for (const F of [
|
|
@@ -3169,18 +3173,18 @@ function lc(t, e, i, n, r = null) {
|
|
|
3169
3173
|
D * o + (S + o - 1) % o,
|
|
3170
3174
|
D * o + (S + 1) % o
|
|
3171
3175
|
])
|
|
3172
|
-
F < 0 || y[F] !== 1 || (y[F] = 2, m
|
|
3176
|
+
F < 0 || y[F] !== 1 || (y[F] = 2, h[m++] = F);
|
|
3173
3177
|
}
|
|
3174
3178
|
const b = g[0] > g[1] ? 0 : 1, x = 1 - b;
|
|
3175
3179
|
if (!(g[b] <= 0 || g[b] < g[x] * 1.15))
|
|
3176
|
-
for (let v = 0; v <
|
|
3177
|
-
const w =
|
|
3180
|
+
for (let v = 0; v < m; v++) {
|
|
3181
|
+
const w = h[v];
|
|
3178
3182
|
i[b][w] <= 0 || c[b][w] < 4 && c[x][w] > 24 || (p[w] = b === 0 ? 0 : 255);
|
|
3179
3183
|
}
|
|
3180
3184
|
}
|
|
3181
3185
|
return p;
|
|
3182
3186
|
}
|
|
3183
|
-
function
|
|
3187
|
+
function dc() {
|
|
3184
3188
|
const t = (n, r) => typeof OffscreenCanvas < "u" ? new OffscreenCanvas(n, r) : Object.assign(document.createElement("canvas"), { width: n, height: r }), e = t(32, 2), i = t(16, 1);
|
|
3185
3189
|
try {
|
|
3186
3190
|
const n = e.getContext("2d", { willReadFrequently: !0 }), r = i.getContext("2d", { willReadFrequently: !0 });
|
|
@@ -3206,7 +3210,7 @@ function uc() {
|
|
|
3206
3210
|
e.width = e.height = i.width = i.height = 0;
|
|
3207
3211
|
}
|
|
3208
3212
|
}
|
|
3209
|
-
function
|
|
3213
|
+
function bn(t, e = 0) {
|
|
3210
3214
|
const i = new Uint8Array(524288);
|
|
3211
3215
|
if (!t) i.fill(1);
|
|
3212
3216
|
else {
|
|
@@ -3232,28 +3236,28 @@ function vn(t, e = 0) {
|
|
|
3232
3236
|
}
|
|
3233
3237
|
return r;
|
|
3234
3238
|
}
|
|
3235
|
-
function
|
|
3236
|
-
if ((t == null ? void 0 : t.length) !== 2 || t.some((p) => !p || p.width < 1024 || p.width !== p.height || !ArrayBuffer.isView(p.data) || p.data.length !== p.width * p.height * 4 || p.colorSpace && p.colorSpace !== "srgb") || (e.bias === void 0 && (e.bias =
|
|
3239
|
+
function fc(t, e, i = null, n = null) {
|
|
3240
|
+
if ((t == null ? void 0 : t.length) !== 2 || t.some((p) => !p || p.width < 1024 || p.width !== p.height || !ArrayBuffer.isView(p.data) || p.data.length !== p.width * p.height * 4 || p.colorSpace && p.colorSpace !== "srgb") || (e.bias === void 0 && (e.bias = dc()), e.bias === null)) return null;
|
|
3237
3241
|
const r = e.bias, o = +(t[0].width === 1024) | +(t[1].width === 1024) << 1;
|
|
3238
|
-
!e.selection || e.selection.map !== n ? (e.selection = { map: n, nativeMask: o, targets:
|
|
3242
|
+
!e.selection || e.selection.map !== n ? (e.selection = { map: n, nativeMask: o, targets: bn(n, o) }, e.buffers = [], e.plans = []) : e.selection.nativeMask !== o && (e.selection = { map: n, nativeMask: o, targets: bn(n, o) });
|
|
3239
3243
|
const s = e.buffers || (e.buffers = []), a = (i == null ? void 0 : i.pixels) === s[0] ? 1 : 0, c = s[a] || (s[a] = new Uint8ClampedArray(1024 * 512 * 4)), l = new Uint32Array(c.buffer, c.byteOffset, c.byteLength / 4), u = r * 65537, f = r * 16843009, y = e.plans || (e.plans = []);
|
|
3240
3244
|
for (let p = 0; p < 2; p++) {
|
|
3241
|
-
const
|
|
3245
|
+
const h = t[p], d = h.data, m = h.width, g = e.selection.targets[p], b = m === 1024;
|
|
3242
3246
|
let x = y[p];
|
|
3243
|
-
if ((x == null ? void 0 : x.width) !==
|
|
3247
|
+
if ((x == null ? void 0 : x.width) !== m)
|
|
3244
3248
|
if (b)
|
|
3245
|
-
x = y[p] = { width:
|
|
3249
|
+
x = y[p] = { width: m };
|
|
3246
3250
|
else {
|
|
3247
|
-
const F = Uint32Array.from({ length: 1024 }, (k, P) => Math.floor(P *
|
|
3251
|
+
const F = Uint32Array.from({ length: 1024 }, (k, P) => Math.floor(P * m / 1024)), T = new Uint32Array(g.length), L = new Uint32Array(512), _ = new Uint32Array(512);
|
|
3248
3252
|
for (let k = 0; k < 512; k++) {
|
|
3249
3253
|
const P = F[k * 2 + 1] - F[k * 2];
|
|
3250
|
-
L[k] = P, _[k] = P *
|
|
3254
|
+
L[k] = P, _[k] = P * m;
|
|
3251
3255
|
}
|
|
3252
3256
|
for (let k = 0; k < g.length; k++) {
|
|
3253
3257
|
const P = g[k] >>> 2, E = P & 511, j = P >>> 10;
|
|
3254
|
-
T[k] = F[j * 2] *
|
|
3258
|
+
T[k] = F[j * 2] * m + F[E * 2];
|
|
3255
3259
|
}
|
|
3256
|
-
x = y[p] = { width:
|
|
3260
|
+
x = y[p] = { width: m, origins: T, columns: L, rows: _ };
|
|
3257
3261
|
}
|
|
3258
3262
|
const { origins: v, columns: w, rows: S } = x, D = (d instanceof Uint8Array || d instanceof Uint8ClampedArray) && d.byteOffset % 4 === 0 ? new Uint32Array(d.buffer, d.byteOffset, d.byteLength / 4) : null;
|
|
3259
3263
|
if (D) {
|
|
@@ -3263,8 +3267,8 @@ function dc(t, e, i = null, n = null) {
|
|
|
3263
3267
|
for (let L = F * 2048, _ = F * 1024 + p * 512; L < T; L += 8, _ += 4) {
|
|
3264
3268
|
const k = D[L], P = D[L + 1], E = D[L + 1024], j = D[L + 1025];
|
|
3265
3269
|
if ((k & P & E & j & Be) !== Be) return null;
|
|
3266
|
-
const
|
|
3267
|
-
l[_] =
|
|
3270
|
+
const q = ((k & 4244438268) >>> 2) + ((P & 4244438268) >>> 2) + ((E & 4244438268) >>> 2) + ((j & 4244438268) >>> 2), G = (k & 50529027) + (P & 50529027) + (E & 50529027) + (j & 50529027) + f >>> 2 & 50529027;
|
|
3271
|
+
l[_] = q + G;
|
|
3268
3272
|
const te = D[L + 4], ne = D[L + 5], ue = D[L + 1028], J = D[L + 1029];
|
|
3269
3273
|
if ((te & ne & ue & J & Be) !== Be) return null;
|
|
3270
3274
|
const Z = ((te & 4244438268) >>> 2) + ((ne & 4244438268) >>> 2) + ((ue & 4244438268) >>> 2) + ((J & 4244438268) >>> 2), Tt = (te & 50529027) + (ne & 50529027) + (ue & 50529027) + (J & 50529027) + f >>> 2 & 50529027;
|
|
@@ -3274,50 +3278,50 @@ function dc(t, e, i = null, n = null) {
|
|
|
3274
3278
|
for (let F = n ? 65536 : 0; F < g.length; F++) {
|
|
3275
3279
|
const T = g[F] >>> 2, L = (T & -513) * 2, _ = L + 1, k = D[L], P = D[_], E = D[L + 1024], j = D[_ + 1024];
|
|
3276
3280
|
if ((k & P & E & j & Be) !== Be) return null;
|
|
3277
|
-
const
|
|
3278
|
-
l[T] =
|
|
3281
|
+
const q = ((k & 4244438268) >>> 2) + ((P & 4244438268) >>> 2) + ((E & 4244438268) >>> 2) + ((j & 4244438268) >>> 2), G = (k & 50529027) + (P & 50529027) + (E & 50529027) + (j & 50529027) + f >>> 2 & 50529027;
|
|
3282
|
+
l[T] = q + G;
|
|
3279
3283
|
}
|
|
3280
3284
|
continue;
|
|
3281
3285
|
}
|
|
3282
|
-
if (
|
|
3283
|
-
const F = Math.floor(
|
|
3286
|
+
if (m % 512 === 0) {
|
|
3287
|
+
const F = Math.floor(m / 1024), T = F * m;
|
|
3284
3288
|
for (let L = 0; L < g.length; L++) {
|
|
3285
|
-
const _ = g[L] >>> 2, k = v[L], P = k + F, E = D[k], j = D[P],
|
|
3286
|
-
if ((E & j &
|
|
3287
|
-
const te = (E & 16711935) + (j & 16711935) + (
|
|
3289
|
+
const _ = g[L] >>> 2, k = v[L], P = k + F, E = D[k], j = D[P], q = D[k + T], G = D[P + T];
|
|
3290
|
+
if ((E & j & q & G & Be) !== Be) return null;
|
|
3291
|
+
const te = (E & 16711935) + (j & 16711935) + (q & 16711935) + (G & 16711935) + u, ne = (E >>> 8 & 16711935) + (j >>> 8 & 16711935) + (q >>> 8 & 16711935) + (G >>> 8 & 16711935) + u;
|
|
3288
3292
|
l[_] = te >>> 2 & 16711935 | (ne >>> 2 & 16711935) << 8;
|
|
3289
3293
|
}
|
|
3290
3294
|
continue;
|
|
3291
3295
|
}
|
|
3292
3296
|
for (let F = 0; F < g.length; F++) {
|
|
3293
|
-
const T = g[F] >>> 2, L = v[F], _ = L + w[T & 511], k = S[T >>> 10], P = D[L], E = D[_], j = D[L + k],
|
|
3294
|
-
if ((P & E & j &
|
|
3295
|
-
const
|
|
3296
|
-
l[T] =
|
|
3297
|
+
const T = g[F] >>> 2, L = v[F], _ = L + w[T & 511], k = S[T >>> 10], P = D[L], E = D[_], j = D[L + k], q = D[_ + k];
|
|
3298
|
+
if ((P & E & j & q & Be) !== Be) return null;
|
|
3299
|
+
const G = (P & 16711935) + (E & 16711935) + (j & 16711935) + (q & 16711935) + u, te = (P >>> 8 & 16711935) + (E >>> 8 & 16711935) + (j >>> 8 & 16711935) + (q >>> 8 & 16711935) + u;
|
|
3300
|
+
l[T] = G >>> 2 & 16711935 | (te >>> 2 & 16711935) << 8;
|
|
3297
3301
|
}
|
|
3298
3302
|
continue;
|
|
3299
3303
|
}
|
|
3300
3304
|
for (let F = 0; F < g.length; F++) {
|
|
3301
3305
|
const T = g[F], L = T >>> 2, _ = (b ? (L & -513) * 2 : v[F]) * 4, k = _ + (b ? 1 : w[L & 511]) * 4, P = (b ? 1024 : S[L >>> 10]) * 4, E = _ + P, j = k + P;
|
|
3302
3306
|
if ((d[_ + 3] & d[k + 3] & d[E + 3] & d[j + 3]) !== 255) return null;
|
|
3303
|
-
for (let
|
|
3304
|
-
c[T +
|
|
3307
|
+
for (let q = 0; q < 3; q++)
|
|
3308
|
+
c[T + q] = d[_ + q] + d[k + q] + d[E + q] + d[j + q] + r >> 2;
|
|
3305
3309
|
c[T + 3] = 255;
|
|
3306
3310
|
}
|
|
3307
3311
|
}
|
|
3308
3312
|
return { pixels: c, width: 1024, height: 512 };
|
|
3309
3313
|
}
|
|
3310
|
-
function
|
|
3314
|
+
function Gt(t, e = Ea, i = null) {
|
|
3311
3315
|
var u, f, y;
|
|
3312
|
-
const n =
|
|
3316
|
+
const n = Yi(t), r = Math.min(1, e / Math.max(n.width, n.height)), o = Math.max(1, Math.round(n.width * r)), s = Math.max(1, Math.round(n.height * r)), a = ((u = i == null ? void 0 : i.readback) == null ? void 0 : u.surface) || (typeof OffscreenCanvas < "u" ? new OffscreenCanvas(o, s) : Object.assign(document.createElement("canvas"), { width: o, height: s }));
|
|
3313
3317
|
a.width !== o && (a.width = o), a.height !== s && (a.height = s);
|
|
3314
3318
|
const c = ((f = i == null ? void 0 : i.readback) == null ? void 0 : f.context) || a.getContext("2d", { willReadFrequently: !0 });
|
|
3315
3319
|
if (!c) return null;
|
|
3316
3320
|
i && (i.readback = { surface: a, context: c }), (y = c.clearRect) == null || y.call(c, 0, 0, o, s);
|
|
3317
|
-
const l =
|
|
3321
|
+
const l = qn.has(t);
|
|
3318
3322
|
return l && (c.save(), c.translate(0, s), c.scale(1, -1)), c.drawImage(t, 0, 0, o, s), l && c.restore(), { pixels: c.getImageData(0, 0, o, s).data, width: o, height: s };
|
|
3319
3323
|
}
|
|
3320
|
-
function
|
|
3324
|
+
function $n(t, e) {
|
|
3321
3325
|
const { width: i, height: n } = t;
|
|
3322
3326
|
if (e.width !== i || e.height !== n) return null;
|
|
3323
3327
|
const r = 3, o = 49, s = 64, a = 6, c = (g) => {
|
|
@@ -3357,7 +3361,7 @@ function Xn(t, e) {
|
|
|
3357
3361
|
for (const g of f)
|
|
3358
3362
|
if (!y.some((b) => Math.abs(b.x - g.x) < 7 && Math.abs(b.y - g.y) < 7) && (y.push(g), y.length === 48))
|
|
3359
3363
|
break;
|
|
3360
|
-
const p = [],
|
|
3364
|
+
const p = [], h = s * 2 + 1;
|
|
3361
3365
|
for (const { x: g, y: b } of y) {
|
|
3362
3366
|
const x = b * i + g, v = [];
|
|
3363
3367
|
for (let k = -r; k <= r; k += 1)
|
|
@@ -3366,23 +3370,23 @@ function Xn(t, e) {
|
|
|
3366
3370
|
const w = (k, P) => {
|
|
3367
3371
|
const E = (b + P) * i + g + k;
|
|
3368
3372
|
if (u.energies[E] < o * 9) return -1;
|
|
3369
|
-
let j = 0,
|
|
3370
|
-
for (let
|
|
3373
|
+
let j = 0, q = 0;
|
|
3374
|
+
for (let G = -r; G <= r; G += 1)
|
|
3371
3375
|
for (let te = -r; te <= r; te += 1)
|
|
3372
|
-
j += v[
|
|
3376
|
+
j += v[q++] * e.gray[E + G * i + te];
|
|
3373
3377
|
return j / Math.sqrt(l.energies[x] * u.energies[E]);
|
|
3374
|
-
}, S = new Float32Array(
|
|
3378
|
+
}, S = new Float32Array(h * (a * 2 + 1));
|
|
3375
3379
|
let D = -1, F = 0, T = 0;
|
|
3376
3380
|
for (let k = -a; k <= a; k += 1)
|
|
3377
3381
|
for (let P = -s; P <= s; P += 1) {
|
|
3378
3382
|
const E = w(P, k);
|
|
3379
|
-
S[(k + a) *
|
|
3383
|
+
S[(k + a) * h + P + s] = E, E > D && (D = E, F = P, T = k);
|
|
3380
3384
|
}
|
|
3381
3385
|
if (D < 0.85 || Math.abs(F) === s || Math.abs(T) === a) continue;
|
|
3382
3386
|
let L = -1;
|
|
3383
3387
|
for (let k = -a; k <= a; k += 1)
|
|
3384
3388
|
for (let P = -s; P <= s; P += 1)
|
|
3385
|
-
Math.abs(P - F) <= 3 && Math.abs(k - T) <= 2 || (L = Math.max(L, S[(k + a) *
|
|
3389
|
+
Math.abs(P - F) <= 3 && Math.abs(k - T) <= 2 || (L = Math.max(L, S[(k + a) * h + P + s]));
|
|
3386
3390
|
if (D - L < 0.015) continue;
|
|
3387
3391
|
const _ = (k, P, E) => Math.abs(k - 2 * P + E) > 1e-6 ? O(0.5 * (k - E) / (k - 2 * P + E), -0.5, 0.5) : 0;
|
|
3388
3392
|
p.push({
|
|
@@ -3398,11 +3402,11 @@ function Xn(t, e) {
|
|
|
3398
3402
|
b.length > d.length && (d = b);
|
|
3399
3403
|
}
|
|
3400
3404
|
if (d.length < Math.max(6, p.length * 0.35) || Math.max(...d.map((g) => g.y)) - Math.min(...d.map((g) => g.y)) < 24) return null;
|
|
3401
|
-
const
|
|
3405
|
+
const m = (g) => (g.sort((b, x) => b - x), (g[Math.floor((g.length - 1) / 2)] + g[Math.floor(g.length / 2)]) / 2);
|
|
3402
3406
|
return {
|
|
3403
|
-
dx:
|
|
3404
|
-
dy:
|
|
3405
|
-
gainRatio:
|
|
3407
|
+
dx: m(d.map((g) => g.dx)),
|
|
3408
|
+
dy: m(d.map((g) => g.dy)),
|
|
3409
|
+
gainRatio: m(d.map((g) => g.gainRatio)),
|
|
3406
3410
|
inliers: d.length
|
|
3407
3411
|
};
|
|
3408
3412
|
}
|
|
@@ -3410,16 +3414,16 @@ function Vt(t) {
|
|
|
3410
3414
|
const [e, i] = t.center, n = e < 0.5 ? 0 : 0.5;
|
|
3411
3415
|
return [Math.min(0.25, e - n, n + 0.5 - e), Math.min(0.5, i, 1 - i)];
|
|
3412
3416
|
}
|
|
3413
|
-
function
|
|
3417
|
+
function Ca(t, e, i, n) {
|
|
3414
3418
|
const s = [], a = [];
|
|
3415
3419
|
for (const c of [-90, 90]) {
|
|
3416
3420
|
const l = i.map(() => ({ width: 193, height: 241, gray: new Float32Array(46513), valid: new Uint8Array(46513) }));
|
|
3417
3421
|
for (let f = 0; f < 241; f += 1) {
|
|
3418
3422
|
const y = (-60 + f * 0.5) * Math.PI / 180;
|
|
3419
3423
|
for (let p = 0; p < 193; p += 1) {
|
|
3420
|
-
const
|
|
3421
|
-
for (let
|
|
3422
|
-
const g = i[
|
|
3424
|
+
const h = (c - 12 + p * 0.125) * Math.PI / 180, d = [Math.cos(y) * Math.sin(h), Math.sin(y), Math.cos(y) * Math.cos(h)];
|
|
3425
|
+
for (let m = 0; m < 2; m += 1) {
|
|
3426
|
+
const g = i[m], b = St(
|
|
3423
3427
|
d,
|
|
3424
3428
|
g,
|
|
3425
3429
|
Math.PI,
|
|
@@ -3429,42 +3433,42 @@ function Ea(t, e, i, n) {
|
|
|
3429
3433
|
);
|
|
3430
3434
|
if (!b) continue;
|
|
3431
3435
|
const x = b.uv.slice();
|
|
3432
|
-
e.dualFisheyeFlipX && (x[0] = 2 * i[
|
|
3436
|
+
e.dualFisheyeFlipX && (x[0] = 2 * i[m].center[0] - x[0]), e.dualFisheyeFlipY && (x[1] = 2 * i[m].center[1] - x[1]);
|
|
3433
3437
|
const v = [0, 0, 0];
|
|
3434
|
-
|
|
3438
|
+
Di(t.pixels, t.width, t.height, x[0], n === "bottom-left" ? 1 - x[1] : x[1], v);
|
|
3435
3439
|
const w = f * 193 + p;
|
|
3436
|
-
l[
|
|
3440
|
+
l[m].gray[w] = v[0] * 0.2126 + v[1] * 0.7152 + v[2] * 0.0722, l[m].valid[w] = 1;
|
|
3437
3441
|
}
|
|
3438
3442
|
}
|
|
3439
3443
|
}
|
|
3440
|
-
const u =
|
|
3444
|
+
const u = $n(...l);
|
|
3441
3445
|
if (!u) return null;
|
|
3442
3446
|
s.push(u.dx * 0.125 * Math.PI / 180, u.dy * 0.5 * Math.PI / 180), a.push(u.gainRatio);
|
|
3443
3447
|
}
|
|
3444
3448
|
return { offsets: s, ratios: a };
|
|
3445
3449
|
}
|
|
3446
|
-
function
|
|
3447
|
-
const r =
|
|
3450
|
+
function hc(t, e, i, n) {
|
|
3451
|
+
const r = Gt(t, 2048);
|
|
3448
3452
|
if (!r) return null;
|
|
3449
3453
|
if (r.pixels[3] === 0) return;
|
|
3450
|
-
const o = n.map((f) => ({ ...f, validRadius: Vt(f) })), s =
|
|
3454
|
+
const o = n.map((f) => ({ ...f, validRadius: Vt(f) })), s = Ca(r, e, o, i.textureOrigin);
|
|
3451
3455
|
if (!s) return null;
|
|
3452
3456
|
const { offsets: a, ratios: c } = s, l = Math.sqrt(O(Math.sqrt(c[0] * c[1]), 0.64, 1.5625)), u = [-1, 1].map((f) => {
|
|
3453
|
-
const y =
|
|
3457
|
+
const y = Yn(r, o, i.textureOrigin, f, e, a);
|
|
3454
3458
|
return y > 0 ? 1 / y : 0;
|
|
3455
3459
|
});
|
|
3456
3460
|
return { offsets: a, polarInverseDepth: u, gain: e.dualFisheyeAutoGain ? [l, 1 / l] : [e.dualFisheyeGainFront, e.dualFisheyeGainBack] };
|
|
3457
3461
|
}
|
|
3458
|
-
function
|
|
3459
|
-
const r =
|
|
3462
|
+
function mc(t, e, i, n) {
|
|
3463
|
+
const r = Gt(t, 2048);
|
|
3460
3464
|
if (!r) return null;
|
|
3461
3465
|
if (r.pixels[3] !== 0)
|
|
3462
|
-
return
|
|
3466
|
+
return pc(r, e, i, n);
|
|
3463
3467
|
}
|
|
3464
|
-
function
|
|
3465
|
-
const r = n.map((l) => ({ ...l, validRadius: Vt(l) })), o =
|
|
3468
|
+
function pc(t, e, i, n) {
|
|
3469
|
+
const r = n.map((l) => ({ ...l, validRadius: Vt(l) })), o = Qn(t, r, e, i.textureOrigin, Math.PI), s = r.map((l) => ({ ...l, focal: l.focal.map((u) => u * o) })), a = Ca(t, e, s, i.textureOrigin);
|
|
3466
3470
|
if (!a) return null;
|
|
3467
|
-
const c = e.dualFisheyeAutoGain ?
|
|
3471
|
+
const c = e.dualFisheyeAutoGain ? za(
|
|
3468
3472
|
t,
|
|
3469
3473
|
e,
|
|
3470
3474
|
i,
|
|
@@ -3480,24 +3484,24 @@ function mc(t, e, i, n) {
|
|
|
3480
3484
|
gain: (c == null ? void 0 : c.gain) || [e.dualFisheyeGainFront, e.dualFisheyeGainBack]
|
|
3481
3485
|
};
|
|
3482
3486
|
}
|
|
3483
|
-
function
|
|
3484
|
-
if (e.reduce((
|
|
3485
|
-
const a = (
|
|
3486
|
-
const
|
|
3487
|
+
function Yn(t, e, i, n = 0, r = {}, o = null) {
|
|
3488
|
+
if (e.reduce((h, d) => h + (d.translationM || []).reduce((m, g) => m + g * g, 0), 0) < 1e-8) return 0;
|
|
3489
|
+
const a = (h, d) => {
|
|
3490
|
+
const m = [];
|
|
3487
3491
|
for (let g = 0; g < e.length; g += 1) {
|
|
3488
|
-
const b = e[g], x = g === 1 && o ?
|
|
3492
|
+
const b = e[g], x = g === 1 && o ? Hi(h, o) : h, v = St(x, b, Math.PI, !0, !1, 1, d > 0 ? 1 / d : 0);
|
|
3489
3493
|
if (!v) return null;
|
|
3490
3494
|
r.dualFisheyeFlipX && (v.uv[0] = 2 * b.center[0] - v.uv[0]), r.dualFisheyeFlipY && (v.uv[1] = 2 * b.center[1] - v.uv[1]);
|
|
3491
3495
|
const w = [0, 0, 0];
|
|
3492
|
-
|
|
3496
|
+
Di(t.pixels, t.width, t.height, v.uv[0], i === "bottom-left" ? 1 - v.uv[1] : v.uv[1], w), m.push(w);
|
|
3493
3497
|
}
|
|
3494
|
-
return
|
|
3498
|
+
return m;
|
|
3495
3499
|
}, c = [];
|
|
3496
3500
|
if (n)
|
|
3497
|
-
for (let
|
|
3498
|
-
const d = n * (60 + 30 *
|
|
3499
|
-
for (let
|
|
3500
|
-
const g = (
|
|
3501
|
+
for (let h = 0; h < 9; h += 1) {
|
|
3502
|
+
const d = n * (60 + 30 * h / 8) * Math.PI / 180;
|
|
3503
|
+
for (let m = 0; m < 128; m += 1) {
|
|
3504
|
+
const g = (m / 128 - 0.5) * 2 * Math.PI, b = [Math.cos(d) * Math.sin(g), Math.sin(d), Math.cos(d) * Math.cos(g)];
|
|
3501
3505
|
let x = !0;
|
|
3502
3506
|
for (let v = 0; v <= 16; v += 1)
|
|
3503
3507
|
if (!a(b, v / 4)) {
|
|
@@ -3508,11 +3512,11 @@ function $n(t, e, i, n = 0, r = {}, o = null) {
|
|
|
3508
3512
|
}
|
|
3509
3513
|
}
|
|
3510
3514
|
else
|
|
3511
|
-
for (let
|
|
3512
|
-
const d = (-55 + 110 *
|
|
3513
|
-
for (const
|
|
3515
|
+
for (let h = 0; h < 64; h += 1) {
|
|
3516
|
+
const d = (-55 + 110 * h / 63) * Math.PI / 180;
|
|
3517
|
+
for (const m of [-90, 90])
|
|
3514
3518
|
for (let g = 0; g < 9; g += 1) {
|
|
3515
|
-
const b = (
|
|
3519
|
+
const b = (m - 4 + g) * Math.PI / 180, x = [Math.cos(d) * Math.sin(b), Math.sin(d), Math.cos(d) * Math.cos(b)];
|
|
3516
3520
|
let v = !0;
|
|
3517
3521
|
for (let w = 0; w <= 16; w += 1)
|
|
3518
3522
|
if (!a(x, w / 4)) {
|
|
@@ -3523,70 +3527,70 @@ function $n(t, e, i, n = 0, r = {}, o = null) {
|
|
|
3523
3527
|
}
|
|
3524
3528
|
}
|
|
3525
3529
|
if (c.length < 64) return 0;
|
|
3526
|
-
const l = (
|
|
3527
|
-
const d = [],
|
|
3530
|
+
const l = (h) => {
|
|
3531
|
+
const d = [], m = [0, 0];
|
|
3528
3532
|
for (const v of c) {
|
|
3529
|
-
const w = a(v,
|
|
3533
|
+
const w = a(v, h);
|
|
3530
3534
|
if (!w) return 1 / 0;
|
|
3531
3535
|
d.push(w);
|
|
3532
|
-
for (let S = 0; S < 2; S += 1) for (const D of w[S])
|
|
3536
|
+
for (let S = 0; S < 2; S += 1) for (const D of w[S]) m[S] += D;
|
|
3533
3537
|
}
|
|
3534
|
-
if (
|
|
3535
|
-
const g = Math.sqrt(O(
|
|
3538
|
+
if (m[0] <= c.length * 3 || m[1] <= c.length * 3) return 1 / 0;
|
|
3539
|
+
const g = Math.sqrt(O(m[1] / m[0], 0.64, 1.5625)), b = d.map((v) => v[0].reduce((w, S, D) => w + Math.abs(S * g - v[1][D] / g) / 3, 0)).sort((v, w) => v - w), x = Math.floor(b.length * 0.8);
|
|
3536
3540
|
return b.slice(0, x).reduce((v, w) => v + w, 0) / x;
|
|
3537
3541
|
}, u = l(0);
|
|
3538
3542
|
let f = u, y = 0;
|
|
3539
|
-
for (let
|
|
3540
|
-
const d =
|
|
3541
|
-
|
|
3543
|
+
for (let h = 1; h <= 16; h += 1) {
|
|
3544
|
+
const d = h / 4, m = l(d);
|
|
3545
|
+
m < f && (f = m, y = d);
|
|
3542
3546
|
}
|
|
3543
3547
|
const p = y;
|
|
3544
|
-
for (let
|
|
3545
|
-
const d = p +
|
|
3548
|
+
for (let h = -4; h <= 4; h += 1) {
|
|
3549
|
+
const d = p + h * 0.05;
|
|
3546
3550
|
if (d <= 0 || d > 4) continue;
|
|
3547
|
-
const
|
|
3548
|
-
|
|
3551
|
+
const m = l(d);
|
|
3552
|
+
m < f && (f = m, y = d);
|
|
3549
3553
|
}
|
|
3550
3554
|
return y === 0 || !Number.isFinite(u) || u - f < 0.5 || f > u * 0.9 ? 0 : 1 / y;
|
|
3551
3555
|
}
|
|
3552
|
-
function
|
|
3556
|
+
function yc(t, e, i, n = !1) {
|
|
3553
3557
|
const r = i[t[1] > 0 ? 1 : 0];
|
|
3554
3558
|
if (!(r > 0)) return e;
|
|
3555
3559
|
const o = Math.sin((n ? 50 : 30) * Math.PI / 180), s = Math.sin((n ? 65 : 50) * Math.PI / 180), a = O((Math.abs(t[1]) - o) / (s - o), 0, 1), c = (e > 0 ? 1 / e : 0) * (1 - a * a * (3 - 2 * a)) + r * a * a * (3 - 2 * a);
|
|
3556
3560
|
return c > 0 ? 1 / c : 0;
|
|
3557
3561
|
}
|
|
3558
|
-
function
|
|
3562
|
+
function gc(t, e, i, n) {
|
|
3559
3563
|
const r = e.map((f) => {
|
|
3560
|
-
const y = f.rotationQuat, p =
|
|
3564
|
+
const y = f.rotationQuat, p = Ba({ w: y[0], x: y[1], y: y[2], z: y[3] }, ...f.translationM || [0, 0, 0]);
|
|
3561
3565
|
return [p.x, p.y, p.z];
|
|
3562
3566
|
}), o = r[1].map((f, y) => f - r[0][y]), s = Math.hypot(o[0], o[2]);
|
|
3563
3567
|
if (s < 1e-3 || Math.abs(o[1]) > s * 0.1) return [0, 0];
|
|
3564
3568
|
const a = [o[0] / s, o[2] / s], c = 193, l = 193, u = Math.tan(25 * Math.PI / 180);
|
|
3565
3569
|
return [-1, 1].map((f) => {
|
|
3566
3570
|
const y = e.map(() => ({ width: c, height: l, gray: new Float32Array(c * l), valid: new Uint8Array(c * l) }));
|
|
3567
|
-
for (let d = 0; d < l; d += 1) for (let
|
|
3568
|
-
const g = (2 *
|
|
3571
|
+
for (let d = 0; d < l; d += 1) for (let m = 0; m < c; m += 1) {
|
|
3572
|
+
const g = (2 * m / (c - 1) - 1) * u, b = (2 * d / (l - 1) - 1) * u, x = [a[0] * g + a[1] * b, f, a[1] * g - a[0] * b], v = Math.hypot(...x);
|
|
3569
3573
|
for (let w = 0; w < 3; w += 1) x[w] /= v;
|
|
3570
3574
|
for (let w = 0; w < 2; w += 1) {
|
|
3571
3575
|
const S = e[w], D = St(x, S, Math.PI, !0, !1, 1);
|
|
3572
3576
|
if (!D) continue;
|
|
3573
3577
|
i.dualFisheyeFlipX && (D.uv[0] = 2 * S.center[0] - D.uv[0]), i.dualFisheyeFlipY && (D.uv[1] = 2 * S.center[1] - D.uv[1]);
|
|
3574
3578
|
const F = [0, 0, 0];
|
|
3575
|
-
|
|
3576
|
-
const T = d * c +
|
|
3579
|
+
Di(t.pixels, t.width, t.height, D.uv[0], n === "bottom-left" ? 1 - D.uv[1] : D.uv[1], F);
|
|
3580
|
+
const T = d * c + m;
|
|
3577
3581
|
y[w].gray[T] = F[0] * 0.2126 + F[1] * 0.7152 + F[2] * 0.0722, y[w].valid[T] = 1;
|
|
3578
3582
|
}
|
|
3579
3583
|
}
|
|
3580
|
-
const p =
|
|
3584
|
+
const p = $n(...y);
|
|
3581
3585
|
if (!p || Math.abs(p.dy) > 1.5) return 0;
|
|
3582
|
-
const
|
|
3583
|
-
return
|
|
3586
|
+
const h = p.dx * 2 * u / (c - 1) / s;
|
|
3587
|
+
return h >= 0.05 && h <= 4 ? h : 0;
|
|
3584
3588
|
});
|
|
3585
3589
|
}
|
|
3586
|
-
function
|
|
3587
|
-
const o = Array.from({ length: 13 }, (p,
|
|
3588
|
-
const
|
|
3589
|
-
for (const g of
|
|
3590
|
+
function Qn(t, e, i, n, r) {
|
|
3591
|
+
const o = Array.from({ length: 13 }, (p, h) => 0.97 + h * 5e-3), s = o.map((p) => e.map((h) => ({ ...h, focal: h.focal.map((d) => d * p) }))), a = (p, h, d) => {
|
|
3592
|
+
const m = [];
|
|
3593
|
+
for (const g of h) {
|
|
3590
3594
|
const b = St(
|
|
3591
3595
|
p,
|
|
3592
3596
|
g,
|
|
@@ -3599,38 +3603,38 @@ function Yn(t, e, i, n, r) {
|
|
|
3599
3603
|
if (!d) continue;
|
|
3600
3604
|
i.dualFisheyeFlipX && (b.uv[0] = 2 * g.center[0] - b.uv[0]), i.dualFisheyeFlipY && (b.uv[1] = 2 * g.center[1] - b.uv[1]);
|
|
3601
3605
|
const x = [0, 0, 0];
|
|
3602
|
-
|
|
3606
|
+
Di(t.pixels, t.width, t.height, b.uv[0], n === "bottom-left" ? 1 - b.uv[1] : b.uv[1], x), m.push(x);
|
|
3603
3607
|
}
|
|
3604
|
-
return
|
|
3608
|
+
return m;
|
|
3605
3609
|
}, c = [];
|
|
3606
|
-
for (const p of
|
|
3607
|
-
const
|
|
3610
|
+
for (const p of ia(i.dualFisheyeSeamLongitudesDeg)) {
|
|
3611
|
+
const h = [];
|
|
3608
3612
|
for (let d = -60; d <= 60; d += 4)
|
|
3609
|
-
for (let
|
|
3613
|
+
for (let m = -2; m <= 2; m += 0.5) {
|
|
3610
3614
|
const g = Gn(
|
|
3611
|
-
(p +
|
|
3615
|
+
(p + m) / 360 + 0.5,
|
|
3612
3616
|
0.5 - d / 180,
|
|
3613
3617
|
e.some((b) => b.projectionModel === "dji_fisheye_lut")
|
|
3614
3618
|
);
|
|
3615
|
-
i.equirectFlipX && (g[0] *= -1), i.equirectFlipY && (g[1] *= -1), s.every((b) => a(g, b, !1)) &&
|
|
3619
|
+
i.equirectFlipX && (g[0] *= -1), i.equirectFlipY && (g[1] *= -1), s.every((b) => a(g, b, !1)) && h.push(g);
|
|
3616
3620
|
}
|
|
3617
|
-
if (
|
|
3618
|
-
c.push(...
|
|
3621
|
+
if (h.length < 16) return 1;
|
|
3622
|
+
c.push(...h);
|
|
3619
3623
|
}
|
|
3620
3624
|
const l = (p) => {
|
|
3621
|
-
const
|
|
3622
|
-
if (Math.min(...d) <
|
|
3623
|
-
const
|
|
3625
|
+
const h = c.map((x) => a(x, p, !0)), d = h.reduce((x, v) => x.map((w, S) => w + v[S].reduce((D, F) => D + F, 0)), [0, 0]);
|
|
3626
|
+
if (Math.min(...d) < h.length * 15) return Number.POSITIVE_INFINITY;
|
|
3627
|
+
const m = Math.sqrt(O(d[1] / d[0], 0.64, 1.5625)), g = h.map((x) => x[0].reduce((v, w, S) => v + Math.abs(w * m - x[1][S] / m) / 3, 0)).sort((x, v) => x - v), b = Math.floor(g.length * 0.8);
|
|
3624
3628
|
return g.slice(0, b).reduce((x, v) => x + v, 0) / b;
|
|
3625
3629
|
}, u = l(e);
|
|
3626
3630
|
if (!Number.isFinite(u) || u < 0.75) return 1;
|
|
3627
3631
|
let f = 6, y = u;
|
|
3628
|
-
return s.forEach((p,
|
|
3632
|
+
return s.forEach((p, h) => {
|
|
3629
3633
|
const d = l(p);
|
|
3630
|
-
d < y && (f =
|
|
3634
|
+
d < y && (f = h, y = d);
|
|
3631
3635
|
}), f === 0 || f === o.length - 1 || u - y < 0.75 || y > u * 0.85 ? 1 : o[f];
|
|
3632
3636
|
}
|
|
3633
|
-
function
|
|
3637
|
+
function vc(t, e, i, n, r, o, s) {
|
|
3634
3638
|
var x, v, w;
|
|
3635
3639
|
const a = !n && [r, o].every((S) => {
|
|
3636
3640
|
var D;
|
|
@@ -3638,17 +3642,17 @@ function gc(t, e, i, n, r, o, s) {
|
|
|
3638
3642
|
}), c = !!(e.dualFisheyeRefineFocal && i && !n && [r, o].every((S) => {
|
|
3639
3643
|
var D;
|
|
3640
3644
|
return (S.projectionModel || "equidistant") === "equidistant" && ((D = S.focal) == null ? void 0 : D.every((F) => F > 0));
|
|
3641
|
-
})), l =
|
|
3645
|
+
})), l = Gt(t, a || c ? 1024 : Ea);
|
|
3642
3646
|
if (!l) return null;
|
|
3643
|
-
let u = c ?
|
|
3647
|
+
let u = c ? Qn(l, [r, o], e, i.textureOrigin, s) : 1;
|
|
3644
3648
|
if (u !== 1) {
|
|
3645
3649
|
const S = { ...r, focal: r.focal.map((F) => F * u) }, D = { ...o, focal: o.focal.map((F) => F * u) };
|
|
3646
|
-
|
|
3650
|
+
xc(e, i, S, D, s) ? (r = S, o = D) : u = 1;
|
|
3647
3651
|
}
|
|
3648
|
-
const f = a ?
|
|
3652
|
+
const f = a ? Yn(l, [r, o], i == null ? void 0 : i.textureOrigin) : 0, p = i && !n && [r, o].every((S) => S.projectionModel === "mei_extended" && S.distortionModel !== "radtan_pro" && Array.isArray(S.rotationQuat)) && [r, o].some((S) => {
|
|
3649
3653
|
var D;
|
|
3650
3654
|
return (D = S.translationM) == null ? void 0 : D.some((F) => Math.abs(F) > 1e-3);
|
|
3651
|
-
}) ?
|
|
3655
|
+
}) ? Gt(t, 1024) : null, h = p ? gc(p, [r, o], e, i.textureOrigin) : [0, 0], d = i && !n && ((x = i.imageSize) == null ? void 0 : x[0]) === 2 * ((v = i.imageSize) == null ? void 0 : v[1]) && [r, o].every((S) => S.projectionModel === "mei_extended" && S.distortionModel !== "radtan_pro" && Array.isArray(S.rotationQuat)), m = d ? Gt(t, 2048) : null, g = m ? ((w = Ca(m, e, [r, o], i.textureOrigin)) == null ? void 0 : w.offsets) || [0, 0, 0, 0] : [0, 0, 0, 0], b = za(
|
|
3652
3656
|
l,
|
|
3653
3657
|
e,
|
|
3654
3658
|
i,
|
|
@@ -3656,12 +3660,12 @@ function gc(t, e, i, n, r, o, s) {
|
|
|
3656
3660
|
r,
|
|
3657
3661
|
o,
|
|
3658
3662
|
s,
|
|
3659
|
-
{ convergenceM: f, polarInverseDepth:
|
|
3663
|
+
{ convergenceM: f, polarInverseDepth: h, imageOffsets: d ? g : null }
|
|
3660
3664
|
);
|
|
3661
|
-
return b ? { ...b, convergenceM: f, polarInverseDepth:
|
|
3665
|
+
return b ? { ...b, convergenceM: f, polarInverseDepth: h, focalScale: u, imageOffsets: g } : null;
|
|
3662
3666
|
}
|
|
3663
|
-
function
|
|
3664
|
-
const { weights: o } =
|
|
3667
|
+
function xc(t, e, i, n, r) {
|
|
3668
|
+
const { weights: o } = Ia(
|
|
3665
3669
|
t,
|
|
3666
3670
|
e,
|
|
3667
3671
|
null,
|
|
@@ -3676,11 +3680,11 @@ function vc(t, e, i, n, r) {
|
|
|
3676
3680
|
const y = u * z + l + f;
|
|
3677
3681
|
a[u * s + f] = o[0][y] > 0 && o[1][y] > 0 ? 1 : 65535;
|
|
3678
3682
|
}
|
|
3679
|
-
if (!
|
|
3683
|
+
if (!Xn(a, s, X, 2, c)) return !1;
|
|
3680
3684
|
}
|
|
3681
3685
|
return !0;
|
|
3682
3686
|
}
|
|
3683
|
-
function
|
|
3687
|
+
function Hn(t) {
|
|
3684
3688
|
const e = z * X, i = new Uint8Array(e);
|
|
3685
3689
|
for (let o = 0; o < e; o++)
|
|
3686
3690
|
t[0][o] <= 0 || t[1][o] <= 0 || (i[o] = 1, o % z && (i[o - 1] = 1), o >= z && (i[o - z] = 1));
|
|
@@ -3690,7 +3694,7 @@ function Qn(t) {
|
|
|
3690
3694
|
for (let o = 0, s = 0; o < e; o++) i[o] && (r[s++] = o);
|
|
3691
3695
|
return r;
|
|
3692
3696
|
}
|
|
3693
|
-
function
|
|
3697
|
+
function Ia(t, e, i, n, r, o, { convergenceM: s, polarInverseDepth: a, registrationOffsets: c, videoOffsets: l }, u) {
|
|
3694
3698
|
var w, S, D, F;
|
|
3695
3699
|
const f = u && !i ? JSON.stringify([
|
|
3696
3700
|
n,
|
|
@@ -3709,34 +3713,34 @@ function Ca(t, e, i, n, r, o, { convergenceM: s, polarInverseDepth: a, registrat
|
|
|
3709
3713
|
t.dualFisheyeFlipY
|
|
3710
3714
|
]) : null;
|
|
3711
3715
|
if (f && u.key === f) return u.map;
|
|
3712
|
-
const y = z * X, p = [new Float64Array(y * 2), new Float64Array(y * 2)],
|
|
3716
|
+
const y = z * X, p = [new Float64Array(y * 2), new Float64Array(y * 2)], h = [new Float32Array(y), new Float32Array(y)], d = [n, r], m = d.map((T) => T.projectionModel === "mei_extended"), g = d.map((T) => T.projectionModel === "dji_fisheye_lut"), b = m.some(Boolean) || g.some(Boolean);
|
|
3713
3717
|
for (let T = 0; T < X; T++) for (let L = 0; L < z; L++) {
|
|
3714
3718
|
const _ = Gn((L + 0.5) / z, (T + 0.5) / X, b);
|
|
3715
3719
|
t.equirectFlipX && (_[0] = -_[0]), t.equirectFlipY && (_[1] = -_[1]);
|
|
3716
|
-
const k =
|
|
3717
|
-
for (let
|
|
3718
|
-
const te =
|
|
3720
|
+
const k = Js(_, b), P = O(Math.floor(k[0] * z), 0, z - 1), j = O(Math.floor(k[1] * X), 0, X - 1) * z + P, q = Zs(i, k[0], k[1]);
|
|
3721
|
+
for (let G = 0; G < 2; G++) {
|
|
3722
|
+
const te = G === 1 && c ? Hi(_, c) : _, ne = d[G], ue = q ? q[G].valid ? { uv: q[G].uv, confidence: q[G].confidence } : null : St(
|
|
3719
3723
|
te,
|
|
3720
3724
|
ne,
|
|
3721
3725
|
o,
|
|
3722
|
-
|
|
3723
|
-
g[
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
+
m[G],
|
|
3727
|
+
g[G],
|
|
3728
|
+
G === 0 ? ((D = e == null ? void 0 : e.front) == null ? void 0 : D.radialScale) || 1 : ((F = e == null ? void 0 : e.back) == null ? void 0 : F.radialScale) || 1,
|
|
3729
|
+
yc(te, s, a, !!l)
|
|
3726
3730
|
);
|
|
3727
3731
|
if (!ue) continue;
|
|
3728
3732
|
let [J, Z] = ue.uv;
|
|
3729
|
-
t.dualFisheyeFlipX && (J = 2 * ne.center[0] - J), t.dualFisheyeFlipY && (Z = 2 * ne.center[1] - Z), p[
|
|
3733
|
+
t.dualFisheyeFlipX && (J = 2 * ne.center[0] - J), t.dualFisheyeFlipY && (Z = 2 * ne.center[1] - Z), p[G][j * 2] = J, p[G][j * 2 + 1] = (e == null ? void 0 : e.textureOrigin) === "bottom-left" ? 1 - Z : Z, h[G][j] = ue.confidence;
|
|
3730
3734
|
}
|
|
3731
3735
|
}
|
|
3732
3736
|
let x = 0;
|
|
3733
3737
|
for (let T = 0; T < y; T++)
|
|
3734
|
-
|
|
3735
|
-
const v = { uv: p, weights:
|
|
3738
|
+
h[0][T] > 0 && h[1][T] > 0 && x++;
|
|
3739
|
+
const v = { uv: p, weights: h, overlapCount: x, gradientIndices: Hn(h) };
|
|
3736
3740
|
return f && (u.key = f, u.map = v), v;
|
|
3737
3741
|
}
|
|
3738
|
-
function
|
|
3739
|
-
const p = u || l,
|
|
3742
|
+
function za(t, e, i, n, r, o, s, { convergenceM: a = 0, polarInverseDepth: c = [0, 0], imageOffsets: l = null, videoOffsets: u = null, previousMask: f = null, mapCache: y = null } = {}) {
|
|
3743
|
+
const p = u || l, h = [new Float32Array(z * X * 3), new Float32Array(z * X * 3)], d = Ia(
|
|
3740
3744
|
e,
|
|
3741
3745
|
i,
|
|
3742
3746
|
n,
|
|
@@ -3745,8 +3749,8 @@ function Ia(t, e, i, n, r, o, s, { convergenceM: a = 0, polarInverseDepth: c = [
|
|
|
3745
3749
|
s,
|
|
3746
3750
|
{ convergenceM: a, polarInverseDepth: c, registrationOffsets: p, videoOffsets: u },
|
|
3747
3751
|
y
|
|
3748
|
-
), { weights:
|
|
3749
|
-
|
|
3752
|
+
), { weights: m } = d;
|
|
3753
|
+
Ks(t, d, h, !!(y && !n));
|
|
3750
3754
|
const g = new Float64Array(z * X);
|
|
3751
3755
|
g.fill(65535);
|
|
3752
3756
|
const b = !!(i && e.dualFisheyeAutoGain);
|
|
@@ -3755,45 +3759,45 @@ function Ia(t, e, i, n, r, o, s, { convergenceM: a = 0, polarInverseDepth: c = [
|
|
|
3755
3759
|
if (b || d.overlapCount === void 0) {
|
|
3756
3760
|
x = 0;
|
|
3757
3761
|
for (let ce = 0; ce < z * X; ce++)
|
|
3758
|
-
if (
|
|
3762
|
+
if (m[0][ce] > 0 && m[1][ce] > 0) {
|
|
3759
3763
|
if (x += 1, !b) continue;
|
|
3760
|
-
const $ = ce * 3, xe =
|
|
3764
|
+
const $ = ce * 3, xe = h[0][$] * 0.2126 + h[0][$ + 1] * 0.7152 + h[0][$ + 2] * 0.0722, pe = h[1][$] * 0.2126 + h[1][$ + 1] * 0.7152 + h[1][$ + 2] * 0.0722;
|
|
3761
3765
|
v += xe, w += pe;
|
|
3762
3766
|
}
|
|
3763
3767
|
}
|
|
3764
3768
|
if (x < 64) return null;
|
|
3765
3769
|
let D = e.dualFisheyeGainFront, F = e.dualFisheyeGainBack;
|
|
3766
3770
|
b && v > x && w > x && (D = Math.sqrt(O(w / v, 0.64, 1.5625)), F = 1 / D);
|
|
3767
|
-
const T = [new Float32Array(g.length), new Float32Array(g.length)], L = d.gradientIndices ||
|
|
3771
|
+
const T = [new Float32Array(g.length), new Float32Array(g.length)], L = d.gradientIndices || Hn(m), _ = new Float64Array(z);
|
|
3768
3772
|
let k = 0;
|
|
3769
3773
|
for (let ce = 0; ce < L.length; ce++) {
|
|
3770
|
-
const $ = L[ce], xe = $ % z, pe = $ * 3, re =
|
|
3771
|
-
if (k = it, _[xe] = it,
|
|
3772
|
-
const
|
|
3774
|
+
const $ = L[ce], xe = $ % z, pe = $ * 3, re = h[0][pe] * D, Te = h[0][pe + 1] * D, et = h[0][pe + 2] * D, tt = h[1][pe] * F, Qt = h[1][pe + 1] * F, Ht = h[1][pe + 2] * F, Le = re * 0.2126 + Te * 0.7152 + et * 0.0722, _e = tt * 0.2126 + Qt * 0.7152 + Ht * 0.0722, it = Le - _e, Ti = xe > 0 ? k : it, ki = $ >= z ? _[xe] : it;
|
|
3775
|
+
if (k = it, _[xe] = it, m[0][$] <= 0 || m[1][$] <= 0) continue;
|
|
3776
|
+
const Ri = (Math.abs(re - tt) + Math.abs(Te - Qt) + Math.abs(et - Ht)) / 3;
|
|
3773
3777
|
T[0][$] = Le < 12 && _e > 24 && Le < _e * 0.25 ? 128 * Math.min(1, (_e - Le) / 64) : 0, T[1][$] = _e < 12 && Le > 24 && _e < Le * 0.25 ? 128 * Math.min(1, (Le - _e) / 64) : 0, f && (T[0][$] += f[$] / 255 * 12, T[1][$] += (1 - f[$] / 255) * 12);
|
|
3774
|
-
const at = Math.abs(it) + Math.abs(
|
|
3775
|
-
g[$] = Math.min(65534,
|
|
3778
|
+
const at = Math.abs(it) + Math.abs(Ti) + Math.abs(ki), Pi = 128 * (1 - 2 * Math.min(m[0][$], m[1][$]) / Math.max(1e-4, m[0][$] + m[1][$]));
|
|
3779
|
+
g[$] = Math.min(65534, Ri + at * 0.35 + Pi);
|
|
3776
3780
|
}
|
|
3777
|
-
const P = z / 2, E = new Float64Array(P * X), j = new Float64Array(P + 1),
|
|
3781
|
+
const P = z / 2, E = new Float64Array(P * X), j = new Float64Array(P + 1), q = new Float64Array(P + 1), G = {}, te = (ce) => {
|
|
3778
3782
|
for (let $ = 0; $ < X; $ += 1) {
|
|
3779
|
-
const xe = $ * z, pe =
|
|
3783
|
+
const xe = $ * z, pe = m[1][xe] > m[0][xe] != ce > 0;
|
|
3780
3784
|
for (let re = 0; re < P; re += 1) {
|
|
3781
3785
|
const Te = xe + ce + re, et = T[0][Te], tt = T[1][Te];
|
|
3782
|
-
j[re + 1] = j[re] + (pe ? tt : et),
|
|
3786
|
+
j[re + 1] = j[re] + (pe ? tt : et), q[re + 1] = q[re] + (pe ? et : tt);
|
|
3783
3787
|
}
|
|
3784
3788
|
for (let re = 0; re < P; re += 1) {
|
|
3785
3789
|
const Te = g[xe + ce + re];
|
|
3786
|
-
E[$ * P + re] = Te >= 65535 ? 65535 : Math.min(65534, Te + j[re] +
|
|
3790
|
+
E[$ * P + re] = Te >= 65535 ? 65535 : Math.min(65534, Te + j[re] + q[P] - q[re]);
|
|
3787
3791
|
}
|
|
3788
3792
|
}
|
|
3789
|
-
return
|
|
3790
|
-
}, ne = te(0), ue = te(P), J = ne && ue && ne.cost / X <= 180 && ue.cost / X <= 180 ?
|
|
3791
|
-
let Z =
|
|
3792
|
-
Z && u && S.every(Boolean) && (Z =
|
|
3793
|
-
const Tt = Z && u && S.every(Boolean) ?
|
|
3793
|
+
return Xn(E, P, X, 2, G);
|
|
3794
|
+
}, ne = te(0), ue = te(P), J = ne && ue && ne.cost / X <= 180 && ue.cost / X <= 180 ? ac(m, ne.seam, ue.seam.map((ce) => ce + P)) : null;
|
|
3795
|
+
let Z = rc(J, h, m, [D, F]);
|
|
3796
|
+
Z && u && S.every(Boolean) && (Z = uc(Z, h, m, [D, F], y && !n ? d : null)), Z && p && (Z = bc(Z, h, m, [D, F], f));
|
|
3797
|
+
const Tt = Z && u && S.every(Boolean) ? nc(h, m, [D, F]) : null;
|
|
3794
3798
|
return { mask: Z, strength: Tt, gain: [D, F] };
|
|
3795
3799
|
}
|
|
3796
|
-
function
|
|
3800
|
+
function Hi(t, e) {
|
|
3797
3801
|
const i = Math.asin(O(t[1], -1, 1));
|
|
3798
3802
|
let n = Math.atan2(t[0], t[2]);
|
|
3799
3803
|
const r = O((Math.abs(t[1]) - Math.sin(50 * Math.PI / 180)) / (Math.sin(70 * Math.PI / 180) - Math.sin(50 * Math.PI / 180)), 0, 1), o = 1 - r * r * (3 - 2 * r);
|
|
@@ -3803,15 +3807,15 @@ function Qi(t, e) {
|
|
|
3803
3807
|
const a = O(i + (e[1] * (1 - s) + e[3] * s) * o, -Math.PI / 2, Math.PI / 2);
|
|
3804
3808
|
return [Math.cos(a) * Math.sin(n), Math.sin(a), Math.cos(a) * Math.cos(n)];
|
|
3805
3809
|
}
|
|
3806
|
-
function
|
|
3810
|
+
function bc(t, e, i, n, r) {
|
|
3807
3811
|
const o = t.slice();
|
|
3808
3812
|
for (const s of [0, X - 2]) {
|
|
3809
3813
|
const a = [0, 0];
|
|
3810
3814
|
for (let l = s; l < s + 2; l += 1) for (let u = 0; u < z; u += 1) {
|
|
3811
3815
|
const f = l * z + u, y = f * 3;
|
|
3812
3816
|
for (let p = 0; p < 2; p += 1) {
|
|
3813
|
-
const
|
|
3814
|
-
|
|
3817
|
+
const h = (e[p][y] * 0.2126 + e[p][y + 1] * 0.7152 + e[p][y + 2] * 0.0722) * n[p];
|
|
3818
|
+
h >= 12 && (a[p] += Math.sqrt(i[p][f]) * Math.min(h, 128));
|
|
3815
3819
|
}
|
|
3816
3820
|
}
|
|
3817
3821
|
let c = a[1] > a[0];
|
|
@@ -3819,7 +3823,7 @@ function xc(t, e, i, n, r) {
|
|
|
3819
3823
|
}
|
|
3820
3824
|
return o;
|
|
3821
3825
|
}
|
|
3822
|
-
function
|
|
3826
|
+
function wc(t, e, i = null) {
|
|
3823
3827
|
if (!e) return t;
|
|
3824
3828
|
const n = new Uint8Array(t.length);
|
|
3825
3829
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -3828,15 +3832,15 @@ function bc(t, e, i = null) {
|
|
|
3828
3832
|
}
|
|
3829
3833
|
return n;
|
|
3830
3834
|
}
|
|
3831
|
-
function
|
|
3835
|
+
function Fc(t, e) {
|
|
3832
3836
|
if ((e == null ? void 0 : e.width) !== t.width || (e == null ? void 0 : e.height) !== t.height) return !0;
|
|
3833
3837
|
const { width: i, height: n, pixels: r } = t, o = e.pixels, s = (r instanceof Uint8Array || r instanceof Uint8ClampedArray) && (o instanceof Uint8Array || o instanceof Uint8ClampedArray) && r.byteOffset % 4 === 0 && o.byteOffset % 4 === 0 && r.length === i * n * 4 && o.length === r.length, a = s ? new Uint32Array(r.buffer, r.byteOffset, r.byteLength / 4) : null, c = s ? new Uint32Array(o.buffer, o.byteOffset, o.byteLength / 4) : null;
|
|
3834
3838
|
for (let l = 0; l < n; l += 8) for (let u = 0; u < i; u += 8) {
|
|
3835
3839
|
let f = 0, y = 0;
|
|
3836
|
-
const p = Math.min(l + 8, n),
|
|
3840
|
+
const p = Math.min(l + 8, n), h = Math.min(u + 8, i), d = l * i + u;
|
|
3837
3841
|
if (a && a[d] === c[d])
|
|
3838
|
-
for (let
|
|
3839
|
-
const b =
|
|
3842
|
+
for (let m = l; m < p; m += 2) for (let g = u; g < h; g += 2) {
|
|
3843
|
+
const b = m * i + g;
|
|
3840
3844
|
if (a[b] !== c[b]) {
|
|
3841
3845
|
const x = b * 4;
|
|
3842
3846
|
f += Math.abs(r[x] - o[x]), f += Math.abs(r[x + 1] - o[x + 1]), f += Math.abs(r[x + 2] - o[x + 2]);
|
|
@@ -3844,17 +3848,17 @@ function wc(t, e) {
|
|
|
3844
3848
|
y += 3;
|
|
3845
3849
|
}
|
|
3846
3850
|
else
|
|
3847
|
-
for (let
|
|
3848
|
-
const b = (
|
|
3851
|
+
for (let m = l; m < p; m += 2) for (let g = u; g < h; g += 2) {
|
|
3852
|
+
const b = (m * i + g) * 4;
|
|
3849
3853
|
f += Math.abs(r[b] - o[b]), f += Math.abs(r[b + 1] - o[b + 1]), f += Math.abs(r[b + 2] - o[b + 2]), y += 3;
|
|
3850
3854
|
}
|
|
3851
3855
|
if (f / y > 12) return !0;
|
|
3852
3856
|
}
|
|
3853
3857
|
return !1;
|
|
3854
3858
|
}
|
|
3855
|
-
function
|
|
3859
|
+
function Mc(t, e, i, n, r, o, s) {
|
|
3856
3860
|
var y;
|
|
3857
|
-
const a = n.every((p) => p.projectionModel === "dji_fisheye_lut"), c = a && (s != null && s.softwareFrames) ?
|
|
3861
|
+
const a = n.every((p) => p.projectionModel === "dji_fisheye_lut"), c = a && (s != null && s.softwareFrames) ? Ia(
|
|
3858
3862
|
e,
|
|
3859
3863
|
i,
|
|
3860
3864
|
null,
|
|
@@ -3863,12 +3867,12 @@ function Fc(t, e, i, n, r, o, s) {
|
|
|
3863
3867
|
{ convergenceM: 0, polarInverseDepth: r.polarInverseDepth || [0, 0], registrationOffsets: r.offsets, videoOffsets: r.offsets },
|
|
3864
3868
|
s.projections || (s.projections = {})
|
|
3865
3869
|
) : null;
|
|
3866
|
-
let l = a && (s != null && s.softwareFrames) ?
|
|
3867
|
-
if (l || (s != null && s.softwareFrames && ((y = s.prepareSoftwareFallback) == null || y.call(s)), l =
|
|
3870
|
+
let l = a && (s != null && s.softwareFrames) ? fc(s.softwareFrames, s.softwareReadback || (s.softwareReadback = {}), s.surface, c) : null;
|
|
3871
|
+
if (l || (s != null && s.softwareFrames && ((y = s.prepareSoftwareFallback) == null || y.call(s)), l = Gt(t, a ? 1024 : Ea, s)), !l) return null;
|
|
3868
3872
|
if (l.pixels[3] === 0) return;
|
|
3869
3873
|
const u = s == null ? void 0 : s.surface;
|
|
3870
|
-
if (u && !
|
|
3871
|
-
const f =
|
|
3874
|
+
if (u && !Fc(l, u)) return { reused: !0 };
|
|
3875
|
+
const f = za(
|
|
3872
3876
|
l,
|
|
3873
3877
|
{
|
|
3874
3878
|
...e,
|
|
@@ -3889,8 +3893,8 @@ function Fc(t, e, i, n, r, o, s) {
|
|
|
3889
3893
|
);
|
|
3890
3894
|
return f != null && f.mask ? (s && (s.surface = l), { mask: f.mask, strength: f.strength }) : null;
|
|
3891
3895
|
}
|
|
3892
|
-
function
|
|
3893
|
-
var
|
|
3896
|
+
function Jn(t, e, i, n) {
|
|
3897
|
+
var qr, Gr, Xr;
|
|
3894
3898
|
const r = i.externalFrames === !0, o = e instanceof HTMLVideoElement, s = o || r, a = t.getContext("webgl", {
|
|
3895
3899
|
alpha: !1,
|
|
3896
3900
|
antialias: !s,
|
|
@@ -3901,14 +3905,14 @@ function Hn(t, e, i, n) {
|
|
|
3901
3905
|
if (!a)
|
|
3902
3906
|
throw new Error("WebGL unavailable");
|
|
3903
3907
|
const c = n === "dual_fisheye" ? Gs(i.dualFisheyeCalibration, i.dualFisheyeFrontLens) : null, l = (c == null ? void 0 : c.textureOrigin) !== "top-left", u = !!(n === "equirect" && i.equirectCameraConvention === "mei" || n === "dual_fisheye" && c && [c.front, c.back].some((M) => ["mei_extended", "dji_fisheye_lut"].includes(M.projectionModel)));
|
|
3904
|
-
t.dataset.insta360MEIConvention = u ? "true" : "false", t.dataset.insta360ProjectionKind = n, t.dataset.insta360CalibrationFrontModel = ((
|
|
3908
|
+
t.dataset.insta360MEIConvention = u ? "true" : "false", t.dataset.insta360ProjectionKind = n, t.dataset.insta360CalibrationFrontModel = ((qr = c == null ? void 0 : c.front) == null ? void 0 : qr.projectionModel) || "";
|
|
3905
3909
|
const f = `
|
|
3906
3910
|
attribute vec2 aClipPosition;
|
|
3907
3911
|
void main() {
|
|
3908
3912
|
gl_Position = vec4(aClipPosition, 0.0, 1.0);
|
|
3909
3913
|
}
|
|
3910
|
-
`, y = i.equirectFlipX ? "1.0 - baseUV.x" : "baseUV.x", p = i.equirectFlipY ? "1.0 - baseUV.y" : "baseUV.y",
|
|
3911
|
-
gl_FragColor = sampleDualFisheye(vec3(${
|
|
3914
|
+
`, y = i.equirectFlipX ? "1.0 - baseUV.x" : "baseUV.x", p = i.equirectFlipY ? "1.0 - baseUV.y" : "baseUV.y", h = i.equirectFlipX ? "-dir.x" : "dir.x", d = i.equirectFlipY ? "-dir.y" : "dir.y", m = n === "dual_fisheye" ? "projectDualFisheye(dir)" : n === "eac" || n === "cubemap" ? "projectCube(dir)" : "projectEquirect(dir)", g = n === "dual_fisheye" ? `
|
|
3915
|
+
gl_FragColor = sampleDualFisheye(vec3(${h}, ${d}, dir.z));
|
|
3912
3916
|
` : `
|
|
3913
3917
|
vec4 base = ${n === "eac" || n === "cubemap" ? "sampleCubeTexture(uv)" : "texture2D(uTex, clampTexelUV(uv))"};
|
|
3914
3918
|
float seamDist = min(uv.x, 1.0 - uv.x);
|
|
@@ -3920,11 +3924,11 @@ function Hn(t, e, i, n) {
|
|
|
3920
3924
|
}
|
|
3921
3925
|
gl_FragColor = base;
|
|
3922
3926
|
`, b = n === "dual_fisheye" ? `
|
|
3923
|
-
vec2 baseUV = ${
|
|
3927
|
+
vec2 baseUV = ${m};
|
|
3924
3928
|
vec2 uv = vec2(${y}, ${p});
|
|
3925
3929
|
${g}
|
|
3926
3930
|
` : `
|
|
3927
|
-
vec2 baseUV = ${
|
|
3931
|
+
vec2 baseUV = ${m};
|
|
3928
3932
|
if (baseUV.x < 0.0 || baseUV.y < 0.0 || baseUV.x > 1.0 || baseUV.y > 1.0) {
|
|
3929
3933
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
3930
3934
|
return;
|
|
@@ -4475,15 +4479,15 @@ function Hn(t, e, i, n) {
|
|
|
4475
4479
|
`}
|
|
4476
4480
|
${b}
|
|
4477
4481
|
}
|
|
4478
|
-
`, v =
|
|
4482
|
+
`, v = Qs(a, f, x);
|
|
4479
4483
|
a.useProgram(v);
|
|
4480
|
-
const w = a.getAttribLocation(v, "aClipPosition"), S = a.getUniformLocation(v, "uTex"), D = a.getUniformLocation(v, "uViewport"), F = a.getUniformLocation(v, "uTexel"), T = a.getUniformLocation(v, "uAspect"), L = a.getUniformLocation(v, "uTanHalfFov"), _ = a.getUniformLocation(v, "uViewQuat"), k = a.getUniformLocation(v, "uVisibleLens"), P = a.getUniformLocation(v, "uSeamWidth"), E = a.getUniformLocation(v, "uDualFisheyeFrontCenter"), j = a.getUniformLocation(v, "uDualFisheyeBackCenter"),
|
|
4481
|
-
if (!
|
|
4484
|
+
const w = a.getAttribLocation(v, "aClipPosition"), S = a.getUniformLocation(v, "uTex"), D = a.getUniformLocation(v, "uViewport"), F = a.getUniformLocation(v, "uTexel"), T = a.getUniformLocation(v, "uAspect"), L = a.getUniformLocation(v, "uTanHalfFov"), _ = a.getUniformLocation(v, "uViewQuat"), k = a.getUniformLocation(v, "uVisibleLens"), P = a.getUniformLocation(v, "uSeamWidth"), E = a.getUniformLocation(v, "uDualFisheyeFrontCenter"), j = a.getUniformLocation(v, "uDualFisheyeBackCenter"), q = a.getUniformLocation(v, "uDualFisheyeFrontValidRadius"), G = a.getUniformLocation(v, "uDualFisheyeBackValidRadius"), te = a.getUniformLocation(v, "uDualFisheyeFrontFocal"), ne = a.getUniformLocation(v, "uDualFisheyeBackFocal"), ue = a.getUniformLocation(v, "uDualFisheyeFrontPrincipalOffset"), J = a.getUniformLocation(v, "uDualFisheyeBackPrincipalOffset"), Z = a.getUniformLocation(v, "uDualFisheyeFrontScale"), Tt = a.getUniformLocation(v, "uDualFisheyeBackScale"), ce = a.getUniformLocation(v, "uDualFisheyeFrontRadial"), $ = a.getUniformLocation(v, "uDualFisheyeBackRadial"), xe = a.getUniformLocation(v, "uDualFisheyeFrontRadialScale"), pe = a.getUniformLocation(v, "uDualFisheyeBackRadialScale"), re = a.getUniformLocation(v, "uDualFisheyeDJIRadial5"), Te = a.getUniformLocation(v, "uDualFisheyeFrontTangential"), et = a.getUniformLocation(v, "uDualFisheyeBackTangential"), tt = a.getUniformLocation(v, "uDualFisheyeFrontXi"), Qt = a.getUniformLocation(v, "uDualFisheyeBackXi"), Ht = a.getUniformLocation(v, "uDualFisheyeFrontThinPrism"), Le = a.getUniformLocation(v, "uDualFisheyeBackThinPrism"), _e = a.getUniformLocation(v, "uDualFisheyeFrontSensorTilt"), it = a.getUniformLocation(v, "uDualFisheyeBackSensorTilt"), Ti = a.getUniformLocation(v, "uDualFisheyeConvergenceM"), ki = a.getUniformLocation(v, "uDualFisheyePolarInverseDepth"), Ri = ["Front", "Back"].map((M) => a.getUniformLocation(v, `uDualFisheye${M}TranslationM`)), at = ["Front", "Back"].map((M) => ["Pro0", "Pro1", "Pro2", "Pro12", "UsePro"].map((R) => a.getUniformLocation(v, `uDualFisheye${M}${R}`))), Pi = a.getUniformLocation(v, "uDualFisheyeFrontRotationQuat"), ja = a.getUniformLocation(v, "uDualFisheyeBackRotationQuat"), Na = a.getUniformLocation(v, "uDualFisheyeFrontUseMEI"), Oa = a.getUniformLocation(v, "uDualFisheyeBackUseMEI"), Va = a.getUniformLocation(v, "uDualFisheyeFrontUseDJI"), Wa = a.getUniformLocation(v, "uDualFisheyeBackUseDJI"), qa = a.getUniformLocation(v, "uDualFisheyeFrontAsymmetric"), Ga = a.getUniformLocation(v, "uDualFisheyeBackAsymmetric"), Xa = a.getUniformLocation(v, "uDualFisheyeFrontAxis"), $a = a.getUniformLocation(v, "uDualFisheyeBackAxis"), Ya = a.getUniformLocation(v, "uDualFisheyeFrontRight"), Qa = a.getUniformLocation(v, "uDualFisheyeBackRight"), Ha = a.getUniformLocation(v, "uDualFisheyeFrontUp"), Ja = a.getUniformLocation(v, "uDualFisheyeBackUp"), Ka = a.getUniformLocation(v, "uDualFisheyeMaxTheta"), Za = a.getUniformLocation(v, "uDualFisheyeBlendBand"), er = a.getUniformLocation(v, "uDualFisheyeSeamX"), tr = a.getUniformLocation(v, "uDualFisheyeSeamBlendX"), ir = a.getUniformLocation(v, "uDualFisheyeSeamFrontWrap"), ar = a.getUniformLocation(v, "uDualFisheyeUseSeamLongitudes"), rr = a.getUniformLocation(v, "uDualFisheyeGain"), io = a.getUniformLocation(v, "uDualFisheyeFrontRemap"), ao = a.getUniformLocation(v, "uDualFisheyeBackRemap"), nr = a.getUniformLocation(v, "uDualFisheyeUseRemap"), or = a.getUniformLocation(v, "uDualFisheyeSeamMask"), sr = a.getUniformLocation(v, "uDualFisheyeUseSeamMask"), cr = a.getUniformLocation(v, "uDualFisheyeVideoOffsets"), lr = a.getUniformLocation(v, "uDualFisheyeVideoSeam"), aa = a.createBuffer();
|
|
4485
|
+
if (!aa)
|
|
4482
4486
|
throw new Error("buffer create failed");
|
|
4483
|
-
a.bindBuffer(a.ARRAY_BUFFER,
|
|
4487
|
+
a.bindBuffer(a.ARRAY_BUFFER, aa), a.bufferData(a.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), a.STATIC_DRAW), a.enableVertexAttribArray(w), a.vertexAttribPointer(w, 2, a.FLOAT, !1, 0, 0);
|
|
4484
4488
|
const ft = a.createTexture();
|
|
4485
4489
|
if (!ft) throw new Error("texture create failed");
|
|
4486
|
-
const Jt = r ? a.createTexture() : null,
|
|
4490
|
+
const Jt = r ? a.createTexture() : null, ro = a.getUniformLocation(v, "uSeparateLenses"), no = a.getUniformLocation(v, "uVerticalLenses");
|
|
4487
4491
|
Jt && (a.activeTexture(a.TEXTURE4), a.bindTexture(a.TEXTURE_2D, Jt), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR), a.uniform1i(a.getUniformLocation(v, "uBackTex"), 4));
|
|
4488
4492
|
let Kt = { width: 1, height: 1 };
|
|
4489
4493
|
a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, ft), a.uniform1i(S, 0), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, l ? 1 : 0), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR), a.texImage2D(
|
|
@@ -4497,15 +4501,15 @@ function Hn(t, e, i, n) {
|
|
|
4497
4501
|
a.UNSIGNED_BYTE,
|
|
4498
4502
|
new Uint8Array([0, 0, 0, 255])
|
|
4499
4503
|
);
|
|
4500
|
-
function
|
|
4504
|
+
function ur(M, R, C, I, V) {
|
|
4501
4505
|
if (!R || !(C instanceof Uint8Array) || I <= 0 || V <= 0)
|
|
4502
4506
|
return null;
|
|
4503
4507
|
const U = a.createTexture();
|
|
4504
4508
|
return U ? (a.activeTexture(a.TEXTURE0 + M), a.bindTexture(a.TEXTURE_2D, U), a.uniform1i(R, M), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, 0), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR), a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, I, V, 0, a.RGBA, a.UNSIGNED_BYTE, C), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, ft), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, 1), U) : null;
|
|
4505
4509
|
}
|
|
4506
4510
|
a.disable(a.CULL_FACE), a.disable(a.DEPTH_TEST);
|
|
4507
|
-
function
|
|
4508
|
-
const R =
|
|
4511
|
+
function oo() {
|
|
4512
|
+
const R = ia(i.dualFisheyeSeamLongitudesDeg).map((V) => Da(V) / 360).sort((V, U) => V - U), C = Fr ? Math.atan2(Et[0], Et[2]) / (2 * Math.PI) + 0.5 : 0.5, I = !(C >= R[0] && C <= R[1]);
|
|
4509
4513
|
return {
|
|
4510
4514
|
seamX: R,
|
|
4511
4515
|
frontWrap: I,
|
|
@@ -4514,85 +4518,85 @@ function Hn(t, e, i, n) {
|
|
|
4514
4518
|
};
|
|
4515
4519
|
}
|
|
4516
4520
|
const Zt = s && typeof e.requestVideoFrameCallback == "function" && typeof e.cancelVideoFrameCallback == "function";
|
|
4517
|
-
let kt = 0, Rt = 0, Pt = 0, ht = i.fovDeg, ei = !0, ti = !0, rt = 0, At = 0, ii = !0,
|
|
4518
|
-
const
|
|
4519
|
-
let je = null, Lt = null, Ne = 0,
|
|
4520
|
-
const
|
|
4521
|
-
let Oe = c ? ye(c.front.validRadius) :
|
|
4522
|
-
const
|
|
4523
|
-
let ke = c ? ye(c.front.focal) :
|
|
4524
|
-
const
|
|
4521
|
+
let kt = 0, Rt = 0, Pt = 0, ht = i.fovDeg, ei = !0, ti = !0, rt = 0, At = 0, ii = !0, ra = { width: 1, height: 1 };
|
|
4522
|
+
const Ai = [];
|
|
4523
|
+
let je = null, Lt = null, Ne = 0, dr = 0, fr = 0, na = "initial";
|
|
4524
|
+
const hr = s && !Zt, Li = Ys(i.background), mr = Yi(e), Me = n === "dual_fisheye" && $s(mr.width, mr.height), be = c && !Me ? c.remap : null, _t = i.dualFisheyeFovDeg * Math.PI / 360, so = c ? c.front.center : i.dualFisheyeFrontCenter || (i.dualFisheyeFrontLens === "left" ? [0.25, 0.5] : [0.75, 0.5]), co = c ? c.back.center : i.dualFisheyeBackCenter || (i.dualFisheyeFrontLens === "left" ? [0.75, 0.5] : [0.25, 0.5]), lo = !!(c && ((Gr = c.imageSize) == null ? void 0 : Gr[1]) > ((Xr = c.imageSize) == null ? void 0 : Xr[0])), ye = (M) => Me && !lo ? [M[1], M[0]] : M, Ut = ye(so), ai = ye(co), pr = Wn(Ut, ai);
|
|
4525
|
+
let Oe = c ? ye(c.front.validRadius) : pr, Ve = c ? ye(c.back.validRadius) : pr;
|
|
4526
|
+
const _i = ye(c ? c.front.scale : fe(i.dualFisheyeScale, [0.247, 0.494])), Ui = ye(c ? c.back.scale : fe(i.dualFisheyeScale, [0.247, 0.494]));
|
|
4527
|
+
let ke = c ? ye(c.front.focal) : Sa(_i, _t), Re = c ? ye(c.back.focal) : Sa(Ui, _t);
|
|
4528
|
+
const oa = c ? ye(c.front.principalOffset) : [0, 0], sa = c ? ye(c.back.principalOffset) : [0, 0], ri = c ? c.front.radial : [0, 0, 0, 0], ni = c ? c.back.radial : [0, 0, 0, 0], yr = c ? c.front.radialScale : 1, gr = c ? c.back.radialScale : 1, ca = c ? c.front.tangential : [0, 0], la = c ? c.back.tangential : [0, 0], vr = c ? c.front.xi : 0, xr = c ? c.back.xi : 0, oi = c ? c.front.thinPrism : [0, 0, 0, 0], si = c ? c.back.thinPrism : [0, 0, 0, 0], br = c ? ye(c.front.sensorTilt) : [0, 0], wr = c ? ye(c.back.sensorTilt) : [0, 0], uo = !!(c && c.front.projectionModel === "mei_extended"), fo = !!(c && c.back.projectionModel === "mei_extended"), Fr = !!(c && c.front.projectionModel === "dji_fisheye_lut"), ho = !!(c && c.back.projectionModel === "dji_fisheye_lut"), Ei = c ? c.front.asymmetric : [0, 0, 0, 0], Ci = c ? c.back.asymmetric : [0, 0, 0, 0], Et = c ? c.front.axis : [0, 0, -1], Ii = c ? c.back.axis : [0, 0, 1], zi = c ? c.front.right : [1, 0, 0], Bi = c ? c.back.right : [-1, 0, 0], ji = c ? c.front.up : [0, 1, 0], Ni = c ? c.back.up : [0, 1, 0], We = {
|
|
4525
4529
|
...c ? c.front : {},
|
|
4526
4530
|
center: Ut,
|
|
4527
4531
|
focal: ke,
|
|
4528
|
-
principalOffset:
|
|
4529
|
-
scale:
|
|
4532
|
+
principalOffset: oa,
|
|
4533
|
+
scale: _i,
|
|
4530
4534
|
validRadius: Oe,
|
|
4531
4535
|
radial: ri,
|
|
4532
|
-
radialScale:
|
|
4533
|
-
tangential:
|
|
4536
|
+
radialScale: yr,
|
|
4537
|
+
tangential: ca,
|
|
4534
4538
|
projectionModel: c ? c.front.projectionModel : "equidistant",
|
|
4535
|
-
xi:
|
|
4539
|
+
xi: vr,
|
|
4536
4540
|
thinPrism: oi,
|
|
4537
4541
|
axis: Et,
|
|
4538
|
-
right:
|
|
4539
|
-
up:
|
|
4540
|
-
},
|
|
4542
|
+
right: zi,
|
|
4543
|
+
up: ji
|
|
4544
|
+
}, qe = {
|
|
4541
4545
|
...c ? c.back : {},
|
|
4542
4546
|
center: ai,
|
|
4543
4547
|
focal: Re,
|
|
4544
|
-
principalOffset:
|
|
4545
|
-
scale:
|
|
4548
|
+
principalOffset: sa,
|
|
4549
|
+
scale: Ui,
|
|
4546
4550
|
validRadius: Ve,
|
|
4547
4551
|
radial: ni,
|
|
4548
|
-
radialScale:
|
|
4549
|
-
tangential:
|
|
4552
|
+
radialScale: gr,
|
|
4553
|
+
tangential: la,
|
|
4550
4554
|
projectionModel: c ? c.back.projectionModel : "equidistant",
|
|
4551
|
-
xi:
|
|
4555
|
+
xi: xr,
|
|
4552
4556
|
thinPrism: si,
|
|
4553
|
-
axis:
|
|
4554
|
-
right:
|
|
4555
|
-
up:
|
|
4556
|
-
},
|
|
4557
|
-
let mt = null, Ue = 0,
|
|
4558
|
-
const
|
|
4559
|
-
nt && (Oe = We.validRadius = Vt(We), Ve =
|
|
4560
|
-
const pt =
|
|
4561
|
-
let ot = [0, 0, 0, 0], st = pt && !zt, Bt = 0,
|
|
4557
|
+
axis: Ii,
|
|
4558
|
+
right: Bi,
|
|
4559
|
+
up: Ni
|
|
4560
|
+
}, Mr = be ? ur(1, io, be.front, be.width, be.height) : null, Dr = be ? ur(2, ao, be.back, be.width, be.height) : null, Ge = oo();
|
|
4561
|
+
let mt = null, Ue = 0, ua = !1, Ct = [i.dualFisheyeGainFront, i.dualFisheyeGainBack], Oi = 0, It = [0, 0];
|
|
4562
|
+
const mo = [c == null ? void 0 : c.front, c == null ? void 0 : c.back].map((M) => (M == null ? void 0 : M.distortionCoeffs) || Array(13).fill(0)), po = !!(s && n === "dual_fisheye" && c && !be && !Me && c.imageSize[0] === 2 * c.imageSize[1] && [We, qe].every((M) => M.projectionModel === "mei_extended" && (M.distortionModel === "radtan_pro" || i.dualFisheyeVideoProtection === !0))), nt = !!(s && n === "dual_fisheye" && c && !be && !Me && c.imageSize[0] === 2 * c.imageSize[1] && [We, qe].every((M) => M.projectionModel === "dji_fisheye_lut"));
|
|
4563
|
+
nt && (Oe = We.validRadius = Vt(We), Ve = qe.validRadius = Vt(qe));
|
|
4564
|
+
const pt = po || nt, zt = pt && i.dualFisheyeVideoRegistration === !0;
|
|
4565
|
+
let ot = [0, 0, 0, 0], st = pt && !zt, Bt = 0, da = 0;
|
|
4562
4566
|
t.dataset.insta360VideoRegistration = zt ? "pending" : pt ? "calibrated" : "unsupported";
|
|
4563
|
-
function
|
|
4564
|
-
if (!zt || st || Bt >= 3 || e.currentTime <
|
|
4567
|
+
function Sr() {
|
|
4568
|
+
if (!zt || st || Bt >= 3 || e.currentTime < da) return;
|
|
4565
4569
|
const M = Date.now();
|
|
4566
4570
|
try {
|
|
4567
|
-
const R = (nt ?
|
|
4571
|
+
const R = (nt ? mc : hc)(e, i, c, [We, qe]);
|
|
4568
4572
|
if (R === void 0) return;
|
|
4569
|
-
R && (ot = R.offsets, It = R.polarInverseDepth || [0, 0], Ct = R.gain, nt ? (ke = ke.map((C) => C * R.focalScale), Re = Re.map((C) => C * R.focalScale), t.dataset.insta360VideoFocalScale = String(R.focalScale)) : (Oe = Vt(We), Ve = Vt(
|
|
4573
|
+
R && (ot = R.offsets, It = R.polarInverseDepth || [0, 0], Ct = R.gain, nt ? (ke = ke.map((C) => C * R.focalScale), Re = Re.map((C) => C * R.focalScale), t.dataset.insta360VideoFocalScale = String(R.focalScale)) : (Oe = Vt(We), Ve = Vt(qe)), st = !0);
|
|
4570
4574
|
} catch {
|
|
4571
4575
|
}
|
|
4572
|
-
Bt += 1,
|
|
4576
|
+
Bt += 1, da = e.currentTime + 1, t.dataset.insta360VideoRegistration = st ? "ready" : Bt < 3 ? "pending" : "fallback", t.dataset.insta360VideoRegistrationAttempts = String(Bt), t.dataset.insta360VideoRegistrationMS = String(Date.now() - M);
|
|
4573
4577
|
}
|
|
4574
4578
|
if (!s && n === "dual_fisheye") {
|
|
4575
|
-
|
|
4579
|
+
ua = !0;
|
|
4576
4580
|
try {
|
|
4577
|
-
const M =
|
|
4581
|
+
const M = vc(
|
|
4578
4582
|
e,
|
|
4579
4583
|
i,
|
|
4580
4584
|
c,
|
|
4581
4585
|
be,
|
|
4582
4586
|
We,
|
|
4583
|
-
|
|
4587
|
+
qe,
|
|
4584
4588
|
_t
|
|
4585
4589
|
);
|
|
4586
|
-
M && (Ct = M.gain,
|
|
4590
|
+
M && (Ct = M.gain, Oi = M.convergenceM, It = M.polarInverseDepth || [0, 0], ot = M.imageOffsets || [0, 0, 0, 0], ke = ke.map((R) => R * M.focalScale), Re = Re.map((R) => R * M.focalScale)), Tr(M == null ? void 0 : M.mask);
|
|
4587
4591
|
} catch (M) {
|
|
4588
4592
|
t.dataset.insta360StaticSeamError = String((M == null ? void 0 : M.message) || M), mt = null, Ue = 0;
|
|
4589
4593
|
}
|
|
4590
4594
|
}
|
|
4591
|
-
t.dataset.insta360StaticSeamAnalyzed =
|
|
4592
|
-
function
|
|
4593
|
-
if (!(M instanceof Uint8Array) || !
|
|
4595
|
+
t.dataset.insta360StaticSeamAnalyzed = ua ? "true" : "false", t.dataset.insta360StaticSeamStatus = ua ? Ue ? "ready" : "fallback" : "not-applicable";
|
|
4596
|
+
function Tr(M, R = null) {
|
|
4597
|
+
if (!(M instanceof Uint8Array) || !or || (mt || (mt = a.createTexture()), !mt)) return !1;
|
|
4594
4598
|
try {
|
|
4595
|
-
a.activeTexture(a.TEXTURE3), a.bindTexture(a.TEXTURE_2D, mt), a.uniform1i(
|
|
4599
|
+
a.activeTexture(a.TEXTURE3), a.bindTexture(a.TEXTURE_2D, mt), a.uniform1i(or, 3), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, 0), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR);
|
|
4596
4600
|
const C = R ? a.LUMINANCE_ALPHA : a.LUMINANCE, I = R ? Uint8Array.from({ length: M.length * 2 }, (V, U) => U % 2 ? R[U >> 1] : M[U >> 1]) : M;
|
|
4597
4601
|
return a.texImage2D(a.TEXTURE_2D, 0, C, z, X, 0, C, a.UNSIGNED_BYTE, I), Ue = 1, !0;
|
|
4598
4602
|
} finally {
|
|
@@ -4601,63 +4605,63 @@ function Hn(t, e, i, n) {
|
|
|
4601
4605
|
}
|
|
4602
4606
|
let yt = null;
|
|
4603
4607
|
const he = {};
|
|
4604
|
-
let
|
|
4605
|
-
function
|
|
4608
|
+
let Vi = 1, ci = null, gt = -1 / 0, Pe = 0, kr = 0;
|
|
4609
|
+
function Rr() {
|
|
4606
4610
|
if (!pt || !st || Pe >= 3 || e.seeking || e.currentTime + 1e-6 < gt) return;
|
|
4607
4611
|
const M = Date.now();
|
|
4608
4612
|
try {
|
|
4609
|
-
const C =
|
|
4613
|
+
const C = Mc(
|
|
4610
4614
|
e,
|
|
4611
4615
|
i,
|
|
4612
4616
|
c,
|
|
4613
|
-
[{ ...We, focal: ke, validRadius: Oe }, { ...
|
|
4617
|
+
[{ ...We, focal: ke, validRadius: Oe }, { ...qe, focal: Re, validRadius: Ve }],
|
|
4614
4618
|
{ offsets: ot, gain: Ct, polarInverseDepth: It },
|
|
4615
4619
|
yt,
|
|
4616
4620
|
he
|
|
4617
4621
|
);
|
|
4618
4622
|
if (C === void 0) return;
|
|
4619
4623
|
if (C != null && C.reused) {
|
|
4620
|
-
gt = e.currentTime +
|
|
4624
|
+
gt = e.currentTime + Vi, t.dataset.insta360VideoSeam = "cached";
|
|
4621
4625
|
return;
|
|
4622
4626
|
}
|
|
4623
4627
|
const I = C == null ? void 0 : C.mask;
|
|
4624
4628
|
if (I instanceof Uint8Array) {
|
|
4625
|
-
const V =
|
|
4626
|
-
|
|
4629
|
+
const V = wc(I, yt, C.strength);
|
|
4630
|
+
Tr(V, C.strength) ? (yt = V, Pe = 0, kr += 1) : Pe += 1;
|
|
4627
4631
|
} else Pe += 1;
|
|
4628
4632
|
} catch {
|
|
4629
4633
|
Pe += 1;
|
|
4630
4634
|
}
|
|
4631
4635
|
Pe >= 3 && (Ue = 0, yt = null);
|
|
4632
4636
|
const R = Date.now() - M;
|
|
4633
|
-
|
|
4637
|
+
Vi = R > 100 ? 5 : R > 33 ? 3 : 1, gt = e.currentTime + Vi, t.dataset.insta360VideoSeamUpdates = String(kr), t.dataset.insta360VideoSeamMS = String(R), t.dataset.insta360VideoSeamInterval = String(Vi), t.dataset.insta360VideoSeam = Ue ? "ready" : Pe >= 3 ? "fallback" : "pending";
|
|
4634
4638
|
}
|
|
4635
|
-
function
|
|
4639
|
+
function fa() {
|
|
4636
4640
|
!Zt || !ti || !s || e.paused || e.ended || At || (At = e.requestVideoFrameCallback(() => {
|
|
4637
|
-
At = 0, (jt ||
|
|
4641
|
+
At = 0, (jt || ma(performance.now(), ui)) && (ii = !0, vt()), fa();
|
|
4638
4642
|
}));
|
|
4639
4643
|
}
|
|
4640
|
-
function
|
|
4644
|
+
function yo() {
|
|
4641
4645
|
!Zt || !At || !s || (e.cancelVideoFrameCallback(At), At = 0);
|
|
4642
4646
|
}
|
|
4643
|
-
function
|
|
4647
|
+
function go(M) {
|
|
4644
4648
|
let R = Number(M) || 0;
|
|
4645
4649
|
return R = (R % 360 + 360) % 360, R > 180 && (R -= 360), R;
|
|
4646
4650
|
}
|
|
4647
|
-
function
|
|
4648
|
-
kt =
|
|
4651
|
+
function vo(M, R, C, I) {
|
|
4652
|
+
kt = go(M), Rt = O(Number(R) || 0, -85, 85), typeof I == "number" ? (Pt = O(Number(C) || 0, -180, 180), ht = O(Number(I) || ee.fovDeg, i.minFovDeg, i.maxFovDeg)) : ht = O(Number(C) || ee.fovDeg, i.minFovDeg, i.maxFovDeg), ei = !0;
|
|
4649
4653
|
}
|
|
4650
|
-
function
|
|
4654
|
+
function xo() {
|
|
4651
4655
|
const M = s ? 1.5 : 2, R = i.maxRenderPixelRatio > 0 ? i.maxRenderPixelRatio : M, C = Math.max(1, Math.min(R, window.devicePixelRatio || 1)), I = i.captureEquirectangular ? 1024 : Math.max(1, t.clientWidth | 0), V = i.captureEquirectangular ? 512 : Math.max(1, t.clientHeight | 0), U = Ce.maxRenderPixels > 0 ? Math.min(1, Math.sqrt(Ce.maxRenderPixels / (I * V * C * C))) : 1, W = Math.max(1, Math.floor(I * C * U)), oe = Math.max(1, Math.floor(V * C * U));
|
|
4652
|
-
(t.width !== W || t.height !== oe) && (t.width = W, t.height = oe, a.viewport(0, 0, W, oe), ei = !0,
|
|
4656
|
+
(t.width !== W || t.height !== oe) && (t.width = W, t.height = oe, a.viewport(0, 0, W, oe), ei = !0, fr += 1, na = "resize", t.dataset.insta360ResizeCount = String(fr), t.dataset.insta360CanvasWidth = String(W), t.dataset.insta360CanvasHeight = String(oe));
|
|
4653
4657
|
}
|
|
4654
|
-
function
|
|
4658
|
+
function Pr() {
|
|
4655
4659
|
for (let M = 0; M < 16 && a.getError() !== a.NO_ERROR; M += 1)
|
|
4656
4660
|
;
|
|
4657
4661
|
}
|
|
4658
|
-
function
|
|
4659
|
-
const I = typeof performance < "u" ? performance.now() : Date.now(), V = Kt.width !== R || Kt.height !== C || I >=
|
|
4660
|
-
V &&
|
|
4662
|
+
function Ar(M, R, C) {
|
|
4663
|
+
const I = typeof performance < "u" ? performance.now() : Date.now(), V = Kt.width !== R || Kt.height !== C || I >= Ir;
|
|
4664
|
+
V && Pr(), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, l ? 1 : 0);
|
|
4661
4665
|
const U = Kt.width === R && Kt.height === C;
|
|
4662
4666
|
try {
|
|
4663
4667
|
U ? a.texSubImage2D(a.TEXTURE_2D, 0, 0, 0, a.RGBA, a.UNSIGNED_BYTE, M) : a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, M);
|
|
@@ -4665,10 +4669,10 @@ function Hn(t, e, i, n) {
|
|
|
4665
4669
|
return t.dataset.insta360TextureStatus = "exception", !1;
|
|
4666
4670
|
}
|
|
4667
4671
|
const W = V ? a.getError() : a.NO_ERROR;
|
|
4668
|
-
return V && (
|
|
4672
|
+
return V && (Ir = I + 1e3), W !== a.NO_ERROR ? (t.dataset.insta360TextureStatus = `error-${W}`, !1) : (Kt = { width: R, height: C }, ra = { width: R, height: C }, t.dataset.insta360TextureStatus = "ready", t.dataset.insta360TextureWidth = String(R), t.dataset.insta360TextureHeight = String(C), !0);
|
|
4669
4673
|
}
|
|
4670
|
-
function
|
|
4671
|
-
const R =
|
|
4674
|
+
function bo(M) {
|
|
4675
|
+
const R = Yi(e);
|
|
4672
4676
|
if (M >= R.width && M >= R.height)
|
|
4673
4677
|
return {
|
|
4674
4678
|
source: e,
|
|
@@ -4687,7 +4691,7 @@ function Hn(t, e, i, n) {
|
|
|
4687
4691
|
const W = U.getContext("2d", { alpha: !1 });
|
|
4688
4692
|
if (!W) return null;
|
|
4689
4693
|
try {
|
|
4690
|
-
|
|
4694
|
+
qn.has(e) && (W.translate(0, V), W.scale(1, -1)), W.drawImage(e, 0, 0, I, V);
|
|
4691
4695
|
} catch {
|
|
4692
4696
|
return U.width = 0, U.height = 0, null;
|
|
4693
4697
|
}
|
|
@@ -4700,40 +4704,40 @@ function Hn(t, e, i, n) {
|
|
|
4700
4704
|
}
|
|
4701
4705
|
};
|
|
4702
4706
|
}
|
|
4703
|
-
function
|
|
4707
|
+
function wo() {
|
|
4704
4708
|
if (r || s && e.readyState < 2) return !1;
|
|
4705
4709
|
a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, ft);
|
|
4706
|
-
const M =
|
|
4710
|
+
const M = Yi(e);
|
|
4707
4711
|
if (s) {
|
|
4708
|
-
const U =
|
|
4709
|
-
return
|
|
4712
|
+
const U = Br(M.width, M.height);
|
|
4713
|
+
return Ar(jr(e, M.width, M.height, U, 0), U.width, U.height);
|
|
4710
4714
|
}
|
|
4711
|
-
const R = Math.max(1, Number(a.getParameter(a.MAX_TEXTURE_SIZE)) || 1), C = Math.max(M.width, M.height), V = [Math.min(C, R,
|
|
4715
|
+
const R = Math.max(1, Number(a.getParameter(a.MAX_TEXTURE_SIZE)) || 1), C = Math.max(M.width, M.height), V = [Math.min(C, R, pn[0]), ...pn].filter((U, W, oe) => U <= R && U <= C && oe.indexOf(U) === W).sort((U, W) => W - U);
|
|
4712
4716
|
for (const U of V) {
|
|
4713
|
-
const W =
|
|
4717
|
+
const W = bo(U);
|
|
4714
4718
|
if (!W) continue;
|
|
4715
|
-
if (
|
|
4719
|
+
if (Ar(W.source, W.width, W.height))
|
|
4716
4720
|
return Ne && (cancelAnimationFrame(Ne), Ne = 0), W.retainUntilDestroy ? (Lt && Lt(), Lt = W.release, t.dataset.insta360TextureSource = "retained") : (je && je(), je = W.release, typeof ImageBitmap < "u" && e instanceof ImageBitmap && (Lt = () => e.close())), !0;
|
|
4717
4721
|
W.retainUntilDestroy || W.release();
|
|
4718
4722
|
}
|
|
4719
4723
|
return !1;
|
|
4720
4724
|
}
|
|
4721
|
-
function
|
|
4725
|
+
function Fo() {
|
|
4722
4726
|
s || !je || Ne || (Ne = requestAnimationFrame(() => {
|
|
4723
4727
|
Ne = requestAnimationFrame(() => {
|
|
4724
4728
|
Ne = 0, je && (je(), je = null, t.dataset.insta360TextureSource = "released");
|
|
4725
4729
|
});
|
|
4726
4730
|
}));
|
|
4727
4731
|
}
|
|
4728
|
-
let
|
|
4729
|
-
function
|
|
4732
|
+
let Lr = "";
|
|
4733
|
+
function ha() {
|
|
4730
4734
|
var U;
|
|
4731
4735
|
if (!ti) return;
|
|
4732
4736
|
const M = typeof performance < "u" ? performance.now() : Date.now();
|
|
4733
|
-
rt = 0,
|
|
4734
|
-
const R = o && !e.paused && !e.ended, C = !R || jt ||
|
|
4735
|
-
if (V && (ii = !1, s && (
|
|
4736
|
-
const W =
|
|
4737
|
+
rt = 0, xo();
|
|
4738
|
+
const R = o && !e.paused && !e.ended, C = !R || jt || ma(M, ui), V = (ii || hr && R) && (!o || C) ? wo() : !1;
|
|
4739
|
+
if (V && (ii = !1, s && (Sr(), Rr())), ei || V) {
|
|
4740
|
+
const W = ra, oe = Er(), Ie = Ut[Me ? 1 : 0] < 0.5 ? 0 : 1, $e = oe.every(Boolean) ? 0 : oe[Ie] ? 1 : 2, De = [
|
|
4737
4741
|
W.width,
|
|
4738
4742
|
W.height,
|
|
4739
4743
|
t.width,
|
|
@@ -4746,63 +4750,63 @@ function Hn(t, e, i, n) {
|
|
|
4746
4750
|
Ve,
|
|
4747
4751
|
ke,
|
|
4748
4752
|
Re,
|
|
4749
|
-
|
|
4753
|
+
Oi,
|
|
4750
4754
|
It,
|
|
4751
4755
|
ot,
|
|
4752
4756
|
Ct,
|
|
4753
4757
|
Ue,
|
|
4754
4758
|
$e
|
|
4755
4759
|
].join(":");
|
|
4756
|
-
if (De !==
|
|
4757
|
-
const Ye = 1 / Math.max(1, W.width), we = 1 / Math.max(1, W.height), Qe = Math.max(Ye * 6, 35e-4), ct = Ot(0, 1, 0, -kt * Math.PI / 180), xt = Ot(1, 0, 0, -Rt * Math.PI / 180), lt = Ot(0, 0, 1, -Pt * Math.PI / 180), ze =
|
|
4758
|
-
F && a.uniform2f(F, Ye, we), D && a.uniform2f(D, t.width, t.height), T && a.uniform1f(T, Y), L && a.uniform1f(L, Math.tan(ht * Math.PI / 360)), _ && a.uniform4f(_, ze.x, ze.y, ze.z, ze.w), P && a.uniform1f(P, Qe), E && a.uniform2f(E, Ut[0], Ut[1]), j && a.uniform2f(j, ai[0], ai[1]),
|
|
4760
|
+
if (De !== Lr) {
|
|
4761
|
+
const Ye = 1 / Math.max(1, W.width), we = 1 / Math.max(1, W.height), Qe = Math.max(Ye * 6, 35e-4), ct = Ot(0, 1, 0, -kt * Math.PI / 180), xt = Ot(1, 0, 0, -Rt * Math.PI / 180), lt = Ot(0, 0, 1, -Pt * Math.PI / 180), ze = wn(Wt(Wt(ct, xt), lt)), Y = t.width / t.height;
|
|
4762
|
+
F && a.uniform2f(F, Ye, we), D && a.uniform2f(D, t.width, t.height), T && a.uniform1f(T, Y), L && a.uniform1f(L, Math.tan(ht * Math.PI / 360)), _ && a.uniform4f(_, ze.x, ze.y, ze.z, ze.w), P && a.uniform1f(P, Qe), E && a.uniform2f(E, Ut[0], Ut[1]), j && a.uniform2f(j, ai[0], ai[1]), q && a.uniform2f(q, Oe[0], Oe[1]), G && a.uniform2f(G, Ve[0], Ve[1]), te && a.uniform2f(te, ke[0], ke[1]), ne && a.uniform2f(ne, Re[0], Re[1]), ue && a.uniform2f(ue, oa[0], oa[1]), J && a.uniform2f(J, sa[0], sa[1]), Z && a.uniform2f(Z, _i[0], _i[1]), Tt && a.uniform2f(Tt, Ui[0], Ui[1]), ce && a.uniform4f(ce, ri[0], ri[1], ri[2], ri[3]), $ && a.uniform4f($, ni[0], ni[1], ni[2], ni[3]), xe && a.uniform1f(xe, yr), pe && a.uniform1f(pe, gr), re && a.uniform2f(
|
|
4759
4763
|
re,
|
|
4760
4764
|
(c == null ? void 0 : c.front.distortionCoeffs[4]) || 0,
|
|
4761
4765
|
(c == null ? void 0 : c.back.distortionCoeffs[4]) || 0
|
|
4762
|
-
), Te && a.uniform2f(Te,
|
|
4766
|
+
), Te && a.uniform2f(Te, ca[0], ca[1]), et && a.uniform2f(et, la[0], la[1]), tt && a.uniform1f(tt, vr), Qt && a.uniform1f(Qt, xr), Ht && a.uniform4f(Ht, oi[0], oi[1], oi[2], oi[3]), Le && a.uniform4f(Le, si[0], si[1], si[2], si[3]), _e && a.uniform2f(_e, br[0], br[1]), it && a.uniform2f(it, wr[0], wr[1]), Ti && a.uniform1f(Ti, Oi), ki && a.uniform2f(ki, ...It), cr && a.uniform4f(cr, ...ot), lr && a.uniform1f(lr, pt ? 1 : 0);
|
|
4763
4767
|
for (let K = 0; K < 2; K += 1) {
|
|
4764
4768
|
const se = K === 0 ? c == null ? void 0 : c.front : c == null ? void 0 : c.back;
|
|
4765
|
-
|
|
4766
|
-
const Fe =
|
|
4769
|
+
Ri[K] && a.uniform3f(Ri[K], ...(se == null ? void 0 : se.translationM) || [0, 0, 0]);
|
|
4770
|
+
const Fe = mo[K];
|
|
4767
4771
|
for (let Ae = 0; Ae < 3; Ae += 1)
|
|
4768
4772
|
at[K][Ae] && a.uniform4fv(at[K][Ae], Fe.slice(Ae * 4, Ae * 4 + 4));
|
|
4769
4773
|
at[K][3] && a.uniform1f(at[K][3], Fe[12]), at[K][4] && a.uniform1f(at[K][4], (se == null ? void 0 : se.distortionModel) === "radtan_pro" ? 1 : 0);
|
|
4770
4774
|
}
|
|
4771
|
-
|
|
4775
|
+
Pi && a.uniform4f(Pi, ...(c == null ? void 0 : c.front.rotationQuat) || [1, 0, 0, 0]), ja && a.uniform4f(ja, ...(c == null ? void 0 : c.back.rotationQuat) || [1, 0, 0, 0]), Na && a.uniform1f(Na, uo ? 1 : 0), Oa && a.uniform1f(Oa, fo ? 1 : 0), Va && a.uniform1f(Va, Fr ? c.front.distortionModel === "dji_fisheye_5" ? 2 : 1 : 0), Wa && a.uniform1f(Wa, ho ? c.back.distortionModel === "dji_fisheye_5" ? 2 : 1 : 0), qa && a.uniform4f(qa, Ei[0], Ei[1], Ei[2], Ei[3]), Ga && a.uniform4f(Ga, Ci[0], Ci[1], Ci[2], Ci[3]), Xa && a.uniform3f(Xa, Et[0], Et[1], Et[2]), $a && a.uniform3f($a, Ii[0], Ii[1], Ii[2]), Ya && a.uniform3f(Ya, zi[0], zi[1], zi[2]), Qa && a.uniform3f(Qa, Bi[0], Bi[1], Bi[2]), Ha && a.uniform3f(Ha, ji[0], ji[1], ji[2]), Ja && a.uniform3f(Ja, Ni[0], Ni[1], Ni[2]), Ka && a.uniform1f(Ka, _t), Za && a.uniform1f(Za, Math.sin(i.dualFisheyeSeamBlendDeg * Math.PI / 180)), er && a.uniform2f(er, Ge.seamX[0], Ge.seamX[1]), tr && a.uniform1f(tr, Ge.blendX), ir && a.uniform1f(ir, Ge.frontWrap ? 1 : 0), ar && a.uniform1f(ar, Ge.enabled ? 1 : 0), rr && a.uniform2f(rr, Ct[0], Ct[1]), nr && a.uniform1f(nr, be ? 1 : 0), sr && a.uniform1f(sr, Ue), k && a.uniform1f(k, $e), Lr = De;
|
|
4772
4776
|
}
|
|
4773
|
-
a.clearColor(
|
|
4777
|
+
a.clearColor(Li.r / 255, Li.g / 255, Li.b / 255, Li.a), a.clear(a.COLOR_BUFFER_BIT), a.drawArrays(a.TRIANGLES, 0, 3), dr += 1, t.dataset.insta360DrawCount = String(dr), t.dataset.insta360LastDrawReason = na, t.dataset.insta360ContextStatus = "ready", V && Fo(), ei = !1;
|
|
4774
4778
|
}
|
|
4775
|
-
o && V && (ui =
|
|
4779
|
+
o && V && (ui = zr(M, ui, jt), jt = !1, R && ((U = i.onPlaybackWork) == null || U.call(i, Math.max(0, performance.now() - M)))), hr && R && (rt = requestAnimationFrame(ha));
|
|
4776
4780
|
}
|
|
4777
|
-
function
|
|
4778
|
-
ti && (s && Zt &&
|
|
4781
|
+
function Mo() {
|
|
4782
|
+
ti && (s && Zt && fa(), vt());
|
|
4779
4783
|
}
|
|
4780
4784
|
function vt(M = "request") {
|
|
4781
|
-
ei = !0,
|
|
4785
|
+
ei = !0, na = M, rt || (rt = requestAnimationFrame(ha));
|
|
4782
4786
|
}
|
|
4783
|
-
function
|
|
4787
|
+
function _r(M) {
|
|
4784
4788
|
t.dataset.insta360ContextStatus = "lost", t.dispatchEvent(new CustomEvent("insta360previewerror", {
|
|
4785
4789
|
bubbles: !0,
|
|
4786
4790
|
detail: { reason: "webgl-context-lost" }
|
|
4787
4791
|
})), M.cancelable && M.preventDefault();
|
|
4788
4792
|
}
|
|
4789
|
-
t.addEventListener("webglcontextlost",
|
|
4793
|
+
t.addEventListener("webglcontextlost", _r);
|
|
4790
4794
|
function Ee(M) {
|
|
4791
|
-
jt = !0, pt && (M == null ? void 0 : M.type) === "seeked" && (he.surface = null, yt = null, gt = -1 / 0, Pe = 0, Ue = 0), zt && !st && (M == null ? void 0 : M.type) === "seeked" && (Bt = 0,
|
|
4795
|
+
jt = !0, pt && (M == null ? void 0 : M.type) === "seeked" && (he.surface = null, yt = null, gt = -1 / 0, Pe = 0, Ue = 0), zt && !st && (M == null ? void 0 : M.type) === "seeked" && (Bt = 0, da = e.currentTime), ii = !0, Zt && fa(), vt();
|
|
4792
4796
|
}
|
|
4793
4797
|
o && (e.addEventListener("play", Ee), e.addEventListener("pause", Ee), e.addEventListener("seeking", Ee), e.addEventListener("seeked", Ee), e.addEventListener("loadeddata", Ee));
|
|
4794
|
-
function
|
|
4795
|
-
ti = !1, rt && cancelAnimationFrame(rt), Ne && cancelAnimationFrame(Ne),
|
|
4798
|
+
function Do() {
|
|
4799
|
+
ti = !1, rt && cancelAnimationFrame(rt), Ne && cancelAnimationFrame(Ne), yo(), t.removeEventListener("webglcontextlost", _r), o && (e.removeEventListener("play", Ee), e.removeEventListener("pause", Ee), e.removeEventListener("seeking", Ee), e.removeEventListener("seeked", Ee), e.removeEventListener("loadeddata", Ee)), je && je(), Lt && Lt(), he.readback && (he.readback.surface.width = 0, he.readback.surface.height = 0);
|
|
4796
4800
|
for (const M of fi) M != null && M.canvas && (M.canvas.width = 0, M.canvas.height = 0);
|
|
4797
4801
|
fi.length = 0, he.surface = null, he.projections = null, he.readback = null, he.softwareReadback = null;
|
|
4798
|
-
for (const M of
|
|
4799
|
-
|
|
4802
|
+
for (const M of Wi) M && (M.width = 0, M.height = 0);
|
|
4803
|
+
Wi.length = 0;
|
|
4800
4804
|
for (const M of li) M != null && M.canvas && (M.canvas.width = 0, M.canvas.height = 0);
|
|
4801
|
-
li.length = 0, a.deleteTexture(ft), Jt && a.deleteTexture(Jt),
|
|
4805
|
+
li.length = 0, a.deleteTexture(ft), Jt && a.deleteTexture(Jt), Mr && a.deleteTexture(Mr), Dr && a.deleteTexture(Dr), mt && a.deleteTexture(mt), a.deleteBuffer(aa), a.deleteProgram(v);
|
|
4802
4806
|
}
|
|
4803
|
-
let
|
|
4804
|
-
function
|
|
4805
|
-
if (i.captureEquirectangular || !r || n !== "dual_fisheye" || be || zt && (!st || !nt) ||
|
|
4807
|
+
let Ur = "", Xe = [!0, !0];
|
|
4808
|
+
function Er() {
|
|
4809
|
+
if (i.captureEquirectangular || !r || n !== "dual_fisheye" || be || zt && (!st || !nt) || Oi > 0 || It.some((Ie) => Ie > 0) || !Ge.enabled) return [!0, !0];
|
|
4806
4810
|
const M = Math.max(1, t.clientWidth) / Math.max(1, t.clientHeight), R = [
|
|
4807
4811
|
kt,
|
|
4808
4812
|
Rt,
|
|
@@ -4815,9 +4819,9 @@ function Hn(t, e, i, n) {
|
|
|
4815
4819
|
Re,
|
|
4816
4820
|
ot
|
|
4817
4821
|
].join(":");
|
|
4818
|
-
if (R ===
|
|
4819
|
-
|
|
4820
|
-
const C =
|
|
4822
|
+
if (R === Ur) return Xe;
|
|
4823
|
+
Ur = R, Xe = [!0, !0];
|
|
4824
|
+
const C = wn(Wt(
|
|
4821
4825
|
Wt(
|
|
4822
4826
|
Ot(0, 1, 0, -kt * Math.PI / 180),
|
|
4823
4827
|
Ot(1, 0, 0, -Rt * Math.PI / 180)
|
|
@@ -4825,22 +4829,22 @@ function Hn(t, e, i, n) {
|
|
|
4825
4829
|
Ot(0, 0, 1, -Pt * Math.PI / 180)
|
|
4826
4830
|
)), I = Math.tan(Math.min(160, ht + 12) * Math.PI / 360), V = [
|
|
4827
4831
|
{ ...We, focal: ke, validRadius: Oe },
|
|
4828
|
-
{ ...
|
|
4832
|
+
{ ...qe, focal: Re, validRadius: Ve }
|
|
4829
4833
|
];
|
|
4830
4834
|
let U = -1;
|
|
4831
4835
|
for (let Ie = -4; Ie <= 4; Ie += 1) for (let $e = -4; $e <= 4; $e += 1) {
|
|
4832
|
-
const De =
|
|
4836
|
+
const De = Ba(C, $e / 4 * M * I, Ie / 4 * I, u ? 1 : -1), Ye = Math.hypot(De.x, De.y, De.z), we = [
|
|
4833
4837
|
De.x / Ye * (i.equirectFlipX ? -1 : 1),
|
|
4834
4838
|
De.y / Ye * (i.equirectFlipY ? -1 : 1),
|
|
4835
4839
|
De.z / Ye
|
|
4836
4840
|
];
|
|
4837
4841
|
if (Math.abs(we[1]) >= Math.sin(45 * Math.PI / 180)) return Xe;
|
|
4838
|
-
const Qe = Math.atan2(we[0], u ? we[2] : -we[2]) / (2 * Math.PI) + 0.5, [ct, xt] =
|
|
4842
|
+
const Qe = Math.atan2(we[0], u ? we[2] : -we[2]) / (2 * Math.PI) + 0.5, [ct, xt] = Ge.seamX, lt = Ge.blendX + 0.01, ze = Qe > ct + lt && Qe < xt - lt, Y = Qe < ct - lt || Qe > xt + lt;
|
|
4839
4843
|
if (!ze && !Y) return Xe;
|
|
4840
|
-
const se = (
|
|
4844
|
+
const se = (Ge.frontWrap ? Y : ze) ? 0 : 1;
|
|
4841
4845
|
if (U >= 0 && U !== se) return Xe;
|
|
4842
4846
|
U = se;
|
|
4843
|
-
const Fe = V[se], Ae = se === 1 ?
|
|
4847
|
+
const Fe = V[se], Ae = se === 1 ? Hi(we, ot) : we, He = St(
|
|
4844
4848
|
Ae,
|
|
4845
4849
|
Fe,
|
|
4846
4850
|
_t,
|
|
@@ -4850,95 +4854,95 @@ function Hn(t, e, i, n) {
|
|
|
4850
4854
|
);
|
|
4851
4855
|
if (!He || He.confidence < 0.1) return Xe;
|
|
4852
4856
|
if (nt) {
|
|
4853
|
-
const
|
|
4854
|
-
|
|
4855
|
-
|
|
4857
|
+
const Xi = V[1 - se], To = se === 0 ? Hi(we, ot) : we, $r = St(
|
|
4858
|
+
To,
|
|
4859
|
+
Xi,
|
|
4856
4860
|
_t,
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4861
|
+
Xi.projectionModel === "mei_extended",
|
|
4862
|
+
Xi.projectionModel === "dji_fisheye_lut",
|
|
4863
|
+
Xi.radialScale || 1
|
|
4860
4864
|
);
|
|
4861
|
-
if (
|
|
4865
|
+
if ($r && $r.confidence > 0) return Xe;
|
|
4862
4866
|
}
|
|
4863
4867
|
}
|
|
4864
4868
|
const oe = (U === 0 ? Ut : ai)[Me ? 1 : 0] < 0.5 ? 0 : 1;
|
|
4865
4869
|
return Xe = [oe === 0, oe === 1], Xe;
|
|
4866
4870
|
}
|
|
4867
|
-
let
|
|
4868
|
-
const
|
|
4869
|
-
let ui = 0,
|
|
4870
|
-
function
|
|
4871
|
+
let Cr = 0, Ce = { level: 0, maxFps: 0, maxRenderPixels: 0, maxTextureSize: 0 };
|
|
4872
|
+
const Wi = [], li = [];
|
|
4873
|
+
let ui = 0, Ir = 0, jt = !0;
|
|
4874
|
+
function ma(M, R) {
|
|
4871
4875
|
const C = Ce.maxFps ? 1e3 / Ce.maxFps : 0;
|
|
4872
4876
|
return !C || M + Math.min(20, C / 2) >= R;
|
|
4873
4877
|
}
|
|
4874
|
-
function
|
|
4878
|
+
function zr(M, R, C = !1) {
|
|
4875
4879
|
const I = Ce.maxFps ? 1e3 / Ce.maxFps : 0;
|
|
4876
4880
|
return I ? C || !R || M - R > I ? M + I : Math.max(R + I, M + I / 2 + Math.min(20, I / 2)) : 0;
|
|
4877
4881
|
}
|
|
4878
|
-
function
|
|
4882
|
+
function Br(M, R) {
|
|
4879
4883
|
const C = Ce.maxTextureSize > 0 ? Math.min(1, Ce.maxTextureSize / Math.max(M, R)) : 1;
|
|
4880
4884
|
return { width: Math.max(1, Math.floor(M * C)), height: Math.max(1, Math.floor(R * C)) };
|
|
4881
4885
|
}
|
|
4882
|
-
function
|
|
4886
|
+
function jr(M, R, C, I, V) {
|
|
4883
4887
|
if (I.width === R && I.height === C) return M;
|
|
4884
|
-
if (M instanceof ImageData) return
|
|
4888
|
+
if (M instanceof ImageData) return Fn(
|
|
4885
4889
|
M,
|
|
4886
4890
|
I.width,
|
|
4887
4891
|
li[V] || (li[V] = {}),
|
|
4888
4892
|
I.height
|
|
4889
4893
|
);
|
|
4890
|
-
let U =
|
|
4891
|
-
return U || (U =
|
|
4894
|
+
let U = Wi[V];
|
|
4895
|
+
return U || (U = Wi[V] = document.createElement("canvas")), (U.width !== I.width || U.height !== I.height) && (U.width = I.width, U.height = I.height), U.getContext("2d").drawImage(M, 0, 0, I.width, I.height), U;
|
|
4892
4896
|
}
|
|
4893
|
-
function
|
|
4894
|
-
!s || !M || M.level === Ce.level || (Ce = M, ui = 0, di = 0,
|
|
4897
|
+
function So(M) {
|
|
4898
|
+
!s || !M || M.level === Ce.level || (Ce = M, ui = 0, di = 0, qi = 0, jt = !0, t.dataset.insta360QualityLevel = String(M.level), t.dataset.insta360MaxFps = String(M.maxFps), vt("quality"));
|
|
4895
4899
|
}
|
|
4896
|
-
let
|
|
4900
|
+
let Nr = -1 / 0, di = 0, qi = 0, Gi = 0, Or = "";
|
|
4897
4901
|
const fi = [];
|
|
4898
|
-
function
|
|
4902
|
+
function Vr(M) {
|
|
4899
4903
|
const R = e.getContext("2d", { willReadFrequently: !0 });
|
|
4900
4904
|
M.forEach((C, I) => {
|
|
4901
|
-
const V = C instanceof ImageData ?
|
|
4905
|
+
const V = C instanceof ImageData ? Fn(C, nt ? 1024 : 512, fi[I] || (fi[I] = {})) : C, U = M.length === 2 && !Me ? e.width / 2 : e.width, W = M.length === 2 && Me ? e.height / 2 : e.height;
|
|
4902
4906
|
R.drawImage(V, Me ? 0 : I * U, Me ? I * W : 0, U, W);
|
|
4903
4907
|
});
|
|
4904
4908
|
}
|
|
4905
|
-
function
|
|
4909
|
+
function Wr(M, R, C = !1) {
|
|
4906
4910
|
if (!ti || !r) return;
|
|
4907
4911
|
const I = ci !== null && (R < ci || R - ci > 0.5);
|
|
4908
4912
|
if (I && (he.surface = null, yt = null, gt = -1 / 0, Ue = 0, Pe = 0), !M.find(Boolean)) return;
|
|
4909
|
-
const U = typeof performance < "u" ? performance.now() : Date.now(), W = M.map(Boolean).join(":"), oe = M.map((Y) => Y ?
|
|
4913
|
+
const U = typeof performance < "u" ? performance.now() : Date.now(), W = M.map(Boolean).join(":"), oe = M.map((Y) => Y ? Br(
|
|
4910
4914
|
Y.displayWidth || Y.videoWidth || Y.width,
|
|
4911
4915
|
Y.displayHeight || Y.videoHeight || Y.height
|
|
4912
4916
|
) : null), Ie = oe.some((Y, K) => {
|
|
4913
4917
|
var se, Fe;
|
|
4914
|
-
return Y && (((se =
|
|
4915
|
-
}), $e = C || I || Ie || W !==
|
|
4916
|
-
if (!$e && (U <
|
|
4918
|
+
return Y && (((se = Ai[K]) == null ? void 0 : se.width) !== Y.width || ((Fe = Ai[K]) == null ? void 0 : Fe.height) !== Y.height);
|
|
4919
|
+
}), $e = C || I || Ie || W !== Or;
|
|
4920
|
+
if (!$e && (U < qi || !ma(U, di))) return;
|
|
4917
4921
|
ci = R;
|
|
4918
|
-
const { width: De, height: Ye } = oe.find(Boolean), we =
|
|
4922
|
+
const { width: De, height: Ye } = oe.find(Boolean), we = Cr || (Cr = a.getParameter(a.MAX_TEXTURE_SIZE));
|
|
4919
4923
|
if (oe.filter(Boolean).some((Y) => Y.width > we || Y.height > we))
|
|
4920
4924
|
throw new Error("Panorama frame exceeds GPU texture limits; select a companion source");
|
|
4921
|
-
a.uniform1f(
|
|
4922
|
-
const Qe = Ie || U >=
|
|
4923
|
-
if (Qe &&
|
|
4925
|
+
a.uniform1f(ro, M.length === 2 ? 1 : 0), a.uniform1f(no, Me ? 1 : 0);
|
|
4926
|
+
const Qe = Ie || U >= Nr;
|
|
4927
|
+
if (Qe && Pr(), M.forEach((Y, K) => {
|
|
4924
4928
|
if (!Y) return;
|
|
4925
4929
|
a.activeTexture(K === 0 ? a.TEXTURE0 : a.TEXTURE4), a.bindTexture(a.TEXTURE_2D, K === 0 ? ft : Jt), a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, l ? 1 : 0);
|
|
4926
|
-
const { width: se, height: Fe } = oe[K], Ae =
|
|
4930
|
+
const { width: se, height: Fe } = oe[K], Ae = jr(
|
|
4927
4931
|
Y,
|
|
4928
4932
|
Y.displayWidth || Y.videoWidth || Y.width,
|
|
4929
4933
|
Y.displayHeight || Y.videoHeight || Y.height,
|
|
4930
4934
|
oe[K],
|
|
4931
4935
|
K
|
|
4932
|
-
), He =
|
|
4933
|
-
(He == null ? void 0 : He.width) === se && (He == null ? void 0 : He.height) === Fe ? a.texSubImage2D(a.TEXTURE_2D, 0, 0, 0, a.RGBA, a.UNSIGNED_BYTE, Ae) : (a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, Ae),
|
|
4936
|
+
), He = Ai[K];
|
|
4937
|
+
(He == null ? void 0 : He.width) === se && (He == null ? void 0 : He.height) === Fe ? a.texSubImage2D(a.TEXTURE_2D, 0, 0, 0, a.RGBA, a.UNSIGNED_BYTE, Ae) : (a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, Ae), Ai[K] = { width: se, height: Fe });
|
|
4934
4938
|
}), Qe) {
|
|
4935
4939
|
if (a.getError() !== a.NO_ERROR) throw new Error("Panorama frame upload failed");
|
|
4936
|
-
|
|
4940
|
+
Nr = U + 1e3;
|
|
4937
4941
|
}
|
|
4938
4942
|
const ct = Math.max(0, (typeof performance < "u" ? performance.now() : Date.now()) - U);
|
|
4939
|
-
Gi = Gi ? Gi * 0.8 + ct * 0.2 : ct, di =
|
|
4943
|
+
Gi = Gi ? Gi * 0.8 + ct * 0.2 : ct, di = zr(U, di, $e), qi = U + Math.min(100, Gi * 1.5), Or = W;
|
|
4940
4944
|
const xt = Me || n === "eac" || n === "cubemap";
|
|
4941
|
-
|
|
4945
|
+
ra = {
|
|
4942
4946
|
width: M.length === 2 && !xt ? De * 2 : De,
|
|
4943
4947
|
height: M.length === 2 && xt ? Ye * 2 : Ye
|
|
4944
4948
|
}, ii = !1;
|
|
@@ -4947,7 +4951,7 @@ function Hn(t, e, i, n) {
|
|
|
4947
4951
|
e.currentTime = R;
|
|
4948
4952
|
const Y = nt && ze && e.width === 2048 && e.height === 1024 && M.length === 2 && M.every((K) => K instanceof ImageData);
|
|
4949
4953
|
try {
|
|
4950
|
-
Y ? (he.softwareFrames = M, he.prepareSoftwareFallback = () =>
|
|
4954
|
+
Y ? (he.softwareFrames = M, he.prepareSoftwareFallback = () => Vr(M)) : Vr(M), Sr(), Rr();
|
|
4951
4955
|
} finally {
|
|
4952
4956
|
he.softwareFrames = null, he.prepareSoftwareFallback = null;
|
|
4953
4957
|
}
|
|
@@ -4956,18 +4960,18 @@ function Hn(t, e, i, n) {
|
|
|
4956
4960
|
}
|
|
4957
4961
|
return {
|
|
4958
4962
|
reset: () => {
|
|
4959
|
-
he.surface = null, yt = null, ci = null, gt = -1 / 0, di = 0,
|
|
4963
|
+
he.surface = null, yt = null, ci = null, gt = -1 / 0, di = 0, qi = 0, Ue = 0, Pe = 0, t.dataset.insta360VideoSeam = "pending", vt("seek");
|
|
4960
4964
|
},
|
|
4961
|
-
presentFrames:
|
|
4965
|
+
presentFrames: Wr,
|
|
4962
4966
|
captureFrames: (M, R) => {
|
|
4963
|
-
|
|
4967
|
+
Wr(M, R, !0), rt && cancelAnimationFrame(rt), ha();
|
|
4964
4968
|
},
|
|
4965
|
-
setPlaybackQuality:
|
|
4966
|
-
getRequiredTracks:
|
|
4967
|
-
start:
|
|
4969
|
+
setPlaybackQuality: So,
|
|
4970
|
+
getRequiredTracks: Er,
|
|
4971
|
+
start: Mo,
|
|
4968
4972
|
requestFrame: vt,
|
|
4969
|
-
destroy:
|
|
4970
|
-
setView:
|
|
4973
|
+
destroy: Do,
|
|
4974
|
+
setView: vo,
|
|
4971
4975
|
getView: () => ({ yawDeg: kt, pitchDeg: Rt, rollDeg: Pt, fovDeg: ht }),
|
|
4972
4976
|
// +Z MEI cameras reverse both screen axes relative to the -Z panorama camera.
|
|
4973
4977
|
dragDirectionSign: u ? -1 : 1
|
|
@@ -4981,7 +4985,7 @@ function Wt(t, e) {
|
|
|
4981
4985
|
w: t.w * e.w - t.x * e.x - t.y * e.y - t.z * e.z
|
|
4982
4986
|
};
|
|
4983
4987
|
}
|
|
4984
|
-
function
|
|
4988
|
+
function wn(t) {
|
|
4985
4989
|
const e = Math.hypot(t.x, t.y, t.z, t.w) || 1;
|
|
4986
4990
|
return {
|
|
4987
4991
|
x: t.x / e,
|
|
@@ -4994,11 +4998,11 @@ function Ot(t, e, i, n) {
|
|
|
4994
4998
|
const r = n / 2, o = Math.sin(r);
|
|
4995
4999
|
return { x: t * o, y: e * o, z: i * o, w: Math.cos(r) };
|
|
4996
5000
|
}
|
|
4997
|
-
function
|
|
5001
|
+
function Ba(t, e, i, n) {
|
|
4998
5002
|
const r = { x: e, y: i, z: n, w: 0 }, o = { x: -t.x, y: -t.y, z: -t.z, w: t.w }, s = Wt(t, r), a = Wt(s, o);
|
|
4999
5003
|
return { x: a.x, y: a.y, z: a.z };
|
|
5000
5004
|
}
|
|
5001
|
-
function
|
|
5005
|
+
function Fn(t, e = 512, i = null, n = null) {
|
|
5002
5006
|
const r = (i == null ? void 0 : i.canvas) || document.createElement("canvas"), o = Math.min(e, t.width), s = n ?? Math.max(1, Math.round(t.height * o / t.width));
|
|
5003
5007
|
(r.width !== o || r.height !== s) && (r.width = o, r.height = s, i && (i.reduced = null)), i && (i.canvas = r);
|
|
5004
5008
|
const a = r.getContext("2d");
|
|
@@ -5010,32 +5014,32 @@ function bn(t, e = 512, i = null, n = null) {
|
|
|
5010
5014
|
let f = i == null ? void 0 : i.columns;
|
|
5011
5015
|
if ((!f || f.length !== o || i.sourceWidth !== t.width) && (f = Uint32Array.from({ length: o }, (y, p) => Math.floor(p * t.width / o)), i && (i.columns = f, i.sourceWidth = t.width)), l)
|
|
5012
5016
|
for (let y = 0; y < s; y++) {
|
|
5013
|
-
const p = Math.floor(y * t.height / s) * t.width,
|
|
5014
|
-
for (let d = 0; d < o; d++) u[
|
|
5017
|
+
const p = Math.floor(y * t.height / s) * t.width, h = y * o;
|
|
5018
|
+
for (let d = 0; d < o; d++) u[h + d] = l[p + f[d]];
|
|
5015
5019
|
}
|
|
5016
5020
|
else
|
|
5017
5021
|
for (let y = 0; y < s; y++) {
|
|
5018
|
-
const p = Math.floor(y * t.height / s) * t.width,
|
|
5019
|
-
for (let d = 0; d < o; d++) for (let
|
|
5020
|
-
c.data[(
|
|
5022
|
+
const p = Math.floor(y * t.height / s) * t.width, h = y * o;
|
|
5023
|
+
for (let d = 0; d < o; d++) for (let m = 0; m < 4; m++)
|
|
5024
|
+
c.data[(h + d) * 4 + m] = t.data[(p + f[d]) * 4 + m];
|
|
5021
5025
|
}
|
|
5022
5026
|
return a.putImageData(c, 0, 0), r;
|
|
5023
5027
|
}
|
|
5024
|
-
function
|
|
5028
|
+
function Dc(t, e, i = null) {
|
|
5025
5029
|
var o;
|
|
5026
5030
|
const n = i || document.createElement("canvas");
|
|
5027
5031
|
i || (n.width = ((o = e.dualFisheyeCalibration) == null ? void 0 : o.front.projectionModel) === "dji_fisheye_lut" ? 2048 : 1024, n.height = n.width / 2);
|
|
5028
|
-
const r =
|
|
5032
|
+
const r = Jn(t, n, Vn({ ...e, externalFrames: !i }), e.projection || "equirect");
|
|
5029
5033
|
return { ...r, destroy() {
|
|
5030
5034
|
r.destroy(), i || (n.width = n.height = 0);
|
|
5031
5035
|
} };
|
|
5032
5036
|
}
|
|
5033
|
-
function
|
|
5034
|
-
return
|
|
5037
|
+
function Sc(t, e, i) {
|
|
5038
|
+
return Jn(t, e, Vn({ ...i, externalFrames: !1 }), i.projection || "dual_fisheye");
|
|
5035
5039
|
}
|
|
5036
|
-
function
|
|
5037
|
-
if (!
|
|
5038
|
-
const e =
|
|
5040
|
+
function Kn(t) {
|
|
5041
|
+
if (!ea(t)) return;
|
|
5042
|
+
const e = ta(t);
|
|
5039
5043
|
if (!e) return;
|
|
5040
5044
|
const i = e[0].track.id !== e[1].track.id;
|
|
5041
5045
|
let n, r, o;
|
|
@@ -5045,7 +5049,7 @@ function Jn(t) {
|
|
|
5045
5049
|
n = a.track.width * 2, r = a.track.height, o = [{ x: 0, y: 0, width: 0.5, height: 1 }, { x: 0.5, y: 0, width: 0.5, height: 1 }];
|
|
5046
5050
|
} else if (n = e[0].track.width, r = e[0].track.height, o = e.map(({ rect: a }) => a), o.some((a) => a.y !== 0 || a.width !== 0.5 || a.height !== 1) || ![0, 0.5].every((a) => o.some((c) => c.x === a))) return;
|
|
5047
5051
|
if (n !== r * 2) return;
|
|
5048
|
-
const s = t.lenses.slice(0, 2).map((a, c) =>
|
|
5052
|
+
const s = t.lenses.slice(0, 2).map((a, c) => kc(a, e[c], o[c], t));
|
|
5049
5053
|
return {
|
|
5050
5054
|
imageSize: [n, r],
|
|
5051
5055
|
textureOrigin: t.textureOrigin === "top-left" ? "top-left" : "bottom-left",
|
|
@@ -5054,20 +5058,20 @@ function Jn(t) {
|
|
|
5054
5058
|
pipeline: { seamLongitudesDeg: [90, 270], featherWidthPx: Math.round(r * 16 / 360) }
|
|
5055
5059
|
};
|
|
5056
5060
|
}
|
|
5057
|
-
async function
|
|
5058
|
-
const i =
|
|
5061
|
+
async function Tc(t, e) {
|
|
5062
|
+
const i = Kn(e), n = ta(e);
|
|
5059
5063
|
if (!i || !n) throw new B("calibration_missing", "Real-time stitching requires two calibrated side-by-side lenses.");
|
|
5060
5064
|
if (typeof VideoDecoder > "u" || typeof EncodedVideoChunk > "u")
|
|
5061
5065
|
throw new B("codec_unsupported", "This browser does not expose WebCodecs video decoding.");
|
|
5062
|
-
const r = [...new Map(n.map(({ track:
|
|
5063
|
-
if (r.some((
|
|
5066
|
+
const r = [...new Map(n.map(({ track: h }) => [h.id, h])).values()];
|
|
5067
|
+
if (r.some((h) => h.timescale <= 0 || !h.samples.length))
|
|
5064
5068
|
throw new B("invalid_manifest", "The calibrated panorama tracks do not contain a playable sample timeline.");
|
|
5065
|
-
const o = r.map(
|
|
5066
|
-
if ((await Promise.all(o.map((
|
|
5069
|
+
const o = r.map(Cn);
|
|
5070
|
+
if ((await Promise.all(o.map((h) => VideoDecoder.isConfigSupported(h)))).some((h) => !h.supported))
|
|
5067
5071
|
throw new B("codec_unsupported", "This browser cannot decode the calibrated panorama tracks.");
|
|
5068
5072
|
const a = document.createElement("canvas");
|
|
5069
5073
|
a.className = "panoramav-canvas";
|
|
5070
|
-
const c =
|
|
5074
|
+
const c = Dc(a, {
|
|
5071
5075
|
projection: "dual_fisheye",
|
|
5072
5076
|
dualFisheyeCalibration: i,
|
|
5073
5077
|
dualFisheyeFrontLens: i.front.center[0] < 0.5 ? "left" : "right",
|
|
@@ -5081,12 +5085,12 @@ async function Sc(t, e) {
|
|
|
5081
5085
|
});
|
|
5082
5086
|
let l, u;
|
|
5083
5087
|
try {
|
|
5084
|
-
l = new
|
|
5085
|
-
c.presentFrames(r.length === 1 ? [
|
|
5088
|
+
l = new Bn(t, r, [], o, (h, d) => {
|
|
5089
|
+
c.presentFrames(r.length === 1 ? [h] : [h, d], h.timestamp / 1e6);
|
|
5086
5090
|
}, async () => {
|
|
5087
5091
|
}, () => c.reset());
|
|
5088
|
-
} catch (
|
|
5089
|
-
throw c.destroy(),
|
|
5092
|
+
} catch (h) {
|
|
5093
|
+
throw c.destroy(), h;
|
|
5090
5094
|
}
|
|
5091
5095
|
c.start(), l.start();
|
|
5092
5096
|
const f = () => {
|
|
@@ -5096,9 +5100,9 @@ async function Sc(t, e) {
|
|
|
5096
5100
|
let y = "", p = !1;
|
|
5097
5101
|
return {
|
|
5098
5102
|
canvas: a,
|
|
5099
|
-
setView(
|
|
5100
|
-
const b = `${
|
|
5101
|
-
p || b === y || (y = b, c.setView(
|
|
5103
|
+
setView(h, d, m, g) {
|
|
5104
|
+
const b = `${h}:${d}:${m}:${g}`;
|
|
5105
|
+
p || b === y || (y = b, c.setView(h, d, m, g), c.requestFrame("view"));
|
|
5102
5106
|
},
|
|
5103
5107
|
requestRender: () => {
|
|
5104
5108
|
p || c.requestFrame("resize");
|
|
@@ -5106,7 +5110,7 @@ async function Sc(t, e) {
|
|
|
5106
5110
|
update: () => l.update(),
|
|
5107
5111
|
play: () => l.play(),
|
|
5108
5112
|
pause: () => l.pause(),
|
|
5109
|
-
seek: (
|
|
5113
|
+
seek: (h) => l.seek(h),
|
|
5110
5114
|
close() {
|
|
5111
5115
|
p || (p = !0, l.close(), a.removeEventListener("insta360previewerror", f), c.destroy(), a.width = a.height = 0);
|
|
5112
5116
|
},
|
|
@@ -5133,9 +5137,9 @@ async function Sc(t, e) {
|
|
|
5133
5137
|
setStabilization: () => "off"
|
|
5134
5138
|
};
|
|
5135
5139
|
}
|
|
5136
|
-
function
|
|
5137
|
-
const r = t.width ?? e.track.width * e.rect.width, o = t.height ?? e.track.height * e.rect.height, s = t.extrinsicQuaternion, a = n.projection.kind === "mei-extended", c = a ? s : [s[0], -s[1], -s[2], -s[3]], l = (
|
|
5138
|
-
const d =
|
|
5140
|
+
function kc(t, e, i, n) {
|
|
5141
|
+
const r = t.width ?? e.track.width * e.rect.width, o = t.height ?? e.track.height * e.rect.height, s = t.extrinsicQuaternion, a = n.projection.kind === "mei-extended", c = a ? s : [s[0], -s[1], -s[2], -s[3]], l = (h) => {
|
|
5142
|
+
const d = Rc(c, h);
|
|
5139
5143
|
return a ? d : [d[0], -d[2], d[1]];
|
|
5140
5144
|
}, u = l([1, 0, 0]), f = l([0, a ? 1 : -1, 0]), y = [t.fx / r * i.width, (t.fy ?? t.fx) / o * i.height], p = Math.min(r, o) * 0.475;
|
|
5141
5145
|
return {
|
|
@@ -5150,7 +5154,7 @@ function Tc(t, e, i, n) {
|
|
|
5150
5154
|
thinPrism: bi(t.thinPrism, 4),
|
|
5151
5155
|
sensorTilt: bi(t.sensorTilt, 2),
|
|
5152
5156
|
xi: t.xi ?? 0,
|
|
5153
|
-
radialScale: a ? 1 :
|
|
5157
|
+
radialScale: a ? 1 : Pc(t),
|
|
5154
5158
|
distortionModel: t.distortionModel,
|
|
5155
5159
|
distortionCoeffs: t.distortionCoeffs,
|
|
5156
5160
|
translationM: t.translation,
|
|
@@ -5163,11 +5167,11 @@ function Tc(t, e, i, n) {
|
|
|
5163
5167
|
function bi(t, e) {
|
|
5164
5168
|
return Array.from({ length: e }, (i, n) => Number((t == null ? void 0 : t[n]) ?? 0));
|
|
5165
5169
|
}
|
|
5166
|
-
function
|
|
5170
|
+
function Rc(t, [e, i, n]) {
|
|
5167
5171
|
const r = Math.hypot(...t), [o, s, a, c] = t.map((f) => f / r), l = s * e + a * i + c * n, u = o * o - s * s - a * a - c * c;
|
|
5168
5172
|
return [2 * l * s + u * e + 2 * o * (a * n - c * i), 2 * l * a + u * i + 2 * o * (c * e - s * n), 2 * l * c + u * n + 2 * o * (s * i - a * e)];
|
|
5169
5173
|
}
|
|
5170
|
-
function
|
|
5174
|
+
function Pc(t) {
|
|
5171
5175
|
const e = t.radialLut1, i = t.radialLut2;
|
|
5172
5176
|
if (!e || !i || e.length < 14 || i.length < 14 || !t.fx) return 1;
|
|
5173
5177
|
let n = 0;
|
|
@@ -5176,7 +5180,7 @@ function Rc(t) {
|
|
|
5176
5180
|
const r = 85 * Math.PI / 180, [o, s, a, c] = bi(t.radial ?? t.distortion, 4), l = r + o * r ** 3 + s * r ** 5 + a * r ** 7 + c * r ** 9, u = 1 + 3 * o * r ** 2 + 5 * s * r ** 4 + 7 * a * r ** 6 + 9 * c * r ** 8, f = t.fx * (l + u * (Math.PI / 2 - r));
|
|
5177
5181
|
return f > 0 ? n / f : 1;
|
|
5178
5182
|
}
|
|
5179
|
-
function
|
|
5183
|
+
function Zn(t) {
|
|
5180
5184
|
var r;
|
|
5181
5185
|
const { width: e, height: i } = t;
|
|
5182
5186
|
if (!e || !i || t.lenses.length !== 2 || !["mei-extended", "equidistant"].includes(t.projection.kind)) return;
|
|
@@ -5185,12 +5189,12 @@ function Kn(t) {
|
|
|
5185
5189
|
const a = s.sourceRect, c = s.extrinsicQuaternion, l = s.width, u = s.height;
|
|
5186
5190
|
if (!a || !l || !u || !c || c.length !== 4 || !c.every(Number.isFinite) || Math.hypot(...c) < 1e-6 || ![s.fx, s.fy, s.cx, s.cy].every((x) => typeof x == "number" && Number.isFinite(x)) || !Object.values(a).every(Number.isFinite) || s.fx <= 0 || s.fy <= 0 || a.width <= 0 || a.height <= 0 || a.x < 0 || a.y < 0 || a.x + a.width > 1 || a.y + a.height > 1) return;
|
|
5187
5191
|
const f = ((r = s.projection) == null ? void 0 : r.kind) === "mei-extended", y = c.map((x) => x / Math.hypot(...c)), p = f ? [y[0], -y[1], -y[2], -y[3]] : y;
|
|
5188
|
-
let
|
|
5192
|
+
let h = xi(p, [0, 0, f ? 1 : -1]), d = xi(p, [0, 1, 0]);
|
|
5189
5193
|
if (!f && o === 1) {
|
|
5190
5194
|
const x = xi(p, [0, 0, 1]);
|
|
5191
|
-
x[2] >
|
|
5195
|
+
x[2] > h[2] && (h = x, d = xi(p, [0, -1, 0]));
|
|
5192
5196
|
}
|
|
5193
|
-
const
|
|
5197
|
+
const m = (x) => f ? x : [x[0], -x[1], x[2]], g = Math.min(l, u) * 0.475, b = [s.fx / l * a.width, s.fy / u * a.height];
|
|
5194
5198
|
n.push({
|
|
5195
5199
|
center: [a.x + s.cx / l * a.width, a.y + s.cy / u * a.height],
|
|
5196
5200
|
focal: b,
|
|
@@ -5207,9 +5211,9 @@ function Kn(t) {
|
|
|
5207
5211
|
translationM: s.translation,
|
|
5208
5212
|
distortionModel: s.distortionModel,
|
|
5209
5213
|
distortionCoeffs: s.distortionCoeffs,
|
|
5210
|
-
axis: h
|
|
5211
|
-
right:
|
|
5212
|
-
up:
|
|
5214
|
+
axis: m(h),
|
|
5215
|
+
right: m(xi(p, [1, 0, 0])),
|
|
5216
|
+
up: m(d),
|
|
5213
5217
|
projectionModel: f ? "mei_extended" : "equidistant"
|
|
5214
5218
|
});
|
|
5215
5219
|
}
|
|
@@ -5221,14 +5225,14 @@ function Kn(t) {
|
|
|
5221
5225
|
pipeline: { seamLongitudesDeg: [90, 270], featherWidthPx: Math.round(Math.min(e, i) * 16 / 360) }
|
|
5222
5226
|
};
|
|
5223
5227
|
}
|
|
5224
|
-
function
|
|
5225
|
-
const i =
|
|
5228
|
+
function Ac(t, e) {
|
|
5229
|
+
const i = Zn(e);
|
|
5226
5230
|
if (!i) throw new B("calibration_missing", "This DNG does not contain supported dual-fisheye calibration.");
|
|
5227
5231
|
if (Math.abs(t.naturalWidth / t.naturalHeight - i.imageSize[0] / i.imageSize[1]) > 5e-3)
|
|
5228
5232
|
throw new B("invalid_manifest", "The developed DNG preview does not preserve the calibrated sensor geometry.");
|
|
5229
5233
|
const n = document.createElement("canvas");
|
|
5230
5234
|
n.className = "panoramav-canvas";
|
|
5231
|
-
const r =
|
|
5235
|
+
const r = Sc(n, t, {
|
|
5232
5236
|
projection: "dual_fisheye",
|
|
5233
5237
|
dualFisheyeCalibration: i,
|
|
5234
5238
|
dualFisheyeFovDeg: 196,
|
|
@@ -5282,7 +5286,7 @@ function xi([t, e, i, n], [r, o, s]) {
|
|
|
5282
5286
|
const a = e * r + i * o + n * s, c = t * t - e * e - i * i - n * n;
|
|
5283
5287
|
return [2 * a * e + c * r + 2 * t * (i * s - n * o), 2 * a * i + c * o + 2 * t * (n * r - e * s), 2 * a * n + c * s + 2 * t * (e * o - i * r)];
|
|
5284
5288
|
}
|
|
5285
|
-
const
|
|
5289
|
+
const Lc = "Panorama is not close to a 2:1 equirectangular projection; raw dual-fisheye media requires vendor stitching, while stereoscopic media needs a compatible projection mode.", _c = /* @__PURE__ */ new Set(["insp", "insv", "osv"]), Mn = /* @__PURE__ */ new Set(["insv", "osv"]), Dn = [
|
|
5286
5290
|
{
|
|
5287
5291
|
extensions: ["pano", "panorama", "360", "insp"],
|
|
5288
5292
|
family: "panorama",
|
|
@@ -5298,7 +5302,7 @@ const Ac = "Panorama is not close to a 2:1 equirectangular projection; raw dual-
|
|
|
5298
5302
|
contentTypes: ["video/panorama", "video/x-panorama", "video/x-insta360", "video/x-osmo360", "application/vnd.filens.panorama+video"]
|
|
5299
5303
|
}
|
|
5300
5304
|
];
|
|
5301
|
-
class
|
|
5305
|
+
class eo {
|
|
5302
5306
|
constructor(e, i = {}, n) {
|
|
5303
5307
|
A(this, "listeners", {
|
|
5304
5308
|
loading: /* @__PURE__ */ new Set(),
|
|
@@ -5365,7 +5369,7 @@ class Zn {
|
|
|
5365
5369
|
}
|
|
5366
5370
|
async load(e, i) {
|
|
5367
5371
|
var s, a, c, l, u, f, y;
|
|
5368
|
-
const n = this.beginLoad(i), r = n.signal, o = this.processor ?
|
|
5372
|
+
const n = this.beginLoad(i), r = n.signal, o = this.processor ? ts(this.processor, r) : void 0;
|
|
5369
5373
|
this.state = {
|
|
5370
5374
|
...this.state,
|
|
5371
5375
|
loading: !0,
|
|
@@ -5391,60 +5395,60 @@ class Zn {
|
|
|
5391
5395
|
}, this.emit("loading", this.state), this.emit("statechange", this.state);
|
|
5392
5396
|
try {
|
|
5393
5397
|
(s = i.signal) != null && s.aborted && n.abort(), H(r), this.osmoFallbackReason = "";
|
|
5394
|
-
const p = new
|
|
5398
|
+
const p = new _o(), h = new Uo(this.scaleToFov(this.state.scale), 1, 1, 1100), d = ((a = i.route) == null ? void 0 : a.family) === "panorama-video", m = Si(i.descriptor.extension ?? ((c = i.route) == null ? void 0 : c.sourceFormat)), g = Nc(m, i.descriptor.contentType);
|
|
5395
5399
|
this.state.family = d ? "panorama-video" : "panorama", this.state.capabilities = {
|
|
5396
5400
|
...this.state.capabilities,
|
|
5397
5401
|
playback: d,
|
|
5398
5402
|
timeline: d,
|
|
5399
5403
|
volume: d
|
|
5400
5404
|
};
|
|
5401
|
-
const b =
|
|
5405
|
+
const b = Mn.has(m) && o && await this.tryCalibratedVendor(e, m, i.descriptor.name, r, p, o);
|
|
5402
5406
|
if (H(r), b && ((l = this.calibratedRenderer) != null && l.canvas)) {
|
|
5403
5407
|
this.finishRealtimeScene(this.calibratedRenderer.canvas);
|
|
5404
5408
|
return;
|
|
5405
5409
|
}
|
|
5406
|
-
if (
|
|
5407
|
-
const x = new
|
|
5410
|
+
if (m === "insv" && this.osmoFallbackReason) throw new Error(`INSV ${this.osmoFallbackReason}`);
|
|
5411
|
+
const x = new Eo({
|
|
5408
5412
|
antialias: !0,
|
|
5409
5413
|
alpha: !1,
|
|
5410
5414
|
preserveDrawingBuffer: !0
|
|
5411
5415
|
});
|
|
5412
5416
|
if (this.renderer = x, x.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)), x.setClearColor(1120295, 1), x.domElement.className = "panoramav-canvas", this.stage.replaceChildren(x.domElement), b) {
|
|
5413
|
-
this.finishScene(x, p,
|
|
5417
|
+
this.finishScene(x, p, h);
|
|
5414
5418
|
return;
|
|
5415
5419
|
}
|
|
5416
|
-
const v =
|
|
5417
|
-
if (H(r),
|
|
5420
|
+
const v = m === "osv" ? await this.resolveOsmoProxy(i.descriptor.name, r) : await le(Oc(e, m, r), r);
|
|
5421
|
+
if (H(r), m === "insp" && o) {
|
|
5418
5422
|
const T = await o.open(v, { format: "insp", signal: r });
|
|
5419
5423
|
if (H(r), T.projection.kind === "mei-extended") {
|
|
5420
|
-
const L = await le(new
|
|
5424
|
+
const L = await le(new Yr().loadAsync(this.sourceToUrl(v, g)), r, (k) => k.dispose());
|
|
5421
5425
|
H(r), this.texture = L, L.anisotropy = x.capabilities.getMaxAnisotropy();
|
|
5422
|
-
const _ = await le(
|
|
5423
|
-
H(r), _.mesh && p.add(_.mesh), this.texture = L, this.calibratedRenderer = _, this.state.vendor = T.vendor, this.state.cameraModel = T.cameraModel, this.state.calibrationSource = T.calibrationSource, this.state.projection = T.projection.kind, this.state.decodeMode = "browser-media", this.state.stitchMode = "calibrated-blend", this.state.naturalWidth = T.width, this.state.naturalHeight = T.height, this.state.warnings = T.confidence === "experimental" ? ["Experimental calibrated INSP preview uses the image's embedded lens calibration, exposure matching, and a content-aware feathered seam."] : T.warnings, this.state.warnings.length && this.emit("warnings", this.state.warnings), H(r), this.finishScene(x, p,
|
|
5426
|
+
const _ = await le(ds(o, T, L), r, (k) => k.close());
|
|
5427
|
+
H(r), _.mesh && p.add(_.mesh), this.texture = L, this.calibratedRenderer = _, this.state.vendor = T.vendor, this.state.cameraModel = T.cameraModel, this.state.calibrationSource = T.calibrationSource, this.state.projection = T.projection.kind, this.state.decodeMode = "browser-media", this.state.stitchMode = "calibrated-blend", this.state.naturalWidth = T.width, this.state.naturalHeight = T.height, this.state.warnings = T.confidence === "experimental" ? ["Experimental calibrated INSP preview uses the image's embedded lens calibration, exposure matching, and a content-aware feathered seam."] : T.warnings, this.state.warnings.length && this.emit("warnings", this.state.warnings), H(r), this.finishScene(x, p, h);
|
|
5424
5428
|
return;
|
|
5425
5429
|
}
|
|
5426
5430
|
if (o.close(), T.projection.kind === "unknown")
|
|
5427
5431
|
throw new Error(T.warnings[0] || "INSP contains an unsupported raw dual-fisheye image.");
|
|
5428
5432
|
}
|
|
5429
|
-
const w = d ? await le(this.createVideoTexture(v, g, r), r, (T) => T.dispose()) : await le(new
|
|
5430
|
-
H(r), this.texture = w, w.colorSpace =
|
|
5431
|
-
const S = new
|
|
5433
|
+
const w = d ? await le(this.createVideoTexture(v, g, r), r, (T) => T.dispose()) : await le(new Yr().loadAsync(this.sourceToUrl(v, g)), r, (T) => T.dispose());
|
|
5434
|
+
H(r), this.texture = w, w.colorSpace = Ji, w.anisotropy = x.capabilities.getMaxAnisotropy(), w.minFilter = Ft, w.generateMipmaps = !1;
|
|
5435
|
+
const S = new Ki(500, 64, 40);
|
|
5432
5436
|
S.scale(-1, 1, 1);
|
|
5433
|
-
const D = new
|
|
5437
|
+
const D = new Co({
|
|
5434
5438
|
map: w
|
|
5435
5439
|
});
|
|
5436
|
-
p.add(new
|
|
5437
|
-
const F =
|
|
5440
|
+
p.add(new Zi(S, D)), this.renderer = x, this.scene = p, this.camera = h, this.texture = w, this.geometry = S, this.material = D, this.state.proxyPreview = this.state.proxyPreview || m === "osv", this.state.decodeMode = this.state.proxyPreview ? "proxy" : "browser-media", this.state.stitchMode = this.state.proxyPreview ? "proxy" : "equirectangular", this.state.naturalWidth = ((u = this.video) == null ? void 0 : u.videoWidth) || Cc(w), this.state.naturalHeight = ((f = this.video) == null ? void 0 : f.videoHeight) || Ic(w);
|
|
5441
|
+
const F = zc(this.state.naturalWidth, this.state.naturalHeight);
|
|
5438
5442
|
if (F) {
|
|
5439
|
-
if (
|
|
5440
|
-
throw new Error(`${
|
|
5443
|
+
if (Mn.has(m))
|
|
5444
|
+
throw new Error(`${m.toUpperCase()} contains an unstitched or unsupported projection. Export a stitched 2:1 video with the camera vendor app before spherical preview.`);
|
|
5441
5445
|
this.state.warnings = [F], this.notice.textContent = F, this.root.append(this.notice), this.emit("warnings", this.state.warnings);
|
|
5442
5446
|
}
|
|
5443
|
-
H(r), this.finishScene(x, p,
|
|
5447
|
+
H(r), this.finishScene(x, p, h);
|
|
5444
5448
|
} catch (p) {
|
|
5445
5449
|
if (r.aborted) throw new DOMException("Panorama preview was aborted.", "AbortError");
|
|
5446
|
-
const
|
|
5447
|
-
throw this.disposeScene(), this.state.loading = !1, this.state.error =
|
|
5450
|
+
const h = Bc(p, i.descriptor.extension ?? ((y = i.route) == null ? void 0 : y.sourceFormat));
|
|
5451
|
+
throw this.disposeScene(), this.state.loading = !1, this.state.error = h.message, this.emit("error", h), this.emit("statechange", this.state), h;
|
|
5448
5452
|
}
|
|
5449
5453
|
}
|
|
5450
5454
|
/** Display a WASM-developed RAW raster with the original sensor calibration. */
|
|
@@ -5493,7 +5497,7 @@ class Zn {
|
|
|
5493
5497
|
return;
|
|
5494
5498
|
}
|
|
5495
5499
|
o.addEventListener("abort", f, { once: !0 }), a.src = this.sourceToUrl(e, "image/jpeg");
|
|
5496
|
-
}), H(o), this.calibratedRenderer =
|
|
5500
|
+
}), H(o), this.calibratedRenderer = Ac(a, i), this.state.stitchMode = this.calibratedRenderer.dynamicSeam ? "static-seam" : "calibrated-blend", this.state.warnings.length && this.emit("warnings", this.state.warnings), H(o), this.finishRealtimeScene(this.calibratedRenderer.canvas);
|
|
5497
5501
|
} catch (a) {
|
|
5498
5502
|
throw o.aborted ? new DOMException("Panorama preview was aborted.", "AbortError") : (this.disposeScene(), this.state.loading = !1, this.state.error = a instanceof Error ? a.message : String(a), this.emit("statechange", this.state), a);
|
|
5499
5503
|
}
|
|
@@ -5588,7 +5592,7 @@ class Zn {
|
|
|
5588
5592
|
var n, r, o, s, a;
|
|
5589
5593
|
if (!((n = this.calibratedRenderer) != null && n.canvas) && (!this.renderer || !this.scene || !this.camera))
|
|
5590
5594
|
return;
|
|
5591
|
-
const e =
|
|
5595
|
+
const e = Sn(90 - this.lat), i = Sn(this.lon);
|
|
5592
5596
|
if ((r = this.camera) == null || r.lookAt(
|
|
5593
5597
|
500 * Math.sin(e) * Math.cos(i),
|
|
5594
5598
|
500 * Math.cos(e),
|
|
@@ -5604,18 +5608,18 @@ class Zn {
|
|
|
5604
5608
|
let a, c;
|
|
5605
5609
|
try {
|
|
5606
5610
|
const y = i === "insv" ? await le(this.resolveInstaCompanion(n), r) : void 0;
|
|
5607
|
-
H(r), c =
|
|
5611
|
+
H(r), c = Uc(e, y, n);
|
|
5608
5612
|
const p = i === "insv" ? await le(this.resolveInstaSidecar(c.primaryName), r) : void 0;
|
|
5609
5613
|
H(r), a = await s.open(c.source, { format: i, sidecar: p, companion: c.companion, signal: r }), H(r);
|
|
5610
|
-
const
|
|
5611
|
-
if (a.projection.kind === "equirectangular" ||
|
|
5612
|
-
return this.state.vendor = a.vendor, this.state.cameraModel = a.cameraModel, this.state.calibrationSource = a.calibrationSource, this.state.projection =
|
|
5613
|
-
const d = await le(
|
|
5614
|
+
const h = a.projection.kind === "unknown" && a.tracks.length === 1 && to(a.tracks[0].width, a.tracks[0].height);
|
|
5615
|
+
if (a.projection.kind === "equirectangular" || h)
|
|
5616
|
+
return this.state.vendor = a.vendor, this.state.cameraModel = a.cameraModel, this.state.calibrationSource = a.calibrationSource, this.state.projection = h ? "equirectangular" : a.projection.kind, this.state.proxyPreview = !!a.proxyPreview || h, this.state.warnings = h ? [...a.warnings, "INSV calibration metadata was unavailable; using its browser-decodable 2:1 stitched track as a proxy."] : a.warnings, this.state.warnings.length && this.emit("warnings", this.state.warnings), s.close(), !1;
|
|
5617
|
+
const d = await le(Kn(a) && !((l = a.imu) != null && l.imuToCameraConfirmed) ? Tc(s, a) : hs(s, a), r, (m) => m.close());
|
|
5614
5618
|
return H(r), d.mesh && o.add(d.mesh), this.calibratedRenderer = d, this.state.vendor = a.vendor, this.state.cameraModel = a.cameraModel, this.state.calibrationSource = a.calibrationSource, this.state.projection = a.projection.kind, this.state.decodeMode = "webcodecs", this.state.stitchMode = "calibrated-blend", this.state.proxyPreview = !1, this.state.stabilizationAvailable = d.stabilizationAvailable, this.state.stabilizationMode = d.stabilizationMode, this.state.naturalWidth = 2048, this.state.naturalHeight = 1024, this.state.duration = d.duration, this.state.currentTime = d.currentTime, this.state.paused = d.paused, this.state.muted = !0, this.createCalibratedControls(d), this.state.warnings = a.confidence === "experimental" ? [`Experimental calibrated ${i.toUpperCase()} preview uses source-specific lens calibration. Dynamic seams and symmetric overlap exposure matching activate after paired frames; IMU stabilization ${d.stabilizationAvailable ? "is available" : "remains disabled until the IMU-to-camera rotation is confirmed"}.`] : a.warnings, this.state.warnings.length && this.emit("warnings", this.state.warnings), !0;
|
|
5615
5619
|
} catch (y) {
|
|
5616
5620
|
if (H(r), s.close(), i === "insv" && a && c && y instanceof B && y.code === "codec_unsupported")
|
|
5617
5621
|
try {
|
|
5618
|
-
const p = await le(
|
|
5622
|
+
const p = await le(ms(a, c.source, c.companion), r, (h) => h.close());
|
|
5619
5623
|
return H(r), p.mesh && o.add(p.mesh), this.calibratedRenderer = p, this.state.vendor = a.vendor, this.state.cameraModel = a.cameraModel, this.state.calibrationSource = a.calibrationSource, this.state.projection = a.projection.kind, this.state.decodeMode = "browser-media", this.state.stitchMode = "calibrated-blend", this.state.proxyPreview = !1, this.state.stabilizationAvailable = !1, this.state.stabilizationMode = "off", this.state.naturalWidth = (u = a.tracks[0]) == null ? void 0 : u.width, this.state.naturalHeight = (f = a.tracks[0]) == null ? void 0 : f.height, this.state.duration = p.duration, this.state.currentTime = p.currentTime, this.state.paused = p.paused, this.state.muted = !0, this.createCalibratedControls(p), this.state.warnings = [
|
|
5620
5624
|
"WebCodecs is unavailable; using browser media decoding. Dynamic seams and IMU stabilization are disabled.",
|
|
5621
5625
|
...a.warnings
|
|
@@ -5623,7 +5627,7 @@ class Zn {
|
|
|
5623
5627
|
} catch (p) {
|
|
5624
5628
|
H(r), y = p;
|
|
5625
5629
|
}
|
|
5626
|
-
return this.osmoFallbackReason = i === "insv" ?
|
|
5630
|
+
return this.osmoFallbackReason = i === "insv" ? jc(y) : y instanceof Error ? y.message : String(y), this.state.warnings = [i === "osv" ? `${this.osmoFallbackReason} Falling back to the camera-generated LRF proxy.` : this.osmoFallbackReason], !1;
|
|
5627
5631
|
}
|
|
5628
5632
|
}
|
|
5629
5633
|
async resolveInstaSidecar(e) {
|
|
@@ -5635,7 +5639,7 @@ class Zn {
|
|
|
5635
5639
|
name: i.split(/[\\/]/).pop(),
|
|
5636
5640
|
relation: "sidecar"
|
|
5637
5641
|
});
|
|
5638
|
-
return
|
|
5642
|
+
return xa(n);
|
|
5639
5643
|
}
|
|
5640
5644
|
createCalibratedControls(e) {
|
|
5641
5645
|
const i = (this.interactionController ?? (this.interactionController = new AbortController())).signal, n = document.createElement("div");
|
|
@@ -5653,7 +5657,7 @@ class Zn {
|
|
|
5653
5657
|
const i = this.calibratedRenderer;
|
|
5654
5658
|
if (!i) return;
|
|
5655
5659
|
const n = i.currentTime;
|
|
5656
|
-
this.state.duration = i.duration, this.state.currentTime = n, this.state.paused = i.paused, this.calibratedPlayButton && (this.calibratedPlayButton.textContent = i.paused ? "Play" : "Pause", this.calibratedPlayButton.setAttribute("aria-label", `${i.paused ? "Play" : "Pause"} panorama video`)), this.calibratedTimeline && (this.calibratedTimeline.max = String(i.duration || 0), this.calibratedTimeline.value = String(n)), this.calibratedTime && (this.calibratedTime.value = `${
|
|
5660
|
+
this.state.duration = i.duration, this.state.currentTime = n, this.state.paused = i.paused, this.calibratedPlayButton && (this.calibratedPlayButton.textContent = i.paused ? "Play" : "Pause", this.calibratedPlayButton.setAttribute("aria-label", `${i.paused ? "Play" : "Pause"} panorama video`)), this.calibratedTimeline && (this.calibratedTimeline.max = String(i.duration || 0), this.calibratedTimeline.value = String(n)), this.calibratedTime && (this.calibratedTime.value = `${Tn(n)} / ${Tn(i.duration)}`);
|
|
5657
5661
|
const r = performance.now();
|
|
5658
5662
|
(e || r - this.lastPlaybackStateEmit >= 250) && (this.lastPlaybackStateEmit = r, this.emit("statechange", this.state));
|
|
5659
5663
|
}
|
|
@@ -5668,7 +5672,7 @@ class Zn {
|
|
|
5668
5672
|
name: i.split(/[\\/]/).pop(),
|
|
5669
5673
|
relation: "companion"
|
|
5670
5674
|
});
|
|
5671
|
-
return
|
|
5675
|
+
return xa(n);
|
|
5672
5676
|
}
|
|
5673
5677
|
finishScene(e, i, n) {
|
|
5674
5678
|
this.renderer = e, this.scene = i, this.camera = n, this.state.loading = !1, this.state.error = null, this.bindInteractions(e.domElement), this.observeResize(), this.resize(), this.startAnimation(), this.emit("rendered", this.state), this.emit("statechange", this.state);
|
|
@@ -5682,7 +5686,7 @@ class Zn {
|
|
|
5682
5686
|
sourceToUrl(e, i) {
|
|
5683
5687
|
if (this.revokeCreatedUrl(), typeof e == "string")
|
|
5684
5688
|
return e;
|
|
5685
|
-
const n = e instanceof Blob && (!i || e.type === i) ? e : new Blob([e instanceof Blob ? e :
|
|
5689
|
+
const n = e instanceof Blob && (!i || e.type === i) ? e : new Blob([e instanceof Blob ? e : Ec(e)], i ? { type: i } : void 0);
|
|
5686
5690
|
return this.createdUrl = URL.createObjectURL(n), this.createdUrl;
|
|
5687
5691
|
}
|
|
5688
5692
|
async createVideoTexture(e, i, n) {
|
|
@@ -5708,7 +5712,7 @@ class Zn {
|
|
|
5708
5712
|
};
|
|
5709
5713
|
for (const a of ["durationchange", "timeupdate", "play", "pause", "volumechange"])
|
|
5710
5714
|
r.addEventListener(a, s, { signal: o });
|
|
5711
|
-
return this.video = r, this.root.append(r), s(), new
|
|
5715
|
+
return this.video = r, this.root.append(r), s(), new Rn(r);
|
|
5712
5716
|
}
|
|
5713
5717
|
async resolveOsmoProxy(e, i) {
|
|
5714
5718
|
const n = String(e ?? "").replace(/\.osv$/i, ".LRF");
|
|
@@ -5722,7 +5726,7 @@ class Zn {
|
|
|
5722
5726
|
relation: "proxy"
|
|
5723
5727
|
})), o = i ? await le(r, i) : await r;
|
|
5724
5728
|
H(i);
|
|
5725
|
-
const s =
|
|
5729
|
+
const s = xa(o);
|
|
5726
5730
|
if (!s)
|
|
5727
5731
|
throw new Error(`OSV spherical preview requires the matching ${n} proxy file. Upload both files together.`);
|
|
5728
5732
|
return this.state.warnings = [
|
|
@@ -5730,8 +5734,8 @@ class Zn {
|
|
|
5730
5734
|
], this.emit("warnings", this.state.warnings), s;
|
|
5731
5735
|
}
|
|
5732
5736
|
disposeScene() {
|
|
5733
|
-
var e, i, n, r, o, s, a, c, l, u, f, y, p,
|
|
5734
|
-
(e = this.interactionController) == null || e.abort(), this.interactionController = void 0, this.pointerDown = !1, this.animationFrame && (cancelAnimationFrame(this.animationFrame), this.animationFrame = 0), (i = this.resizeObserver) == null || i.disconnect(), this.resizeObserver = null, window.removeEventListener("resize", this.resize), (n = this.texture) == null || n.dispose(), (r = this.video) == null || r.pause(), (o = this.video) == null || o.removeAttribute("src"), (s = this.video) == null || s.load(), (a = this.video) == null || a.remove(), (c = this.geometry) == null || c.dispose(), (l = this.material) == null || l.dispose(), (u = this.renderer) == null || u.dispose(), (y = (f = this.renderer) == null ? void 0 : f.forceContextLoss) == null || y.call(f), (p = this.calibratedRenderer) == null || p.close(), (
|
|
5737
|
+
var e, i, n, r, o, s, a, c, l, u, f, y, p, h;
|
|
5738
|
+
(e = this.interactionController) == null || e.abort(), this.interactionController = void 0, this.pointerDown = !1, this.animationFrame && (cancelAnimationFrame(this.animationFrame), this.animationFrame = 0), (i = this.resizeObserver) == null || i.disconnect(), this.resizeObserver = null, window.removeEventListener("resize", this.resize), (n = this.texture) == null || n.dispose(), (r = this.video) == null || r.pause(), (o = this.video) == null || o.removeAttribute("src"), (s = this.video) == null || s.load(), (a = this.video) == null || a.remove(), (c = this.geometry) == null || c.dispose(), (l = this.material) == null || l.dispose(), (u = this.renderer) == null || u.dispose(), (y = (f = this.renderer) == null ? void 0 : f.forceContextLoss) == null || y.call(f), (p = this.calibratedRenderer) == null || p.close(), (h = this.processor) == null || h.close(), this.texture = null, this.video = null, this.geometry = null, this.material = null, this.renderer = null, this.calibratedRenderer = null, this.calibratedPlayButton = null, this.calibratedTimeline = null, this.calibratedTime = null, this.lastPlaybackStateEmit = 0, this.hint.style.bottom = "", this.osmoFallbackReason = "", this.scene = null, this.camera = null, this.revokeCreatedUrl(), this.stage.replaceChildren(), this.root.querySelectorAll(".panoramav-calibrated-controls, .panoramav-notice").forEach((d) => d.remove());
|
|
5735
5739
|
}
|
|
5736
5740
|
revokeCreatedUrl() {
|
|
5737
5741
|
this.createdUrl && (URL.revokeObjectURL(this.createdUrl), this.createdUrl = null);
|
|
@@ -5741,22 +5745,22 @@ class Zn {
|
|
|
5741
5745
|
n(i);
|
|
5742
5746
|
}
|
|
5743
5747
|
}
|
|
5744
|
-
function
|
|
5748
|
+
function Yc(t = {}) {
|
|
5745
5749
|
return {
|
|
5746
5750
|
id: "panorama",
|
|
5747
5751
|
family: "panorama",
|
|
5748
|
-
supports: (e) => ["pano", "panorama", "360", "insp", "360v", "vr360", "insv", "osv"].includes(
|
|
5749
|
-
createSession: (e, i) => new
|
|
5752
|
+
supports: (e) => ["pano", "panorama", "360", "insp", "360v", "vr360", "insv", "osv"].includes(Si(e)),
|
|
5753
|
+
createSession: (e, i) => new eo(e, i, t.processor)
|
|
5750
5754
|
};
|
|
5751
5755
|
}
|
|
5752
|
-
function
|
|
5753
|
-
const e = new Set(
|
|
5754
|
-
return [...
|
|
5756
|
+
function Qc(t = Po()) {
|
|
5757
|
+
const e = new Set(Dn.flatMap((i) => i.extensions));
|
|
5758
|
+
return [...Dn, ...t.filter((i) => !i.extensions.some((n) => e.has(n)))];
|
|
5755
5759
|
}
|
|
5756
|
-
function
|
|
5760
|
+
function Uc(t, e, i) {
|
|
5757
5761
|
return e && i && /_10_/i.test(i) ? { source: e, companion: t, primaryName: i.replace(/_10_/i, "_00_") } : { source: t, companion: e, primaryName: i };
|
|
5758
5762
|
}
|
|
5759
|
-
function
|
|
5763
|
+
function Ec(t) {
|
|
5760
5764
|
if (ArrayBuffer.isView(t)) {
|
|
5761
5765
|
const e = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
5762
5766
|
if (e.buffer instanceof ArrayBuffer) return e;
|
|
@@ -5765,38 +5769,38 @@ function Uc(t) {
|
|
|
5765
5769
|
}
|
|
5766
5770
|
return t;
|
|
5767
5771
|
}
|
|
5768
|
-
function
|
|
5772
|
+
function Cc(t) {
|
|
5769
5773
|
const e = t.image;
|
|
5770
5774
|
return (e == null ? void 0 : e.naturalWidth) ?? (e == null ? void 0 : e.width);
|
|
5771
5775
|
}
|
|
5772
|
-
function
|
|
5776
|
+
function Ic(t) {
|
|
5773
5777
|
const e = t.image;
|
|
5774
5778
|
return (e == null ? void 0 : e.naturalHeight) ?? (e == null ? void 0 : e.height);
|
|
5775
5779
|
}
|
|
5776
|
-
function
|
|
5780
|
+
function to(t, e) {
|
|
5777
5781
|
if (!t || !e)
|
|
5778
5782
|
return !1;
|
|
5779
5783
|
const i = t / e;
|
|
5780
5784
|
return i >= 1.8 && i <= 2.2;
|
|
5781
5785
|
}
|
|
5782
|
-
function Ic(t, e) {
|
|
5783
|
-
return t && e && !eo(t, e) ? Ac : void 0;
|
|
5784
|
-
}
|
|
5785
5786
|
function zc(t, e) {
|
|
5786
|
-
|
|
5787
|
-
|
|
5787
|
+
return t && e && !to(t, e) ? Lc : void 0;
|
|
5788
|
+
}
|
|
5789
|
+
function Bc(t, e) {
|
|
5790
|
+
const i = Si(e);
|
|
5791
|
+
return t instanceof Error && t.message.startsWith(i.toUpperCase()) ? t : _c.has(i) ? new Error(`${i.toUpperCase()} source could not be decoded by this browser. Stitch or export it with the camera vendor app as a 2:1 JPEG, MP4, or WebM file.`) : t instanceof Error ? t : new Error(String(t));
|
|
5788
5792
|
}
|
|
5789
|
-
function
|
|
5793
|
+
function jc(t) {
|
|
5790
5794
|
return t instanceof B ? t.code === "sidecar_missing" ? "This INSV needs its matching .insv.pb calibration sidecar. Upload the sidecar with the video, or export a stitched 2:1 MP4/WebM file." : t.code === "calibration_missing" || t.code === "invalid_manifest" ? "This INSV needs both matching _00_/_10_ lens files and valid calibration metadata. Upload the pair, or export a stitched 2:1 MP4/WebM file." : t.message : t instanceof Error ? t.message : String(t);
|
|
5791
5795
|
}
|
|
5792
|
-
function
|
|
5796
|
+
function xa(t) {
|
|
5793
5797
|
if (t)
|
|
5794
5798
|
return typeof t == "object" && "source" in t ? t.source : t;
|
|
5795
5799
|
}
|
|
5796
|
-
function
|
|
5800
|
+
function Nc(t, e) {
|
|
5797
5801
|
if (e && e !== "application/octet-stream")
|
|
5798
5802
|
return e;
|
|
5799
|
-
switch (
|
|
5803
|
+
switch (Si(t)) {
|
|
5800
5804
|
case "insp":
|
|
5801
5805
|
return "image/jpeg";
|
|
5802
5806
|
case "insv":
|
|
@@ -5806,40 +5810,40 @@ function jc(t, e) {
|
|
|
5806
5810
|
return e;
|
|
5807
5811
|
}
|
|
5808
5812
|
}
|
|
5809
|
-
async function
|
|
5810
|
-
if (
|
|
5813
|
+
async function Oc(t, e, i) {
|
|
5814
|
+
if (Si(e) !== "insp" || typeof t != "string")
|
|
5811
5815
|
return t;
|
|
5812
5816
|
const n = await fetch(t, { signal: i });
|
|
5813
5817
|
if (!n.ok)
|
|
5814
5818
|
throw new Error(`INSP source request failed: ${n.status} ${n.statusText}`.trim());
|
|
5815
5819
|
return n.blob();
|
|
5816
5820
|
}
|
|
5817
|
-
function
|
|
5821
|
+
function Sn(t) {
|
|
5818
5822
|
return t * Math.PI / 180;
|
|
5819
5823
|
}
|
|
5820
|
-
function
|
|
5824
|
+
function Tn(t) {
|
|
5821
5825
|
const e = Math.max(0, Number.isFinite(t) ? t : 0);
|
|
5822
5826
|
return `${Math.floor(e / 60)}:${Math.floor(e % 60).toString().padStart(2, "0")}`;
|
|
5823
5827
|
}
|
|
5824
|
-
function
|
|
5828
|
+
function Si(t) {
|
|
5825
5829
|
return String(t ?? "").trim().replace(/^\./, "").toLowerCase();
|
|
5826
5830
|
}
|
|
5827
|
-
const
|
|
5831
|
+
const Hc = [{
|
|
5828
5832
|
extensions: ["dng"],
|
|
5829
5833
|
family: "image",
|
|
5830
5834
|
driverId: "raw-image",
|
|
5831
5835
|
targetFormat: "jpg",
|
|
5832
5836
|
contentTypes: ["image/dng", "image/x-adobe-dng"]
|
|
5833
5837
|
}];
|
|
5834
|
-
function
|
|
5838
|
+
function Jc(t) {
|
|
5835
5839
|
return {
|
|
5836
5840
|
id: "raw-image",
|
|
5837
5841
|
family: "image",
|
|
5838
5842
|
supports: (e) => e.replace(/^\./, "").toLowerCase() === "dng",
|
|
5839
|
-
createSession: (e, i) => new
|
|
5843
|
+
createSession: (e, i) => new Vc(e, i ?? {}, t)
|
|
5840
5844
|
};
|
|
5841
5845
|
}
|
|
5842
|
-
class
|
|
5846
|
+
class Vc {
|
|
5843
5847
|
constructor(e, i, n) {
|
|
5844
5848
|
A(this, "child");
|
|
5845
5849
|
A(this, "controller");
|
|
@@ -5864,11 +5868,11 @@ class Oc {
|
|
|
5864
5868
|
try {
|
|
5865
5869
|
(a = i.signal) != null && a.aborted && n.abort(), H(r);
|
|
5866
5870
|
const c = s ? await le(s.open(e, { format: "dng", signal: r }), r) : void 0;
|
|
5867
|
-
if (H(r), c &&
|
|
5871
|
+
if (H(r), c && Zn(c)) {
|
|
5868
5872
|
if (!(s != null && s.decodeImage)) throw new Error("Calibrated DNG preview requires a panorama processor with WASM image decoding.");
|
|
5869
5873
|
const l = await le(s.decodeImage(r), r);
|
|
5870
5874
|
H(r), s.close();
|
|
5871
|
-
const u = new
|
|
5875
|
+
const u = new eo(this.host, this.options);
|
|
5872
5876
|
this.attach(u), await le(u.loadCalibratedImage(l, c, o), r);
|
|
5873
5877
|
} else {
|
|
5874
5878
|
s == null || s.close();
|
|
@@ -5881,7 +5885,7 @@ class Oc {
|
|
|
5881
5885
|
H(r);
|
|
5882
5886
|
const u = [...(c == null ? void 0 : c.warnings) ?? [], ...l.warnings ?? []];
|
|
5883
5887
|
this.state.warnings = u, u.length && this.emit("warnings", u), H(r);
|
|
5884
|
-
const f =
|
|
5888
|
+
const f = Ao().createSession(this.host, this.options);
|
|
5885
5889
|
this.attach(f, u), await le(f.load(l.source, {
|
|
5886
5890
|
...o,
|
|
5887
5891
|
descriptor: { ...i.descriptor, source: l.source, extension: l.format, contentType: l.contentType },
|
|
@@ -5944,13 +5948,13 @@ class Oc {
|
|
|
5944
5948
|
}
|
|
5945
5949
|
}
|
|
5946
5950
|
export {
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5951
|
+
Hc as R,
|
|
5952
|
+
$c as a,
|
|
5953
|
+
Yc as b,
|
|
5954
|
+
wi as c,
|
|
5955
|
+
Jc as d,
|
|
5956
|
+
Qc as e,
|
|
5957
|
+
rs as f,
|
|
5958
|
+
Xc as g,
|
|
5955
5959
|
Se as t
|
|
5956
5960
|
};
|