@kalyptos/narcissus 0.1.2 → 0.1.3
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.
|
@@ -1075,32 +1075,34 @@ function Te(e, t) {
|
|
|
1075
1075
|
for (let t = 0; t < 4; t++) e[i * 4 + t] /= a;
|
|
1076
1076
|
}), e;
|
|
1077
1077
|
}
|
|
1078
|
-
var
|
|
1078
|
+
var Ee = class {
|
|
1079
1079
|
#e = /* @__PURE__ */ new Map();
|
|
1080
1080
|
update(e, t, n, r) {
|
|
1081
1081
|
let i = this.#e, a = De(e, t), o = -1;
|
|
1082
|
-
for (let [e, r] of i) t(r.page.id) ? (o = Math.max(o, r.level), !r.held && (r.start !== null && n - r.start >= 250 && (r.start = null), a.has(e) || (r.frozen =
|
|
1082
|
+
for (let [e, r] of i) t(r.page.id) ? (o = Math.max(o, r.level), !r.held && (r.start !== null && n - r.start >= 250 && (r.start = null), a.has(e) || (r.frozen = z(r, n), r.start = null, r.out = null, r.covered = !1, r.held = !0))) : i.delete(e);
|
|
1083
1083
|
let s = /* @__PURE__ */ new Set();
|
|
1084
1084
|
for (let [e, t] of a) {
|
|
1085
1085
|
let r = i.get(e);
|
|
1086
|
-
if (r)
|
|
1087
|
-
else {
|
|
1086
|
+
if (!r) {
|
|
1088
1087
|
let r = Oe(t, e % 4, n);
|
|
1089
1088
|
o = Math.max(o, r.level), i.set(e, r), s.add(r);
|
|
1089
|
+
} else if (r.held) {
|
|
1090
|
+
let e = z(r, n);
|
|
1091
|
+
r.held = !1, r.out = null, e < 255 && (r.start = n - e / 255 * 250, s.add(r));
|
|
1090
1092
|
}
|
|
1091
1093
|
}
|
|
1092
1094
|
let l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
1093
1095
|
for (let e of i.values()) if (e.held) {
|
|
1094
1096
|
l.set(e.cell, e);
|
|
1095
1097
|
for (let t = e.level, n = e.col, r = e.row; t <= o; t++, n >>= 1, r >>= 1) {
|
|
1096
|
-
let i =
|
|
1098
|
+
let i = R(t, n, r), a = u.get(i);
|
|
1097
1099
|
a ? a.push(e) : u.set(i, [e]);
|
|
1098
1100
|
}
|
|
1099
1101
|
}
|
|
1100
1102
|
let d = (e) => {
|
|
1101
1103
|
let t = [...u.get(e.cell) ?? []];
|
|
1102
1104
|
for (let n = e.level + 1, r = e.col >> 1, i = e.row >> 1; n <= o; n++, r >>= 1, i >>= 1) {
|
|
1103
|
-
let e = l.get(
|
|
1105
|
+
let e = l.get(R(n, r, i));
|
|
1104
1106
|
e && t.push(e);
|
|
1105
1107
|
}
|
|
1106
1108
|
return t;
|
|
@@ -1111,7 +1113,8 @@ var R = .25, Ee = class {
|
|
|
1111
1113
|
m += e.splats;
|
|
1112
1114
|
for (let t of d(e)) f.has(t) || (f.add(t), m += t.splats, g(t.page));
|
|
1113
1115
|
}
|
|
1114
|
-
let
|
|
1116
|
+
for (let e of i.values()) e.held && e.out !== null && !f.has(e) && (m += e.splats);
|
|
1117
|
+
let _ = 1 * r;
|
|
1115
1118
|
for (let e of s) {
|
|
1116
1119
|
let t = d(e).filter((e) => !f.has(e)), n = t.reduce((e, t) => e + t.splats, e.splats), r = new Set(t.map((e) => e.page).filter((e) => !p.has(e))), i = [...r].reduce((e, t) => e + c(t.row.count), 0);
|
|
1117
1120
|
if (m + n > _ || h + i > _) e.start = null;
|
|
@@ -1123,12 +1126,13 @@ var R = .25, Ee = class {
|
|
|
1123
1126
|
}
|
|
1124
1127
|
let v = /* @__PURE__ */ new Map(), y = !1;
|
|
1125
1128
|
for (let [e, t] of i) {
|
|
1126
|
-
if (t.held &&
|
|
1129
|
+
if (t.held && f.has(t)) t.out !== null && (t.frozen = z(t, n)), t.out = null, t.covered = !0;
|
|
1130
|
+
else if (t.held && (t.covered && t.out === null && (t.out = n), !t.covered || z(t, n) === 0)) {
|
|
1127
1131
|
i.delete(e);
|
|
1128
1132
|
continue;
|
|
1129
1133
|
}
|
|
1130
1134
|
(t.held || t.start !== null) && (y = !0);
|
|
1131
|
-
let r =
|
|
1135
|
+
let r = z(t, n);
|
|
1132
1136
|
if (!r) continue;
|
|
1133
1137
|
let a = v.get(t.page.id);
|
|
1134
1138
|
a ? a.factors = (a.factors | r << 8 * t.q) >>> 0 : v.set(t.page.id, {
|
|
@@ -1162,36 +1166,38 @@ function Oe(t, n, r) {
|
|
|
1162
1166
|
level: a,
|
|
1163
1167
|
col: o,
|
|
1164
1168
|
row: s,
|
|
1165
|
-
cell:
|
|
1169
|
+
cell: R(a, o, s),
|
|
1166
1170
|
splats: ke(t.row, n),
|
|
1167
1171
|
start: r,
|
|
1168
1172
|
frozen: 0,
|
|
1173
|
+
out: null,
|
|
1174
|
+
covered: !1,
|
|
1169
1175
|
held: !1
|
|
1170
1176
|
};
|
|
1171
1177
|
}
|
|
1172
|
-
var
|
|
1178
|
+
var R = (e, t, n) => ((e + 1) * 2 ** 21 + t) * 2 ** 21 + n;
|
|
1173
1179
|
function ke({ count: e, quadrants: t }, n) {
|
|
1174
1180
|
return (n < 3 ? t[n] : e) - (n > 0 ? t[n - 1] : 0);
|
|
1175
1181
|
}
|
|
1176
|
-
function
|
|
1177
|
-
return e.held ? e.frozen : e.start === null ? 255 : Math.min(255, Math.round((t - e.start) / 250 * 255));
|
|
1182
|
+
function z(e, t) {
|
|
1183
|
+
return e.held ? e.out === null ? e.frozen : Math.max(0, Math.round(e.frozen * (1 - (t - e.out) / 250))) : e.start === null ? 255 : Math.min(255, Math.round((t - e.start) / 250 * 255));
|
|
1178
1184
|
}
|
|
1179
1185
|
//#endregion
|
|
1180
1186
|
//#region src/engine/plan/footprint.ts
|
|
1181
|
-
var
|
|
1187
|
+
var Ae = [
|
|
1182
1188
|
0,
|
|
1183
1189
|
0,
|
|
1184
1190
|
0
|
|
1185
1191
|
];
|
|
1186
|
-
function
|
|
1192
|
+
function je(e, t, n, r) {
|
|
1187
1193
|
let i = (e * e + e * t + t * t + n * n + n * r + r * r) / 3;
|
|
1188
1194
|
return 1 + 15 * Math.max(0, 1 - i) ** 2;
|
|
1189
1195
|
}
|
|
1190
|
-
function
|
|
1196
|
+
function Me(e, t, n, r, i, a, o, s = 1, c = {
|
|
1191
1197
|
shown: !1,
|
|
1192
1198
|
pixels: 0,
|
|
1193
1199
|
weight: 1
|
|
1194
|
-
}, l =
|
|
1200
|
+
}, l = Ae) {
|
|
1195
1201
|
let u = (e[0] + e[3]) / 2 - l[0], d = (e[1] + e[4]) / 2 - l[1], f = (e[2] + e[5]) / 2 - l[2], p = (e[3] - e[0]) / 2, m = (e[4] - e[1]) / 2, h = (e[5] - e[2]) / 2, g = t[0] * u + t[4] * d + t[8] * f + t[12], _ = t[1] * u + t[5] * d + t[9] * f + t[13], v = -(t[2] * u + t[6] * d + t[10] * f + t[14]), y = Math.abs(t[0]) * p + Math.abs(t[4]) * m + Math.abs(t[8]) * h, b = Math.abs(t[1]) * p + Math.abs(t[5]) * m + Math.abs(t[9]) * h, x = Math.abs(t[2]) * p + Math.abs(t[6]) * m + Math.abs(t[10]) * h;
|
|
1196
1202
|
if (c.pixels = 0, c.weight = 1, c.shown = !1, v + x < a || v - x > o) return c;
|
|
1197
1203
|
let S = Math.max(a, v - x), C = Math.max(a, v + x), w = i * n / r;
|
|
@@ -1199,26 +1205,26 @@ function Ne(e, t, n, r, i, a, o, s = 1, c = {
|
|
|
1199
1205
|
let T = Math.min((g - y) / S, (g - y) / C) / w, E = Math.max((g + y) / S, (g + y) / C) / w, D = Math.min((_ - b) / S, (_ - b) / C) / i, O = Math.max((_ + b) / S, (_ + b) / C) / i;
|
|
1200
1206
|
if (E < -s || T > s || O < -s || D > s) return c;
|
|
1201
1207
|
let k = Math.max(-s, T), A = Math.min(s, E), j = Math.max(-s, D), M = Math.min(s, O), N = (E - T) * (O - D), ee = (A - k) * (M - j);
|
|
1202
|
-
return N <= 0 || ee <= 0 || (c.shown = E > -1 && T < 1 && O > -1 && D < 1, c.pixels = N * n * r / 4, c.weight =
|
|
1208
|
+
return N <= 0 || ee <= 0 || (c.shown = E > -1 && T < 1 && O > -1 && D < 1, c.pixels = N * n * r / 4, c.weight = je(k, A, j, M)), c;
|
|
1203
1209
|
}
|
|
1204
|
-
var B = /* @__PURE__ */ new Float64Array(6),
|
|
1210
|
+
var B = /* @__PURE__ */ new Float64Array(6), Ne = {
|
|
1205
1211
|
shown: !1,
|
|
1206
1212
|
pixels: 0,
|
|
1207
1213
|
weight: 1
|
|
1208
1214
|
};
|
|
1209
|
-
function
|
|
1215
|
+
function Pe(e, [t, n, r], i, a, o, s, c, l, u = Ae) {
|
|
1210
1216
|
let d = r / 2, f = Math.max(0, t - e[0], n - e[1], e[3] - t - r, e[4] - n - r);
|
|
1211
1217
|
B[2] = e[2], B[5] = e[5];
|
|
1212
1218
|
let p = 0;
|
|
1213
1219
|
for (let r = 0; r < 4; r++) {
|
|
1214
1220
|
let m = t + (r & 1) * d, h = n + (r >> 1) * d;
|
|
1215
|
-
B[0] = Math.max(e[0], m - f), B[1] = Math.max(e[1], h - f), B[3] = Math.min(e[3], m + d + f), B[4] = Math.min(e[4], h + d + f), !(B[0] > B[3] || B[1] > B[4]) &&
|
|
1221
|
+
B[0] = Math.max(e[0], m - f), B[1] = Math.max(e[1], h - f), B[3] = Math.min(e[3], m + d + f), B[4] = Math.min(e[4], h + d + f), !(B[0] > B[3] || B[1] > B[4]) && Me(B, i, a, o, s, c, l, 1, Ne, u).shown && (p |= 1 << r);
|
|
1216
1222
|
}
|
|
1217
1223
|
return p;
|
|
1218
1224
|
}
|
|
1219
1225
|
//#endregion
|
|
1220
1226
|
//#region src/engine/world/tree.ts
|
|
1221
|
-
var V = (e, t, n) => (e * 256 + t) * 256 + n,
|
|
1227
|
+
var V = (e, t, n) => (e * 256 + t) * 256 + n, Fe = class {
|
|
1222
1228
|
roots = [];
|
|
1223
1229
|
pages = /* @__PURE__ */ new Map();
|
|
1224
1230
|
units = /* @__PURE__ */ new Map();
|
|
@@ -1318,7 +1324,7 @@ var V = (e, t, n) => (e * 256 + t) * 256 + n, Ie = class {
|
|
|
1318
1324
|
}
|
|
1319
1325
|
async load(e, t, n) {
|
|
1320
1326
|
for (;;) {
|
|
1321
|
-
let r = this.wanted().filter((n) =>
|
|
1327
|
+
let r = this.wanted().filter((n) => Ie(n, e, t));
|
|
1322
1328
|
if (r.length === 0) return;
|
|
1323
1329
|
(await Promise.all(r.map((e) => n(e.path)))).forEach((e, t) => this.add(e, r[t].path));
|
|
1324
1330
|
}
|
|
@@ -1396,7 +1402,7 @@ function U(e, t) {
|
|
|
1396
1402
|
n: Math.floor(e.n / n) * n
|
|
1397
1403
|
};
|
|
1398
1404
|
}
|
|
1399
|
-
function
|
|
1405
|
+
function Ie(e, t, n) {
|
|
1400
1406
|
let r = 250 * 2 ** e.level;
|
|
1401
1407
|
return t >= e.e && t < e.e + r && n >= e.n && n < e.n + r;
|
|
1402
1408
|
}
|
|
@@ -1410,7 +1416,7 @@ function W(t) {
|
|
|
1410
1416
|
}
|
|
1411
1417
|
//#endregion
|
|
1412
1418
|
//#region src/engine/plan/cut.ts
|
|
1413
|
-
var
|
|
1419
|
+
var Le = 1 / .8 ** 2, Re = 1.1, ze = class {
|
|
1414
1420
|
#e = /* @__PURE__ */ new Map();
|
|
1415
1421
|
#t = /* @__PURE__ */ new Map();
|
|
1416
1422
|
#n = {
|
|
@@ -1419,13 +1425,13 @@ var Re = 1 / .8 ** 2, ze = 1.1, Be = class {
|
|
|
1419
1425
|
weight: 1
|
|
1420
1426
|
};
|
|
1421
1427
|
plan(e, t, n, r) {
|
|
1422
|
-
let { budget: i, capacity: a, now: o, predicted: s } = r, l = [], u = [], d = [], f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = e.wanted(), h = /* @__PURE__ */ new Map(), g = new
|
|
1428
|
+
let { budget: i, capacity: a, now: o, predicted: s } = r, l = [], u = [], d = [], f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = e.wanted(), h = /* @__PURE__ */ new Map(), g = new He(), _ = 0, v = 0, y = (e) => {
|
|
1423
1429
|
let t = e.page, r = t.row.count;
|
|
1424
1430
|
l.push(t), u.push(e.visible), d.push(e.near), v += c(r), _ += e.visible;
|
|
1425
1431
|
let i = this.#e.get(t.id), a = i !== void 0, s = e.pixels * e.weight, f = s / Math.max(1, r);
|
|
1426
1432
|
m.length && e.pixels > 0 && h.set(t.id, f);
|
|
1427
1433
|
let p = a && !e.shown && o - (this.#t.get(t.id) ?? -Infinity) <= 1500 ? i : null;
|
|
1428
|
-
(r < s * (a ?
|
|
1434
|
+
(r < s * (a ? Le : 1) || p !== null) && Ve(t, n) && g.push({
|
|
1429
1435
|
page: t,
|
|
1430
1436
|
shown: e.shown,
|
|
1431
1437
|
held: p,
|
|
@@ -1485,35 +1491,35 @@ var Re = 1 / .8 ** 2, ze = 1.1, Be = class {
|
|
|
1485
1491
|
};
|
|
1486
1492
|
}
|
|
1487
1493
|
#r(e, t, n) {
|
|
1488
|
-
let r = this.#i(e, t,
|
|
1494
|
+
let r = this.#i(e, t, Re), i = r.shown, { pixels: a, weight: o } = r, s = i;
|
|
1489
1495
|
if (n) {
|
|
1490
|
-
let t = this.#i(e, n,
|
|
1496
|
+
let t = this.#i(e, n, Re);
|
|
1491
1497
|
t.pixels > a && ({pixels: a, weight: o} = t), s ||= t.shown;
|
|
1492
1498
|
}
|
|
1493
1499
|
return {
|
|
1494
1500
|
page: e,
|
|
1495
1501
|
shown: i,
|
|
1496
1502
|
near: s,
|
|
1497
|
-
visible: i ?
|
|
1503
|
+
visible: i ? Be(e, t) : 0,
|
|
1498
1504
|
pixels: a,
|
|
1499
1505
|
weight: o
|
|
1500
1506
|
};
|
|
1501
1507
|
}
|
|
1502
1508
|
#i(e, t, n) {
|
|
1503
1509
|
let { width: r, height: i, tan: a, near: o, far: s } = t;
|
|
1504
|
-
return
|
|
1510
|
+
return Me(e.box, t.view, r, i, a, o, s, n, this.#n, t.origin);
|
|
1505
1511
|
}
|
|
1506
1512
|
};
|
|
1507
|
-
function
|
|
1508
|
-
let { width: n, height: r, tan: i, near: a, far: o, origin: s } = t, c =
|
|
1513
|
+
function Be(e, t) {
|
|
1514
|
+
let { width: n, height: r, tan: i, near: a, far: o, origin: s } = t, c = Pe(e.box, W(e), t.view, n, r, i, a, o, s), l = 0;
|
|
1509
1515
|
for (let t = 0; t < 4; t++) c & 1 << t && (l += ke(e.row, t));
|
|
1510
1516
|
return l;
|
|
1511
1517
|
}
|
|
1512
|
-
function
|
|
1518
|
+
function Ve(e, t) {
|
|
1513
1519
|
let { children: n } = e;
|
|
1514
1520
|
return e.g > 0 && t(e.id) && !n.includes(void 0) && n.some((e) => e !== null);
|
|
1515
1521
|
}
|
|
1516
|
-
var
|
|
1522
|
+
var He = class {
|
|
1517
1523
|
#e = [];
|
|
1518
1524
|
get size() {
|
|
1519
1525
|
return this.#e.length;
|
|
@@ -1548,16 +1554,16 @@ function G(e, t) {
|
|
|
1548
1554
|
}
|
|
1549
1555
|
//#endregion
|
|
1550
1556
|
//#region src/engine/quality.ts
|
|
1551
|
-
var
|
|
1552
|
-
function
|
|
1553
|
-
return Math.min(n, Math.sqrt(
|
|
1557
|
+
var Ue = 5e5, We = 2073600, Ge = [1, .85], Ke = 30, qe = 55, Je = 2e3, Ye = 5e3, Xe = 5e5, Ze = .9;
|
|
1558
|
+
function Qe(e, t, n, r) {
|
|
1559
|
+
return Math.min(n, Math.sqrt(We / Math.max(1, e * t))) * r;
|
|
1554
1560
|
}
|
|
1555
|
-
function
|
|
1561
|
+
function $e(e, t) {
|
|
1556
1562
|
if (!e.length) return 0;
|
|
1557
1563
|
let n = [...e].sort((e, t) => e - t);
|
|
1558
1564
|
return n[Math.ceil(n.length * t) - 1];
|
|
1559
1565
|
}
|
|
1560
|
-
var
|
|
1566
|
+
var et = class {
|
|
1561
1567
|
#e = 0;
|
|
1562
1568
|
#t;
|
|
1563
1569
|
#n;
|
|
@@ -1570,7 +1576,7 @@ var tt = class {
|
|
|
1570
1576
|
this.#n = t, this.#r = Math.max(t, n), this.#t = Math.min(this.#r, Math.max(this.#n, e));
|
|
1571
1577
|
}
|
|
1572
1578
|
get scale() {
|
|
1573
|
-
return
|
|
1579
|
+
return Ge[this.#e];
|
|
1574
1580
|
}
|
|
1575
1581
|
get budget() {
|
|
1576
1582
|
return this.#t;
|
|
@@ -1589,19 +1595,19 @@ var tt = class {
|
|
|
1589
1595
|
ms: e
|
|
1590
1596
|
}), this.#i = this.#i.filter((n) => t - n.time <= Math.max(1e3, 2 * e)), t - this.#i[0].time < 300) return !1;
|
|
1591
1597
|
let a = this.#i.reduce((e, t) => e + t.ms, 0) / this.#i.length;
|
|
1592
|
-
if (this.#o = a > 1e3 /
|
|
1593
|
-
let e = Math.floor(Math.min(.9, 1e3 /
|
|
1598
|
+
if (this.#o = a > 1e3 / Ke ? this.#o + i : 0, this.#s = a <= 1e3 / qe ? this.#s + i : 0, this.#o >= Je) {
|
|
1599
|
+
let e = Math.floor(Math.min(.9, 1e3 / Ke / a) * this.#t);
|
|
1594
1600
|
if (this.#t > this.#n) this.#t = Math.max(this.#n, e);
|
|
1595
|
-
else if (this.#e <
|
|
1601
|
+
else if (this.#e < Ge.length - 1) this.#e++;
|
|
1596
1602
|
else return !1;
|
|
1597
|
-
} else if (this.#s >=
|
|
1603
|
+
} else if (this.#s >= Ye) {
|
|
1598
1604
|
if (this.#e > 0) this.#e--;
|
|
1599
|
-
else if (this.#t < this.#r && r >=
|
|
1605
|
+
else if (this.#t < this.#r && r >= Ze * this.#t) this.#t = Math.min(this.#r, this.#t + Xe);
|
|
1600
1606
|
else return !1;
|
|
1601
1607
|
} else return !1;
|
|
1602
1608
|
return this.#c(), !0;
|
|
1603
1609
|
}
|
|
1604
|
-
},
|
|
1610
|
+
}, tt = class {
|
|
1605
1611
|
#e;
|
|
1606
1612
|
#t = [];
|
|
1607
1613
|
#n = /* @__PURE__ */ new Set();
|
|
@@ -1680,12 +1686,12 @@ var tt = class {
|
|
|
1680
1686
|
pages: o
|
|
1681
1687
|
};
|
|
1682
1688
|
}
|
|
1683
|
-
},
|
|
1689
|
+
}, nt = {
|
|
1684
1690
|
idx: 8,
|
|
1685
1691
|
concurrency: 8,
|
|
1686
1692
|
gap: 65536,
|
|
1687
1693
|
span: 2097152
|
|
1688
|
-
},
|
|
1694
|
+
}, rt = 1e3, it = 3e4, at = 1e3, ot = 2e3, st = class {
|
|
1689
1695
|
#e;
|
|
1690
1696
|
#t;
|
|
1691
1697
|
#n;
|
|
@@ -1715,8 +1721,8 @@ var tt = class {
|
|
|
1715
1721
|
#y = -Infinity;
|
|
1716
1722
|
#b = !1;
|
|
1717
1723
|
#x = !1;
|
|
1718
|
-
constructor(e, t, n, r, i, a =
|
|
1719
|
-
this.#e = e, this.#t = t, this.#n = n, this.#r = r, this.#i = i, this.#a = a, this.#o = new
|
|
1724
|
+
constructor(e, t, n, r, i, a = nt) {
|
|
1725
|
+
this.#e = e, this.#t = t, this.#n = n, this.#r = r, this.#i = i, this.#a = a, this.#o = new tt(a);
|
|
1720
1726
|
}
|
|
1721
1727
|
update(e, t, n) {
|
|
1722
1728
|
if (!this.#x) {
|
|
@@ -1783,7 +1789,7 @@ var tt = class {
|
|
|
1783
1789
|
let n = this.#e.pages.get(e);
|
|
1784
1790
|
if (!n) return;
|
|
1785
1791
|
let { keep: r } = this.#s, i = this.#c;
|
|
1786
|
-
this.#n.add(e, t, [n.unit.e, n.unit.n], (e) => r.has(e) || i.has(e)) ? (this.#g.add(e), this.#m.delete(e) && this.#j(e)) : (this.#m.set(e, this.#u +
|
|
1792
|
+
this.#n.add(e, t, [n.unit.e, n.unit.n], (e) => r.has(e) || i.has(e)) ? (this.#g.add(e), this.#m.delete(e) && this.#j(e)) : (this.#m.set(e, this.#u + at), this.#A(e, at)), this.#r();
|
|
1787
1793
|
};
|
|
1788
1794
|
#E(e) {
|
|
1789
1795
|
this.#x || (this.#f.delete(e), this.#k(e.pack), this.#l = this.#l.filter((e) => this.#N(e.id, e.pack)), this.#o.want(this.#l), this.#o.done(e), this.#w(), this.#r());
|
|
@@ -1797,7 +1803,7 @@ var tt = class {
|
|
|
1797
1803
|
this.#b = !0, this.#i();
|
|
1798
1804
|
return;
|
|
1799
1805
|
}
|
|
1800
|
-
let n = this.#p.get(e), r = n ? Math.min(2 * n.delay,
|
|
1806
|
+
let n = this.#p.get(e), r = n ? Math.min(2 * n.delay, it) : rt;
|
|
1801
1807
|
this.#p.set(e, {
|
|
1802
1808
|
delay: r,
|
|
1803
1809
|
until: this.#u + r
|
|
@@ -1818,11 +1824,11 @@ var tt = class {
|
|
|
1818
1824
|
}
|
|
1819
1825
|
#M() {
|
|
1820
1826
|
let e = this.#u;
|
|
1821
|
-
if (e - this.#y <
|
|
1827
|
+
if (e - this.#y < ot) return;
|
|
1822
1828
|
this.#y = e;
|
|
1823
1829
|
for (let e of this.#g) this.#n.holds(e) || this.#g.delete(e);
|
|
1824
1830
|
for (let [t, n] of this.#m) n <= e && this.#m.delete(t);
|
|
1825
|
-
for (let [t, n] of this.#_) e - n >=
|
|
1831
|
+
for (let [t, n] of this.#_) e - n >= ot && this.#_.delete(t);
|
|
1826
1832
|
let { keep: t } = this.#s;
|
|
1827
1833
|
if (this.#e.pages.size <= 2 * (this.#g.size + t.size)) return;
|
|
1828
1834
|
let n = /* @__PURE__ */ new Set([
|
|
@@ -1847,7 +1853,7 @@ var tt = class {
|
|
|
1847
1853
|
};
|
|
1848
1854
|
//#endregion
|
|
1849
1855
|
//#region src/engine/stream/remote.ts
|
|
1850
|
-
function
|
|
1856
|
+
function ct(e, t) {
|
|
1851
1857
|
let n = /* @__PURE__ */ new Map();
|
|
1852
1858
|
return (r) => {
|
|
1853
1859
|
if ("unfetch" in r) return void n.get(r.unfetch)?.abort();
|
|
@@ -1870,29 +1876,29 @@ function lt(e, t) {
|
|
|
1870
1876
|
}
|
|
1871
1877
|
//#endregion
|
|
1872
1878
|
//#region src/engine/stream/worker.ts?worker&inline
|
|
1873
|
-
var ut = "(function(){var e=class extends Error{name=`Missing`};let t=async(t,n,r)=>{let i=await fetch(t,n?{signal:r,headers:{Range:`bytes=${n[0]}-${n[1]-1}`}}:{signal:r});if(i.status===404)throw new e(`http 404 for ${t}`);if(i.status!==200&&i.status!==206)throw Error(`http ${i.status} for ${t}`);let a=new Uint8Array(await i.arrayBuffer());return n&&i.status===200?a.slice(n[0],n[1]):a},n=.28209479177387814,r=15.625,i=`GMIX`,a={position:0,alpha:6,rotationIndex:7,rotation:8,scale:11,dc:14,label:17},o={origin:0,step:3,scaleMin:6,scaleMax:9,dcMin:12,dcMax:15,shScale:18};async function s(e,t){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function c(e){return s(e,new DecompressionStream(`deflate-raw`))}function l(e){return s(e,new CompressionStream(`deflate-raw`))}async function u(e,t,n){let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||String.fromCharCode(...e.subarray(0,4))!==t)throw Error(`not a ${n} file`);let i=r.getUint16(4,!0);if(i!==1)throw Error(`${n} version ${i}; narcissus reads 1`);let a;try{a=await c(e.subarray(8))}catch{throw Error(`${n} body is not a valid deflate stream`)}return new DataView(a.buffer,a.byteOffset,a.byteLength)}function d(e,t){let n=``;for(let r=0;r<8;r++){let i=e.getUint8(t+r);n+=i.toString(16).padStart(2,`0`)}return n}function f(e,t){let n=/* @__PURE__ */ new Float32Array(6);for(let r=0;r<6;r++)n[r]=e.getFloat32(t+20+4*r,!0);return{g:e.getUint8(t),i:e.getUint8(t+1),j:e.getUint8(t+2),count:e.getUint32(t+4,!0),quadrants:[e.getUint32(t+8,!0),e.getUint32(t+12,!0),e.getUint32(t+16,!0)],box:n,offset:e.getUint32(t+44,!0),length:e.getUint32(t+48,!0)}}async function p(e){let t=await u(e,i,`.idx`);if(t.byteLength<40)throw Error(`.idx header is cut off`);let n=t.getUint16(32,!0),r=t.getUint8(34),a=t.getUint16(36,!0),o=40+n*52+r*9+a*11;if(t.byteLength!==o)throw Error(`.idx holds ${t.byteLength} bytes, its counts need ${o}`);let s=d(t,24),c={level:t.getUint8(0),e:t.getInt32(4,!0),n:t.getInt32(8,!0),pack:d(t,12),packSize:t.getUint32(20,!0),col:s===`0000000000000000`?null:s,rows:[],children:[],descendants:[]},l=40;for(let e=0;e<n;e++,l+=52)c.rows.push(f(t,l));for(let e=0;e<r;e++,l+=9)c.children.push({quadrant:t.getUint8(l),idx:d(t,l+1)});for(let e=0;e<a;e++,l+=11)c.descendants.push({depth:t.getUint8(l),column:t.getUint8(l+1),row:t.getUint8(l+2),idx:d(t,l+3)});return c}function m(e,t,n){return`u/${e.level}/${e.e}/${e.n}.${t}.${n}`}let h=/(?:^|\\/)u\\/(\\d+)\\/(-?\\d+)\\/(-?\\d+)\\.([0-9a-f]{16})\\.(?:idx|pack|col)$/;function g(e){let t=h.exec(e);return t?{level:Number(t[1]),e:Number(t[2]),n:Number(t[3]),hash:t[4]}:null}async function _(e){let t=await u(e,`GMCL`,`.col`);if(t.byteLength<60)throw Error(`.col header is cut off`);let n=t.getUint16(0,!0),r=60+12*n*n;if(t.byteLength!==r)throw Error(`.col holds ${t.byteLength} bytes, ${n} nodes need ${r}`);let i=new Float32Array(12*n*n),a=60;for(let e=0;e<12;e++){let r=t.getFloat32(12+4*e,!0)/127;for(let o=0;o<n;o++){let s=0;for(let c=0;c<n;c++,a++)s=s+t.getInt8(a)<<24>>24,i[(e*n+o)*n+c]=s*r}}return{n,pitch:t.getFloat32(4,!0),margin:t.getFloat32(8,!0),values:i}}function v(e,t,n,r){let{n:i,pitch:a,margin:o,values:s}=e,c=i-1,l=Math.min(Math.max((t+o)/a-.5,0),c),u=Math.min(Math.max((n+o)/a-.5,0),c),d=Math.min(Math.floor(l),Math.max(c-1,0)),f=Math.min(Math.floor(u),Math.max(c-1,0)),p=Math.min(d+1,c),m=Math.min(f+1,c),h=l-d,g=u-f,_=(1-h)*(1-g),v=h*(1-g),y=(1-h)*g,b=h*g,x=i*i;for(let e=0,t=0;e<12;e++,t+=x)r[e]=s[t+f*i+d]*_+s[t+f*i+p]*v+s[t+m*i+d]*y+s[t+m*i+p]*b;return r}let y=Float64Array.from({length:256},(e,t)=>(t/255-.5)*Math.SQRT2);function b(e,t,n,r,i){let a=y[t],o=y[n],s=y[r];i[e]=Math.sqrt(Math.max(0,1-a*a-o*o-s*s)),i[e>0?0:1]=a,i[e>1?1:2]=o,i[e>2?2:3]=s}function x(e,t,n,r,i){let a=e[0],o=e[1],s=e[2],c=e[3],l=t*t,u=n*n,d=r*r,f=1-2*(s*s+c*c),p=2*(o*s-a*c),m=2*(o*c+a*s),h=2*(o*s+a*c),g=1-2*(o*o+c*c),_=2*(s*c-a*o),v=2*(o*c-a*s),y=2*(s*c+a*o),b=1-2*(o*o+s*s);i[0]=3*Math.sqrt(f*f*l+p*p*u+m*m*d),i[1]=3*Math.sqrt(h*h*l+g*g*u+_*_*d),i[2]=3*Math.sqrt(v*v*l+y*y*u+b*b*d)}function S(e){if(e.length<128)throw Error(`page payload is shorter than its header`);return new DataView(e.buffer,e.byteOffset,e.byteLength)}function C(e){let t=S(e),n=t.getUint32(0,!0),r=t.getUint16(16,!0),i=128+(17+(r>0?2:0))*n,a=i+r*9;if(e.length!==a)throw Error(`page payload holds ${e.length} bytes, its header needs ${a}`);return{view:t,count:n,k:r,book:i}}function w(e){return[e.getUint32(4,!0),e.getUint32(8,!0),e.getUint32(12,!0)]}function T(e,t){let{view:n,count:r,k:i,book:s}=C(e),c=/* @__PURE__ */ new Float32Array(27);for(let e=0;e<27;e++)c[e]=n.getFloat32(20+4*e,!0);i===0&&c.fill(0,o.shScale);let l=new Uint32Array(r*4),u=new Float32Array(Math.ceil(r/256)*6),d=/* @__PURE__ */ new Float64Array(768);for(let e=0;e<3;e++){let t=c[o.scaleMin+e],n=c[o.scaleMax+e]-t;for(let r=0;r<256;r++)d[e*256+r]=Math.exp(t+r/255*n)}let f=c[o.step],p=c[o.step+1],m=c[o.step+2],h=128+a.position*r,g=128+a.alpha*r,_=128+a.rotationIndex*r,v=128+a.rotation*r,y=128+a.scale*r,S=/* @__PURE__ */ new Float64Array(4),T=/* @__PURE__ */ new Float64Array(3),O=0,k=0,A=0;for(let t=0,n=0;n<r;t++){let i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,C=-1/0;for(let t=Math.min(n+256,r);n<t;n++){let t=e[h+n]|e[h+r+n]<<8;O=O+(t>>>1^-(t&1))&65535,t=e[h+2*r+n]|e[h+3*r+n]<<8,k=k+(t>>>1^-(t&1))&65535,t=e[h+4*r+n]|e[h+5*r+n]<<8,A=A+(t>>>1^-(t&1))&65535;let u=e[_+n],w=e[v+n],E=e[v+r+n],D=e[v+2*r+n],j=e[y+n],M=e[y+r+n],N=e[y+2*r+n],P=n*4;l[P]=O|k<<16,l[P+1]=A|e[g+n]<<16|u<<24,l[P+2]=w|E<<8|D<<16|j<<24,l[P+3]=M|N<<8,b(u,w,E,D,S),x(S,d[j],d[256+M],d[512+N],T);let F=O*f,I=k*p,L=A*m;i=Math.min(i,F-T[0]),a=Math.min(a,I-T[1]),o=Math.min(o,L-T[2]),s=Math.max(s,F+T[0]),c=Math.max(c,I+T[1]),C=Math.max(C,L+T[2])}u.set([i,a,o,s,c,C],t*6)}let j=t?D(e,r,i,s,l,c,t):E(e,r,i,s);return{count:r,quadrants:w(n),geometry:l,colour:j,params:c,clusters:u}}function E(e,t,n,r){let i=new Uint32Array(t*3),o=128+a.dc*t,s=128+a.label*t;for(let a=0;a<t;a++){let c=a*3;if(i[c]=e[o+a]|e[o+t+a]<<8|e[o+2*t+a]<<16,n===0)continue;let l=r+(e[s+a]|e[s+t+a]<<8)*9;i[c]|=e[l]<<24,i[c+1]=e[l+1]|e[l+2]<<8|e[l+3]<<16|e[l+4]<<24,i[c+2]=e[l+5]|e[l+6]<<8|e[l+7]<<16|e[l+8]<<24}return i}function D(e,t,r,i,s,c,l){let u=128+a.dc*t,d=128+a.label*t,f=new Int8Array(e.buffer,e.byteOffset+i,r*9),p=new Float32Array(t*3),m=new Float32Array(t*9),h=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0],_=/* @__PURE__ */ new Float32Array(9),y=/* @__PURE__ */ new Float32Array(12),b=c[o.origin],x=c[o.origin+1],S=c[o.step],C=c[o.step+1],w=/* @__PURE__ */ new Float64Array(768);for(let e=0;e<3;e++){let t=c[o.dcMin+e],n=c[o.dcMax+e]-t;for(let r=0;r<256;r++)w[e*256+r]=t+r/255*n}let T=new Float64Array(Math.max(r,1)*9);for(let e=0;e<r*9;e++)T[e]=f[e]/127*c[o.shScale+e%9];for(let i=0;i<t;i++){let a=s[i*4];v(l,b+(a&65535)*S,x+(a>>>16)*C,y);for(let r=0;r<3;r++){let a=i*3+r;p[a]=w[r*256+e[u+r*t+i]]+y[r]/n,h[r]=Math.min(h[r],p[a]),g[r]=Math.max(g[r],p[a])}let o=r>0?(e[d+i]|e[d+t+i]<<8)*9:0;for(let e=0;e<9;e++){let t=i*9+e;m[t]=T[o+e]+y[3+e],_[e]=Math.max(_[e],Math.abs(m[t]))}}for(let e=0;e<3;e++)c[o.dcMin+e]=t>0?h[e]:0,c[o.dcMax+e]=t>0?g[e]:0;c.set(_,o.shScale);let E=[0,1,2].map(e=>{let t=c[o.dcMax+e]-c[o.dcMin+e];return t>0?255/t:0}),D=Array.from(_,e=>e>0?127/e:0),O=[0,1,2].map(e=>c[o.dcMin+e]),k=new Uint32Array(t*3),A=new Uint8Array(k.buffer);for(let e=0;e<t;e++){let t=e*4*3;for(let n=0;n<3;n++){let r=Math.round((p[e*3+n]-O[n])*E[n]);A[t+n]=Math.min(255,Math.max(0,r))}for(let n=0;n<9;n++){let r=Math.round(m[e*9+n]*D[n]);A[t+3+n]=Math.min(127,Math.max(-127,r))}}return k}async function O(e,t){return p(await A(e,t))}async function*k(e,t,n,r){let i=t.col===null?null:M(e,t.col,n),a=await j(e,t,r),o=await i;for(let[e,n]of t.pages.entries()){let t=await c(a[e]);r?.throwIfAborted(),yield{id:n.id,page:T(t,o)}}}async function A(e,t){let n=await e.cache.get(t);if(n)return n;let r=await e.fetch(e.base+t,null);return e.cache.put(t,r),r}async function j(e,t,n){let r=t.pages.map(e=>`${t.pack}#${e.offset}+${e.length}`),i=await Promise.all(r.map(t=>e.cache.get(t)));if(n?.throwIfAborted(),i.every(e=>e!==void 0))return i;let a=await e.fetch(e.base+t.pack,[t.start,t.end],n);if(a.length!==t.end-t.start)throw Error(`${t.pack}: ${a.length} bytes for ${t.start}-${t.end}`);return t.pages.map((n,o)=>{let s=a.slice(n.offset-t.start,n.offset-t.start+n.length);return i[o]||e.cache.put(r[o],s),s})}function M(e,t,n){let r=n.get(t);if(r)n.delete(t);else{let i=A(e,t).then(_);i.catch(()=>{n.get(t)===i&&n.delete(t)}),r=i}if(n.set(t,r),n.size>64){let[e]=n.keys();n.delete(e)}return r}function N(e){let t=/* @__PURE__ */ new Map,n=0;return{async get(e){let n=t.get(e);return n&&(t.delete(e),t.set(e,n)),n},async put(r,i){let a=t.get(r);if(a&&(t.delete(r),n-=a.length),!(i.length>e)){t.set(r,i),n+=i.length;for(let[r,i]of t){if(n<=e)break;t.delete(r),n-=i.length}}}}}async function P(e,t){let n;try{n=await(await I()).getDirectoryHandle(String(t),{create:!0})}catch{return null}let r=/* @__PURE__ */ new Map,i=0,a=!1,o=(e,t)=>{i+=t-(r.get(e)??0),r.delete(e),r.set(e,t)},s=e=>{i-=r.get(e)??0,r.delete(e)},c=()=>{if(a)for(let[t,a]of r){if(i<=e)break;r.delete(t),i-=a,n.removeEntry(t).catch(()=>void 0)}};return z(n).then(e=>{let t=[...r];r.clear(),i=0;for(let{name:t,size:n}of e.sort((e,t)=>e.time-t.time))o(t,n);for(let[e,n]of t)o(e,n);a=!0,c()}),{async get(e){let t=encodeURIComponent(e);if(a&&!r.has(t))return;let i=await L(n,t);return i?o(t,i.length):s(t),i},async put(t,r){if(r.length===0||r.length>e)return;let i=encodeURIComponent(t);await R(n,i,r)&&(o(i,r.length),c())}}}async function F(e){let t=new Set(Array.from({length:e},(e,t)=>String(t)));try{let e=await I(),n=[];for await(let[r,i]of e.entries())(i.kind!==`directory`||!t.has(r))&&n.push(r);let r={recursive:!0};for(let t of n)await e.removeEntry(t,r).catch(()=>void 0)}catch{}}async function I(){return(await navigator.storage.getDirectory()).getDirectoryHandle(`cache`,{create:!0})}async function L(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return n.size>0?new Uint8Array(await n.arrayBuffer()):void 0}catch{return}}async function R(e,t,n){let r;try{return r=await(await e.getFileHandle(t,{create:!0})).createWritable(),await r.write(n),await r.close(),!0}catch{return r?.abort().catch(()=>void 0),!1}}async function z(e){let t=[];try{for await(let[n,r]of e.entries()){if(r.kind!==`file`)continue;let e=await r.getFile().catch(()=>null);e&&t.push({name:n,size:e.size,time:e.lastModified})}}catch{}return t}function B(t){let n=/* @__PURE__ */ new Map,r=0;return{fetch:(i,a,o)=>new Promise((s,c)=>{if(o?.aborted)return c(o.reason);let l=++r,u=()=>{n.delete(l),t({unfetch:l}),c(o.reason)};n.set(l,t=>{o?.removeEventListener(`abort`,u),`bytes`in t?s(t.bytes):c(t.missing?new e(t.error):Error(t.error))}),o?.addEventListener(`abort`,u,{once:!0}),t({fetch:l,url:i,range:a})}),take(e){let t=n.get(e.fetched);n.delete(e.fetched),t?.(e)}}}let V=(e,t,n)=>Math.min(n,Math.max(t,e));function ee(e,t,n){return n>t?V(Math.round((e-t)/(n-t)*255),0,255):0}function te(e,t){return t>0?V(Math.round(e/t*127),-127,127):0}function H(e){return e&=1023,e=(e|e<<16)&50331903,e=(e|e<<8)&50393103,e=(e|e<<4)&51130563,(e|e<<2)&153391689}function ne(e,t,n){return H(e>>6)|H(t>>6)<<1|H(n>>6)<<2}function re(e,t){let n=/* @__PURE__ */ new Float32Array(9);for(let r=0;r<t;r++)for(let t=0;t<9;t++)n[t]=Math.max(n[t],Math.abs(e[r*9+t]));return n}function ie(e,t,n){let r=new Int8Array(t*9);for(let i=0;i<t;i++)for(let t=0;t<9;t++)r[i*9+t]=te(e[i*9+t],n[t]);let i=e=>r.subarray(e*9,(e+1)*9),a=/* @__PURE__ */ new Map,o=[],s=new Uint16Array(t);for(let e=0;e<t;e++){let t=i(e).join(),n=a.get(t);n===void 0&&(n=o.length,a.set(t,n),o.push(e)),s[e]=n}if(o.length>2048){let e=o.length/256,n=Array.from({length:256},(t,n)=>o[Math.floor(n*e)]);o.splice(0,o.length,...n);for(let e=0;e<t;e++){let t=1/0;for(let n=0;n<256;n++){let i=0;for(let t=0;t<9;t++)i+=(r[e*9+t]-r[o[n]*9+t])**2;i<t&&(t=i,s[e]=n)}}}let c=new Int8Array(o.length*9);return o.forEach((e,t)=>c.set(i(e),t*9)),{book:c,labels:s}}function ae(e,t){let{count:n,position:i,rotation:o,scale:s,alpha:c,dc:l,sh:u}=e,d=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0],p=[...d],m=[...f],h=[...d],g=[...f];for(let e=0;e<n;e++)for(let t=0;t<3;t++)d[t]=Math.min(d[t],i[e*3+t]),f[t]=Math.max(f[t],i[e*3+t]),p[t]=Math.min(p[t],s[e*3+t]),m[t]=Math.max(m[t],s[e*3+t]),h[t]=Math.min(h[t],l[e*3+t]),g[t]=Math.max(g[t],l[e*3+t]);let _=5e-4*2**t.g,v=Float32Array.from(d),y=Float32Array.from(d,(e,t)=>Math.max(_,(f[t]-e)/65535)),b=new Uint16Array(n*3);for(let e=0;e<n;e++)for(let t=0;t<3;t++){let n=(i[e*3+t]-v[t])/y[t];b[e*3+t]=V(Math.round(n),0,65535)}let S=r*2**t.g,C=(t.i+.5)*S,w=(t.j+.5)*S,T=new Uint8Array(n),E=new Float64Array(n);for(let e=0;e<n;e++){let t=+(i[e*3]>=C),n=+(i[e*3+1]>=w);T[e]=t+2*n,E[e]=T[e]*2**30+ne(b[e*3],b[e*3+1],b[e*3+2])}let D=Uint32Array.from({length:n},(e,t)=>t).sort((e,t)=>E[e]-E[t]),O=[0,0,0];for(let e=1;e<4;e++)O[e-1]=T.filter(t=>t<e).length;let k=u?re(u,n):/* @__PURE__ */ new Float32Array(9),{book:A,labels:j}=u?ie(u,n,k):{book:null,labels:null},M=A?A.length/9:0,N=17+(M>0?2:0),P=new Uint8Array(128+N*n+M*9),F=new DataView(P.buffer);F.setUint32(0,n,!0),O.forEach((e,t)=>F.setUint32(4+4*t,e,!0)),F.setUint16(16,M,!0),[...v,...y,...p,...m,...h,...g,...k].forEach((e,t)=>F.setFloat32(20+4*t,e,!0));let I=e=>128+e*n,L=new Float32Array([...d,...f]),R=/* @__PURE__ */ new Float64Array(4),z=/* @__PURE__ */ new Float64Array(3),B=[0,0,0];for(let e=0;e<n;e++){let t=D[e];for(let n=0;n<3;n++){let r=b[t*3+n]-B[n]<<16>>16,i=r<0?-2*r-1:2*r;B[n]=b[t*3+n],P[I(a.position+2*n)+e]=i&255,P[I(a.position+2*n+1)+e]=i>>8}P[I(a.alpha)+e]=V(Math.round(c[t]*255),0,255);let n=Math.hypot(...o.subarray(t*4,t*4+4));for(let e=0;e<4;e++)R[e]=o[t*4+e]/n;let r=0;for(let e=1;e<4;e++)Math.abs(R[e])>Math.abs(R[r])&&(r=e);let u=R[r]<0?-1:1;P[I(a.rotationIndex)+e]=r;for(let t=0,n=0;t<4;t++){if(t===r)continue;let i=Math.round((u*R[t]/Math.SQRT2+.5)*255);P[I(a.rotation+n++)+e]=V(i,0,255)}for(let n=0;n<3;n++)P[I(a.scale+n)+e]=ee(s[t*3+n],p[n],m[n]),P[I(a.dc+n)+e]=ee(l[t*3+n],h[n],g[n]);j&&(P[I(a.label)+e]=j[t]&255,P[I(a.label+1)+e]=j[t]>>8);let[d,f,_]=[0,1,2].map(e=>Math.exp(s[t*3+e]));x(R,d,f,_,z);for(let e=0;e<3;e++)L[e]=Math.min(L[e],i[t*3+e]-z[e]),L[3+e]=Math.max(L[3+e],i[t*3+e]+z[e])}return A&&P.set(new Uint8Array(A.buffer),I(N)),{payload:P,row:{g:t.g,i:t.i,j:t.j,count:n,quadrants:O,box:L,offset:0,length:0}}}function oe(e,t,n){e.setUint8(t,n.g),e.setUint8(t+1,n.i),e.setUint8(t+2,n.j),e.setUint32(t+4,n.count,!0),n.quadrants.forEach((n,r)=>e.setUint32(t+8+4*r,n,!0)),n.box.forEach((n,r)=>e.setFloat32(t+20+4*r,n,!0)),e.setUint32(t+44,n.offset,!0),e.setUint32(t+48,n.length,!0)}function se(e,t,n){for(let r=0;r<4;r++)e[t+r]=n.charCodeAt(r)}function U(e){return Uint8Array.from({length:8},(t,n)=>parseInt(e.slice(2*n,2*n+2),16))}async function ce(e,t){let n=await l(e),r=new Uint8Array(8+n.length);return se(r,0,t),new DataView(r.buffer).setUint16(4,1,!0),r.set(n,8),r}async function le(e){let{rows:t,children:n,descendants:r}=e,a=new Uint8Array(40+t.length*52+n.length*9+r.length*11),o=new DataView(a.buffer);o.setUint8(0,e.level),o.setInt32(4,e.e,!0),o.setInt32(8,e.n,!0),a.set(U(e.pack),12),o.setUint32(20,e.packSize,!0),e.col&&a.set(U(e.col),24),o.setUint16(32,t.length,!0),o.setUint8(34,n.length),o.setUint16(36,r.length,!0);let s=40;for(let e of t)oe(o,s,e),s+=52;for(let e of n)o.setUint8(s,e.quadrant),a.set(U(e.idx),s+1),s+=9;for(let e of r)o.setUint8(s,e.depth),o.setUint8(s+1,e.column),o.setUint8(s+2,e.row),a.set(U(e.idx),s+3),s+=11;return ce(a,i)}function ue(e){let t=3421674724,n=2216829733;for(let r=0;r<e.length;r++){n=(n^e[r])>>>0;let i=n*435;t=t*435+(n<<8>>>0)+Math.floor(i/4294967296)>>>0,n=i>>>0}return t.toString(16).padStart(8,`0`)+n.toString(16).padStart(8,`0`)}function de(e){return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/2**32}}let W=16384,fe=1408,pe=65535,G=324121,me=.4,he=[[12,1/7e3,0,1/9e3,.7],[9,1/2300,1.1,1/3100,.4],[6,1/800,.3,1/1100,2],[3,1/150,.9,1/210,1.7]],ge=he.reduce((e,[t,n,,r])=>e+t*(n+r),0),_e=Float32Array.from({length:fe*9},(e,t)=>{let n=Math.floor(t/9),r=t%9,i=(n*(37+2*r)+11*r)%255-127;return r===0&&(i=n%255-127),r===1&&(i=20*Math.floor(n/255)-50),i/127*.04}),K=new TextEncoder,ve={version:1,crs:`synthetic`,height:`synthetic`,leaf:250,roots:[512e4,6144e3].map(e=>({level:12,e:0,n:e})).map(e=>({...e,idx:m(e,q(e,`idx`),`idx`)})),extent:{e:[44e4,9e5],n:[605e4,641e4],h:[0,80]}},ye=K.encode(JSON.stringify(ve));function be(){return async(t,n)=>{if(t.endsWith(`world.json`))return Se(ye,n);let r=g(t),i=t.slice(t.lastIndexOf(`.`)+1);if(!r||i!==`idx`&&i!==`pack`||!Ce(r)||r.hash!==q(r,i))throw new e(`no file ${t}`);return i===`idx`?Se(await ke(r),n):Ae(r,n,t)}}function xe(e,t){let n=30;for(let[r,i,a,o,s]of he)n+=r*Math.sin(i*e+a)*Math.sin(o*t+s);return n}function Se(e,t){return t?e.slice(t[0],t[1]):e.slice()}function q(e,t){return ue(K.encode(`${e.level}/${e.e}/${e.n}.${t}`))}function J(e,t,n){let{e:r,n:i}=ve.extent;return e<r[1]&&e+n>r[0]&&t<i[1]&&t+n>i[0]}function Ce({level:e,e:t,n}){let r=250*2**e;return e<=12&&t%r===0&&n%r===0&&J(t,n,r)}function we(e){return e===0?[1,0]:e===12?[16,15,14,13]:[e+1]}function Te(e){let t=0;for(let n=0;n<8;n++)t|=(e>>2*n&1)<<n;return t}function Ee(e){let t=[];for(let n of we(e.level)){let i=r*2**n,a=250*2**e.level/i;for(let r=0;r<a*a;r++){let a=Te(r),o=Te(r>>1);J(e.e+a*i,e.n+o*i,i)&&t.push({g:n,i:a,j:o})}}return t}function De(e,t){let n=e.level-t,r=250*2**n,i=[];for(let a=0;n>=0&&a<2**t;a++)for(let o=0;o<2**t;o++){let t={level:n,e:e.e+o*r,n:e.n+a*r};J(t.e,t.n,r)&&i.push({column:o,row:a,unit:t})}return i}function Oe(e,{g:t,i:n,j:i},a){let o=r*2**t,s=o/128,c=3*1.2*s,l=1.17*s,u=xe(e.e+(n+.5)*o,e.n+(i+.5)*o),d=ge*o/2,f=Float32Array.of(n*o-c,i*o-c,Math.max(0,u-d)-l,(n+1)*o+c,(i+1)*o+c,Math.min(60,u+d)+l),p=W/4;return{g:t,i:n,j:i,count:W,quadrants:[p,2*p,3*p],box:f,offset:a,length:G}}function ke(e){let t=Ee(e),n=[];for(let{column:t,row:r,unit:i}of De(e,1))n.push({quadrant:t+2*r,idx:q(i,`idx`)});let r=[];for(let t of[2,3])for(let{column:n,row:i,unit:a}of De(e,t))r.push({depth:t,column:n,row:i,idx:q(a,`idx`)});return le({level:e.level,e:e.e,n:e.n,pack:q(e,`pack`),packSize:t.length*324173+16,col:null,rows:t.map((t,n)=>Oe(e,t,n*G)),children:n,descendants:r})}function Ae(e,t,n){let r=Ee(e);if(!t||t[0]%G!=0||t[1]%G!=0||t[0]>=t[1]||t[1]>r.length*G)throw Error(`${n}: the synthetic world serves whole pages only`);let i=new Uint8Array(t[1]-t[0]);for(let n=0;n<i.length;n+=G)je(Ne(e,r[(t[0]+n)/G]),i,n);return i}function je(e,t,n){let r=n;for(let n=0;n<e.length;n+=pe){let i=Math.min(pe,e.length-n);t[r]=+(n+i===e.length),t[r+1]=i&255,t[r+2]=i>>8,t[r+3]=~i&255,t[r+4]=~i>>8&255,t.set(e.subarray(n,n+i),r+5),r+=5+i}}let Me=e=>de(parseInt(ue(K.encode(e)).slice(8),16));function Ne(e,{g:t,i,j:a}){let o=W,s=r*2**t/128,c=Me(`${e.level}/${e.e}/${e.n}/${t}/${i}/${a}`),l=new Float64Array(3*o),u=new Float32Array(4*o),d=new Float32Array(3*o),f=new Float32Array(o),p=new Float32Array(3*o),m=new Float32Array(9*o);for(let t=0;t<o;t++){let r=(i*128+t%128+.5+me*(2*c()-1))*s,o=(a*128+Math.floor(t/128)+.5+me*(2*c()-1))*s,h=xe(e.e+r,e.n+o);l[3*t]=r,l[3*t+1]=o,l[3*t+2]=h;let g=Math.PI*c(),_=.1/2*(2*c()-1);u[4*t]=Math.cos(g)*Math.cos(_),u[4*t+1]=Math.cos(g)*Math.sin(_),u[4*t+2]=Math.sin(g)*Math.sin(_),u[4*t+3]=Math.sin(g)*Math.cos(_);for(let e=0;e<2;e++)d[3*t+e]=Math.log(s*(.6+.6*c()));d[3*t+2]=Math.log(s*.15*(.5+.5*c())),f[t]=.35+.65*c();let v=h/60,y=.5+.5*Math.sin((e.e+r)/410)*Math.sin((e.n+o)/330);p[3*t]=(.32+.2*v+.1*y-.5)/n,p[3*t+1]=(.42+.15*y-.1*v-.5)/n,p[3*t+2]=(.25+.1*v+.04*c()-.5)/n;let b=t%fe;m.set(_e.subarray(9*b,9*(b+1)),9*t)}return ae({count:o,position:l,rotation:u,scale:d,alpha:f,dc:p,sh:m},{g:t,i,j:a}).payload}let Y=2**20,X=self,Z,Pe=/* @__PURE__ */ new Map,Q=/* @__PURE__ */ new Map,Fe=B(e=>X.postMessage(e,[]));X.onmessage=({data:e})=>{`fetched`in e?Fe.take(e):e.type===`init`?(Z=Ie(e),Z.catch(()=>void 0)):e.type===`abort`?Q.get(e.id)?.abort():Re(e)};async function Ie(e){return e.source===`synthetic`?{fetch:be(),cache:await $({...e,cache:`none`}),base:e.base}:{fetch:e.source===`page`?Fe.fetch:t,cache:await $(e),base:e.base}}async function $({cache:e,shard:t,shards:n}){return e===`memory`?N(256*Y):e===`none`?{get:async()=>void 0,put:async()=>void 0}:(t===0&&F(n),await P(await Le()/n,t)??N(256*Y))}async function Le(){try{let{quota:e}=await navigator.storage.estimate();return Math.min(4096*Y,e===void 0?1/0:e/2)}catch{return 4096*Y}}async function Re(t){let{id:n}=t,r=new AbortController;Q.set(n,r);try{if(!Z)throw Error(`stream worker used before init`);let e=await Z;if(t.type===`idx`)X.postMessage({id:n,value:await O(e,t.path)},[]);else{for await(let i of k(e,t.batch,Pe,r.signal))X.postMessage({id:n,page:i},ze(i));X.postMessage({id:n,done:!0},[])}}catch(t){let r=t instanceof Error?t.message:String(t);X.postMessage({id:n,error:r,missing:t instanceof e},[])}finally{Q.delete(n)}}function ze({page:e}){let t=/* @__PURE__ */ new Set;for(let n of[e.geometry,e.colour,e.params,e.clusters])t.add(n.buffer);return[...t]}})();", dt = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", ut], { type: "text/javascript;charset=utf-8" });
|
|
1874
|
-
function
|
|
1879
|
+
var lt = "(function(){var e=class extends Error{name=`Missing`};let t=async(t,n,r)=>{let i=await fetch(t,n?{signal:r,headers:{Range:`bytes=${n[0]}-${n[1]-1}`}}:{signal:r});if(i.status===404)throw new e(`http 404 for ${t}`);if(i.status!==200&&i.status!==206)throw Error(`http ${i.status} for ${t}`);let a=new Uint8Array(await i.arrayBuffer());return n&&i.status===200?a.slice(n[0],n[1]):a},n=.28209479177387814,r=15.625,i=`GMIX`,a={position:0,alpha:6,rotationIndex:7,rotation:8,scale:11,dc:14,label:17},o={origin:0,step:3,scaleMin:6,scaleMax:9,dcMin:12,dcMax:15,shScale:18};async function s(e,t){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function c(e){return s(e,new DecompressionStream(`deflate-raw`))}function l(e){return s(e,new CompressionStream(`deflate-raw`))}async function u(e,t,n){let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||String.fromCharCode(...e.subarray(0,4))!==t)throw Error(`not a ${n} file`);let i=r.getUint16(4,!0);if(i!==1)throw Error(`${n} version ${i}; narcissus reads 1`);let a;try{a=await c(e.subarray(8))}catch{throw Error(`${n} body is not a valid deflate stream`)}return new DataView(a.buffer,a.byteOffset,a.byteLength)}function d(e,t){let n=``;for(let r=0;r<8;r++){let i=e.getUint8(t+r);n+=i.toString(16).padStart(2,`0`)}return n}function f(e,t){let n=/* @__PURE__ */ new Float32Array(6);for(let r=0;r<6;r++)n[r]=e.getFloat32(t+20+4*r,!0);return{g:e.getUint8(t),i:e.getUint8(t+1),j:e.getUint8(t+2),count:e.getUint32(t+4,!0),quadrants:[e.getUint32(t+8,!0),e.getUint32(t+12,!0),e.getUint32(t+16,!0)],box:n,offset:e.getUint32(t+44,!0),length:e.getUint32(t+48,!0)}}async function p(e){let t=await u(e,i,`.idx`);if(t.byteLength<40)throw Error(`.idx header is cut off`);let n=t.getUint16(32,!0),r=t.getUint8(34),a=t.getUint16(36,!0),o=40+n*52+r*9+a*11;if(t.byteLength!==o)throw Error(`.idx holds ${t.byteLength} bytes, its counts need ${o}`);let s=d(t,24),c={level:t.getUint8(0),e:t.getInt32(4,!0),n:t.getInt32(8,!0),pack:d(t,12),packSize:t.getUint32(20,!0),col:s===`0000000000000000`?null:s,rows:[],children:[],descendants:[]},l=40;for(let e=0;e<n;e++,l+=52)c.rows.push(f(t,l));for(let e=0;e<r;e++,l+=9)c.children.push({quadrant:t.getUint8(l),idx:d(t,l+1)});for(let e=0;e<a;e++,l+=11)c.descendants.push({depth:t.getUint8(l),column:t.getUint8(l+1),row:t.getUint8(l+2),idx:d(t,l+3)});return c}function m(e,t,n){return`u/${e.level}/${e.e}/${e.n}.${t}.${n}`}let h=/(?:^|\\/)u\\/(\\d+)\\/(-?\\d+)\\/(-?\\d+)\\.([0-9a-f]{16})\\.(?:idx|pack|col)$/;function g(e){let t=h.exec(e);return t?{level:Number(t[1]),e:Number(t[2]),n:Number(t[3]),hash:t[4]}:null}async function _(e){let t=await u(e,`GMCL`,`.col`);if(t.byteLength<60)throw Error(`.col header is cut off`);let n=t.getUint16(0,!0),r=60+12*n*n;if(t.byteLength!==r)throw Error(`.col holds ${t.byteLength} bytes, ${n} nodes need ${r}`);let i=new Float32Array(12*n*n),a=60;for(let e=0;e<12;e++){let r=t.getFloat32(12+4*e,!0)/127;for(let o=0;o<n;o++){let s=0;for(let c=0;c<n;c++,a++)s=s+t.getInt8(a)<<24>>24,i[(e*n+o)*n+c]=s*r}}return{n,pitch:t.getFloat32(4,!0),margin:t.getFloat32(8,!0),values:i}}function v(e,t,n,r){let{n:i,pitch:a,margin:o,values:s}=e,c=i-1,l=Math.min(Math.max((t+o)/a-.5,0),c),u=Math.min(Math.max((n+o)/a-.5,0),c),d=Math.min(Math.floor(l),Math.max(c-1,0)),f=Math.min(Math.floor(u),Math.max(c-1,0)),p=Math.min(d+1,c),m=Math.min(f+1,c),h=l-d,g=u-f,_=(1-h)*(1-g),v=h*(1-g),y=(1-h)*g,b=h*g,x=i*i;for(let e=0,t=0;e<12;e++,t+=x)r[e]=s[t+f*i+d]*_+s[t+f*i+p]*v+s[t+m*i+d]*y+s[t+m*i+p]*b;return r}let y=Float64Array.from({length:256},(e,t)=>(t/255-.5)*Math.SQRT2);function b(e,t,n,r,i){let a=y[t],o=y[n],s=y[r];i[e]=Math.sqrt(Math.max(0,1-a*a-o*o-s*s)),i[e>0?0:1]=a,i[e>1?1:2]=o,i[e>2?2:3]=s}function x(e,t,n,r,i){let a=e[0],o=e[1],s=e[2],c=e[3],l=t*t,u=n*n,d=r*r,f=1-2*(s*s+c*c),p=2*(o*s-a*c),m=2*(o*c+a*s),h=2*(o*s+a*c),g=1-2*(o*o+c*c),_=2*(s*c-a*o),v=2*(o*c-a*s),y=2*(s*c+a*o),b=1-2*(o*o+s*s);i[0]=3*Math.sqrt(f*f*l+p*p*u+m*m*d),i[1]=3*Math.sqrt(h*h*l+g*g*u+_*_*d),i[2]=3*Math.sqrt(v*v*l+y*y*u+b*b*d)}function S(e){if(e.length<128)throw Error(`page payload is shorter than its header`);return new DataView(e.buffer,e.byteOffset,e.byteLength)}function C(e){let t=S(e),n=t.getUint32(0,!0),r=t.getUint16(16,!0),i=128+(17+(r>0?2:0))*n,a=i+r*9;if(e.length!==a)throw Error(`page payload holds ${e.length} bytes, its header needs ${a}`);return{view:t,count:n,k:r,book:i}}function w(e){return[e.getUint32(4,!0),e.getUint32(8,!0),e.getUint32(12,!0)]}function T(e,t){let{view:n,count:r,k:i,book:s}=C(e),c=/* @__PURE__ */ new Float32Array(27);for(let e=0;e<27;e++)c[e]=n.getFloat32(20+4*e,!0);i===0&&c.fill(0,o.shScale);let l=new Uint32Array(r*4),u=new Float32Array(Math.ceil(r/256)*6),d=/* @__PURE__ */ new Float64Array(768);for(let e=0;e<3;e++){let t=c[o.scaleMin+e],n=c[o.scaleMax+e]-t;for(let r=0;r<256;r++)d[e*256+r]=Math.exp(t+r/255*n)}let f=c[o.step],p=c[o.step+1],m=c[o.step+2],h=128+a.position*r,g=128+a.alpha*r,_=128+a.rotationIndex*r,v=128+a.rotation*r,y=128+a.scale*r,S=/* @__PURE__ */ new Float64Array(4),T=/* @__PURE__ */ new Float64Array(3),O=0,k=0,A=0;for(let t=0,n=0;n<r;t++){let i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,C=-1/0;for(let t=Math.min(n+256,r);n<t;n++){let t=e[h+n]|e[h+r+n]<<8;O=O+(t>>>1^-(t&1))&65535,t=e[h+2*r+n]|e[h+3*r+n]<<8,k=k+(t>>>1^-(t&1))&65535,t=e[h+4*r+n]|e[h+5*r+n]<<8,A=A+(t>>>1^-(t&1))&65535;let u=e[_+n],w=e[v+n],E=e[v+r+n],D=e[v+2*r+n],j=e[y+n],M=e[y+r+n],N=e[y+2*r+n],P=n*4;l[P]=O|k<<16,l[P+1]=A|e[g+n]<<16|u<<24,l[P+2]=w|E<<8|D<<16|j<<24,l[P+3]=M|N<<8,b(u,w,E,D,S),x(S,d[j],d[256+M],d[512+N],T);let F=O*f,I=k*p,L=A*m;i=Math.min(i,F-T[0]),a=Math.min(a,I-T[1]),o=Math.min(o,L-T[2]),s=Math.max(s,F+T[0]),c=Math.max(c,I+T[1]),C=Math.max(C,L+T[2])}u.set([i,a,o,s,c,C],t*6)}let j=t?D(e,r,i,s,l,c,t):E(e,r,i,s);return{count:r,quadrants:w(n),geometry:l,colour:j,params:c,clusters:u}}function E(e,t,n,r){let i=new Uint32Array(t*3),o=128+a.dc*t,s=128+a.label*t;for(let a=0;a<t;a++){let c=a*3;if(i[c]=e[o+a]|e[o+t+a]<<8|e[o+2*t+a]<<16,n===0)continue;let l=r+(e[s+a]|e[s+t+a]<<8)*9;i[c]|=e[l]<<24,i[c+1]=e[l+1]|e[l+2]<<8|e[l+3]<<16|e[l+4]<<24,i[c+2]=e[l+5]|e[l+6]<<8|e[l+7]<<16|e[l+8]<<24}return i}function D(e,t,r,i,s,c,l){let u=128+a.dc*t,d=128+a.label*t,f=new Int8Array(e.buffer,e.byteOffset+i,r*9),p=new Float32Array(t*3),m=new Float32Array(t*9),h=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0],_=/* @__PURE__ */ new Float32Array(9),y=/* @__PURE__ */ new Float32Array(12),b=c[o.origin],x=c[o.origin+1],S=c[o.step],C=c[o.step+1],w=/* @__PURE__ */ new Float64Array(768);for(let e=0;e<3;e++){let t=c[o.dcMin+e],n=c[o.dcMax+e]-t;for(let r=0;r<256;r++)w[e*256+r]=t+r/255*n}let T=new Float64Array(Math.max(r,1)*9);for(let e=0;e<r*9;e++)T[e]=f[e]/127*c[o.shScale+e%9];for(let i=0;i<t;i++){let a=s[i*4];v(l,b+(a&65535)*S,x+(a>>>16)*C,y);for(let r=0;r<3;r++){let a=i*3+r;p[a]=w[r*256+e[u+r*t+i]]+y[r]/n,h[r]=Math.min(h[r],p[a]),g[r]=Math.max(g[r],p[a])}let o=r>0?(e[d+i]|e[d+t+i]<<8)*9:0;for(let e=0;e<9;e++){let t=i*9+e;m[t]=T[o+e]+y[3+e],_[e]=Math.max(_[e],Math.abs(m[t]))}}for(let e=0;e<3;e++)c[o.dcMin+e]=t>0?h[e]:0,c[o.dcMax+e]=t>0?g[e]:0;c.set(_,o.shScale);let E=[0,1,2].map(e=>{let t=c[o.dcMax+e]-c[o.dcMin+e];return t>0?255/t:0}),D=Array.from(_,e=>e>0?127/e:0),O=[0,1,2].map(e=>c[o.dcMin+e]),k=new Uint32Array(t*3),A=new Uint8Array(k.buffer);for(let e=0;e<t;e++){let t=e*4*3;for(let n=0;n<3;n++){let r=Math.round((p[e*3+n]-O[n])*E[n]);A[t+n]=Math.min(255,Math.max(0,r))}for(let n=0;n<9;n++){let r=Math.round(m[e*9+n]*D[n]);A[t+3+n]=Math.min(127,Math.max(-127,r))}}return k}async function O(e,t){return p(await A(e,t))}async function*k(e,t,n,r){let i=t.col===null?null:M(e,t.col,n),a=await j(e,t,r),o=await i;for(let[e,n]of t.pages.entries()){let t=await c(a[e]);r?.throwIfAborted(),yield{id:n.id,page:T(t,o)}}}async function A(e,t){let n=await e.cache.get(t);if(n)return n;let r=await e.fetch(e.base+t,null);return e.cache.put(t,r),r}async function j(e,t,n){let r=t.pages.map(e=>`${t.pack}#${e.offset}+${e.length}`),i=await Promise.all(r.map(t=>e.cache.get(t)));if(n?.throwIfAborted(),i.every(e=>e!==void 0))return i;let a=await e.fetch(e.base+t.pack,[t.start,t.end],n);if(a.length!==t.end-t.start)throw Error(`${t.pack}: ${a.length} bytes for ${t.start}-${t.end}`);return t.pages.map((n,o)=>{let s=a.slice(n.offset-t.start,n.offset-t.start+n.length);return i[o]||e.cache.put(r[o],s),s})}function M(e,t,n){let r=n.get(t);if(r)n.delete(t);else{let i=A(e,t).then(_);i.catch(()=>{n.get(t)===i&&n.delete(t)}),r=i}if(n.set(t,r),n.size>64){let[e]=n.keys();n.delete(e)}return r}function N(e){let t=/* @__PURE__ */ new Map,n=0;return{async get(e){let n=t.get(e);return n&&(t.delete(e),t.set(e,n)),n},async put(r,i){let a=t.get(r);if(a&&(t.delete(r),n-=a.length),!(i.length>e)){t.set(r,i),n+=i.length;for(let[r,i]of t){if(n<=e)break;t.delete(r),n-=i.length}}}}}async function P(e,t){let n;try{n=await(await I()).getDirectoryHandle(String(t),{create:!0})}catch{return null}let r=/* @__PURE__ */ new Map,i=0,a=!1,o=(e,t)=>{i+=t-(r.get(e)??0),r.delete(e),r.set(e,t)},s=e=>{i-=r.get(e)??0,r.delete(e)},c=()=>{if(a)for(let[t,a]of r){if(i<=e)break;r.delete(t),i-=a,n.removeEntry(t).catch(()=>void 0)}};return z(n).then(e=>{let t=[...r];r.clear(),i=0;for(let{name:t,size:n}of e.sort((e,t)=>e.time-t.time))o(t,n);for(let[e,n]of t)o(e,n);a=!0,c()}),{async get(e){let t=encodeURIComponent(e);if(a&&!r.has(t))return;let i=await L(n,t);return i?o(t,i.length):s(t),i},async put(t,r){if(r.length===0||r.length>e)return;let i=encodeURIComponent(t);await R(n,i,r)&&(o(i,r.length),c())}}}async function F(e){let t=new Set(Array.from({length:e},(e,t)=>String(t)));try{let e=await I(),n=[];for await(let[r,i]of e.entries())(i.kind!==`directory`||!t.has(r))&&n.push(r);let r={recursive:!0};for(let t of n)await e.removeEntry(t,r).catch(()=>void 0)}catch{}}async function I(){return(await navigator.storage.getDirectory()).getDirectoryHandle(`cache`,{create:!0})}async function L(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return n.size>0?new Uint8Array(await n.arrayBuffer()):void 0}catch{return}}async function R(e,t,n){let r;try{return r=await(await e.getFileHandle(t,{create:!0})).createWritable(),await r.write(n),await r.close(),!0}catch{return r?.abort().catch(()=>void 0),!1}}async function z(e){let t=[];try{for await(let[n,r]of e.entries()){if(r.kind!==`file`)continue;let e=await r.getFile().catch(()=>null);e&&t.push({name:n,size:e.size,time:e.lastModified})}}catch{}return t}function B(t){let n=/* @__PURE__ */ new Map,r=0;return{fetch:(i,a,o)=>new Promise((s,c)=>{if(o?.aborted)return c(o.reason);let l=++r,u=()=>{n.delete(l),t({unfetch:l}),c(o.reason)};n.set(l,t=>{o?.removeEventListener(`abort`,u),`bytes`in t?s(t.bytes):c(t.missing?new e(t.error):Error(t.error))}),o?.addEventListener(`abort`,u,{once:!0}),t({fetch:l,url:i,range:a})}),take(e){let t=n.get(e.fetched);n.delete(e.fetched),t?.(e)}}}let V=(e,t,n)=>Math.min(n,Math.max(t,e));function ee(e,t,n){return n>t?V(Math.round((e-t)/(n-t)*255),0,255):0}function te(e,t){return t>0?V(Math.round(e/t*127),-127,127):0}function H(e){return e&=1023,e=(e|e<<16)&50331903,e=(e|e<<8)&50393103,e=(e|e<<4)&51130563,(e|e<<2)&153391689}function ne(e,t,n){return H(e>>6)|H(t>>6)<<1|H(n>>6)<<2}function re(e,t){let n=/* @__PURE__ */ new Float32Array(9);for(let r=0;r<t;r++)for(let t=0;t<9;t++)n[t]=Math.max(n[t],Math.abs(e[r*9+t]));return n}function ie(e,t,n){let r=new Int8Array(t*9);for(let i=0;i<t;i++)for(let t=0;t<9;t++)r[i*9+t]=te(e[i*9+t],n[t]);let i=e=>r.subarray(e*9,(e+1)*9),a=/* @__PURE__ */ new Map,o=[],s=new Uint16Array(t);for(let e=0;e<t;e++){let t=i(e).join(),n=a.get(t);n===void 0&&(n=o.length,a.set(t,n),o.push(e)),s[e]=n}if(o.length>2048){let e=o.length/256,n=Array.from({length:256},(t,n)=>o[Math.floor(n*e)]);o.splice(0,o.length,...n);for(let e=0;e<t;e++){let t=1/0;for(let n=0;n<256;n++){let i=0;for(let t=0;t<9;t++)i+=(r[e*9+t]-r[o[n]*9+t])**2;i<t&&(t=i,s[e]=n)}}}let c=new Int8Array(o.length*9);return o.forEach((e,t)=>c.set(i(e),t*9)),{book:c,labels:s}}function ae(e,t){let{count:n,position:i,rotation:o,scale:s,alpha:c,dc:l,sh:u}=e,d=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0],p=[...d],m=[...f],h=[...d],g=[...f];for(let e=0;e<n;e++)for(let t=0;t<3;t++)d[t]=Math.min(d[t],i[e*3+t]),f[t]=Math.max(f[t],i[e*3+t]),p[t]=Math.min(p[t],s[e*3+t]),m[t]=Math.max(m[t],s[e*3+t]),h[t]=Math.min(h[t],l[e*3+t]),g[t]=Math.max(g[t],l[e*3+t]);let _=5e-4*2**t.g,v=Float32Array.from(d),y=Float32Array.from(d,(e,t)=>Math.max(_,(f[t]-e)/65535)),b=new Uint16Array(n*3);for(let e=0;e<n;e++)for(let t=0;t<3;t++){let n=(i[e*3+t]-v[t])/y[t];b[e*3+t]=V(Math.round(n),0,65535)}let S=r*2**t.g,C=(t.i+.5)*S,w=(t.j+.5)*S,T=new Uint8Array(n),E=new Float64Array(n);for(let e=0;e<n;e++){let t=+(i[e*3]>=C),n=+(i[e*3+1]>=w);T[e]=t+2*n,E[e]=T[e]*2**30+ne(b[e*3],b[e*3+1],b[e*3+2])}let D=Uint32Array.from({length:n},(e,t)=>t).sort((e,t)=>E[e]-E[t]),O=[0,0,0];for(let e=1;e<4;e++)O[e-1]=T.filter(t=>t<e).length;let k=u?re(u,n):/* @__PURE__ */ new Float32Array(9),{book:A,labels:j}=u?ie(u,n,k):{book:null,labels:null},M=A?A.length/9:0,N=17+(M>0?2:0),P=new Uint8Array(128+N*n+M*9),F=new DataView(P.buffer);F.setUint32(0,n,!0),O.forEach((e,t)=>F.setUint32(4+4*t,e,!0)),F.setUint16(16,M,!0),[...v,...y,...p,...m,...h,...g,...k].forEach((e,t)=>F.setFloat32(20+4*t,e,!0));let I=e=>128+e*n,L=new Float32Array([...d,...f]),R=/* @__PURE__ */ new Float64Array(4),z=/* @__PURE__ */ new Float64Array(3),B=[0,0,0];for(let e=0;e<n;e++){let t=D[e];for(let n=0;n<3;n++){let r=b[t*3+n]-B[n]<<16>>16,i=r<0?-2*r-1:2*r;B[n]=b[t*3+n],P[I(a.position+2*n)+e]=i&255,P[I(a.position+2*n+1)+e]=i>>8}P[I(a.alpha)+e]=V(Math.round(c[t]*255),0,255);let n=Math.hypot(...o.subarray(t*4,t*4+4));for(let e=0;e<4;e++)R[e]=o[t*4+e]/n;let r=0;for(let e=1;e<4;e++)Math.abs(R[e])>Math.abs(R[r])&&(r=e);let u=R[r]<0?-1:1;P[I(a.rotationIndex)+e]=r;for(let t=0,n=0;t<4;t++){if(t===r)continue;let i=Math.round((u*R[t]/Math.SQRT2+.5)*255);P[I(a.rotation+n++)+e]=V(i,0,255)}for(let n=0;n<3;n++)P[I(a.scale+n)+e]=ee(s[t*3+n],p[n],m[n]),P[I(a.dc+n)+e]=ee(l[t*3+n],h[n],g[n]);j&&(P[I(a.label)+e]=j[t]&255,P[I(a.label+1)+e]=j[t]>>8);let[d,f,_]=[0,1,2].map(e=>Math.exp(s[t*3+e]));x(R,d,f,_,z);for(let e=0;e<3;e++)L[e]=Math.min(L[e],i[t*3+e]-z[e]),L[3+e]=Math.max(L[3+e],i[t*3+e]+z[e])}return A&&P.set(new Uint8Array(A.buffer),I(N)),{payload:P,row:{g:t.g,i:t.i,j:t.j,count:n,quadrants:O,box:L,offset:0,length:0}}}function oe(e,t,n){e.setUint8(t,n.g),e.setUint8(t+1,n.i),e.setUint8(t+2,n.j),e.setUint32(t+4,n.count,!0),n.quadrants.forEach((n,r)=>e.setUint32(t+8+4*r,n,!0)),n.box.forEach((n,r)=>e.setFloat32(t+20+4*r,n,!0)),e.setUint32(t+44,n.offset,!0),e.setUint32(t+48,n.length,!0)}function se(e,t,n){for(let r=0;r<4;r++)e[t+r]=n.charCodeAt(r)}function U(e){return Uint8Array.from({length:8},(t,n)=>parseInt(e.slice(2*n,2*n+2),16))}async function ce(e,t){let n=await l(e),r=new Uint8Array(8+n.length);return se(r,0,t),new DataView(r.buffer).setUint16(4,1,!0),r.set(n,8),r}async function le(e){let{rows:t,children:n,descendants:r}=e,a=new Uint8Array(40+t.length*52+n.length*9+r.length*11),o=new DataView(a.buffer);o.setUint8(0,e.level),o.setInt32(4,e.e,!0),o.setInt32(8,e.n,!0),a.set(U(e.pack),12),o.setUint32(20,e.packSize,!0),e.col&&a.set(U(e.col),24),o.setUint16(32,t.length,!0),o.setUint8(34,n.length),o.setUint16(36,r.length,!0);let s=40;for(let e of t)oe(o,s,e),s+=52;for(let e of n)o.setUint8(s,e.quadrant),a.set(U(e.idx),s+1),s+=9;for(let e of r)o.setUint8(s,e.depth),o.setUint8(s+1,e.column),o.setUint8(s+2,e.row),a.set(U(e.idx),s+3),s+=11;return ce(a,i)}function ue(e){let t=3421674724,n=2216829733;for(let r=0;r<e.length;r++){n=(n^e[r])>>>0;let i=n*435;t=t*435+(n<<8>>>0)+Math.floor(i/4294967296)>>>0,n=i>>>0}return t.toString(16).padStart(8,`0`)+n.toString(16).padStart(8,`0`)}function de(e){return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/2**32}}let W=16384,fe=1408,pe=65535,G=324121,me=.4,he=[[12,1/7e3,0,1/9e3,.7],[9,1/2300,1.1,1/3100,.4],[6,1/800,.3,1/1100,2],[3,1/150,.9,1/210,1.7]],ge=he.reduce((e,[t,n,,r])=>e+t*(n+r),0),_e=Float32Array.from({length:fe*9},(e,t)=>{let n=Math.floor(t/9),r=t%9,i=(n*(37+2*r)+11*r)%255-127;return r===0&&(i=n%255-127),r===1&&(i=20*Math.floor(n/255)-50),i/127*.04}),K=new TextEncoder,ve={version:1,crs:`synthetic`,height:`synthetic`,leaf:250,roots:[512e4,6144e3].map(e=>({level:12,e:0,n:e})).map(e=>({...e,idx:m(e,q(e,`idx`),`idx`)})),extent:{e:[44e4,9e5],n:[605e4,641e4],h:[0,80]}},ye=K.encode(JSON.stringify(ve));function be(){return async(t,n)=>{if(t.endsWith(`world.json`))return Se(ye,n);let r=g(t),i=t.slice(t.lastIndexOf(`.`)+1);if(!r||i!==`idx`&&i!==`pack`||!Ce(r)||r.hash!==q(r,i))throw new e(`no file ${t}`);return i===`idx`?Se(await ke(r),n):Ae(r,n,t)}}function xe(e,t){let n=30;for(let[r,i,a,o,s]of he)n+=r*Math.sin(i*e+a)*Math.sin(o*t+s);return n}function Se(e,t){return t?e.slice(t[0],t[1]):e.slice()}function q(e,t){return ue(K.encode(`${e.level}/${e.e}/${e.n}.${t}`))}function J(e,t,n){let{e:r,n:i}=ve.extent;return e<r[1]&&e+n>r[0]&&t<i[1]&&t+n>i[0]}function Ce({level:e,e:t,n}){let r=250*2**e;return e<=12&&t%r===0&&n%r===0&&J(t,n,r)}function we(e){return e===0?[1,0]:e===12?[16,15,14,13]:[e+1]}function Te(e){let t=0;for(let n=0;n<8;n++)t|=(e>>2*n&1)<<n;return t}function Ee(e){let t=[];for(let n of we(e.level)){let i=r*2**n,a=250*2**e.level/i;for(let r=0;r<a*a;r++){let a=Te(r),o=Te(r>>1);J(e.e+a*i,e.n+o*i,i)&&t.push({g:n,i:a,j:o})}}return t}function De(e,t){let n=e.level-t,r=250*2**n,i=[];for(let a=0;n>=0&&a<2**t;a++)for(let o=0;o<2**t;o++){let t={level:n,e:e.e+o*r,n:e.n+a*r};J(t.e,t.n,r)&&i.push({column:o,row:a,unit:t})}return i}function Oe(e,{g:t,i:n,j:i},a){let o=r*2**t,s=o/128,c=3*1.2*s,l=1.17*s,u=xe(e.e+(n+.5)*o,e.n+(i+.5)*o),d=ge*o/2,f=Float32Array.of(n*o-c,i*o-c,Math.max(0,u-d)-l,(n+1)*o+c,(i+1)*o+c,Math.min(60,u+d)+l),p=W/4;return{g:t,i:n,j:i,count:W,quadrants:[p,2*p,3*p],box:f,offset:a,length:G}}function ke(e){let t=Ee(e),n=[];for(let{column:t,row:r,unit:i}of De(e,1))n.push({quadrant:t+2*r,idx:q(i,`idx`)});let r=[];for(let t of[2,3])for(let{column:n,row:i,unit:a}of De(e,t))r.push({depth:t,column:n,row:i,idx:q(a,`idx`)});return le({level:e.level,e:e.e,n:e.n,pack:q(e,`pack`),packSize:t.length*324173+16,col:null,rows:t.map((t,n)=>Oe(e,t,n*G)),children:n,descendants:r})}function Ae(e,t,n){let r=Ee(e);if(!t||t[0]%G!=0||t[1]%G!=0||t[0]>=t[1]||t[1]>r.length*G)throw Error(`${n}: the synthetic world serves whole pages only`);let i=new Uint8Array(t[1]-t[0]);for(let n=0;n<i.length;n+=G)je(Ne(e,r[(t[0]+n)/G]),i,n);return i}function je(e,t,n){let r=n;for(let n=0;n<e.length;n+=pe){let i=Math.min(pe,e.length-n);t[r]=+(n+i===e.length),t[r+1]=i&255,t[r+2]=i>>8,t[r+3]=~i&255,t[r+4]=~i>>8&255,t.set(e.subarray(n,n+i),r+5),r+=5+i}}let Me=e=>de(parseInt(ue(K.encode(e)).slice(8),16));function Ne(e,{g:t,i,j:a}){let o=W,s=r*2**t/128,c=Me(`${e.level}/${e.e}/${e.n}/${t}/${i}/${a}`),l=new Float64Array(3*o),u=new Float32Array(4*o),d=new Float32Array(3*o),f=new Float32Array(o),p=new Float32Array(3*o),m=new Float32Array(9*o);for(let t=0;t<o;t++){let r=(i*128+t%128+.5+me*(2*c()-1))*s,o=(a*128+Math.floor(t/128)+.5+me*(2*c()-1))*s,h=xe(e.e+r,e.n+o);l[3*t]=r,l[3*t+1]=o,l[3*t+2]=h;let g=Math.PI*c(),_=.1/2*(2*c()-1);u[4*t]=Math.cos(g)*Math.cos(_),u[4*t+1]=Math.cos(g)*Math.sin(_),u[4*t+2]=Math.sin(g)*Math.sin(_),u[4*t+3]=Math.sin(g)*Math.cos(_);for(let e=0;e<2;e++)d[3*t+e]=Math.log(s*(.6+.6*c()));d[3*t+2]=Math.log(s*.15*(.5+.5*c())),f[t]=.35+.65*c();let v=h/60,y=.5+.5*Math.sin((e.e+r)/410)*Math.sin((e.n+o)/330);p[3*t]=(.32+.2*v+.1*y-.5)/n,p[3*t+1]=(.42+.15*y-.1*v-.5)/n,p[3*t+2]=(.25+.1*v+.04*c()-.5)/n;let b=t%fe;m.set(_e.subarray(9*b,9*(b+1)),9*t)}return ae({count:o,position:l,rotation:u,scale:d,alpha:f,dc:p,sh:m},{g:t,i,j:a}).payload}let Y=2**20,X=self,Z,Pe=/* @__PURE__ */ new Map,Q=/* @__PURE__ */ new Map,Fe=B(e=>X.postMessage(e,[]));X.onmessage=({data:e})=>{`fetched`in e?Fe.take(e):e.type===`init`?(Z=Ie(e),Z.catch(()=>void 0)):e.type===`abort`?Q.get(e.id)?.abort():Re(e)};async function Ie(e){return e.source===`synthetic`?{fetch:be(),cache:await $({...e,cache:`none`}),base:e.base}:{fetch:e.source===`page`?Fe.fetch:t,cache:await $(e),base:e.base}}async function $({cache:e,shard:t,shards:n}){return e===`memory`?N(256*Y):e===`none`?{get:async()=>void 0,put:async()=>void 0}:(t===0&&F(n),await P(await Le()/n,t)??N(256*Y))}async function Le(){try{let{quota:e}=await navigator.storage.estimate();return Math.min(4096*Y,e===void 0?1/0:e/2)}catch{return 4096*Y}}async function Re(t){let{id:n}=t,r=new AbortController;Q.set(n,r);try{if(!Z)throw Error(`stream worker used before init`);let e=await Z;if(t.type===`idx`)X.postMessage({id:n,value:await O(e,t.path)},[]);else{for await(let i of k(e,t.batch,Pe,r.signal))X.postMessage({id:n,page:i},ze(i));X.postMessage({id:n,done:!0},[])}}catch(t){let r=t instanceof Error?t.message:String(t);X.postMessage({id:n,error:r,missing:t instanceof e},[])}finally{Q.delete(n)}}function ze({page:e}){let t=/* @__PURE__ */ new Set;for(let n of[e.geometry,e.colour,e.params,e.clusters])t.add(n.buffer);return[...t]}})();", ut = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", lt], { type: "text/javascript;charset=utf-8" });
|
|
1880
|
+
function dt(e) {
|
|
1875
1881
|
let t;
|
|
1876
1882
|
try {
|
|
1877
|
-
if (t =
|
|
1883
|
+
if (t = ut && (self.URL || self.webkitURL).createObjectURL(ut), !t) throw "";
|
|
1878
1884
|
let n = new Worker(t, { name: e?.name });
|
|
1879
1885
|
return n.addEventListener("error", () => {
|
|
1880
1886
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
1881
1887
|
}), n;
|
|
1882
1888
|
} catch {
|
|
1883
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
1889
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(lt), { name: e?.name });
|
|
1884
1890
|
}
|
|
1885
1891
|
}
|
|
1886
1892
|
//#endregion
|
|
1887
1893
|
//#region src/engine/stream/loader.ts
|
|
1888
|
-
var
|
|
1894
|
+
var ft = class {
|
|
1889
1895
|
#e;
|
|
1890
1896
|
#t = /* @__PURE__ */ new Map();
|
|
1891
1897
|
#n = 0;
|
|
1892
1898
|
constructor(e) {
|
|
1893
1899
|
let { base: t, cache: n, source: r, workers: i } = e;
|
|
1894
1900
|
this.#e = Array.from({ length: i }, (e, a) => {
|
|
1895
|
-
let o = new
|
|
1901
|
+
let o = new dt(), s = { worker: o }, c = typeof r == "function" ? ct(r, (e, t) => o.postMessage(e, t)) : void 0;
|
|
1896
1902
|
o.onmessage = ({ data: e }) => {
|
|
1897
1903
|
"id" in e ? this.#i(e) : c?.(e);
|
|
1898
1904
|
}, o.onerror = () => this.#a(s);
|
|
@@ -1917,7 +1923,7 @@ var pt = class {
|
|
|
1917
1923
|
}
|
|
1918
1924
|
batch(e, t, n) {
|
|
1919
1925
|
if (t.aborted) return Promise.reject(K());
|
|
1920
|
-
let r = this.#e[
|
|
1926
|
+
let r = this.#e[pt(`${e.pack}#${e.window}`, this.#e.length)], i = {
|
|
1921
1927
|
type: "batch",
|
|
1922
1928
|
id: ++this.#n,
|
|
1923
1929
|
batch: e
|
|
@@ -1961,7 +1967,7 @@ var pt = class {
|
|
|
1961
1967
|
for (let t of this.#t.values()) t.slot === e && t.reject(e.error);
|
|
1962
1968
|
}
|
|
1963
1969
|
};
|
|
1964
|
-
function
|
|
1970
|
+
function pt(e, t) {
|
|
1965
1971
|
let n = 2166136261;
|
|
1966
1972
|
for (let t = 0; t < e.length; t++) n = Math.imul(n ^ e.charCodeAt(t), 16777619);
|
|
1967
1973
|
return (n >>> 0) % t;
|
|
@@ -1971,46 +1977,46 @@ function K() {
|
|
|
1971
1977
|
}
|
|
1972
1978
|
//#endregion
|
|
1973
1979
|
//#region src/engine/engine.ts
|
|
1974
|
-
var
|
|
1980
|
+
var mt = class extends Error {
|
|
1975
1981
|
constructor() {
|
|
1976
1982
|
super("This viewer needs WebGPU. Update to the latest Chrome, Edge, Safari or Firefox."), this.name = "NoWebGpu";
|
|
1977
1983
|
}
|
|
1978
1984
|
};
|
|
1979
|
-
async function
|
|
1985
|
+
async function ht(e, t) {
|
|
1980
1986
|
let n = await p();
|
|
1981
|
-
if (!n) throw new
|
|
1987
|
+
if (!n) throw new mt();
|
|
1982
1988
|
let r = e.getContext("webgpu");
|
|
1983
|
-
if (!r) throw n.device.destroy(), new
|
|
1989
|
+
if (!r) throw n.device.destroy(), new mt();
|
|
1984
1990
|
r.configure({
|
|
1985
1991
|
device: n.device,
|
|
1986
1992
|
format: n.format,
|
|
1987
1993
|
alphaMode: "opaque"
|
|
1988
1994
|
}), (t.cache ?? "opfs") === "opfs" && navigator.storage?.persist().catch(() => !1);
|
|
1989
1995
|
let { source: i = "http" } = t;
|
|
1990
|
-
return new
|
|
1996
|
+
return new zt(e, n, r, t, i === "synthetic" ? (await import("./synthetic-BeGCzYIv.js")).synthetic() : i === "http" ? s : i);
|
|
1991
1997
|
}
|
|
1992
|
-
var
|
|
1993
|
-
function
|
|
1998
|
+
var gt = .2, _t = 25165824, vt = 3.25, yt = 2, bt = 1024, xt = 2048, St = 100, Ct = 2, wt = 300, Tt = 100, Et = 250, Dt = 300, Ot = 1e3, kt = 400, At = 5e3, jt = 60, q = Math.PI / 180, Mt = "The viewer was closed.", Nt = "Another world was opened.";
|
|
1999
|
+
function Pt(e, t) {
|
|
1994
2000
|
let n = Math.min(t.maxStorageBufferBindingSize, t.maxBufferSize), r = (t, r) => {
|
|
1995
2001
|
let i = Math.ceil(e * t / 256) * 256;
|
|
1996
2002
|
return Math.min(i, Math.floor(n / r / 256) * 256);
|
|
1997
2003
|
};
|
|
1998
2004
|
return {
|
|
1999
|
-
pool: r(
|
|
2000
|
-
frame: r(
|
|
2005
|
+
pool: r(vt, 16),
|
|
2006
|
+
frame: r(yt, 24)
|
|
2001
2007
|
};
|
|
2002
2008
|
}
|
|
2003
|
-
function
|
|
2009
|
+
function Ft(e, t) {
|
|
2004
2010
|
let [n, r, i] = t;
|
|
2005
|
-
if (Math.hypot(n - e[0], r - e[1], i - e[2]) <=
|
|
2006
|
-
let a = (e) => Math.round(e /
|
|
2011
|
+
if (Math.hypot(n - e[0], r - e[1], i - e[2]) <= xt) return e;
|
|
2012
|
+
let a = (e) => Math.round(e / bt) * bt;
|
|
2007
2013
|
return [
|
|
2008
2014
|
a(n),
|
|
2009
2015
|
a(r),
|
|
2010
2016
|
a(i)
|
|
2011
2017
|
];
|
|
2012
2018
|
}
|
|
2013
|
-
function
|
|
2019
|
+
function It(e, t, n, r, i, a) {
|
|
2014
2020
|
let o = 2 * e[0] / t[0] - 1, s = 1 - 2 * e[1] / t[1], c = [
|
|
2015
2021
|
n * o / r[0],
|
|
2016
2022
|
n * s / r[5],
|
|
@@ -2022,17 +2028,17 @@ function Lt(e, t, n, r, i, a) {
|
|
|
2022
2028
|
d + a[2]
|
|
2023
2029
|
];
|
|
2024
2030
|
}
|
|
2025
|
-
function
|
|
2031
|
+
function Lt(e, t) {
|
|
2026
2032
|
return [
|
|
2027
2033
|
e.e - t[0],
|
|
2028
2034
|
e.n - t[1],
|
|
2029
2035
|
e.h - t[2]
|
|
2030
2036
|
];
|
|
2031
2037
|
}
|
|
2032
|
-
function
|
|
2033
|
-
e.push(t), e.length >
|
|
2038
|
+
function Rt(e, t) {
|
|
2039
|
+
e.push(t), e.length > jt && e.shift();
|
|
2034
2040
|
}
|
|
2035
|
-
var
|
|
2041
|
+
var zt = class {
|
|
2036
2042
|
#e;
|
|
2037
2043
|
#t;
|
|
2038
2044
|
#n;
|
|
@@ -2043,7 +2049,7 @@ var Bt = class {
|
|
|
2043
2049
|
#s;
|
|
2044
2050
|
#c;
|
|
2045
2051
|
#l;
|
|
2046
|
-
#u = new
|
|
2052
|
+
#u = new ze();
|
|
2047
2053
|
#d = new Ee();
|
|
2048
2054
|
#f = (e) => this.#s.has(e);
|
|
2049
2055
|
#p = null;
|
|
@@ -2110,7 +2116,7 @@ var Bt = class {
|
|
|
2110
2116
|
e.height,
|
|
2111
2117
|
1
|
|
2112
2118
|
], this.#k = [Math.max(1, e.width), Math.max(1, e.height)];
|
|
2113
|
-
let { pool: a, frame: o } =
|
|
2119
|
+
let { pool: a, frame: o } = Pt(this.#ne, t.device.limits);
|
|
2114
2120
|
this.#s = new _(t.device, a), this.#c = new Ce(t, n, this.#s, o), this.#l = o, t.device.lost.then((e) => {
|
|
2115
2121
|
if (!this.#ee) {
|
|
2116
2122
|
this.#te = !0, cancelAnimationFrame(this.#A);
|
|
@@ -2119,34 +2125,34 @@ var Bt = class {
|
|
|
2119
2125
|
});
|
|
2120
2126
|
}
|
|
2121
2127
|
async open(e) {
|
|
2122
|
-
if (this.#ee) throw Error(
|
|
2128
|
+
if (this.#ee) throw Error(Mt);
|
|
2123
2129
|
let t = ++this.#_, i = () => {
|
|
2124
|
-
if (this.#ee) throw Error(
|
|
2125
|
-
if (t !== this.#_) throw Error(
|
|
2130
|
+
if (this.#ee) throw Error(Mt);
|
|
2131
|
+
if (t !== this.#_) throw Error(Nt);
|
|
2126
2132
|
}, { cache: a = "opfs", source: o = "http" } = this.#r;
|
|
2127
2133
|
o === "http" && (e = new URL(e, document.baseURI).href);
|
|
2128
2134
|
let s = await this.#i(e, null), c = r(JSON.parse(new TextDecoder().decode(s)));
|
|
2129
2135
|
i();
|
|
2130
|
-
let l = new
|
|
2136
|
+
let l = new ft({
|
|
2131
2137
|
base: n(e),
|
|
2132
2138
|
workers: Math.min(6, Math.max(2, navigator.hardwareConcurrency - 2)),
|
|
2133
2139
|
cache: a,
|
|
2134
2140
|
source: o
|
|
2135
|
-
}), u = new
|
|
2141
|
+
}), u = new Fe(c);
|
|
2136
2142
|
try {
|
|
2137
2143
|
let e = await Promise.all(c.roots.map((e) => l.idx(e.idx)));
|
|
2138
2144
|
i(), e.forEach((e, t) => u.add(e, c.roots[t].idx));
|
|
2139
2145
|
} catch (e) {
|
|
2140
2146
|
throw l.destroy(), e;
|
|
2141
2147
|
}
|
|
2142
|
-
return this.#g?.destroy(), this.#g = null, this.#h?.destroy(), this.#p = e, this.#m = u, this.#h = l, this.#N = null, this.#u = new
|
|
2148
|
+
return this.#g?.destroy(), this.#g = null, this.#h?.destroy(), this.#p = e, this.#m = u, this.#h = l, this.#N = null, this.#u = new ze(), this.#d = new Ee(), this.#s.clear(), this.#g = this.#oe(u, l), this.#I = !0, this.requestFrame(), c;
|
|
2143
2149
|
}
|
|
2144
2150
|
setCamera(e) {
|
|
2145
2151
|
if (this.#ee) return;
|
|
2146
2152
|
let t = performance.now(), n = t - this.#b, r = this.#y, i = this.#x;
|
|
2147
|
-
if (n >
|
|
2153
|
+
if (n > Et) i.fill(0);
|
|
2148
2154
|
else if (n > 0) {
|
|
2149
|
-
let t = 1 - Math.exp(-n /
|
|
2155
|
+
let t = 1 - Math.exp(-n / Tt);
|
|
2150
2156
|
i[0] += t * ((e.e - r.e) / n - i[0]), i[1] += t * ((e.n - r.n) / n - i[1]), i[2] += t * ((e.h - r.h) / n - i[2]);
|
|
2151
2157
|
}
|
|
2152
2158
|
this.#b = t, this.#y = { ...e }, this.#F = !0, this.#$ || this.requestFrame();
|
|
@@ -2199,8 +2205,8 @@ var Bt = class {
|
|
|
2199
2205
|
stats() {
|
|
2200
2206
|
let e = this.#s, t = this.#g, n = this.#c.stats();
|
|
2201
2207
|
return {
|
|
2202
|
-
frameMs:
|
|
2203
|
-
cpuMs:
|
|
2208
|
+
frameMs: $e(this.#W, .5),
|
|
2209
|
+
cpuMs: $e(this.#G, .5),
|
|
2204
2210
|
gpuMs: n.gpuMs,
|
|
2205
2211
|
passes: n.passes,
|
|
2206
2212
|
drawn: n.drawn,
|
|
@@ -2239,7 +2245,7 @@ var Bt = class {
|
|
|
2239
2245
|
}
|
|
2240
2246
|
warm() {
|
|
2241
2247
|
let e = performance.now();
|
|
2242
|
-
e - this.#V <
|
|
2248
|
+
e - this.#V < Ot || (this.#H = e + kt, this.requestFrame());
|
|
2243
2249
|
}
|
|
2244
2250
|
onFrame(e) {
|
|
2245
2251
|
return this.#Q.add(e), () => this.#Q.delete(e);
|
|
@@ -2278,11 +2284,11 @@ var Bt = class {
|
|
|
2278
2284
|
return this.#o.budget;
|
|
2279
2285
|
}
|
|
2280
2286
|
#re() {
|
|
2281
|
-
let { budget: e, budgetRange: t = [e, e] } = this.#a, n = Math.floor(
|
|
2282
|
-
return new
|
|
2287
|
+
let { budget: e, budgetRange: t = [e, e] } = this.#a, n = Math.floor(Pt(Infinity, this.#t.device.limits).frame / yt), r = (e) => Math.max(1, Math.min(e, n));
|
|
2288
|
+
return new et(r(e), [r(t[0]), r(t[1])]);
|
|
2283
2289
|
}
|
|
2284
2290
|
#ie() {
|
|
2285
|
-
let { pool: e, frame: t } =
|
|
2291
|
+
let { pool: e, frame: t } = Pt(this.#ne, this.#t.device.limits);
|
|
2286
2292
|
(e > this.#s.capacity || t > this.#l) && this.#ae(e, t), this.#I = !0, this.requestFrame();
|
|
2287
2293
|
}
|
|
2288
2294
|
#ae(e, t) {
|
|
@@ -2294,14 +2300,14 @@ var Bt = class {
|
|
|
2294
2300
|
this.#c = n, this.#l = t;
|
|
2295
2301
|
}
|
|
2296
2302
|
#oe(e, t) {
|
|
2297
|
-
return new
|
|
2303
|
+
return new st(e, t, this.#s, () => {
|
|
2298
2304
|
this.#R = !0, this.requestFrame();
|
|
2299
2305
|
}, this.#se);
|
|
2300
2306
|
}
|
|
2301
2307
|
#se = () => {
|
|
2302
2308
|
let e = this.#p, t = this.#m;
|
|
2303
2309
|
this.#v || this.#ee || e === null || (this.#v = !0, this.open(e).then(() => this.#v = !1, () => {
|
|
2304
|
-
this.#v = !1, this.#m === t && setTimeout(this.#se,
|
|
2310
|
+
this.#v = !1, this.#m === t && setTimeout(this.#se, At);
|
|
2305
2311
|
}));
|
|
2306
2312
|
};
|
|
2307
2313
|
#ce(e, t, n) {
|
|
@@ -2315,12 +2321,12 @@ var Bt = class {
|
|
|
2315
2321
|
};
|
|
2316
2322
|
}
|
|
2317
2323
|
#le() {
|
|
2318
|
-
let [e, t, n] = this.#O, r =
|
|
2324
|
+
let [e, t, n] = this.#O, r = Qe(e, t, n, this.#o.scale), i = Math.max(1, Math.round(e * r)), a = Math.max(1, Math.round(t * r));
|
|
2319
2325
|
(i !== this.#k[0] || a !== this.#k[1]) && (this.#k = [i, a], this.#e.width = i, this.#e.height = a, this.#c.resize(i, a), this.#I = !0, this.requestFrame());
|
|
2320
2326
|
}
|
|
2321
2327
|
#ue = (e) => {
|
|
2322
2328
|
if (this.#A = 0, !(this.#ee || this.#te)) {
|
|
2323
|
-
if (this.#j >=
|
|
2329
|
+
if (this.#j >= Ct) this.#M = !0;
|
|
2324
2330
|
else {
|
|
2325
2331
|
this.#$ = !0;
|
|
2326
2332
|
for (let t of this.#Q) t(e);
|
|
@@ -2333,21 +2339,21 @@ var Bt = class {
|
|
|
2333
2339
|
#de(e) {
|
|
2334
2340
|
let t = performance.now(), n = this.#o, r = this.#s, i = this.#y, [a, o] = this.#k, s = this.#a.viewDistance, c = this.#F;
|
|
2335
2341
|
this.#F = !1;
|
|
2336
|
-
let l =
|
|
2342
|
+
let l = Ft(this.#S, [
|
|
2337
2343
|
i.e,
|
|
2338
2344
|
i.n,
|
|
2339
2345
|
i.h
|
|
2340
2346
|
]);
|
|
2341
2347
|
l !== this.#S && (this.#S = l, r.setOrigin(l));
|
|
2342
|
-
let u =
|
|
2343
|
-
y(this.#C, u, i.yaw * q, i.pitch * q), b(this.#w, i.fov * q, a / o,
|
|
2348
|
+
let u = Lt(i, l);
|
|
2349
|
+
y(this.#C, u, i.yaw * q, i.pitch * q), b(this.#w, i.fov * q, a / o, gt, s);
|
|
2344
2350
|
let d = {
|
|
2345
2351
|
time: t,
|
|
2346
2352
|
width: a,
|
|
2347
2353
|
height: o,
|
|
2348
2354
|
view: new Float32Array(this.#C),
|
|
2349
2355
|
proj: new Float32Array(this.#w),
|
|
2350
|
-
near:
|
|
2356
|
+
near: gt,
|
|
2351
2357
|
far: s,
|
|
2352
2358
|
camera: Float32Array.from(u),
|
|
2353
2359
|
origin: l
|
|
@@ -2355,11 +2361,11 @@ var Bt = class {
|
|
|
2355
2361
|
Te(this.#D, S(this.#E, d.proj, d.view));
|
|
2356
2362
|
let f = this.#m, p = this.#g, m = this.#R || this.#I || this.#z, h = this.#N, g = h;
|
|
2357
2363
|
if (f && p) {
|
|
2358
|
-
let e = !p.idle && t - this.#P >=
|
|
2364
|
+
let e = !p.idle && t - this.#P >= St, n = this.#I || this.#R || this.#z || this.#L;
|
|
2359
2365
|
(!g || c || e || n) && (g = this.#fe(f, t, c));
|
|
2360
2366
|
}
|
|
2361
2367
|
let _ = this.#B, v = this.#z;
|
|
2362
|
-
g && p && (g !== h && (m || !h || g.cut.length !== h.cut.length || g.cut.some((e, t) => e !== h.cut[t])) && ({drawn: _, fading: v} = this.#d.update(g.cut, this.#f, t, this.#ne)), p.update(g, new Set(_.map((e) => e.id)), t)), r.upload(
|
|
2368
|
+
g && p && (g !== h && (m || !h || g.cut.length !== h.cut.length || g.cut.some((e, t) => e !== h.cut[t])) && ({drawn: _, fading: v} = this.#d.update(g.cut, this.#f, t, this.#ne)), p.update(g, new Set(_.map((e) => e.id)), t)), r.upload(_t) > 0 && (this.#R = !0), (_ !== this.#B || this.#R) && r.draw(_), this.#z = v, this.#B = _;
|
|
2363
2369
|
let x = this.#J.splice(0).map((e) => this.#me(e, d)), C = this.#Y.splice(0).map((e) => this.#he(e, l)), w = this.#c.render(d, this.#D, this.#r.sky, x, C), T = performance.now() - t;
|
|
2364
2370
|
if (!this.#R && !this.#L && !v && r.queued === 0 && (!p || p.idle) && (!g || g.load.length === 0 && g.idx.length === 0) && this.#X.length) {
|
|
2365
2371
|
let e = this.#X.splice(0);
|
|
@@ -2378,14 +2384,14 @@ var Bt = class {
|
|
|
2378
2384
|
width: a / s,
|
|
2379
2385
|
height: o / s,
|
|
2380
2386
|
tan: Math.tan(r.fov * q / 2),
|
|
2381
|
-
near:
|
|
2387
|
+
near: gt,
|
|
2382
2388
|
far: this.#a.viewDistance
|
|
2383
2389
|
}, u = {
|
|
2384
2390
|
...l,
|
|
2385
2391
|
view: this.#C
|
|
2386
2392
|
}, d = {
|
|
2387
2393
|
budget: c,
|
|
2388
|
-
capacity: i.capacity - Math.ceil(
|
|
2394
|
+
capacity: i.capacity - Math.ceil(1 * c),
|
|
2389
2395
|
now: t,
|
|
2390
2396
|
predicted: n ? this.#pe(l) : void 0
|
|
2391
2397
|
}, f = this.#u.plan(e, u, this.#f, d);
|
|
@@ -2395,9 +2401,9 @@ var Bt = class {
|
|
|
2395
2401
|
let t = this.#x;
|
|
2396
2402
|
if (t.every((e) => e === 0)) return;
|
|
2397
2403
|
let n = this.#y, r = [
|
|
2398
|
-
n.e + t[0] *
|
|
2399
|
-
n.n + t[1] *
|
|
2400
|
-
n.h + t[2] *
|
|
2404
|
+
n.e + t[0] * wt - e.origin[0],
|
|
2405
|
+
n.n + t[1] * wt - e.origin[1],
|
|
2406
|
+
n.h + t[2] * wt - e.origin[2]
|
|
2401
2407
|
];
|
|
2402
2408
|
return {
|
|
2403
2409
|
...e,
|
|
@@ -2405,7 +2411,7 @@ var Bt = class {
|
|
|
2405
2411
|
};
|
|
2406
2412
|
}
|
|
2407
2413
|
#me({ x: e, y: t, resolve: n }, r) {
|
|
2408
|
-
let i = this.#C.slice(), a = this.#S, o = [r.width, r.height], s = (n) =>
|
|
2414
|
+
let i = this.#C.slice(), a = this.#S, o = [r.width, r.height], s = (n) => It([e, t], o, n, r.proj, i, a);
|
|
2409
2415
|
return {
|
|
2410
2416
|
x: e,
|
|
2411
2417
|
y: t,
|
|
@@ -2424,12 +2430,12 @@ var Bt = class {
|
|
|
2424
2430
|
};
|
|
2425
2431
|
}
|
|
2426
2432
|
#ge(e, t, n) {
|
|
2427
|
-
let r = this.#o, { gpuMs: i } = this.#c.stats(), a = e - this.#V, o = a <= Math.max(
|
|
2428
|
-
o &&
|
|
2433
|
+
let r = this.#o, { gpuMs: i } = this.#c.stats(), a = e - this.#V, o = a <= Math.max(Et, 2 * i, 2 * t);
|
|
2434
|
+
o && Rt(this.#W, a), Rt(this.#G, t), this.#V = e;
|
|
2429
2435
|
let s = r.budget;
|
|
2430
|
-
r.sample(a, e, o && n, this.#N?.planned ?? 0) && (this.#le(), r.budget !== s && this.#ie()), n ? this.#U = e : r.scale < 1 && e - this.#U >
|
|
2436
|
+
r.sample(a, e, o && n, this.#N?.planned ?? 0) && (this.#le(), r.budget !== s && this.#ie()), n ? this.#U = e : r.scale < 1 && e - this.#U > Dt && (r.full(), this.#le());
|
|
2431
2437
|
}
|
|
2432
|
-
},
|
|
2438
|
+
}, Bt = 45, Vt = {
|
|
2433
2439
|
yaw: 0,
|
|
2434
2440
|
pitch: -35,
|
|
2435
2441
|
dist: 300
|
|
@@ -2438,8 +2444,8 @@ var Bt = class {
|
|
|
2438
2444
|
dist: [1, 2485],
|
|
2439
2445
|
clearance: 10,
|
|
2440
2446
|
floor: 50
|
|
2441
|
-
},
|
|
2442
|
-
function
|
|
2447
|
+
}, Ht = .1, Y = Math.PI / 180, Ut = (e, [t, n]) => Math.min(n, Math.max(t, e)), Wt = (e) => (e % 360 + 360) % 360, Gt = (e, t) => (t - e + 540) % 360 - 180;
|
|
2448
|
+
function Kt({ leaf: e, roots: t, extent: n }) {
|
|
2443
2449
|
let r = {
|
|
2444
2450
|
e: (n.e[0] + n.e[1]) / 2,
|
|
2445
2451
|
n: (n.n[0] + n.n[1]) / 2,
|
|
@@ -2456,7 +2462,7 @@ function qt({ leaf: e, roots: t, extent: n }) {
|
|
|
2456
2462
|
}
|
|
2457
2463
|
return i;
|
|
2458
2464
|
}
|
|
2459
|
-
function
|
|
2465
|
+
function qt(e) {
|
|
2460
2466
|
let t = e.split(",");
|
|
2461
2467
|
if (t.length !== 6 || t.some((e) => e.trim() === "")) return null;
|
|
2462
2468
|
let [n, r, i, a, o, s] = t.map(Number);
|
|
@@ -2476,7 +2482,7 @@ function Jt(e) {
|
|
|
2476
2482
|
dist: s
|
|
2477
2483
|
};
|
|
2478
2484
|
}
|
|
2479
|
-
function
|
|
2485
|
+
function Jt(e) {
|
|
2480
2486
|
let t = (e, t) => +e.toFixed(t);
|
|
2481
2487
|
return [
|
|
2482
2488
|
t(e.e, 2),
|
|
@@ -2492,14 +2498,14 @@ function X(e, t, n = J) {
|
|
|
2492
2498
|
e: e.e,
|
|
2493
2499
|
n: e.n,
|
|
2494
2500
|
h: e.h,
|
|
2495
|
-
yaw:
|
|
2496
|
-
pitch:
|
|
2497
|
-
dist:
|
|
2501
|
+
yaw: Wt(e.yaw),
|
|
2502
|
+
pitch: Ut(e.pitch, n.pitch),
|
|
2503
|
+
dist: Ut(e.dist, n.dist)
|
|
2498
2504
|
};
|
|
2499
2505
|
if (t) {
|
|
2500
2506
|
let e = Z(r), i = Math.max(n.floor, t(e.e, e.n) + n.clearance);
|
|
2501
2507
|
if (e.h < i) return {
|
|
2502
|
-
|
|
2508
|
+
...Qt({
|
|
2503
2509
|
...e,
|
|
2504
2510
|
h: i
|
|
2505
2511
|
}, r),
|
|
@@ -2508,7 +2514,7 @@ function X(e, t, n = J) {
|
|
|
2508
2514
|
}
|
|
2509
2515
|
return r;
|
|
2510
2516
|
}
|
|
2511
|
-
function
|
|
2517
|
+
function Yt(e, t) {
|
|
2512
2518
|
let n = Math.cos(t * Y);
|
|
2513
2519
|
return {
|
|
2514
2520
|
e: Math.sin(e * Y) * n,
|
|
@@ -2517,14 +2523,14 @@ function Xt(e, t) {
|
|
|
2517
2523
|
};
|
|
2518
2524
|
}
|
|
2519
2525
|
function Z(e) {
|
|
2520
|
-
let t =
|
|
2526
|
+
let t = Yt(e.yaw, e.pitch);
|
|
2521
2527
|
return {
|
|
2522
2528
|
e: e.e - t.e * e.dist,
|
|
2523
2529
|
n: e.n - t.n * e.dist,
|
|
2524
2530
|
h: e.h - t.h * e.dist
|
|
2525
2531
|
};
|
|
2526
2532
|
}
|
|
2527
|
-
function
|
|
2533
|
+
function Xt(e) {
|
|
2528
2534
|
return {
|
|
2529
2535
|
...Z(e),
|
|
2530
2536
|
yaw: e.yaw,
|
|
@@ -2532,7 +2538,7 @@ function Zt(e) {
|
|
|
2532
2538
|
fov: 45
|
|
2533
2539
|
};
|
|
2534
2540
|
}
|
|
2535
|
-
function
|
|
2541
|
+
function Zt(e, t, n) {
|
|
2536
2542
|
let r = Z(e), [i, a, o] = [
|
|
2537
2543
|
n.e - r.e,
|
|
2538
2544
|
n.n - r.n,
|
|
@@ -2543,7 +2549,7 @@ function Qt(e, t, n) {
|
|
|
2543
2549
|
y: (d * l - o * u) / f
|
|
2544
2550
|
};
|
|
2545
2551
|
}
|
|
2546
|
-
function
|
|
2552
|
+
function Qt(e, t) {
|
|
2547
2553
|
let [n, r, i] = [
|
|
2548
2554
|
t.e - e.e,
|
|
2549
2555
|
t.n - e.n,
|
|
@@ -2553,17 +2559,17 @@ function $t(e, t) {
|
|
|
2553
2559
|
e: t.e,
|
|
2554
2560
|
n: t.n,
|
|
2555
2561
|
h: t.h,
|
|
2556
|
-
yaw:
|
|
2562
|
+
yaw: Wt(Math.atan2(n, r) / Y),
|
|
2557
2563
|
pitch: Math.asin(i / a) / Y,
|
|
2558
2564
|
dist: a
|
|
2559
2565
|
};
|
|
2560
2566
|
}
|
|
2561
|
-
function
|
|
2567
|
+
function $t(e, t, n, r = J) {
|
|
2562
2568
|
let i = Z(e), a = X({
|
|
2563
2569
|
...e,
|
|
2564
2570
|
yaw: t,
|
|
2565
2571
|
pitch: n
|
|
2566
|
-
}, void 0, r), o =
|
|
2572
|
+
}, void 0, r), o = Yt(a.yaw, a.pitch);
|
|
2567
2573
|
return {
|
|
2568
2574
|
...a,
|
|
2569
2575
|
e: i.e + o.e * a.dist,
|
|
@@ -2571,8 +2577,8 @@ function en(e, t, n, r = J) {
|
|
|
2571
2577
|
h: i.h + o.h * a.dist
|
|
2572
2578
|
};
|
|
2573
2579
|
}
|
|
2574
|
-
function
|
|
2575
|
-
return e.dist * Math.max(Math.sin(-e.pitch * Y),
|
|
2580
|
+
function en(e) {
|
|
2581
|
+
return e.dist * Math.max(Math.sin(-e.pitch * Y), Ht);
|
|
2576
2582
|
}
|
|
2577
2583
|
function Q(e, t, n, r) {
|
|
2578
2584
|
let [i, a] = [Math.sin(e.yaw * Y), Math.cos(e.yaw * Y)];
|
|
@@ -2583,30 +2589,30 @@ function Q(e, t, n, r) {
|
|
|
2583
2589
|
h: e.h + r
|
|
2584
2590
|
};
|
|
2585
2591
|
}
|
|
2586
|
-
function
|
|
2587
|
-
return Q(e, t, n * e.dist /
|
|
2592
|
+
function tn(e, t, n) {
|
|
2593
|
+
return Q(e, t, n * e.dist / en(e), 0);
|
|
2588
2594
|
}
|
|
2589
|
-
function
|
|
2595
|
+
function nn(e, t, n) {
|
|
2590
2596
|
return {
|
|
2591
2597
|
e: e.e + (t.e - e.e) * n,
|
|
2592
2598
|
n: e.n + (t.n - e.n) * n,
|
|
2593
2599
|
h: e.h + (t.h - e.h) * n,
|
|
2594
|
-
yaw:
|
|
2600
|
+
yaw: Wt(e.yaw + Gt(e.yaw, t.yaw) * n),
|
|
2595
2601
|
pitch: e.pitch + (t.pitch - e.pitch) * n,
|
|
2596
2602
|
dist: e.dist * (t.dist / e.dist) ** n
|
|
2597
2603
|
};
|
|
2598
2604
|
}
|
|
2599
|
-
function
|
|
2605
|
+
function rn(e, t) {
|
|
2600
2606
|
let n = e.dist * 1e-5;
|
|
2601
|
-
return Math.abs(e.e - t.e) < n && Math.abs(e.n - t.n) < n && Math.abs(e.h - t.h) < n && Math.abs(e.dist - t.dist) < n && Math.abs(
|
|
2607
|
+
return Math.abs(e.e - t.e) < n && Math.abs(e.n - t.n) < n && Math.abs(e.h - t.h) < n && Math.abs(e.dist - t.dist) < n && Math.abs(Gt(e.yaw, t.yaw)) < .001 && Math.abs(e.pitch - t.pitch) < .001;
|
|
2602
2608
|
}
|
|
2603
2609
|
//#endregion
|
|
2604
2610
|
//#region src/controls/controls.ts
|
|
2605
|
-
var
|
|
2606
|
-
function
|
|
2611
|
+
var an = .2, on = .002, sn = .005, cn = .5, ln = .05;
|
|
2612
|
+
function un(e, t) {
|
|
2607
2613
|
return 2 * e * Math.tan(45 * Math.PI / 360) / Math.max(1, t);
|
|
2608
2614
|
}
|
|
2609
|
-
function
|
|
2615
|
+
function dn(e) {
|
|
2610
2616
|
let t = (t) => +!!e.has(t);
|
|
2611
2617
|
return [
|
|
2612
2618
|
t("KeyD") - t("KeyA") + t("ArrowRight") - t("ArrowLeft"),
|
|
@@ -2614,10 +2620,10 @@ function fn(e) {
|
|
|
2614
2620
|
t("KeyE") - t("KeyQ")
|
|
2615
2621
|
];
|
|
2616
2622
|
}
|
|
2617
|
-
function
|
|
2618
|
-
return
|
|
2623
|
+
function fn(e, t, n, r, i = J) {
|
|
2624
|
+
return rn(e, t) ? t : X(nn(e, t, 1 - Math.exp(-n / ln)), r, i);
|
|
2619
2625
|
}
|
|
2620
|
-
var
|
|
2626
|
+
var pn = class {
|
|
2621
2627
|
#e;
|
|
2622
2628
|
#t;
|
|
2623
2629
|
#n;
|
|
@@ -2655,7 +2661,7 @@ var mn = class {
|
|
|
2655
2661
|
return this.#p.add(e), () => this.#p.delete(e);
|
|
2656
2662
|
}
|
|
2657
2663
|
moveTo(e, t) {
|
|
2658
|
-
let n = this.#d, r = Math.min(n.dist,
|
|
2664
|
+
let n = this.#d, r = Math.min(n.dist, Vt.dist);
|
|
2659
2665
|
this.#d = this.#E({
|
|
2660
2666
|
...n,
|
|
2661
2667
|
e,
|
|
@@ -2682,7 +2688,7 @@ var mn = class {
|
|
|
2682
2688
|
e.buttons & 6 || t && e.shiftKey ? $(this.#c, r, i) : t && $(this.#s, r, i);
|
|
2683
2689
|
} else if (n) {
|
|
2684
2690
|
let e = this.#C();
|
|
2685
|
-
$(this.#c, e.x - n.x, e.y - n.y), this.#l += (n.d - e.d) *
|
|
2691
|
+
$(this.#c, e.x - n.x, e.y - n.y), this.#l += (n.d - e.d) * sn;
|
|
2686
2692
|
} else $(this.#s, r, i);
|
|
2687
2693
|
this.#w();
|
|
2688
2694
|
};
|
|
@@ -2690,7 +2696,7 @@ var mn = class {
|
|
|
2690
2696
|
this.#a.delete(e.pointerId);
|
|
2691
2697
|
};
|
|
2692
2698
|
#y = (e) => {
|
|
2693
|
-
e.preventDefault(), this.#l += e.deltaY *
|
|
2699
|
+
e.preventDefault(), this.#l += e.deltaY * on, this.#w();
|
|
2694
2700
|
};
|
|
2695
2701
|
#b = (e) => {
|
|
2696
2702
|
e.code === "KeyF" && !e.repeat && (this.#u = !this.#u), this.#o.add(e.code), this.#u && this.#w();
|
|
@@ -2702,7 +2708,7 @@ var mn = class {
|
|
|
2702
2708
|
let t = await this.#t.pick(e.offsetX, e.offsetY);
|
|
2703
2709
|
if (!t || this.#i.signal.aborted) return;
|
|
2704
2710
|
let [n, r, i] = t;
|
|
2705
|
-
this.#d = X(
|
|
2711
|
+
this.#d = X(Qt(Z(this.#f), {
|
|
2706
2712
|
e: n,
|
|
2707
2713
|
n: r,
|
|
2708
2714
|
h: i
|
|
@@ -2725,13 +2731,13 @@ var mn = class {
|
|
|
2725
2731
|
this.#h = e;
|
|
2726
2732
|
let n = this.#d, [r, i] = this.#c;
|
|
2727
2733
|
if (r || i) {
|
|
2728
|
-
let e =
|
|
2729
|
-
n =
|
|
2734
|
+
let e = un(n.dist, this.#e.clientHeight);
|
|
2735
|
+
n = tn(n, -r * e, i * e);
|
|
2730
2736
|
}
|
|
2731
2737
|
let [a, o] = this.#s;
|
|
2732
2738
|
if (a || o) {
|
|
2733
|
-
let [e, t] = [n.yaw + a *
|
|
2734
|
-
n = this.#u ?
|
|
2739
|
+
let [e, t] = [n.yaw + a * an, n.pitch - o * an];
|
|
2740
|
+
n = this.#u ? $t(n, e, t, this.#r) : X({
|
|
2735
2741
|
...n,
|
|
2736
2742
|
yaw: e,
|
|
2737
2743
|
pitch: t
|
|
@@ -2741,14 +2747,14 @@ var mn = class {
|
|
|
2741
2747
|
...n,
|
|
2742
2748
|
dist: n.dist * Math.exp(this.#l)
|
|
2743
2749
|
}, void 0, this.#r)), this.#c = [0, 0], this.#s = [0, 0], this.#l = 0;
|
|
2744
|
-
let [s, c, l] =
|
|
2750
|
+
let [s, c, l] = dn(this.#o), u = this.#u && (s !== 0 || l !== 0 || c !== 0);
|
|
2745
2751
|
if (u) {
|
|
2746
|
-
let e =
|
|
2752
|
+
let e = cn * en(n) * t;
|
|
2747
2753
|
n = Q(n, s * e, c * e, l * e);
|
|
2748
2754
|
}
|
|
2749
2755
|
let d = this.#f;
|
|
2750
2756
|
if (d !== n) {
|
|
2751
|
-
this.#d = n = this.#E(n), this.#f =
|
|
2757
|
+
this.#d = n = this.#E(n), this.#f = fn(d, n, t, this.#n, this.#r), this.#D();
|
|
2752
2758
|
for (let e of this.#p) e();
|
|
2753
2759
|
}
|
|
2754
2760
|
u || this.#f !== this.#d ? this.#w() : this.#h = null;
|
|
@@ -2757,11 +2763,11 @@ var mn = class {
|
|
|
2757
2763
|
return X(e, this.#n, this.#r);
|
|
2758
2764
|
}
|
|
2759
2765
|
#D() {
|
|
2760
|
-
this.#t.setCamera(
|
|
2766
|
+
this.#t.setCamera(Xt(this.#f));
|
|
2761
2767
|
}
|
|
2762
2768
|
};
|
|
2763
2769
|
function $(e, t, n) {
|
|
2764
2770
|
e[0] += t, e[1] += n;
|
|
2765
2771
|
}
|
|
2766
2772
|
//#endregion
|
|
2767
|
-
export { ae as S,
|
|
2773
|
+
export { ae as S, rn as _, Z as a, ht as b, Q as c, $t as d, Qt as f, Zt as g, qt as h, nn as i, Jt as l, tn as m, Bt as n, X as o, Kt as p, J as r, Vt as s, pn as t, en as u, Xt as v, Ue as x, mt as y };
|
package/dist/element/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import type { Drawn } from '../types.ts';
|
|
|
3
3
|
import type { PageNode } from '../world/tree.ts';
|
|
4
4
|
export declare const FADE_MS = 250;
|
|
5
5
|
/** share of the budget fading splats, and the pool slots of pages held for them, may take */
|
|
6
|
-
export declare const FADE_CAP =
|
|
6
|
+
export declare const FADE_CAP = 1;
|
|
7
7
|
export declare class Fader {
|
|
8
8
|
#private;
|
|
9
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, x as b, y as x } from "./controls-
|
|
1
|
+
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, x as b, y as x } from "./controls-IBLB-RWS.js";
|
|
2
2
|
import { t as S } from "./ports-DZRKjdYD.js";
|
|
3
3
|
import { t as C } from "./http-DL7R39Nc.js";
|
|
4
4
|
//#region src/engine/plugins/grade.wgsl?raw
|