world.ts 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +880 -894
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ft = (e, t) => {
|
|
2
2
|
let n;
|
|
3
3
|
return (...i) => {
|
|
4
4
|
clearTimeout(n), n = setTimeout(() => e(...i), t);
|
|
5
5
|
};
|
|
6
|
-
},
|
|
6
|
+
}, ue = (e, t) => Array.from({ length: t - e }, (n, i) => i + e), Pt = ({
|
|
7
7
|
gl: e,
|
|
8
8
|
vertexSource: t,
|
|
9
9
|
fragmentSource: n
|
|
@@ -11,71 +11,71 @@ const St = (e, t) => {
|
|
|
11
11
|
const i = e.createProgram();
|
|
12
12
|
if (!i)
|
|
13
13
|
throw new Error("Program creation failed");
|
|
14
|
-
const r =
|
|
14
|
+
const r = it(
|
|
15
15
|
e,
|
|
16
16
|
e.createShader(e.VERTEX_SHADER),
|
|
17
17
|
t
|
|
18
|
-
), o =
|
|
18
|
+
), o = it(
|
|
19
19
|
e,
|
|
20
20
|
e.createShader(e.FRAGMENT_SHADER),
|
|
21
21
|
n
|
|
22
22
|
);
|
|
23
23
|
if (e.attachShader(i, r), e.attachShader(i, o), e.linkProgram(i), !e.getProgramParameter(i, e.LINK_STATUS))
|
|
24
24
|
throw console.error("Link failure", e.getProgramInfoLog(i)), new Error("Link failure");
|
|
25
|
-
const s = () => e.useProgram(i), a = {}, c = (
|
|
26
|
-
if (a[
|
|
27
|
-
return a[
|
|
28
|
-
const y = e.getUniformLocation(i,
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
-
y && U !==
|
|
25
|
+
const s = () => e.useProgram(i), a = {}, c = (g, w) => {
|
|
26
|
+
if (a[g])
|
|
27
|
+
return a[g];
|
|
28
|
+
const y = e.getUniformLocation(i, g);
|
|
29
|
+
let S;
|
|
30
|
+
const b = (U) => {
|
|
31
|
+
y && U !== S && (w(y, U), S = U);
|
|
32
32
|
};
|
|
33
|
-
return a[
|
|
34
|
-
}, f = (
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
),
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
),
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
-
), p = (
|
|
44
|
-
|
|
45
|
-
(
|
|
46
|
-
), E = (
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
),
|
|
50
|
-
|
|
51
|
-
(
|
|
52
|
-
), x = (
|
|
53
|
-
|
|
54
|
-
(
|
|
33
|
+
return a[g] = { set: b }, { set: b };
|
|
34
|
+
}, f = (g) => c(g, (w, y) => e.uniform1f(w, y)), l = (g) => c(g, (w, y) => e.uniform1i(w, y)), h = (g) => c(
|
|
35
|
+
g,
|
|
36
|
+
(w, [y = 0, S = 0]) => e.uniform2f(w, y, S)
|
|
37
|
+
), d = (g) => c(
|
|
38
|
+
g,
|
|
39
|
+
(w, [y = 0, S = 0]) => e.uniform2i(w, y, S)
|
|
40
|
+
), m = (g) => c(
|
|
41
|
+
g,
|
|
42
|
+
(w, [y = 0, S = 0, b = 0]) => e.uniform3f(w, y, S, b)
|
|
43
|
+
), p = (g) => c(
|
|
44
|
+
g,
|
|
45
|
+
(w, [y = 0, S = 0, b = 0]) => e.uniform3i(w, y, S, b)
|
|
46
|
+
), E = (g) => c(
|
|
47
|
+
g,
|
|
48
|
+
(w, [y = 0, S = 0, b = 0, U = 0]) => e.uniform4f(w, y, S, b, U)
|
|
49
|
+
), v = (g) => c(
|
|
50
|
+
g,
|
|
51
|
+
(w, [y = 0, S = 0, b = 0, U = 0]) => e.uniform4i(w, y, S, b, U)
|
|
52
|
+
), x = (g) => c(
|
|
53
|
+
g,
|
|
54
|
+
(w, y) => e.uniformMatrix4fv(w, !1, y)
|
|
55
55
|
), M = ({
|
|
56
|
-
name:
|
|
57
|
-
buffer:
|
|
56
|
+
name: g,
|
|
57
|
+
buffer: w,
|
|
58
58
|
size: y,
|
|
59
|
-
type:
|
|
60
|
-
stride:
|
|
59
|
+
type: S,
|
|
60
|
+
stride: b,
|
|
61
61
|
offset: U
|
|
62
62
|
}) => {
|
|
63
|
-
const F = e.getAttribLocation(i,
|
|
63
|
+
const F = e.getAttribLocation(i, g);
|
|
64
64
|
if (F === -1)
|
|
65
|
-
throw new Error(`Missing attribute: ${
|
|
65
|
+
throw new Error(`Missing attribute: ${g}`);
|
|
66
66
|
return { use: () => {
|
|
67
|
-
|
|
67
|
+
w.use(), e.enableVertexAttribArray(F), ["u16", "i32"].includes(S) ? e.vertexAttribIPointer(
|
|
68
68
|
F,
|
|
69
69
|
y,
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
S === "u16" ? e.UNSIGNED_SHORT : e.INT,
|
|
71
|
+
b || 0,
|
|
72
72
|
U || 0
|
|
73
73
|
) : e.vertexAttribPointer(
|
|
74
74
|
F,
|
|
75
75
|
y,
|
|
76
76
|
e.FLOAT,
|
|
77
77
|
!1,
|
|
78
|
-
|
|
78
|
+
b || 0,
|
|
79
79
|
U || 0
|
|
80
80
|
);
|
|
81
81
|
} };
|
|
@@ -83,29 +83,29 @@ const St = (e, t) => {
|
|
|
83
83
|
return {
|
|
84
84
|
use: s,
|
|
85
85
|
uniform1f: f,
|
|
86
|
-
uniform1i:
|
|
86
|
+
uniform1i: l,
|
|
87
87
|
uniform2f: h,
|
|
88
|
-
uniform2i:
|
|
89
|
-
uniform3f:
|
|
88
|
+
uniform2i: d,
|
|
89
|
+
uniform3f: m,
|
|
90
90
|
uniform3i: p,
|
|
91
91
|
uniform4f: E,
|
|
92
|
-
uniform4i:
|
|
92
|
+
uniform4i: v,
|
|
93
93
|
uniformMatrix4f: x,
|
|
94
|
-
attribute1f: (
|
|
95
|
-
attribute2f: (
|
|
96
|
-
attribute3f: (
|
|
97
|
-
attribute3i: (
|
|
94
|
+
attribute1f: (g, w, y = {}) => M({ name: g, buffer: w, size: 1, type: "f32", ...y }),
|
|
95
|
+
attribute2f: (g, w, y = {}) => M({ name: g, buffer: w, size: 2, type: "f32", ...y }),
|
|
96
|
+
attribute3f: (g, w, y = {}) => M({ name: g, buffer: w, size: 3, type: "f32", ...y }),
|
|
97
|
+
attribute3i: (g, w, y = {}) => M({ name: g, buffer: w, size: 3, type: "i32", ...y }),
|
|
98
98
|
dispose: () => {
|
|
99
99
|
e.deleteProgram(i), e.deleteShader(r), e.deleteShader(o);
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
},
|
|
102
|
+
}, it = (e, t, n) => {
|
|
103
103
|
if (!t)
|
|
104
104
|
throw new Error("Shader creation failed");
|
|
105
105
|
if (e.shaderSource(t, n), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS))
|
|
106
106
|
throw console.error("Compilation failed", e.getShaderInfoLog(t)), new Error("Compilation failure");
|
|
107
107
|
return t;
|
|
108
|
-
},
|
|
108
|
+
}, zt = (e) => {
|
|
109
109
|
const t = /* @__PURE__ */ new Map();
|
|
110
110
|
return {
|
|
111
111
|
get: ({
|
|
@@ -115,20 +115,20 @@ const St = (e, t) => {
|
|
|
115
115
|
const s = r + o, a = t.get(s);
|
|
116
116
|
if (a)
|
|
117
117
|
return a;
|
|
118
|
-
const c =
|
|
118
|
+
const c = Pt({ gl: e, vertexSource: r, fragmentSource: o });
|
|
119
119
|
return t.set(s, c), c;
|
|
120
120
|
},
|
|
121
121
|
dispose: () => [...t.values()].forEach((r) => r.dispose())
|
|
122
122
|
};
|
|
123
|
-
},
|
|
123
|
+
}, Mi = (e) => {
|
|
124
124
|
const t = e.getContext("webgl2");
|
|
125
125
|
if (!t)
|
|
126
126
|
throw new Error("No WebGL2");
|
|
127
|
-
const n =
|
|
127
|
+
const n = zt(t), { dispose: i } = n;
|
|
128
128
|
return { gl: t, programs: n, dispose: i };
|
|
129
129
|
};
|
|
130
|
-
var
|
|
131
|
-
function
|
|
130
|
+
var Lt = 1e-6, W = typeof Float32Array < "u" ? Float32Array : Array;
|
|
131
|
+
function Nt(e) {
|
|
132
132
|
W = e;
|
|
133
133
|
}
|
|
134
134
|
Math.hypot || (Math.hypot = function() {
|
|
@@ -136,70 +136,73 @@ Math.hypot || (Math.hypot = function() {
|
|
|
136
136
|
e += arguments[t] * arguments[t];
|
|
137
137
|
return Math.sqrt(e);
|
|
138
138
|
});
|
|
139
|
-
function
|
|
139
|
+
function It() {
|
|
140
140
|
var e = new W(9);
|
|
141
141
|
return W != Float32Array && (e[1] = 0, e[2] = 0, e[3] = 0, e[5] = 0, e[6] = 0, e[7] = 0), e[0] = 1, e[4] = 1, e[8] = 1, e;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function ae() {
|
|
144
144
|
var e = new W(16);
|
|
145
145
|
return W != Float32Array && (e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0), e[0] = 1, e[5] = 1, e[10] = 1, e[15] = 1, e;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Ot(e) {
|
|
148
148
|
return e[0] = 1, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[5] = 1, e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[10] = 1, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, e;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
var n = t[0], i = t[1], r = t[2], o = t[3], s = t[4], a = t[5], c = t[6], f = t[7],
|
|
152
|
-
return F ? (F = 1 / F, e[0] = (a * U - c *
|
|
150
|
+
function Dt(e, t) {
|
|
151
|
+
var n = t[0], i = t[1], r = t[2], o = t[3], s = t[4], a = t[5], c = t[6], f = t[7], l = t[8], h = t[9], d = t[10], m = t[11], p = t[12], E = t[13], v = t[14], x = t[15], M = n * a - i * s, _ = n * c - r * s, u = n * f - o * s, T = i * c - r * a, A = i * f - o * a, R = r * f - o * c, g = l * E - h * p, w = l * v - d * p, y = l * x - m * p, S = h * v - d * E, b = h * x - m * E, U = d * x - m * v, F = M * U - _ * b + u * S + T * y - A * w + R * g;
|
|
152
|
+
return F ? (F = 1 / F, e[0] = (a * U - c * b + f * S) * F, e[1] = (r * b - i * U - o * S) * F, e[2] = (E * R - v * A + x * T) * F, e[3] = (d * A - h * R - m * T) * F, e[4] = (c * y - s * U - f * w) * F, e[5] = (n * U - r * y + o * w) * F, e[6] = (v * u - p * R - x * _) * F, e[7] = (l * R - d * u + m * _) * F, e[8] = (s * b - a * y + f * g) * F, e[9] = (i * y - n * b - o * g) * F, e[10] = (p * A - E * u + x * M) * F, e[11] = (h * u - l * A - m * M) * F, e[12] = (a * w - s * S - c * g) * F, e[13] = (n * S - i * w + r * g) * F, e[14] = (E * _ - p * T - v * M) * F, e[15] = (l * T - h * _ + d * M) * F, e) : null;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
var i = t[0], r = t[1], o = t[2], s = t[3], a = t[4], c = t[5], f = t[6],
|
|
156
|
-
return e[0] = _ * i +
|
|
154
|
+
function Ct(e, t, n) {
|
|
155
|
+
var i = t[0], r = t[1], o = t[2], s = t[3], a = t[4], c = t[5], f = t[6], l = t[7], h = t[8], d = t[9], m = t[10], p = t[11], E = t[12], v = t[13], x = t[14], M = t[15], _ = n[0], u = n[1], T = n[2], A = n[3];
|
|
156
|
+
return e[0] = _ * i + u * a + T * h + A * E, e[1] = _ * r + u * c + T * d + A * v, e[2] = _ * o + u * f + T * m + A * x, e[3] = _ * s + u * l + T * p + A * M, _ = n[4], u = n[5], T = n[6], A = n[7], e[4] = _ * i + u * a + T * h + A * E, e[5] = _ * r + u * c + T * d + A * v, e[6] = _ * o + u * f + T * m + A * x, e[7] = _ * s + u * l + T * p + A * M, _ = n[8], u = n[9], T = n[10], A = n[11], e[8] = _ * i + u * a + T * h + A * E, e[9] = _ * r + u * c + T * d + A * v, e[10] = _ * o + u * f + T * m + A * x, e[11] = _ * s + u * l + T * p + A * M, _ = n[12], u = n[13], T = n[14], A = n[15], e[12] = _ * i + u * a + T * h + A * E, e[13] = _ * r + u * c + T * d + A * v, e[14] = _ * o + u * f + T * m + A * x, e[15] = _ * s + u * l + T * p + A * M, e;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function Xt(e, t, n) {
|
|
159
159
|
var i = n[0], r = n[1], o = n[2];
|
|
160
160
|
return e[0] = t[0] * i, e[1] = t[1] * i, e[2] = t[2] * i, e[3] = t[3] * i, e[4] = t[4] * r, e[5] = t[5] * r, e[6] = t[6] * r, e[7] = t[7] * r, e[8] = t[8] * o, e[9] = t[9] * o, e[10] = t[10] * o, e[11] = t[11] * o, e[12] = t[12], e[13] = t[13], e[14] = t[14], e[15] = t[15], e;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
var n = t[0], i = t[1], r = t[2], o = t[3], s = n + n, a = i + i, c = r + r, f = n * s,
|
|
164
|
-
return e[0] = 1 - h - p, e[1] =
|
|
162
|
+
function He(e, t) {
|
|
163
|
+
var n = t[0], i = t[1], r = t[2], o = t[3], s = n + n, a = i + i, c = r + r, f = n * s, l = i * s, h = i * a, d = r * s, m = r * a, p = r * c, E = o * s, v = o * a, x = o * c;
|
|
164
|
+
return e[0] = 1 - h - p, e[1] = l + x, e[2] = d - v, e[3] = 0, e[4] = l - x, e[5] = 1 - f - p, e[6] = m + E, e[7] = 0, e[8] = d + v, e[9] = m - E, e[10] = 1 - f - h, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, e;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function Wt(e, t, n, i, r) {
|
|
167
167
|
var o = 1 / Math.tan(t / 2), s;
|
|
168
168
|
return e[0] = o / n, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[5] = o, e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[11] = -1, e[12] = 0, e[13] = 0, e[15] = 0, r != null && r !== 1 / 0 ? (s = 1 / (i - r), e[10] = (r + i) * s, e[14] = 2 * r * i * s) : (e[10] = -1, e[14] = -2 * i), e;
|
|
169
169
|
}
|
|
170
|
-
var
|
|
171
|
-
function
|
|
170
|
+
var Gt = Wt;
|
|
171
|
+
function N() {
|
|
172
172
|
var e = new W(3);
|
|
173
173
|
return W != Float32Array && (e[0] = 0, e[1] = 0, e[2] = 0), e;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Bt(e) {
|
|
176
176
|
var t = new W(3);
|
|
177
177
|
return t[0] = e[0], t[1] = e[1], t[2] = e[2], t;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function jt(e) {
|
|
180
180
|
var t = e[0], n = e[1], i = e[2];
|
|
181
181
|
return Math.hypot(t, n, i);
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function rt(e, t, n) {
|
|
184
184
|
var i = new W(3);
|
|
185
185
|
return i[0] = e, i[1] = t, i[2] = n, i;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function ze(e, t) {
|
|
188
188
|
return e[0] = t[0], e[1] = t[1], e[2] = t[2], e;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function he(e, t, n, i) {
|
|
191
191
|
return e[0] = t, e[1] = n, e[2] = i, e;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function Je(e, t, n) {
|
|
194
194
|
return e[0] = t[0] + n[0], e[1] = t[1] + n[1], e[2] = t[2] + n[2], e;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function je(e, t, n) {
|
|
197
197
|
return e[0] = t[0] - n[0], e[1] = t[1] - n[1], e[2] = t[2] - n[2], e;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Ke(e, t, n) {
|
|
200
200
|
return e[0] = t[0] * n, e[1] = t[1] * n, e[2] = t[2] * n, e;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Se(e, t, n, i) {
|
|
203
|
+
return e[0] = t[0] + n[0] * i, e[1] = t[1] + n[1] * i, e[2] = t[2] + n[2] * i, e;
|
|
204
|
+
}
|
|
205
|
+
function Re(e, t) {
|
|
203
206
|
var n = t[0] - e[0], i = t[1] - e[1], r = t[2] - e[2];
|
|
204
207
|
return Math.hypot(n, i, r);
|
|
205
208
|
}
|
|
@@ -207,20 +210,20 @@ function Vt(e, t) {
|
|
|
207
210
|
var n = t[0], i = t[1], r = t[2], o = n * n + i * i + r * r;
|
|
208
211
|
return o > 0 && (o = 1 / Math.sqrt(o)), e[0] = t[0] * o, e[1] = t[1] * o, e[2] = t[2] * o, e;
|
|
209
212
|
}
|
|
210
|
-
function
|
|
213
|
+
function Zt(e, t) {
|
|
211
214
|
return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
|
|
212
215
|
}
|
|
213
216
|
function Ge(e, t, n) {
|
|
214
217
|
var i = t[0], r = t[1], o = t[2], s = n[0], a = n[1], c = n[2];
|
|
215
218
|
return e[0] = r * c - o * a, e[1] = o * s - i * c, e[2] = i * a - r * s, e;
|
|
216
219
|
}
|
|
217
|
-
function
|
|
220
|
+
function Yt(e, t, n, i) {
|
|
218
221
|
var r = t[0], o = t[1], s = t[2];
|
|
219
222
|
return e[0] = r + i * (n[0] - r), e[1] = o + i * (n[1] - o), e[2] = s + i * (n[2] - s), e;
|
|
220
223
|
}
|
|
221
|
-
var
|
|
224
|
+
var De = je, kt = jt;
|
|
222
225
|
(function() {
|
|
223
|
-
var e =
|
|
226
|
+
var e = N();
|
|
224
227
|
return function(t, n, i, r, o, s) {
|
|
225
228
|
var a, c;
|
|
226
229
|
for (n || (n = 3), i || (i = 0), r ? c = Math.min(r * n + i, t.length) : c = t.length, a = i; a < c; a += n)
|
|
@@ -228,47 +231,47 @@ var oe = Bt, Yt = Wt;
|
|
|
228
231
|
return t;
|
|
229
232
|
};
|
|
230
233
|
})();
|
|
231
|
-
function
|
|
234
|
+
function ie() {
|
|
232
235
|
var e = new W(4);
|
|
233
236
|
return W != Float32Array && (e[0] = 0, e[1] = 0, e[2] = 0, e[3] = 0), e;
|
|
234
237
|
}
|
|
235
|
-
function
|
|
238
|
+
function dt(e) {
|
|
236
239
|
var t = new W(4);
|
|
237
240
|
return t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t;
|
|
238
241
|
}
|
|
239
|
-
function
|
|
242
|
+
function $t(e, t) {
|
|
240
243
|
return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e;
|
|
241
244
|
}
|
|
242
|
-
function
|
|
245
|
+
function ot(e, t, n, i, r) {
|
|
243
246
|
return e[0] = t, e[1] = n, e[2] = i, e[3] = r, e;
|
|
244
247
|
}
|
|
245
|
-
function
|
|
248
|
+
function Ht(e, t, n) {
|
|
246
249
|
return e[0] = t[0] + n[0], e[1] = t[1] + n[1], e[2] = t[2] + n[2], e[3] = t[3] + n[3], e;
|
|
247
250
|
}
|
|
248
|
-
function
|
|
251
|
+
function Jt(e, t, n) {
|
|
249
252
|
return e[0] = t[0] - n[0], e[1] = t[1] - n[1], e[2] = t[2] - n[2], e[3] = t[3] - n[3], e;
|
|
250
253
|
}
|
|
251
|
-
function
|
|
254
|
+
function Kt(e, t, n) {
|
|
252
255
|
return e[0] = t[0] * n, e[1] = t[1] * n, e[2] = t[2] * n, e[3] = t[3] * n, e;
|
|
253
256
|
}
|
|
254
|
-
function
|
|
257
|
+
function Qt(e, t) {
|
|
255
258
|
var n = t[0] - e[0], i = t[1] - e[1], r = t[2] - e[2], o = t[3] - e[3];
|
|
256
259
|
return Math.hypot(n, i, r, o);
|
|
257
260
|
}
|
|
258
|
-
function
|
|
261
|
+
function qt(e, t) {
|
|
259
262
|
var n = t[0], i = t[1], r = t[2], o = t[3], s = n * n + i * i + r * r + o * o;
|
|
260
263
|
return s > 0 && (s = 1 / Math.sqrt(s)), e[0] = n * s, e[1] = i * s, e[2] = r * s, e[3] = o * s, e;
|
|
261
264
|
}
|
|
262
|
-
function
|
|
265
|
+
function en(e, t) {
|
|
263
266
|
return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3];
|
|
264
267
|
}
|
|
265
|
-
function
|
|
268
|
+
function st(e, t, n) {
|
|
266
269
|
var i = t[0], r = t[1], o = t[2], s = t[3];
|
|
267
270
|
return e[0] = n[0] * i + n[4] * r + n[8] * o + n[12] * s, e[1] = n[1] * i + n[5] * r + n[9] * o + n[13] * s, e[2] = n[2] * i + n[6] * r + n[10] * o + n[14] * s, e[3] = n[3] * i + n[7] * r + n[11] * o + n[15] * s, e;
|
|
268
271
|
}
|
|
269
|
-
var
|
|
272
|
+
var tn = Jt;
|
|
270
273
|
(function() {
|
|
271
|
-
var e =
|
|
274
|
+
var e = ie();
|
|
272
275
|
return function(t, n, i, r, o, s) {
|
|
273
276
|
var a, c;
|
|
274
277
|
for (n || (n = 4), i || (i = 0), r ? c = Math.min(r * n + i, t.length) : c = t.length, a = i; a < c; a += n)
|
|
@@ -280,20 +283,20 @@ function Ve() {
|
|
|
280
283
|
var e = new W(4);
|
|
281
284
|
return W != Float32Array && (e[0] = 0, e[1] = 0, e[2] = 0), e[3] = 1, e;
|
|
282
285
|
}
|
|
283
|
-
function
|
|
286
|
+
function nn(e, t, n) {
|
|
284
287
|
n = n * 0.5;
|
|
285
288
|
var i = Math.sin(n);
|
|
286
289
|
return e[0] = i * t[0], e[1] = i * t[1], e[2] = i * t[2], e[3] = Math.cos(n), e;
|
|
287
290
|
}
|
|
288
|
-
function
|
|
289
|
-
var n =
|
|
291
|
+
function rn(e, t) {
|
|
292
|
+
var n = cn(e, t);
|
|
290
293
|
return Math.acos(2 * n * n - 1);
|
|
291
294
|
}
|
|
292
295
|
function Le(e, t, n, i) {
|
|
293
|
-
var r = t[0], o = t[1], s = t[2], a = t[3], c = n[0], f = n[1],
|
|
294
|
-
return
|
|
296
|
+
var r = t[0], o = t[1], s = t[2], a = t[3], c = n[0], f = n[1], l = n[2], h = n[3], d, m, p, E, v;
|
|
297
|
+
return m = r * c + o * f + s * l + a * h, m < 0 && (m = -m, c = -c, f = -f, l = -l, h = -h), 1 - m > Lt ? (d = Math.acos(m), p = Math.sin(d), E = Math.sin((1 - i) * d) / p, v = Math.sin(i * d) / p) : (E = 1 - i, v = i), e[0] = E * r + v * c, e[1] = E * o + v * f, e[2] = E * s + v * l, e[3] = E * a + v * h, e;
|
|
295
298
|
}
|
|
296
|
-
function
|
|
299
|
+
function on(e, t) {
|
|
297
300
|
var n = t[0] + t[4] + t[8], i;
|
|
298
301
|
if (n > 0)
|
|
299
302
|
i = Math.sqrt(n + 1), e[3] = 0.5 * i, i = 0.5 / i, e[0] = (t[5] - t[7]) * i, e[1] = (t[6] - t[2]) * i, e[2] = (t[1] - t[3]) * i;
|
|
@@ -305,12 +308,12 @@ function rn(e, t) {
|
|
|
305
308
|
}
|
|
306
309
|
return e;
|
|
307
310
|
}
|
|
308
|
-
var
|
|
311
|
+
var sn = dt, cn = en, mt = qt;
|
|
309
312
|
(function() {
|
|
310
|
-
var e =
|
|
313
|
+
var e = N(), t = rt(1, 0, 0), n = rt(0, 1, 0);
|
|
311
314
|
return function(i, r, o) {
|
|
312
|
-
var s =
|
|
313
|
-
return s < -0.999999 ? (Ge(e, t, r),
|
|
315
|
+
var s = Zt(r, o);
|
|
316
|
+
return s < -0.999999 ? (Ge(e, t, r), kt(e) < 1e-6 && Ge(e, n, r), Vt(e, e), nn(i, e, Math.PI), i) : s > 0.999999 ? (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1, i) : (Ge(e, r, o), i[0] = e[0], i[1] = e[1], i[2] = e[2], i[3] = 1 + s, mt(i, i));
|
|
314
317
|
};
|
|
315
318
|
})();
|
|
316
319
|
(function() {
|
|
@@ -320,45 +323,45 @@ var on = ut, sn = qt, ht = Qt;
|
|
|
320
323
|
};
|
|
321
324
|
})();
|
|
322
325
|
(function() {
|
|
323
|
-
var e =
|
|
326
|
+
var e = It();
|
|
324
327
|
return function(t, n, i, r) {
|
|
325
|
-
return e[0] = i[0], e[3] = i[1], e[6] = i[2], e[1] = r[0], e[4] = r[1], e[7] = r[2], e[2] = -n[0], e[5] = -n[1], e[8] = -n[2],
|
|
328
|
+
return e[0] = i[0], e[3] = i[1], e[6] = i[2], e[1] = r[0], e[4] = r[1], e[7] = r[2], e[2] = -n[0], e[5] = -n[1], e[8] = -n[2], mt(t, on(t, e));
|
|
326
329
|
};
|
|
327
330
|
})();
|
|
328
|
-
function
|
|
331
|
+
function le() {
|
|
329
332
|
var e = new W(2);
|
|
330
333
|
return W != Float32Array && (e[0] = 0, e[1] = 0), e;
|
|
331
334
|
}
|
|
332
|
-
function
|
|
335
|
+
function an(e) {
|
|
333
336
|
var t = new W(2);
|
|
334
337
|
return t[0] = e[0], t[1] = e[1], t;
|
|
335
338
|
}
|
|
336
|
-
function
|
|
339
|
+
function fn(e, t) {
|
|
337
340
|
return e[0] = t[0], e[1] = t[1], e;
|
|
338
341
|
}
|
|
339
|
-
function
|
|
342
|
+
function ln(e, t, n) {
|
|
340
343
|
return e[0] = t, e[1] = n, e;
|
|
341
344
|
}
|
|
342
|
-
function
|
|
345
|
+
function un(e, t, n) {
|
|
343
346
|
return e[0] = t[0] + n[0], e[1] = t[1] + n[1], e;
|
|
344
347
|
}
|
|
345
|
-
function
|
|
348
|
+
function hn(e, t, n) {
|
|
346
349
|
return e[0] = t[0] - n[0], e[1] = t[1] - n[1], e;
|
|
347
350
|
}
|
|
348
|
-
function
|
|
351
|
+
function dn(e, t, n) {
|
|
349
352
|
return e[0] = t[0] * n, e[1] = t[1] * n, e;
|
|
350
353
|
}
|
|
351
|
-
function
|
|
354
|
+
function mn(e, t) {
|
|
352
355
|
var n = t[0] - e[0], i = t[1] - e[1];
|
|
353
356
|
return Math.hypot(n, i);
|
|
354
357
|
}
|
|
355
|
-
function
|
|
358
|
+
function pn(e, t) {
|
|
356
359
|
var n = t[0] - e[0], i = t[1] - e[1];
|
|
357
360
|
return n * n + i * i;
|
|
358
361
|
}
|
|
359
|
-
var vn =
|
|
362
|
+
var vn = hn;
|
|
360
363
|
(function() {
|
|
361
|
-
var e =
|
|
364
|
+
var e = le();
|
|
362
365
|
return function(t, n, i, r, o, s) {
|
|
363
366
|
var a, c;
|
|
364
367
|
for (n || (n = 2), i || (i = 0), r ? c = Math.min(r * n + i, t.length) : c = t.length, a = i; a < c; a += n)
|
|
@@ -366,58 +369,58 @@ var vn = un;
|
|
|
366
369
|
return t;
|
|
367
370
|
};
|
|
368
371
|
})();
|
|
369
|
-
const k = 40075017, Ne = (e) => e / 180 * Math.PI,
|
|
372
|
+
const k = 40075017, Ne = (e) => e / 180 * Math.PI, xn = (e) => e * 180 / Math.PI, En = (e, t, n) => {
|
|
370
373
|
const i = Math.sqrt(t * t - 4 * e * n);
|
|
371
374
|
return [(-t - i) / (2 * e), (-t + i) / (2 * e)];
|
|
372
|
-
},
|
|
375
|
+
}, _n = (e, t, n) => Math.min(Math.max(e, t), n), ct = Math.atan(Math.sinh(Math.PI)), L = ([e = 0, t = 0, n = 0], i = N()) => he(
|
|
373
376
|
i,
|
|
374
377
|
e / 360 + 0.5,
|
|
375
|
-
-Math.asinh(Math.tan(
|
|
378
|
+
-Math.asinh(Math.tan(_n(Ne(t), -ct, ct))) / (2 * Math.PI) + 0.5,
|
|
376
379
|
n / k
|
|
377
|
-
),
|
|
380
|
+
), K = ([e = 0, t = 0, n = 0], i = N()) => he(
|
|
378
381
|
i,
|
|
379
382
|
(e - 0.5) * 360,
|
|
380
|
-
|
|
383
|
+
xn(Math.atan(Math.sinh(-(t - 0.5) * (2 * Math.PI)))),
|
|
381
384
|
n * k
|
|
382
|
-
),
|
|
385
|
+
), pt = ([e = 0, t = 0, n = 0], i = N()) => {
|
|
383
386
|
const r = 2 ** -n;
|
|
384
|
-
return
|
|
385
|
-
},
|
|
386
|
-
const i = Math.cos(e * 0.5), r = Math.sin(e * 0.5), o = Math.cos(t * 0.5), s = Math.sin(t * 0.5), a = Math.cos(n * 0.5), c = Math.sin(n * 0.5), f = r * o * a + i * s * c,
|
|
387
|
-
return [f,
|
|
388
|
-
},
|
|
389
|
-
const r = (c, f,
|
|
387
|
+
return he(i, e * r, t * r, 0);
|
|
388
|
+
}, vt = ([e = 0, t = 0, n = 0]) => {
|
|
389
|
+
const i = Math.cos(e * 0.5), r = Math.sin(e * 0.5), o = Math.cos(t * 0.5), s = Math.sin(t * 0.5), a = Math.cos(n * 0.5), c = Math.sin(n * 0.5), f = r * o * a + i * s * c, l = i * s * a - r * o * c, h = i * o * c + r * s * a, d = i * o * a - r * s * c;
|
|
390
|
+
return [f, l, h, d];
|
|
391
|
+
}, Tn = ([e = 0, t = 0, n = 0, i = 0]) => {
|
|
392
|
+
const r = (c, f, l) => Math.max(f, Math.min(c, l)), o = Math.atan2(2 * (i * e - t * n), 1 - 2 * (e * e + t * t)), s = Math.asin(r(2 * (i * t + n * e), -1, 1)), a = Math.atan2(2 * (i * n - e * t), 1 - 2 * (t * t + n * n));
|
|
390
393
|
return [o, s, a];
|
|
391
|
-
},
|
|
394
|
+
}, xt = {
|
|
392
395
|
target: [0, 0, 0],
|
|
393
396
|
offset: [0, 0],
|
|
394
397
|
distance: k,
|
|
395
398
|
orientation: [0, 0, 0],
|
|
396
399
|
fieldOfView: 45
|
|
397
|
-
},
|
|
400
|
+
}, ne = (e, t) => {
|
|
398
401
|
const { target: n, offset: i, distance: r, orientation: o, fieldOfView: s } = {
|
|
399
|
-
...
|
|
402
|
+
...xt,
|
|
400
403
|
...e
|
|
401
|
-
}, [a = 0, c = 0] = t, [f = 0,
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
const T =
|
|
404
|
+
}, [a = 0, c = 0] = t, [f = 0, l = 0] = i, h = Math.tan(Ne(45) / 2) / Math.tan(Ne(s) / 2), d = r / k * h, m = Math.max(1e3 / k, d), p = 1e3, E = 1e-3, v = m * p, x = m * E, M = ie(), _ = ae();
|
|
405
|
+
Ot(_), Gt(_, Ne(s), a / c, x, v), Xt(_, _, [1, -1, 1]);
|
|
406
|
+
const u = ae();
|
|
407
|
+
He(u, vt(o));
|
|
408
|
+
const T = Ct(ae(), _, u), A = Dt(ae(), T);
|
|
406
409
|
if (!A)
|
|
407
410
|
throw new Error("No inverse");
|
|
408
411
|
const R = (D) => {
|
|
409
|
-
const
|
|
410
|
-
return
|
|
411
|
-
},
|
|
412
|
-
const H = 2 * D / a - 1,
|
|
413
|
-
return
|
|
414
|
-
},
|
|
415
|
-
const [Z = 0, H = 0,
|
|
416
|
-
return
|
|
417
|
-
},
|
|
412
|
+
const V = [a * D, c * D], Z = [f * D, l * D];
|
|
413
|
+
return ne({ ...e, offset: Z }, V);
|
|
414
|
+
}, g = ([D = 0, V = 0], Z = ie()) => {
|
|
415
|
+
const H = 2 * D / a - 1, Ee = -(2 * V / c - 1);
|
|
416
|
+
return ot(Z, H, Ee, 0, 1);
|
|
417
|
+
}, w = ([D = 0, V = 0, , Z = 0], H = le()) => Z < 0 ? H : ln(H, (1 + D / Z) * a * 0.5, (1 - V / Z) * c * 0.5), y = (D, V = N()) => {
|
|
418
|
+
const [Z = 0, H = 0, Ee = 0, _e = 0] = st(M, D, A);
|
|
419
|
+
return he(V, Z / _e, H / _e, Ee / _e);
|
|
420
|
+
}, S = ([D = 0, V = 0, Z = 0], H = ie()) => st(H, ot(H, D, V, Z, 1), T), [b = 0, U = 0] = g([f + a / 2, l + c / 2]), [F = 0, z = 0, P = 0] = y([b, U, -1, 1]), [X = 0, C = 0, O = 0] = y([b, U, 1.00001, 1]), [G = 0] = En(
|
|
418
421
|
(X - F) ** 2 + (C - z) ** 2 + (O - P) ** 2,
|
|
419
422
|
2 * (F * (X - F) + z * (C - z) + P * (O - P)),
|
|
420
|
-
F ** 2 + z ** 2 + P ** 2 -
|
|
423
|
+
F ** 2 + z ** 2 + P ** 2 - d ** 2
|
|
421
424
|
);
|
|
422
425
|
if (isNaN(G))
|
|
423
426
|
throw new Error("Unexpected");
|
|
@@ -425,27 +428,27 @@ const k = 40075017, Ne = (e) => e / 180 * Math.PI, pn = (e) => e * 180 / Math.PI
|
|
|
425
428
|
F + G * (X - F),
|
|
426
429
|
z + G * (C - z),
|
|
427
430
|
P + G * (O - P)
|
|
428
|
-
],
|
|
431
|
+
], Q = De(N(), L(n), $), q = (D, V = N()) => Je(V, D, Q), Y = (D, V = N()) => De(V, D, Q);
|
|
429
432
|
return {
|
|
430
|
-
camera:
|
|
433
|
+
camera: Q,
|
|
431
434
|
screen: t,
|
|
432
435
|
projection: _,
|
|
433
|
-
modelView:
|
|
436
|
+
modelView: u,
|
|
434
437
|
fieldScale: h,
|
|
435
438
|
scale: R,
|
|
436
|
-
screenToClip:
|
|
437
|
-
clipToScreen:
|
|
439
|
+
screenToClip: g,
|
|
440
|
+
clipToScreen: w,
|
|
438
441
|
clipToLocal: y,
|
|
439
|
-
localToClip:
|
|
440
|
-
localToWorld:
|
|
442
|
+
localToClip: S,
|
|
443
|
+
localToWorld: q,
|
|
441
444
|
worldToLocal: Y,
|
|
442
|
-
project: (D) =>
|
|
443
|
-
unproject: (D, { targetZ:
|
|
444
|
-
const Z =
|
|
445
|
-
return
|
|
445
|
+
project: (D) => w(S(Y(L(D)))),
|
|
446
|
+
unproject: (D, { targetZ: V = 0 } = {}) => {
|
|
447
|
+
const Z = g(D), [H = 0, Ee = 0, , _e = 0] = Z, bt = [H, Ee, -1, _e], et = K(q(y(Z))), tt = K(q(y(bt))), [, , We = 0] = et, [, , nt = 0] = tt, Ut = We === nt ? 0 : (V - We) / (nt - We);
|
|
448
|
+
return Yt(N(), et, tt, Ut);
|
|
446
449
|
}
|
|
447
450
|
};
|
|
448
|
-
},
|
|
451
|
+
}, yn = 100, Ai = (e, t, n) => {
|
|
449
452
|
const {
|
|
450
453
|
enabled: i = () => !0,
|
|
451
454
|
draggable: r = () => !0,
|
|
@@ -453,79 +456,79 @@ const k = 40075017, Ne = (e) => e / 180 * Math.PI, pn = (e) => e * 180 / Math.PI
|
|
|
453
456
|
onChangeView: s
|
|
454
457
|
} = n;
|
|
455
458
|
let a = !1, c = !1;
|
|
456
|
-
const { view: f } = n,
|
|
457
|
-
const [
|
|
459
|
+
const { view: f } = n, l = ([R = 0, g = 0]) => {
|
|
460
|
+
const [w, y] = [
|
|
458
461
|
e.width / devicePixelRatio,
|
|
459
462
|
e.height / devicePixelRatio
|
|
460
|
-
], { camera:
|
|
463
|
+
], { camera: S, fieldScale: b } = ne(f(), [w, y]), { position: U, layer: F } = t.pick([R, g]);
|
|
461
464
|
if (!F)
|
|
462
465
|
return;
|
|
463
|
-
const z =
|
|
466
|
+
const z = Re(L(U), S) * k / b, P = [R - w / 2, g - y / 2];
|
|
464
467
|
s({
|
|
465
468
|
offset: P,
|
|
466
469
|
target: U,
|
|
467
470
|
distance: z
|
|
468
471
|
}), c = !0;
|
|
469
|
-
}, h = (R,
|
|
472
|
+
}, h = (R, g) => {
|
|
470
473
|
if (!r() || t.dragging)
|
|
471
474
|
return;
|
|
472
|
-
c ||
|
|
473
|
-
const [
|
|
475
|
+
c || l([R, g]);
|
|
476
|
+
const [w, y] = [
|
|
474
477
|
e.width / devicePixelRatio,
|
|
475
478
|
e.height / devicePixelRatio
|
|
476
479
|
];
|
|
477
480
|
s({
|
|
478
|
-
offset: [R -
|
|
481
|
+
offset: [R - w / 2, g - y / 2]
|
|
479
482
|
});
|
|
480
|
-
},
|
|
483
|
+
}, d = (R, g, w, y) => {
|
|
481
484
|
if (!o())
|
|
482
485
|
return;
|
|
483
|
-
r() && !c &&
|
|
484
|
-
const [
|
|
486
|
+
r() && !c && l([R, g]);
|
|
487
|
+
const [S, b] = [
|
|
485
488
|
e.width / devicePixelRatio,
|
|
486
489
|
e.height / devicePixelRatio
|
|
487
490
|
], [U = 0, F = 0, z = 0] = f().orientation ?? [], P = [
|
|
488
491
|
Math.min(
|
|
489
492
|
Math.PI / 2 - 0.1,
|
|
490
|
-
Math.max(0.1, U - y /
|
|
493
|
+
Math.max(0.1, U - y / b * Math.PI)
|
|
491
494
|
),
|
|
492
495
|
F,
|
|
493
|
-
z -
|
|
496
|
+
z - w / S * Math.PI
|
|
494
497
|
];
|
|
495
498
|
s({
|
|
496
499
|
orientation: P
|
|
497
500
|
});
|
|
498
501
|
};
|
|
499
|
-
let
|
|
502
|
+
let m = !1;
|
|
500
503
|
const p = (R) => {
|
|
501
|
-
R.preventDefault(), c = !1,
|
|
504
|
+
R.preventDefault(), c = !1, m = !0;
|
|
502
505
|
}, E = () => {
|
|
503
|
-
|
|
504
|
-
},
|
|
505
|
-
!i() || !
|
|
506
|
+
m = !1;
|
|
507
|
+
}, v = ({ buttons: R, movementX: g, movementY: w, x: y, y: S }) => {
|
|
508
|
+
!i() || !m || (R === 1 && r() ? h(y, S) : R === 2 && o() && d(y, S, g, w));
|
|
506
509
|
}, x = (R) => {
|
|
507
510
|
R.preventDefault();
|
|
508
|
-
const
|
|
509
|
-
if (!
|
|
511
|
+
const g = R.touches.item(0);
|
|
512
|
+
if (!g)
|
|
510
513
|
return;
|
|
511
|
-
const { clientX:
|
|
512
|
-
h(
|
|
513
|
-
}, M =
|
|
514
|
+
const { clientX: w, clientY: y } = g;
|
|
515
|
+
h(w, y);
|
|
516
|
+
}, M = Ft(() => a = !1, 100), _ = ({ x: R, y: g, deltaY: w }) => {
|
|
514
517
|
if (!i())
|
|
515
518
|
return;
|
|
516
|
-
a || (r() &&
|
|
517
|
-
let { distance: y } = { ...
|
|
519
|
+
a || (r() && l([R, g]), a = !0);
|
|
520
|
+
let { distance: y } = { ...xt, ...f() };
|
|
518
521
|
y = Math.min(
|
|
519
|
-
Math.max(y * Math.exp(
|
|
522
|
+
Math.max(y * Math.exp(w * 1e-3), yn),
|
|
520
523
|
k
|
|
521
524
|
), s({ distance: y }), M();
|
|
522
|
-
},
|
|
523
|
-
return e.addEventListener("mousedown", p), e.addEventListener("mousemove",
|
|
525
|
+
}, u = (R) => R.preventDefault(), T = (R) => R.preventDefault();
|
|
526
|
+
return e.addEventListener("mousedown", p), e.addEventListener("mousemove", v), e.addEventListener("touchstart", p, { passive: !1 }), e.addEventListener("touchmove", x, { passive: !1 }), e.addEventListener("gesturestart", u), e.addEventListener("wheel", _, { passive: !0 }), e.addEventListener("contextmenu", T), window.addEventListener("mouseup", E), {
|
|
524
527
|
dispose: () => {
|
|
525
|
-
e.removeEventListener("mousedown", p), e.removeEventListener("mousemove",
|
|
528
|
+
e.removeEventListener("mousedown", p), e.removeEventListener("mousemove", v), e.removeEventListener("touchstart", p), e.removeEventListener("touchmove", x), e.removeEventListener("gesturestart", u), e.removeEventListener("wheel", _), e.removeEventListener("contextmenu", T), window.removeEventListener("mouseup", E);
|
|
526
529
|
}
|
|
527
530
|
};
|
|
528
|
-
},
|
|
531
|
+
}, j = ({
|
|
529
532
|
gl: e,
|
|
530
533
|
type: t,
|
|
531
534
|
target: n
|
|
@@ -545,7 +548,7 @@ const k = 40075017, Ne = (e) => e / 180 * Math.PI, pn = (e) => e * 180 / Math.PI
|
|
|
545
548
|
use: o,
|
|
546
549
|
dispose: () => e.deleteBuffer(i)
|
|
547
550
|
};
|
|
548
|
-
}, Be = 2 ** 30, J = ([e = 0, t = 0, n = 0]) => [Math.floor(e * Be), Math.floor(t * Be), Math.floor(n * Be)],
|
|
551
|
+
}, Be = 2 ** 30, J = ([e = 0, t = 0, n = 0]) => [Math.floor(e * Be), Math.floor(t * Be), Math.floor(n * Be)], me = (e, t, n) => {
|
|
549
552
|
const { pickable: i, depth: r, polygonOffset: o } = {
|
|
550
553
|
pickable: () => !0,
|
|
551
554
|
depth: () => !0,
|
|
@@ -563,7 +566,7 @@ const k = 40075017, Ne = (e) => e / 180 * Math.PI, pn = (e) => e * 180 / Math.PI
|
|
|
563
566
|
e.ONE_MINUS_SRC_ALPHA
|
|
564
567
|
);
|
|
565
568
|
};
|
|
566
|
-
var
|
|
569
|
+
var pe = `#version 300 es
|
|
567
570
|
|
|
568
571
|
precision highp float;
|
|
569
572
|
|
|
@@ -585,11 +588,11 @@ vec2 pack_index(in int index) {
|
|
|
585
588
|
void main(void) {
|
|
586
589
|
result = vec4(pack_depth(gl_FragCoord.z), pack_index(index));
|
|
587
590
|
}`;
|
|
588
|
-
const
|
|
589
|
-
function
|
|
591
|
+
const Et = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2FkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGFzeW5jIG49Pntjb25zdFtpLHRdPW4uZGF0YTtpZihpIT09ImxvYWQiKXJldHVybjtjb25zdCBvPW5ldyBBYm9ydENvbnRyb2xsZXIse3NpZ25hbDpjfT1vLHI9ZT0+e2NvbnN0W3MsYV09ZS5kYXRhO3M9PT0iY2FuY2VsIiYmYT09PXQmJm8uYWJvcnQoKX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIscik7dHJ5e2NvbnN0IGU9YXdhaXQgZmV0Y2godCx7bW9kZToiY29ycyIsc2lnbmFsOmN9KTtpZighZS5vayl7cG9zdE1lc3NhZ2Uoe3VybDp0LGltYWdlOnZvaWQgMH0pO3JldHVybn1jb25zdCBzPWF3YWl0IGUuYmxvYigpLGE9YXdhaXQgY3JlYXRlSW1hZ2VCaXRtYXAocyk7cG9zdE1lc3NhZ2Uoe3VybDp0LGltYWdlOmF9KX1jYXRjaChlKXtpZighKGUgaW5zdGFuY2VvZiBFcnJvcikpdGhyb3cgZTtpZihlLm1lc3NhZ2U9PT0iVGhlIHVzZXIgYWJvcnRlZCBhIHJlcXVlc3QuInx8ZS5tZXNzYWdlLnN0YXJ0c1dpdGgoInNpZ25hbCBpcyBhYm9ydGVkIHdpdGhvdXQgcmVhc29uIikpcmV0dXJuO2lmKGUubWVzc2FnZT09PSJGYWlsZWQgdG8gZmV0Y2giKXtwb3N0TWVzc2FnZSh7dXJsOnQsaW1hZ2U6dm9pZCAwfSk7cmV0dXJufXRocm93IGV9ZmluYWxseXtyZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixyKX19KX0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPWltYWdlLWxvYWQtd29ya2VyLWR6cmprQ3RLLmpzLm1hcAo=", at = typeof window < "u" && window.Blob && new Blob([atob(Et)], { type: "text/javascript;charset=utf-8" });
|
|
592
|
+
function gn(e) {
|
|
590
593
|
let t;
|
|
591
594
|
try {
|
|
592
|
-
if (t =
|
|
595
|
+
if (t = at && (window.URL || window.webkitURL).createObjectURL(at), !t)
|
|
593
596
|
throw "";
|
|
594
597
|
const n = new Worker(t, {
|
|
595
598
|
name: e?.name
|
|
@@ -599,7 +602,7 @@ function yn(e) {
|
|
|
599
602
|
}), n;
|
|
600
603
|
} catch {
|
|
601
604
|
return new Worker(
|
|
602
|
-
"data:text/javascript;base64," +
|
|
605
|
+
"data:text/javascript;base64," + Et,
|
|
603
606
|
{
|
|
604
607
|
name: e?.name
|
|
605
608
|
}
|
|
@@ -608,26 +611,26 @@ function yn(e) {
|
|
|
608
611
|
t && (window.URL || window.webkitURL).revokeObjectURL(t);
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
|
-
const
|
|
614
|
+
const be = gn(), wn = ({
|
|
612
615
|
url: e,
|
|
613
616
|
onLoad: t
|
|
614
617
|
}) => {
|
|
615
618
|
let n = !1;
|
|
616
619
|
const i = ({ data: s }) => {
|
|
617
|
-
r || e !== s.url || (
|
|
620
|
+
r || e !== s.url || (be.removeEventListener("message", i), s.image && (n = !0, t(s.image)));
|
|
618
621
|
};
|
|
619
|
-
|
|
622
|
+
be.addEventListener("message", i);
|
|
620
623
|
let r = !1;
|
|
621
624
|
const o = () => {
|
|
622
|
-
n || (r = !0,
|
|
625
|
+
n || (r = !0, be.postMessage(["cancel", e]));
|
|
623
626
|
};
|
|
624
|
-
return
|
|
627
|
+
return be.postMessage(["load", e]), {
|
|
625
628
|
get loaded() {
|
|
626
629
|
return n;
|
|
627
630
|
},
|
|
628
631
|
cancel: o
|
|
629
632
|
};
|
|
630
|
-
},
|
|
633
|
+
}, _t = (e) => {
|
|
631
634
|
const t = e.createTexture();
|
|
632
635
|
if (!t)
|
|
633
636
|
throw new Error("Texture creation failed");
|
|
@@ -641,12 +644,12 @@ const Ue = yn(), wn = ({
|
|
|
641
644
|
0
|
|
642
645
|
);
|
|
643
646
|
}, dispose: () => e.deleteTexture(t) };
|
|
644
|
-
},
|
|
647
|
+
}, Tt = ({
|
|
645
648
|
gl: e,
|
|
646
649
|
url: t,
|
|
647
650
|
onLoad: n
|
|
648
651
|
}) => {
|
|
649
|
-
const i =
|
|
652
|
+
const i = _t(e), r = wn({
|
|
650
653
|
url: t,
|
|
651
654
|
onLoad: (c) => {
|
|
652
655
|
c && (i.use(), e.texImage2D(
|
|
@@ -670,7 +673,7 @@ const Ue = yn(), wn = ({
|
|
|
670
673
|
}
|
|
671
674
|
};
|
|
672
675
|
};
|
|
673
|
-
var
|
|
676
|
+
var Rn = `#version 300 es
|
|
674
677
|
|
|
675
678
|
precision highp float;
|
|
676
679
|
|
|
@@ -682,7 +685,7 @@ out vec4 result;
|
|
|
682
685
|
void main() {
|
|
683
686
|
result = texture(image, uv_out) * color_out;
|
|
684
687
|
if (result.a == 0.f) discard;
|
|
685
|
-
}`,
|
|
688
|
+
}`, Mn = `#version 300 es
|
|
686
689
|
|
|
687
690
|
precision highp float;
|
|
688
691
|
|
|
@@ -717,10 +720,10 @@ void main(void) {
|
|
|
717
720
|
uv_out = uv;
|
|
718
721
|
color_out = color;
|
|
719
722
|
}`;
|
|
720
|
-
const
|
|
723
|
+
const Si = (e, t = {}) => {
|
|
721
724
|
const { gl: n } = e;
|
|
722
725
|
let i, r = [0, 0];
|
|
723
|
-
const o =
|
|
726
|
+
const o = j({ gl: n, type: "f32", target: "array" }), s = j({ gl: n, type: "f32", target: "array" }), a = j({ gl: n, type: "u16", target: "element" });
|
|
724
727
|
o.set(
|
|
725
728
|
[
|
|
726
729
|
[-1, -1],
|
|
@@ -741,70 +744,70 @@ const Ai = (e, t = {}) => {
|
|
|
741
744
|
[0, 3, 2]
|
|
742
745
|
].flat()
|
|
743
746
|
);
|
|
744
|
-
const c =
|
|
747
|
+
const c = se(
|
|
745
748
|
() => t.url?.() ?? "",
|
|
746
749
|
(p) => {
|
|
747
|
-
const E =
|
|
750
|
+
const E = Tt({
|
|
748
751
|
gl: n,
|
|
749
752
|
url: p,
|
|
750
|
-
onLoad: ({ width:
|
|
751
|
-
r = [
|
|
753
|
+
onLoad: ({ width: v, height: x }) => {
|
|
754
|
+
r = [v, x], n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), i?.dispose(), i = E;
|
|
752
755
|
}
|
|
753
756
|
});
|
|
754
757
|
}
|
|
755
|
-
), { renderProgram: f, depthProgram:
|
|
758
|
+
), { renderProgram: f, depthProgram: l } = An(e, {
|
|
756
759
|
cornerBuffer: o,
|
|
757
760
|
uvBuffer: s,
|
|
758
761
|
indexBuffer: a
|
|
759
762
|
}), h = ({
|
|
760
|
-
viewport: { projection: p, modelView: E, camera:
|
|
763
|
+
viewport: { projection: p, modelView: E, camera: v, screen: x },
|
|
761
764
|
depth: M = !1,
|
|
762
765
|
index: _ = 0
|
|
763
766
|
}) => {
|
|
764
|
-
const
|
|
765
|
-
if (c(), !i ||
|
|
767
|
+
const u = t.position?.() ?? [0, 0, 0], T = t.color?.() ?? [1, 1, 1, 1], A = t.size?.() ?? 100, R = t.minSizePixels?.() ?? 0, g = t.maxSizePixels?.() ?? Number.MAX_VALUE;
|
|
768
|
+
if (c(), !i || me(n, M, t))
|
|
766
769
|
return;
|
|
767
|
-
(M ?
|
|
770
|
+
(M ? l : f).execute({
|
|
768
771
|
projection: p,
|
|
769
772
|
modelView: E,
|
|
770
|
-
camera: J(
|
|
773
|
+
camera: J(v),
|
|
771
774
|
screen: x,
|
|
772
775
|
image: i,
|
|
773
776
|
imageSize: r,
|
|
774
|
-
position: J(
|
|
777
|
+
position: J(L(u)),
|
|
775
778
|
color: T,
|
|
776
779
|
size: A,
|
|
777
780
|
minSizePixels: R,
|
|
778
|
-
maxSizePixels:
|
|
781
|
+
maxSizePixels: g,
|
|
779
782
|
index: _
|
|
780
783
|
});
|
|
781
|
-
},
|
|
784
|
+
}, d = () => {
|
|
782
785
|
o.dispose(), s.dispose(), a.dispose(), i?.dispose();
|
|
783
|
-
},
|
|
786
|
+
}, m = ve(t);
|
|
784
787
|
return {
|
|
785
788
|
render: h,
|
|
786
|
-
dispose:
|
|
787
|
-
...
|
|
789
|
+
dispose: d,
|
|
790
|
+
...m
|
|
788
791
|
};
|
|
789
|
-
},
|
|
792
|
+
}, An = ({ gl: e, programs: t }, {
|
|
790
793
|
cornerBuffer: n,
|
|
791
794
|
uvBuffer: i,
|
|
792
795
|
indexBuffer: r
|
|
793
796
|
}) => {
|
|
794
797
|
const o = (c = !1) => {
|
|
795
798
|
const f = t.get({
|
|
796
|
-
vertexSource:
|
|
797
|
-
fragmentSource: c ?
|
|
798
|
-
}),
|
|
799
|
+
vertexSource: Mn,
|
|
800
|
+
fragmentSource: c ? pe : Rn
|
|
801
|
+
}), l = f.attribute2f("corner", n, {
|
|
799
802
|
stride: 2 * Float32Array.BYTES_PER_ELEMENT
|
|
800
803
|
}), h = f.attribute2f("uv", i, {
|
|
801
804
|
stride: 2 * Float32Array.BYTES_PER_ELEMENT
|
|
802
|
-
}),
|
|
805
|
+
}), d = f.uniformMatrix4f("projection"), m = f.uniformMatrix4f("model_view"), p = f.uniform3i("camera"), E = f.uniform2f("screen"), v = f.uniform1i("image"), x = f.uniform2f("image_size"), M = f.uniform3i("position"), _ = f.uniform4f("color"), u = f.uniform1i("index"), T = f.uniform1f("size"), A = f.uniform1f("min_size_pixels"), R = f.uniform1f("max_size_pixels");
|
|
803
806
|
return { execute: ({
|
|
804
|
-
projection:
|
|
807
|
+
projection: w,
|
|
805
808
|
modelView: y,
|
|
806
|
-
camera:
|
|
807
|
-
screen:
|
|
809
|
+
camera: S,
|
|
810
|
+
screen: b,
|
|
808
811
|
image: U,
|
|
809
812
|
imageSize: F,
|
|
810
813
|
position: z,
|
|
@@ -814,14 +817,14 @@ const Ai = (e, t = {}) => {
|
|
|
814
817
|
maxSizePixels: O,
|
|
815
818
|
index: G
|
|
816
819
|
}) => {
|
|
817
|
-
f.use(),
|
|
820
|
+
f.use(), l.use(), h.use(), d.set(w), m.set(y), p.set(S), E.set(b), x.set(F), M.set(z), _.set(P), T.set(X), A.set(C), R.set(O), u.set(G), e.activeTexture(e.TEXTURE0), v.set(0), U.use(), r.use(), e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0);
|
|
818
821
|
} };
|
|
819
822
|
}, s = o(), a = o(!0);
|
|
820
823
|
return { renderProgram: s, depthProgram: a };
|
|
821
824
|
}, bi = (e) => ({
|
|
822
825
|
children: e,
|
|
823
826
|
dispose: () => e.forEach((n) => n.dispose())
|
|
824
|
-
}),
|
|
827
|
+
}), Ui = (e) => {
|
|
825
828
|
const { keys: t, create: n } = e, i = /* @__PURE__ */ new Map();
|
|
826
829
|
return {
|
|
827
830
|
get children() {
|
|
@@ -837,13 +840,13 @@ const Ai = (e, t = {}) => {
|
|
|
837
840
|
},
|
|
838
841
|
dispose: () => Object.values(i).forEach((s) => s.dispose())
|
|
839
842
|
};
|
|
840
|
-
},
|
|
843
|
+
}, Fi = (e) => ({
|
|
841
844
|
render: e,
|
|
842
845
|
dispose: () => {
|
|
843
846
|
}
|
|
844
|
-
}),
|
|
847
|
+
}), Pi = () => ({ dispose: () => {
|
|
845
848
|
} });
|
|
846
|
-
var
|
|
849
|
+
var Sn = `#version 300 es
|
|
847
850
|
|
|
848
851
|
precision highp float;
|
|
849
852
|
|
|
@@ -927,81 +930,81 @@ void main(void) {
|
|
|
927
930
|
color_out = color;
|
|
928
931
|
distance_out = distance;
|
|
929
932
|
}`;
|
|
930
|
-
const
|
|
933
|
+
const zi = (e, t = {}) => {
|
|
931
934
|
const { gl: n } = e;
|
|
932
935
|
let i = 0;
|
|
933
|
-
const r =
|
|
936
|
+
const r = j({ gl: n, type: "i32", target: "array" }), o = j({ gl: n, type: "u16", target: "element" }), s = j({ gl: n, type: "f32", target: "array" }), a = j({ gl: n, type: "f32", target: "array" }), { renderProgram: c, depthProgram: f } = Un(e, {
|
|
934
937
|
positionBuffer: r,
|
|
935
938
|
indexBuffer: o,
|
|
936
939
|
cornerBuffer: s,
|
|
937
940
|
distanceBuffer: a
|
|
938
|
-
}),
|
|
939
|
-
|
|
941
|
+
}), l = _t(n);
|
|
942
|
+
l.use(), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.REPEAT);
|
|
940
943
|
const h = ({
|
|
941
|
-
viewport: { projection:
|
|
942
|
-
depth:
|
|
944
|
+
viewport: { projection: v, modelView: x, camera: M, screen: _ },
|
|
945
|
+
depth: u = !1,
|
|
943
946
|
index: T = 0
|
|
944
947
|
}) => {
|
|
945
|
-
|
|
946
|
-
const A = t.color?.() ?? [1, 1, 1, 1], R = t.width?.() ?? 1,
|
|
947
|
-
if (
|
|
948
|
+
d(), m();
|
|
949
|
+
const A = t.color?.() ?? [1, 1, 1, 1], R = t.width?.() ?? 1, g = t.minWidthPixels?.() ?? 0, w = t.maxWidthPixels?.() ?? Number.MAX_VALUE, y = t.depthWidthPixels?.(), S = t.dashSize?.() ?? 1e3, b = t.dashOffset?.() ?? 0;
|
|
950
|
+
if (me(n, u, t))
|
|
948
951
|
return;
|
|
949
|
-
(
|
|
950
|
-
projection:
|
|
952
|
+
(u ? f : c).execute({
|
|
953
|
+
projection: v,
|
|
951
954
|
modelView: x,
|
|
952
955
|
camera: J(M),
|
|
953
956
|
screen: _,
|
|
954
957
|
count: i,
|
|
955
958
|
color: A,
|
|
956
959
|
width: R,
|
|
957
|
-
minWidthPixels:
|
|
958
|
-
maxWidthPixels:
|
|
960
|
+
minWidthPixels: u && y !== void 0 ? Math.max(g, y) : g,
|
|
961
|
+
maxWidthPixels: u && y !== void 0 ? Math.max(w, y) : w,
|
|
959
962
|
index: T,
|
|
960
|
-
dash:
|
|
961
|
-
dashSize:
|
|
962
|
-
dashOffset:
|
|
963
|
+
dash: l,
|
|
964
|
+
dashSize: S,
|
|
965
|
+
dashOffset: b
|
|
963
966
|
});
|
|
964
|
-
},
|
|
967
|
+
}, d = se(
|
|
965
968
|
() => t.points?.() ?? [],
|
|
966
|
-
(
|
|
967
|
-
const x =
|
|
969
|
+
(v) => {
|
|
970
|
+
const x = v.flatMap((T) => {
|
|
968
971
|
const [A] = T, [R] = T.slice(-1);
|
|
969
|
-
return !A || !R ? [] : ((
|
|
970
|
-
const y = new Array(
|
|
971
|
-
for (let
|
|
972
|
-
const [
|
|
972
|
+
return !A || !R ? [] : ((w) => {
|
|
973
|
+
const y = new Array(w.length * 3 * 4);
|
|
974
|
+
for (let S = 0; S < w.length; S++) {
|
|
975
|
+
const [b = 0, U = 0, F = 0] = w[S] ?? [];
|
|
973
976
|
for (let z = 0; z < 4; z++) {
|
|
974
|
-
const P =
|
|
975
|
-
y[P + 0] =
|
|
977
|
+
const P = S * 3 * 4 + z * 3;
|
|
978
|
+
y[P + 0] = b, y[P + 1] = U, y[P + 2] = F;
|
|
976
979
|
}
|
|
977
980
|
}
|
|
978
981
|
return y;
|
|
979
|
-
})([A, ...T, R].map((
|
|
980
|
-
}), { indexData: M } =
|
|
982
|
+
})([A, ...T, R].map((w) => J(L(w))));
|
|
983
|
+
}), { indexData: M } = v.reduce(
|
|
981
984
|
({ indexData: T, count: A }, R) => {
|
|
982
985
|
if (R.length === 0)
|
|
983
986
|
return { indexData: T, count: A };
|
|
984
|
-
const
|
|
985
|
-
const [y = 0,
|
|
986
|
-
(F) => F +
|
|
987
|
+
const g = ue(0, (R.length - 1) * 2).flatMap((w) => {
|
|
988
|
+
const [y = 0, S = 0, b = 0, U = 0] = [0, 1, 2, 3].map(
|
|
989
|
+
(F) => F + w * 2 + A
|
|
987
990
|
);
|
|
988
991
|
return [
|
|
989
992
|
y,
|
|
990
|
-
|
|
993
|
+
S,
|
|
991
994
|
U,
|
|
992
995
|
/**/
|
|
993
996
|
y,
|
|
994
997
|
U,
|
|
995
|
-
|
|
998
|
+
b
|
|
996
999
|
];
|
|
997
1000
|
});
|
|
998
|
-
return A += (R.length + 2) * 4, T = T.concat(
|
|
1001
|
+
return A += (R.length + 2) * 4, T = T.concat(g), { indexData: T, count: A };
|
|
999
1002
|
},
|
|
1000
1003
|
{ indexData: [], count: 0 }
|
|
1001
1004
|
);
|
|
1002
1005
|
i = M.length;
|
|
1003
|
-
const _ =
|
|
1004
|
-
(T) => T.length === 0 ? [] :
|
|
1006
|
+
const _ = v.flatMap(
|
|
1007
|
+
(T) => T.length === 0 ? [] : ue(0, (T.length + 1) * 2).flatMap(() => [
|
|
1005
1008
|
-1,
|
|
1006
1009
|
-1,
|
|
1007
1010
|
//
|
|
@@ -1014,69 +1017,69 @@ const Pi = (e, t = {}) => {
|
|
|
1014
1017
|
1,
|
|
1015
1018
|
1
|
|
1016
1019
|
])
|
|
1017
|
-
),
|
|
1020
|
+
), u = v.flatMap((T) => {
|
|
1018
1021
|
const R = T.map(
|
|
1019
|
-
(
|
|
1022
|
+
(S, b) => Re(L(S), L(T[b - 1] ?? S)) * k
|
|
1020
1023
|
).reduce(
|
|
1021
|
-
({ current:
|
|
1024
|
+
({ current: S, result: b }, U) => (S += U, b.push(S), { current: S, result: b }),
|
|
1022
1025
|
{ current: 0, result: [] }
|
|
1023
|
-
).result, [
|
|
1024
|
-
return
|
|
1025
|
-
const
|
|
1026
|
-
for (let U = 0; U <
|
|
1027
|
-
|
|
1028
|
-
return
|
|
1029
|
-
})([
|
|
1026
|
+
).result, [g] = R, [w] = R.slice(-1);
|
|
1027
|
+
return g === void 0 || w === void 0 ? [] : ((S) => {
|
|
1028
|
+
const b = new Array(S.length * 4);
|
|
1029
|
+
for (let U = 0; U < S.length; U++)
|
|
1030
|
+
b[U * 4 + 0] = S[U], b[U * 4 + 1] = S[U], b[U * 4 + 2] = S[U], b[U * 4 + 3] = S[U];
|
|
1031
|
+
return b;
|
|
1032
|
+
})([g, ...R, w]);
|
|
1030
1033
|
});
|
|
1031
|
-
r.set(x), o.set(M), s.set(_), a.set(
|
|
1034
|
+
r.set(x), o.set(M), s.set(_), a.set(u);
|
|
1032
1035
|
}
|
|
1033
|
-
),
|
|
1036
|
+
), m = se(
|
|
1034
1037
|
() => t.dashPattern?.(),
|
|
1035
|
-
(
|
|
1036
|
-
|
|
1038
|
+
(v) => {
|
|
1039
|
+
v = v ?? [[1, 1, 1, 1]], l.use(), n.texImage2D(
|
|
1037
1040
|
n.TEXTURE_2D,
|
|
1038
1041
|
0,
|
|
1039
1042
|
n.RGBA,
|
|
1040
|
-
|
|
1043
|
+
v.length,
|
|
1041
1044
|
1,
|
|
1042
1045
|
0,
|
|
1043
1046
|
n.RGBA,
|
|
1044
1047
|
n.UNSIGNED_BYTE,
|
|
1045
|
-
new Uint8Array(
|
|
1048
|
+
new Uint8Array(v.flatMap((x) => [...x.map((M) => M * 255)]))
|
|
1046
1049
|
);
|
|
1047
1050
|
}
|
|
1048
1051
|
), p = () => {
|
|
1049
|
-
|
|
1050
|
-
}, E =
|
|
1052
|
+
l.dispose(), r.dispose(), o.dispose(), s.dispose(), a.dispose();
|
|
1053
|
+
}, E = ve(t);
|
|
1051
1054
|
return {
|
|
1052
1055
|
render: h,
|
|
1053
1056
|
dispose: p,
|
|
1054
1057
|
...E
|
|
1055
1058
|
};
|
|
1056
|
-
},
|
|
1059
|
+
}, Un = ({ gl: e, programs: t }, {
|
|
1057
1060
|
positionBuffer: n,
|
|
1058
1061
|
indexBuffer: i,
|
|
1059
1062
|
cornerBuffer: r,
|
|
1060
1063
|
distanceBuffer: o
|
|
1061
1064
|
}) => {
|
|
1062
1065
|
const s = (f = !1) => {
|
|
1063
|
-
const
|
|
1066
|
+
const l = t.get({
|
|
1064
1067
|
vertexSource: bn,
|
|
1065
|
-
fragmentSource: f ?
|
|
1066
|
-
}), h = Float32Array.BYTES_PER_ELEMENT,
|
|
1067
|
-
stride:
|
|
1068
|
-
}), p =
|
|
1069
|
-
stride:
|
|
1070
|
-
offset:
|
|
1071
|
-
}), E =
|
|
1072
|
-
stride:
|
|
1073
|
-
offset:
|
|
1074
|
-
}),
|
|
1068
|
+
fragmentSource: f ? pe : Sn
|
|
1069
|
+
}), h = Float32Array.BYTES_PER_ELEMENT, d = Int32Array.BYTES_PER_ELEMENT, m = l.attribute3i("previous", n, {
|
|
1070
|
+
stride: d * 3
|
|
1071
|
+
}), p = l.attribute3i("current", n, {
|
|
1072
|
+
stride: d * 3,
|
|
1073
|
+
offset: d * 3 * 4
|
|
1074
|
+
}), E = l.attribute3i("next", n, {
|
|
1075
|
+
stride: d * 3,
|
|
1076
|
+
offset: d * 3 * 4 * 2
|
|
1077
|
+
}), v = l.attribute2f("corner", r, {
|
|
1075
1078
|
stride: h * 2
|
|
1076
|
-
}), x =
|
|
1079
|
+
}), x = l.attribute1f("distance", o, {
|
|
1077
1080
|
stride: h,
|
|
1078
1081
|
offset: h * 1 * 4
|
|
1079
|
-
}), M =
|
|
1082
|
+
}), M = l.uniformMatrix4f("projection"), _ = l.uniformMatrix4f("model_view"), u = l.uniform3i("camera"), T = l.uniform2f("screen"), A = l.uniform4f("color"), R = l.uniform1f("width"), g = l.uniform1f("max_width_pixels"), w = l.uniform1f("min_width_pixels"), y = l.uniform1i("index"), S = l.uniform1i("dash"), b = l.uniform1f("dash_size"), U = l.uniform1f("dash_offset");
|
|
1080
1083
|
return { execute: ({
|
|
1081
1084
|
projection: z,
|
|
1082
1085
|
modelView: P,
|
|
@@ -1085,19 +1088,19 @@ const Pi = (e, t = {}) => {
|
|
|
1085
1088
|
count: O,
|
|
1086
1089
|
color: G,
|
|
1087
1090
|
width: $,
|
|
1088
|
-
minWidthPixels:
|
|
1089
|
-
maxWidthPixels:
|
|
1091
|
+
minWidthPixels: Q,
|
|
1092
|
+
maxWidthPixels: q,
|
|
1090
1093
|
index: Y,
|
|
1091
|
-
dash:
|
|
1092
|
-
dashSize:
|
|
1094
|
+
dash: ee,
|
|
1095
|
+
dashSize: qe,
|
|
1093
1096
|
dashOffset: D
|
|
1094
1097
|
}) => {
|
|
1095
|
-
O !== 0 && (
|
|
1098
|
+
O !== 0 && (l.use(), m.use(), p.use(), E.use(), v.use(), x.use(), M.set(z), _.set(P), u.set(X), T.set(C), A.set(G), R.set($), w.set(Q), g.set(q), y.set(Y), b.set(qe), U.set(D), e.activeTexture(e.TEXTURE0), S.set(0), ee.use(), i.use(), e.drawElements(e.TRIANGLES, O, e.UNSIGNED_SHORT, 0));
|
|
1096
1099
|
} };
|
|
1097
1100
|
}, a = s(), c = s(!0);
|
|
1098
1101
|
return { renderProgram: a, depthProgram: c };
|
|
1099
1102
|
};
|
|
1100
|
-
var
|
|
1103
|
+
var Fn = `#version 300 es
|
|
1101
1104
|
|
|
1102
1105
|
precision highp float;
|
|
1103
1106
|
|
|
@@ -1107,7 +1110,7 @@ out vec4 result;
|
|
|
1107
1110
|
void main() {
|
|
1108
1111
|
if (color_out.a == 0.f) discard;
|
|
1109
1112
|
result = color_out;
|
|
1110
|
-
}`,
|
|
1113
|
+
}`, Pn = `#version 300 es
|
|
1111
1114
|
|
|
1112
1115
|
precision highp float;
|
|
1113
1116
|
|
|
@@ -1147,68 +1150,68 @@ void main(void) {
|
|
|
1147
1150
|
|
|
1148
1151
|
color_out = color + diffuse * vec4(vec3(clamp(dot(qn.xyz / qn.w, vec3(0.f, 0.f, 1.f)), 0.f, 1.f)), 1.f);
|
|
1149
1152
|
}`;
|
|
1150
|
-
const
|
|
1153
|
+
const Li = (e, t = {}) => {
|
|
1151
1154
|
const { gl: n } = e;
|
|
1152
1155
|
let i = 0;
|
|
1153
|
-
const r =
|
|
1156
|
+
const r = j({ gl: n, type: "f32", target: "array" }), o = j({ gl: n, type: "u16", target: "element" }), s = j({ gl: n, type: "f32", target: "array" }), { renderProgram: a, depthProgram: c } = zn(e, {
|
|
1154
1157
|
vertexBuffer: r,
|
|
1155
1158
|
indexBuffer: o,
|
|
1156
1159
|
normalBuffer: s
|
|
1157
1160
|
}), f = ({
|
|
1158
|
-
viewport: { projection:
|
|
1161
|
+
viewport: { projection: m, modelView: p, camera: E, screen: v },
|
|
1159
1162
|
depth: x = !1,
|
|
1160
1163
|
index: M = 0
|
|
1161
1164
|
}) => {
|
|
1162
|
-
const _ = t.position?.() ?? [0, 0, 0],
|
|
1163
|
-
if (
|
|
1165
|
+
const _ = t.position?.() ?? [0, 0, 0], u = t.orientation?.() ?? [0, 0, 0, 1], T = t.color?.() ?? [1, 1, 1, 1], A = t.diffuse?.() ?? [0, 0, 0, 0], R = t.size?.() ?? 1, g = t.minSizePixels?.() ?? 0, w = t.maxSizePixels?.() ?? Number.MAX_VALUE;
|
|
1166
|
+
if (l(), me(n, x, t))
|
|
1164
1167
|
return;
|
|
1165
|
-
const y = ([
|
|
1168
|
+
const y = ([b = 0, U = 0, F = 0, z = 0]) => [-b, U, F, z];
|
|
1166
1169
|
(x ? c : a).execute({
|
|
1167
|
-
projection:
|
|
1170
|
+
projection: m,
|
|
1168
1171
|
modelView: p,
|
|
1169
1172
|
camera: J(E),
|
|
1170
|
-
screen:
|
|
1173
|
+
screen: v,
|
|
1171
1174
|
count: i,
|
|
1172
|
-
position: J(
|
|
1173
|
-
orientation:
|
|
1175
|
+
position: J(L(_)),
|
|
1176
|
+
orientation: He(ae(), y(u)),
|
|
1174
1177
|
color: T,
|
|
1175
1178
|
diffuse: A,
|
|
1176
1179
|
size: R,
|
|
1177
|
-
minSizePixels:
|
|
1178
|
-
maxSizePixels:
|
|
1180
|
+
minSizePixels: g,
|
|
1181
|
+
maxSizePixels: w,
|
|
1179
1182
|
index: M
|
|
1180
1183
|
});
|
|
1181
|
-
},
|
|
1184
|
+
}, l = se(
|
|
1182
1185
|
() => t.mesh?.(),
|
|
1183
|
-
(
|
|
1184
|
-
const { vertices: p = [], indices: E = [], normals:
|
|
1186
|
+
(m) => {
|
|
1187
|
+
const { vertices: p = [], indices: E = [], normals: v = [] } = m ?? {};
|
|
1185
1188
|
r.set(p.flatMap((x) => [...x])), o.set(E.flatMap((x) => [...x])), s.set(
|
|
1186
|
-
|
|
1189
|
+
v.length === 0 ? p.flatMap(() => [0, 0, 0]) : v.flatMap((x) => [...x])
|
|
1187
1190
|
), i = E.length * 3;
|
|
1188
1191
|
}
|
|
1189
1192
|
), h = () => {
|
|
1190
1193
|
r.dispose(), o.dispose(), s.dispose();
|
|
1191
|
-
},
|
|
1194
|
+
}, d = ve(t);
|
|
1192
1195
|
return {
|
|
1193
1196
|
render: f,
|
|
1194
1197
|
dispose: h,
|
|
1195
|
-
...
|
|
1198
|
+
...d
|
|
1196
1199
|
};
|
|
1197
|
-
},
|
|
1200
|
+
}, zn = ({ gl: e, programs: t }, {
|
|
1198
1201
|
vertexBuffer: n,
|
|
1199
1202
|
indexBuffer: i,
|
|
1200
1203
|
normalBuffer: r
|
|
1201
1204
|
}) => {
|
|
1202
1205
|
const o = (c = !1) => {
|
|
1203
1206
|
const f = t.get({
|
|
1204
|
-
vertexSource:
|
|
1205
|
-
fragmentSource: c ?
|
|
1206
|
-
}),
|
|
1207
|
+
vertexSource: Pn,
|
|
1208
|
+
fragmentSource: c ? pe : Fn
|
|
1209
|
+
}), l = f.attribute3f("vertex", n), h = f.attribute3f("normal", r), d = f.uniformMatrix4f("projection"), m = f.uniformMatrix4f("model_view"), p = f.uniform3i("camera"), E = f.uniform3i("position"), v = f.uniformMatrix4f("orientation"), x = f.uniform2f("screen"), M = f.uniform4f("color"), _ = f.uniform4f("diffuse"), u = f.uniform1f("size"), T = f.uniform1f("min_size_pixels"), A = f.uniform1f("max_size_pixels"), R = f.uniform1i("index");
|
|
1207
1210
|
return { execute: ({
|
|
1208
|
-
projection:
|
|
1211
|
+
projection: w,
|
|
1209
1212
|
modelView: y,
|
|
1210
|
-
camera:
|
|
1211
|
-
screen:
|
|
1213
|
+
camera: S,
|
|
1214
|
+
screen: b,
|
|
1212
1215
|
count: U,
|
|
1213
1216
|
position: F,
|
|
1214
1217
|
orientation: z,
|
|
@@ -1219,47 +1222,47 @@ const zi = (e, t = {}) => {
|
|
|
1219
1222
|
maxSizePixels: G,
|
|
1220
1223
|
index: $
|
|
1221
1224
|
}) => {
|
|
1222
|
-
f.use(),
|
|
1225
|
+
f.use(), l.use(), h.use(), d.set(w), m.set(y), p.set(S), x.set(b), E.set(F), v.set(z), M.set(P), _.set(X), u.set(C), T.set(O), A.set(G), R.set($), i.use(), e.drawElements(e.TRIANGLES, U, e.UNSIGNED_SHORT, 0);
|
|
1223
1226
|
} };
|
|
1224
1227
|
}, s = o(), a = o(!0);
|
|
1225
1228
|
return { renderProgram: s, depthProgram: a };
|
|
1226
1229
|
};
|
|
1227
|
-
function
|
|
1230
|
+
function Ln(e, t, n = 2) {
|
|
1228
1231
|
const i = t && t.length, r = i ? t[0] * n : e.length;
|
|
1229
|
-
let o =
|
|
1232
|
+
let o = yt(e, 0, r, n, !0);
|
|
1230
1233
|
const s = [];
|
|
1231
1234
|
if (!o || o.next === o.prev)
|
|
1232
1235
|
return s;
|
|
1233
1236
|
let a, c, f;
|
|
1234
|
-
if (i && (o =
|
|
1237
|
+
if (i && (o = Cn(e, t, o, n)), e.length > 80 * n) {
|
|
1235
1238
|
a = 1 / 0, c = 1 / 0;
|
|
1236
|
-
let
|
|
1237
|
-
for (let
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1239
|
+
let l = -1 / 0, h = -1 / 0;
|
|
1240
|
+
for (let d = n; d < r; d += n) {
|
|
1241
|
+
const m = e[d], p = e[d + 1];
|
|
1242
|
+
m < a && (a = m), p < c && (c = p), m > l && (l = m), p > h && (h = p);
|
|
1240
1243
|
}
|
|
1241
|
-
f = Math.max(
|
|
1244
|
+
f = Math.max(l - a, h - c), f = f !== 0 ? 32767 / f : 0;
|
|
1242
1245
|
}
|
|
1243
|
-
return
|
|
1246
|
+
return ye(o, s, n, a, c, f, 0), s;
|
|
1244
1247
|
}
|
|
1245
|
-
function
|
|
1248
|
+
function yt(e, t, n, i, r) {
|
|
1246
1249
|
let o;
|
|
1247
|
-
if (r ===
|
|
1250
|
+
if (r === Hn(e, t, n, i) > 0)
|
|
1248
1251
|
for (let s = t; s < n; s += i)
|
|
1249
|
-
o =
|
|
1252
|
+
o = ft(s / i | 0, e[s], e[s + 1], o);
|
|
1250
1253
|
else
|
|
1251
1254
|
for (let s = n - i; s >= t; s -= i)
|
|
1252
|
-
o =
|
|
1253
|
-
return o &&
|
|
1255
|
+
o = ft(s / i | 0, e[s], e[s + 1], o);
|
|
1256
|
+
return o && de(o, o.next) && (we(o), o = o.next), o;
|
|
1254
1257
|
}
|
|
1255
|
-
function
|
|
1258
|
+
function oe(e, t) {
|
|
1256
1259
|
if (!e)
|
|
1257
1260
|
return e;
|
|
1258
1261
|
t || (t = e);
|
|
1259
1262
|
let n = e, i;
|
|
1260
1263
|
do
|
|
1261
|
-
if (i = !1, !n.steiner && (
|
|
1262
|
-
if (
|
|
1264
|
+
if (i = !1, !n.steiner && (de(n, n.next) || I(n.prev, n, n.next) === 0)) {
|
|
1265
|
+
if (we(n), n = t = n.prev, n === n.next)
|
|
1263
1266
|
break;
|
|
1264
1267
|
i = !0;
|
|
1265
1268
|
} else
|
|
@@ -1267,75 +1270,75 @@ function ce(e, t) {
|
|
|
1267
1270
|
while (i || n !== t);
|
|
1268
1271
|
return t;
|
|
1269
1272
|
}
|
|
1270
|
-
function
|
|
1273
|
+
function ye(e, t, n, i, r, o, s) {
|
|
1271
1274
|
if (!e)
|
|
1272
1275
|
return;
|
|
1273
|
-
!s && o &&
|
|
1276
|
+
!s && o && jn(e, i, r, o);
|
|
1274
1277
|
let a = e;
|
|
1275
1278
|
for (; e.prev !== e.next; ) {
|
|
1276
1279
|
const c = e.prev, f = e.next;
|
|
1277
|
-
if (o ?
|
|
1278
|
-
t.push(c.i, e.i, f.i),
|
|
1280
|
+
if (o ? In(e, i, r, o) : Nn(e)) {
|
|
1281
|
+
t.push(c.i, e.i, f.i), we(e), e = f.next, a = f.next;
|
|
1279
1282
|
continue;
|
|
1280
1283
|
}
|
|
1281
1284
|
if (e = f, e === a) {
|
|
1282
|
-
s ? s === 1 ? (e =
|
|
1285
|
+
s ? s === 1 ? (e = On(oe(e), t), ye(e, t, n, i, r, o, 2)) : s === 2 && Dn(e, t, n, i, r, o) : ye(oe(e), t, n, i, r, o, 1);
|
|
1283
1286
|
break;
|
|
1284
1287
|
}
|
|
1285
1288
|
}
|
|
1286
1289
|
}
|
|
1287
|
-
function
|
|
1290
|
+
function Nn(e) {
|
|
1288
1291
|
const t = e.prev, n = e, i = e.next;
|
|
1289
1292
|
if (I(t, n, i) >= 0)
|
|
1290
1293
|
return !1;
|
|
1291
|
-
const r = t.x, o = n.x, s = i.x, a = t.y, c = n.y, f = i.y,
|
|
1294
|
+
const r = t.x, o = n.x, s = i.x, a = t.y, c = n.y, f = i.y, l = Math.min(r, o, s), h = Math.min(a, c, f), d = Math.max(r, o, s), m = Math.max(a, c, f);
|
|
1292
1295
|
let p = i.next;
|
|
1293
1296
|
for (; p !== t; ) {
|
|
1294
|
-
if (p.x >=
|
|
1297
|
+
if (p.x >= l && p.x <= d && p.y >= h && p.y <= m && Te(r, a, o, c, s, f, p.x, p.y) && I(p.prev, p, p.next) >= 0)
|
|
1295
1298
|
return !1;
|
|
1296
1299
|
p = p.next;
|
|
1297
1300
|
}
|
|
1298
1301
|
return !0;
|
|
1299
1302
|
}
|
|
1300
|
-
function
|
|
1303
|
+
function In(e, t, n, i) {
|
|
1301
1304
|
const r = e.prev, o = e, s = e.next;
|
|
1302
1305
|
if (I(r, o, s) >= 0)
|
|
1303
1306
|
return !1;
|
|
1304
|
-
const a = r.x, c = o.x, f = s.x,
|
|
1305
|
-
let _ = e.prevZ,
|
|
1306
|
-
for (; _ && _.z >= x &&
|
|
1307
|
-
if (_.x >=
|
|
1307
|
+
const a = r.x, c = o.x, f = s.x, l = r.y, h = o.y, d = s.y, m = Math.min(a, c, f), p = Math.min(l, h, d), E = Math.max(a, c, f), v = Math.max(l, h, d), x = Ze(m, p, t, n, i), M = Ze(E, v, t, n, i);
|
|
1308
|
+
let _ = e.prevZ, u = e.nextZ;
|
|
1309
|
+
for (; _ && _.z >= x && u && u.z <= M; ) {
|
|
1310
|
+
if (_.x >= m && _.x <= E && _.y >= p && _.y <= v && _ !== r && _ !== s && Te(a, l, c, h, f, d, _.x, _.y) && I(_.prev, _, _.next) >= 0 || (_ = _.prevZ, u.x >= m && u.x <= E && u.y >= p && u.y <= v && u !== r && u !== s && Te(a, l, c, h, f, d, u.x, u.y) && I(u.prev, u, u.next) >= 0))
|
|
1308
1311
|
return !1;
|
|
1309
|
-
|
|
1312
|
+
u = u.nextZ;
|
|
1310
1313
|
}
|
|
1311
1314
|
for (; _ && _.z >= x; ) {
|
|
1312
|
-
if (_.x >=
|
|
1315
|
+
if (_.x >= m && _.x <= E && _.y >= p && _.y <= v && _ !== r && _ !== s && Te(a, l, c, h, f, d, _.x, _.y) && I(_.prev, _, _.next) >= 0)
|
|
1313
1316
|
return !1;
|
|
1314
1317
|
_ = _.prevZ;
|
|
1315
1318
|
}
|
|
1316
|
-
for (;
|
|
1317
|
-
if (
|
|
1319
|
+
for (; u && u.z <= M; ) {
|
|
1320
|
+
if (u.x >= m && u.x <= E && u.y >= p && u.y <= v && u !== r && u !== s && Te(a, l, c, h, f, d, u.x, u.y) && I(u.prev, u, u.next) >= 0)
|
|
1318
1321
|
return !1;
|
|
1319
|
-
|
|
1322
|
+
u = u.nextZ;
|
|
1320
1323
|
}
|
|
1321
1324
|
return !0;
|
|
1322
1325
|
}
|
|
1323
|
-
function
|
|
1326
|
+
function On(e, t) {
|
|
1324
1327
|
let n = e;
|
|
1325
1328
|
do {
|
|
1326
1329
|
const i = n.prev, r = n.next.next;
|
|
1327
|
-
!
|
|
1330
|
+
!de(i, r) && wt(i, n, n.next, r) && ge(i, r) && ge(r, i) && (t.push(i.i, n.i, r.i), we(n), we(n.next), n = e = r), n = n.next;
|
|
1328
1331
|
} while (n !== e);
|
|
1329
|
-
return
|
|
1332
|
+
return oe(n);
|
|
1330
1333
|
}
|
|
1331
|
-
function
|
|
1334
|
+
function Dn(e, t, n, i, r, o) {
|
|
1332
1335
|
let s = e;
|
|
1333
1336
|
do {
|
|
1334
1337
|
let a = s.next.next;
|
|
1335
1338
|
for (; a !== s.prev; ) {
|
|
1336
|
-
if (s.i !== a.i &&
|
|
1337
|
-
let c =
|
|
1338
|
-
s =
|
|
1339
|
+
if (s.i !== a.i && Yn(s, a)) {
|
|
1340
|
+
let c = Rt(s, a);
|
|
1341
|
+
s = oe(s, s.next), c = oe(c, c.next), ye(s, t, n, i, r, o, 0), ye(c, t, n, i, r, o, 0);
|
|
1339
1342
|
return;
|
|
1340
1343
|
}
|
|
1341
1344
|
a = a.next;
|
|
@@ -1343,18 +1346,18 @@ function On(e, t, n, i, r, o) {
|
|
|
1343
1346
|
s = s.next;
|
|
1344
1347
|
} while (s !== e);
|
|
1345
1348
|
}
|
|
1346
|
-
function
|
|
1349
|
+
function Cn(e, t, n, i) {
|
|
1347
1350
|
const r = [];
|
|
1348
1351
|
for (let o = 0, s = t.length; o < s; o++) {
|
|
1349
|
-
const a = t[o] * i, c = o < s - 1 ? t[o + 1] * i : e.length, f =
|
|
1350
|
-
f === f.next && (f.steiner = !0), r.push(
|
|
1352
|
+
const a = t[o] * i, c = o < s - 1 ? t[o + 1] * i : e.length, f = yt(e, a, c, i, !1);
|
|
1353
|
+
f === f.next && (f.steiner = !0), r.push(Zn(f));
|
|
1351
1354
|
}
|
|
1352
|
-
r.sort(
|
|
1355
|
+
r.sort(Xn);
|
|
1353
1356
|
for (let o = 0; o < r.length; o++)
|
|
1354
|
-
n =
|
|
1357
|
+
n = Wn(r[o], n);
|
|
1355
1358
|
return n;
|
|
1356
1359
|
}
|
|
1357
|
-
function
|
|
1360
|
+
function Xn(e, t) {
|
|
1358
1361
|
let n = e.x - t.x;
|
|
1359
1362
|
if (n === 0 && (n = e.y - t.y, n === 0)) {
|
|
1360
1363
|
const i = (e.next.y - e.y) / (e.next.x - e.x), r = (t.next.y - t.y) / (t.next.x - t.x);
|
|
@@ -1362,21 +1365,21 @@ function Cn(e, t) {
|
|
|
1362
1365
|
}
|
|
1363
1366
|
return n;
|
|
1364
1367
|
}
|
|
1365
|
-
function
|
|
1366
|
-
const n =
|
|
1368
|
+
function Wn(e, t) {
|
|
1369
|
+
const n = Gn(e, t);
|
|
1367
1370
|
if (!n)
|
|
1368
1371
|
return t;
|
|
1369
|
-
const i =
|
|
1370
|
-
return
|
|
1372
|
+
const i = Rt(n, e);
|
|
1373
|
+
return oe(i, i.next), oe(n, n.next);
|
|
1371
1374
|
}
|
|
1372
|
-
function
|
|
1375
|
+
function Gn(e, t) {
|
|
1373
1376
|
let n = t;
|
|
1374
1377
|
const i = e.x, r = e.y;
|
|
1375
1378
|
let o = -1 / 0, s;
|
|
1376
|
-
if (
|
|
1379
|
+
if (de(e, n))
|
|
1377
1380
|
return n;
|
|
1378
1381
|
do {
|
|
1379
|
-
if (
|
|
1382
|
+
if (de(e, n.next))
|
|
1380
1383
|
return n.next;
|
|
1381
1384
|
if (r <= n.y && r >= n.next.y && n.next.y !== n.y) {
|
|
1382
1385
|
const h = n.x + (r - n.y) * (n.next.x - n.x) / (n.next.y - n.y);
|
|
@@ -1388,24 +1391,24 @@ function Wn(e, t) {
|
|
|
1388
1391
|
if (!s)
|
|
1389
1392
|
return null;
|
|
1390
1393
|
const a = s, c = s.x, f = s.y;
|
|
1391
|
-
let
|
|
1394
|
+
let l = 1 / 0;
|
|
1392
1395
|
n = s;
|
|
1393
1396
|
do {
|
|
1394
|
-
if (i >= n.x && n.x >= c && i !== n.x &&
|
|
1397
|
+
if (i >= n.x && n.x >= c && i !== n.x && gt(r < f ? i : o, r, c, f, r < f ? o : i, r, n.x, n.y)) {
|
|
1395
1398
|
const h = Math.abs(r - n.y) / (i - n.x);
|
|
1396
|
-
|
|
1399
|
+
ge(n, e) && (h < l || h === l && (n.x > s.x || n.x === s.x && Bn(s, n))) && (s = n, l = h);
|
|
1397
1400
|
}
|
|
1398
1401
|
n = n.next;
|
|
1399
1402
|
} while (n !== a);
|
|
1400
1403
|
return s;
|
|
1401
1404
|
}
|
|
1402
|
-
function
|
|
1405
|
+
function Bn(e, t) {
|
|
1403
1406
|
return I(e.prev, e, t.prev) < 0 && I(t.next, e, e.next) < 0;
|
|
1404
1407
|
}
|
|
1405
|
-
function
|
|
1408
|
+
function jn(e, t, n, i) {
|
|
1406
1409
|
let r = e;
|
|
1407
1410
|
do
|
|
1408
|
-
r.z === 0 && (r.z =
|
|
1411
|
+
r.z === 0 && (r.z = Ze(r.x, r.y, t, n, i)), r.prevZ = r.prev, r.nextZ = r.next, r = r.next;
|
|
1409
1412
|
while (r !== e);
|
|
1410
1413
|
r.prevZ.nextZ = null, r.prevZ = null, Vn(r);
|
|
1411
1414
|
}
|
|
@@ -1429,57 +1432,57 @@ function Vn(e) {
|
|
|
1429
1432
|
} while (t > 1);
|
|
1430
1433
|
return e;
|
|
1431
1434
|
}
|
|
1432
|
-
function
|
|
1435
|
+
function Ze(e, t, n, i, r) {
|
|
1433
1436
|
return e = (e - n) * r | 0, t = (t - i) * r | 0, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, e | t << 1;
|
|
1434
1437
|
}
|
|
1435
|
-
function
|
|
1438
|
+
function Zn(e) {
|
|
1436
1439
|
let t = e, n = e;
|
|
1437
1440
|
do
|
|
1438
1441
|
(t.x < n.x || t.x === n.x && t.y < n.y) && (n = t), t = t.next;
|
|
1439
1442
|
while (t !== e);
|
|
1440
1443
|
return n;
|
|
1441
1444
|
}
|
|
1442
|
-
function
|
|
1445
|
+
function gt(e, t, n, i, r, o, s, a) {
|
|
1443
1446
|
return (r - s) * (t - a) >= (e - s) * (o - a) && (e - s) * (i - a) >= (n - s) * (t - a) && (n - s) * (o - a) >= (r - s) * (i - a);
|
|
1444
1447
|
}
|
|
1445
|
-
function
|
|
1446
|
-
return !(e === s && t === a) &&
|
|
1448
|
+
function Te(e, t, n, i, r, o, s, a) {
|
|
1449
|
+
return !(e === s && t === a) && gt(e, t, n, i, r, o, s, a);
|
|
1447
1450
|
}
|
|
1448
|
-
function
|
|
1449
|
-
return e.next.i !== t.i && e.prev.i !== t.i && !
|
|
1450
|
-
(
|
|
1451
|
+
function Yn(e, t) {
|
|
1452
|
+
return e.next.i !== t.i && e.prev.i !== t.i && !kn(e, t) && // dones't intersect other edges
|
|
1453
|
+
(ge(e, t) && ge(t, e) && $n(e, t) && // locally visible
|
|
1451
1454
|
(I(e.prev, e, t.prev) || I(e, t.prev, t)) || // does not create opposite-facing sectors
|
|
1452
|
-
|
|
1455
|
+
de(e, t) && I(e.prev, e, e.next) > 0 && I(t.prev, t, t.next) > 0);
|
|
1453
1456
|
}
|
|
1454
1457
|
function I(e, t, n) {
|
|
1455
1458
|
return (t.y - e.y) * (n.x - t.x) - (t.x - e.x) * (n.y - t.y);
|
|
1456
1459
|
}
|
|
1457
|
-
function
|
|
1460
|
+
function de(e, t) {
|
|
1458
1461
|
return e.x === t.x && e.y === t.y;
|
|
1459
1462
|
}
|
|
1460
|
-
function
|
|
1461
|
-
const r =
|
|
1462
|
-
return !!(r !== o && s !== a || r === 0 &&
|
|
1463
|
+
function wt(e, t, n, i) {
|
|
1464
|
+
const r = Fe(I(e, t, n)), o = Fe(I(e, t, i)), s = Fe(I(n, i, e)), a = Fe(I(n, i, t));
|
|
1465
|
+
return !!(r !== o && s !== a || r === 0 && Ue(e, n, t) || o === 0 && Ue(e, i, t) || s === 0 && Ue(n, e, i) || a === 0 && Ue(n, t, i));
|
|
1463
1466
|
}
|
|
1464
|
-
function
|
|
1467
|
+
function Ue(e, t, n) {
|
|
1465
1468
|
return t.x <= Math.max(e.x, n.x) && t.x >= Math.min(e.x, n.x) && t.y <= Math.max(e.y, n.y) && t.y >= Math.min(e.y, n.y);
|
|
1466
1469
|
}
|
|
1467
|
-
function
|
|
1470
|
+
function Fe(e) {
|
|
1468
1471
|
return e > 0 ? 1 : e < 0 ? -1 : 0;
|
|
1469
1472
|
}
|
|
1470
|
-
function
|
|
1473
|
+
function kn(e, t) {
|
|
1471
1474
|
let n = e;
|
|
1472
1475
|
do {
|
|
1473
|
-
if (n.i !== e.i && n.next.i !== e.i && n.i !== t.i && n.next.i !== t.i &&
|
|
1476
|
+
if (n.i !== e.i && n.next.i !== e.i && n.i !== t.i && n.next.i !== t.i && wt(n, n.next, e, t))
|
|
1474
1477
|
return !0;
|
|
1475
1478
|
n = n.next;
|
|
1476
1479
|
} while (n !== e);
|
|
1477
1480
|
return !1;
|
|
1478
1481
|
}
|
|
1479
|
-
function
|
|
1482
|
+
function ge(e, t) {
|
|
1480
1483
|
return I(e.prev, e, e.next) < 0 ? I(e, t, e.next) >= 0 && I(e, e.prev, t) >= 0 : I(e, t, e.prev) < 0 || I(e, e.next, t) < 0;
|
|
1481
1484
|
}
|
|
1482
|
-
function
|
|
1485
|
+
function $n(e, t) {
|
|
1483
1486
|
let n = e, i = !1;
|
|
1484
1487
|
const r = (e.x + t.x) / 2, o = (e.y + t.y) / 2;
|
|
1485
1488
|
do
|
|
@@ -1487,18 +1490,18 @@ function kn(e, t) {
|
|
|
1487
1490
|
while (n !== e);
|
|
1488
1491
|
return i;
|
|
1489
1492
|
}
|
|
1490
|
-
function
|
|
1491
|
-
const n =
|
|
1493
|
+
function Rt(e, t) {
|
|
1494
|
+
const n = Ye(e.i, e.x, e.y), i = Ye(t.i, t.x, t.y), r = e.next, o = t.prev;
|
|
1492
1495
|
return e.next = t, t.prev = e, n.next = r, r.prev = n, i.next = n, n.prev = i, o.next = i, i.prev = o, i;
|
|
1493
1496
|
}
|
|
1494
|
-
function
|
|
1495
|
-
const r =
|
|
1497
|
+
function ft(e, t, n, i) {
|
|
1498
|
+
const r = Ye(e, t, n);
|
|
1496
1499
|
return i ? (r.next = i.next, r.prev = i, i.next.prev = r, i.next = r) : (r.prev = r, r.next = r), r;
|
|
1497
1500
|
}
|
|
1498
|
-
function
|
|
1501
|
+
function we(e) {
|
|
1499
1502
|
e.next.prev = e.prev, e.prev.next = e.next, e.prevZ && (e.prevZ.nextZ = e.nextZ), e.nextZ && (e.nextZ.prevZ = e.prevZ);
|
|
1500
1503
|
}
|
|
1501
|
-
function
|
|
1504
|
+
function Ye(e, t, n) {
|
|
1502
1505
|
return {
|
|
1503
1506
|
i: e,
|
|
1504
1507
|
// vertex index in coordinates array
|
|
@@ -1517,13 +1520,13 @@ function Ze(e, t, n) {
|
|
|
1517
1520
|
// indicates whether this is a steiner point
|
|
1518
1521
|
};
|
|
1519
1522
|
}
|
|
1520
|
-
function
|
|
1523
|
+
function Hn(e, t, n, i) {
|
|
1521
1524
|
let r = 0;
|
|
1522
1525
|
for (let o = t, s = n - i; o < n; o += i)
|
|
1523
1526
|
r += (e[s] - e[o]) * (e[o + 1] + e[s + 1]), s = o;
|
|
1524
1527
|
return r;
|
|
1525
1528
|
}
|
|
1526
|
-
function
|
|
1529
|
+
function Jn(e) {
|
|
1527
1530
|
const t = [], n = [], i = e[0][0].length;
|
|
1528
1531
|
let r = 0, o = 0;
|
|
1529
1532
|
for (const s of e) {
|
|
@@ -1534,7 +1537,7 @@ function Hn(e) {
|
|
|
1534
1537
|
}
|
|
1535
1538
|
return { vertices: t, holes: n, dimensions: i };
|
|
1536
1539
|
}
|
|
1537
|
-
var
|
|
1540
|
+
var Kn = `#version 300 es
|
|
1538
1541
|
|
|
1539
1542
|
precision highp float;
|
|
1540
1543
|
|
|
@@ -1543,7 +1546,7 @@ out vec4 result;
|
|
|
1543
1546
|
|
|
1544
1547
|
void main() {
|
|
1545
1548
|
result = color_out;
|
|
1546
|
-
}`,
|
|
1549
|
+
}`, Qn = `#version 300 es
|
|
1547
1550
|
|
|
1548
1551
|
precision highp float;
|
|
1549
1552
|
|
|
@@ -1567,84 +1570,84 @@ void main(void) {
|
|
|
1567
1570
|
gl_Position = transform(position);
|
|
1568
1571
|
color_out = color;
|
|
1569
1572
|
}`;
|
|
1570
|
-
const
|
|
1573
|
+
const Ni = (e, t = {}) => {
|
|
1571
1574
|
const { gl: n } = e;
|
|
1572
1575
|
let i = 0;
|
|
1573
|
-
const r =
|
|
1576
|
+
const r = j({ gl: n, type: "i32", target: "array" }), o = j({ gl: n, type: "u16", target: "element" }), { renderProgram: s, depthProgram: a } = qn(e, {
|
|
1574
1577
|
positionBuffer: r,
|
|
1575
1578
|
indexBuffer: o
|
|
1576
1579
|
}), c = ({
|
|
1577
|
-
viewport: { projection:
|
|
1578
|
-
depth:
|
|
1580
|
+
viewport: { projection: d, modelView: m, camera: p, screen: E },
|
|
1581
|
+
depth: v = !1,
|
|
1579
1582
|
index: x = 0
|
|
1580
1583
|
}) => {
|
|
1581
1584
|
const M = t.color?.() ?? [1, 1, 1, 1];
|
|
1582
|
-
if (f(),
|
|
1585
|
+
if (f(), me(n, v, t))
|
|
1583
1586
|
return;
|
|
1584
|
-
(
|
|
1585
|
-
projection:
|
|
1586
|
-
modelView:
|
|
1587
|
+
(v ? a : s).execute({
|
|
1588
|
+
projection: d,
|
|
1589
|
+
modelView: m,
|
|
1587
1590
|
camera: J(p),
|
|
1588
1591
|
screen: E,
|
|
1589
1592
|
count: i,
|
|
1590
1593
|
color: M,
|
|
1591
1594
|
index: x
|
|
1592
1595
|
});
|
|
1593
|
-
}, f =
|
|
1596
|
+
}, f = se(
|
|
1594
1597
|
() => t.points?.() ?? [],
|
|
1595
|
-
(
|
|
1596
|
-
const { vertices:
|
|
1597
|
-
|
|
1598
|
-
(E) => E.map((
|
|
1598
|
+
(d) => {
|
|
1599
|
+
const { vertices: m, indices: p } = ei(
|
|
1600
|
+
d.map(
|
|
1601
|
+
(E) => E.map((v) => v.map((x) => J(L(x)))).filter((v) => v.length > 0)
|
|
1599
1602
|
).filter((E) => E.length > 0)
|
|
1600
1603
|
);
|
|
1601
|
-
r.set(
|
|
1604
|
+
r.set(m), o.set(p), i = p.length;
|
|
1602
1605
|
}
|
|
1603
|
-
),
|
|
1606
|
+
), l = () => {
|
|
1604
1607
|
r.dispose(), o.dispose();
|
|
1605
|
-
}, h =
|
|
1608
|
+
}, h = ve(t);
|
|
1606
1609
|
return {
|
|
1607
1610
|
render: c,
|
|
1608
|
-
dispose:
|
|
1611
|
+
dispose: l,
|
|
1609
1612
|
...h
|
|
1610
1613
|
};
|
|
1611
|
-
},
|
|
1614
|
+
}, qn = ({ gl: e, programs: t }, {
|
|
1612
1615
|
positionBuffer: n,
|
|
1613
1616
|
indexBuffer: i
|
|
1614
1617
|
}) => {
|
|
1615
1618
|
const r = (a = !1) => {
|
|
1616
1619
|
const c = t.get({
|
|
1617
|
-
vertexSource:
|
|
1618
|
-
fragmentSource: a ?
|
|
1620
|
+
vertexSource: Qn,
|
|
1621
|
+
fragmentSource: a ? pe : Kn
|
|
1619
1622
|
}), f = c.attribute3i("position", n, {
|
|
1620
1623
|
stride: 3 * Int32Array.BYTES_PER_ELEMENT
|
|
1621
|
-
}),
|
|
1624
|
+
}), l = c.uniformMatrix4f("projection"), h = c.uniformMatrix4f("model_view"), d = c.uniform3i("camera"), m = c.uniform2f("screen"), p = c.uniform4f("color"), E = c.uniform1i("index");
|
|
1622
1625
|
return { execute: ({
|
|
1623
1626
|
projection: x,
|
|
1624
1627
|
modelView: M,
|
|
1625
1628
|
camera: _,
|
|
1626
|
-
screen:
|
|
1629
|
+
screen: u,
|
|
1627
1630
|
count: T,
|
|
1628
1631
|
color: A,
|
|
1629
1632
|
index: R
|
|
1630
1633
|
}) => {
|
|
1631
|
-
T !== 0 && (c.use(), f.use(),
|
|
1634
|
+
T !== 0 && (c.use(), f.use(), l.set(x), h.set(M), d.set(_), m.set(u), p.set(A), E.set(R), i.use(), e.drawElements(e.TRIANGLES, T, e.UNSIGNED_SHORT, 0));
|
|
1632
1635
|
} };
|
|
1633
1636
|
}, o = r(), s = r(!0);
|
|
1634
1637
|
return { renderProgram: o, depthProgram: s };
|
|
1635
|
-
},
|
|
1638
|
+
}, ei = (e) => {
|
|
1636
1639
|
const [t, n] = e.reduce(
|
|
1637
1640
|
([i, r, o], s) => {
|
|
1638
|
-
const a =
|
|
1641
|
+
const a = Jn(s);
|
|
1639
1642
|
return i.push(...a.vertices), r.push(
|
|
1640
|
-
...
|
|
1643
|
+
...Ln(a.vertices, a.holes, a.dimensions).map((c) => c + o)
|
|
1641
1644
|
), o += a.vertices.length / a.dimensions, [i, r, o];
|
|
1642
1645
|
},
|
|
1643
1646
|
[[], [], 0]
|
|
1644
1647
|
);
|
|
1645
1648
|
return { vertices: t, indices: n };
|
|
1646
1649
|
};
|
|
1647
|
-
var
|
|
1650
|
+
var ti = `#version 300 es
|
|
1648
1651
|
|
|
1649
1652
|
precision highp float;
|
|
1650
1653
|
|
|
@@ -1659,7 +1662,7 @@ void main() {
|
|
|
1659
1662
|
vec4 value = texture(image, vec2(d, a));
|
|
1660
1663
|
if (value.r == 0.f) discard;
|
|
1661
1664
|
result = vec4(0, 1., 0, value.r);
|
|
1662
|
-
}`,
|
|
1665
|
+
}`, ni = `#version 300 es
|
|
1663
1666
|
|
|
1664
1667
|
precision highp float;
|
|
1665
1668
|
|
|
@@ -1686,8 +1689,8 @@ void main(void) {
|
|
|
1686
1689
|
gl_Position = transform(q.xyz / q.w);
|
|
1687
1690
|
uv_out = uv;
|
|
1688
1691
|
}`;
|
|
1689
|
-
const
|
|
1690
|
-
const { gl: n } = e, i =
|
|
1692
|
+
const Ii = (e, t = {}) => {
|
|
1693
|
+
const { gl: n } = e, i = ri(n), r = j({ gl: n, type: "f32", target: "array" }), o = j({ gl: n, type: "u16", target: "element" });
|
|
1691
1694
|
r.set(
|
|
1692
1695
|
[
|
|
1693
1696
|
[-1, -1],
|
|
@@ -1701,68 +1704,68 @@ const Ni = (e, t = {}) => {
|
|
|
1701
1704
|
[0, 3, 2]
|
|
1702
1705
|
].flat()
|
|
1703
1706
|
);
|
|
1704
|
-
const s =
|
|
1707
|
+
const s = se(
|
|
1705
1708
|
() => t.image?.(),
|
|
1706
|
-
(
|
|
1707
|
-
|
|
1709
|
+
(d) => {
|
|
1710
|
+
d && i.set(d);
|
|
1708
1711
|
}
|
|
1709
|
-
), { renderProgram: a, depthProgram: c } =
|
|
1712
|
+
), { renderProgram: a, depthProgram: c } = ii(e, {
|
|
1710
1713
|
uvBuffer: r,
|
|
1711
1714
|
indexBuffer: o
|
|
1712
1715
|
}), f = ({
|
|
1713
|
-
viewport: { projection:
|
|
1714
|
-
depth:
|
|
1716
|
+
viewport: { projection: d, modelView: m, camera: p, screen: E },
|
|
1717
|
+
depth: v = !1,
|
|
1715
1718
|
index: x = 0
|
|
1716
1719
|
}) => {
|
|
1717
|
-
const M = t.position?.() ?? [0, 0, 0], _ = t.orientation?.() ?? [0, 0, 0, 1],
|
|
1718
|
-
if (s(),
|
|
1720
|
+
const M = t.position?.() ?? [0, 0, 0], _ = t.orientation?.() ?? [0, 0, 0, 1], u = t.range?.() ?? 1e3;
|
|
1721
|
+
if (s(), me(n, v, t))
|
|
1719
1722
|
return;
|
|
1720
|
-
(
|
|
1721
|
-
projection:
|
|
1722
|
-
modelView:
|
|
1723
|
+
(v ? c : a).execute({
|
|
1724
|
+
projection: d,
|
|
1725
|
+
modelView: m,
|
|
1723
1726
|
camera: J(p),
|
|
1724
1727
|
screen: E,
|
|
1725
1728
|
image: i,
|
|
1726
|
-
range:
|
|
1727
|
-
position: J(
|
|
1728
|
-
orientation:
|
|
1729
|
+
range: u,
|
|
1730
|
+
position: J(L(M)),
|
|
1731
|
+
orientation: He(ae(), _),
|
|
1729
1732
|
index: x
|
|
1730
1733
|
});
|
|
1731
|
-
},
|
|
1734
|
+
}, l = () => {
|
|
1732
1735
|
r.dispose(), o.dispose(), i.dispose();
|
|
1733
|
-
}, h =
|
|
1736
|
+
}, h = ve(t);
|
|
1734
1737
|
return {
|
|
1735
1738
|
render: f,
|
|
1736
|
-
dispose:
|
|
1739
|
+
dispose: l,
|
|
1737
1740
|
...h
|
|
1738
1741
|
};
|
|
1739
|
-
},
|
|
1742
|
+
}, ii = ({ gl: e, programs: t }, {
|
|
1740
1743
|
uvBuffer: n,
|
|
1741
1744
|
indexBuffer: i
|
|
1742
1745
|
}) => {
|
|
1743
1746
|
const r = (a = !1) => {
|
|
1744
1747
|
const c = t.get({
|
|
1745
|
-
vertexSource:
|
|
1746
|
-
fragmentSource: a ?
|
|
1748
|
+
vertexSource: ni,
|
|
1749
|
+
fragmentSource: a ? pe : ti
|
|
1747
1750
|
}), f = c.attribute2f("uv", n, {
|
|
1748
1751
|
stride: 2 * Float32Array.BYTES_PER_ELEMENT
|
|
1749
|
-
}),
|
|
1752
|
+
}), l = c.uniformMatrix4f("projection"), h = c.uniformMatrix4f("model_view"), d = c.uniform3i("camera"), m = c.uniform2f("screen"), p = c.uniform1i("image"), E = c.uniform1f("range"), v = c.uniform3i("position"), x = c.uniformMatrix4f("orientation"), M = c.uniform1i("index");
|
|
1750
1753
|
return { execute: ({
|
|
1751
|
-
projection:
|
|
1754
|
+
projection: u,
|
|
1752
1755
|
modelView: T,
|
|
1753
1756
|
camera: A,
|
|
1754
1757
|
screen: R,
|
|
1755
|
-
image:
|
|
1756
|
-
range:
|
|
1758
|
+
image: g,
|
|
1759
|
+
range: w,
|
|
1757
1760
|
position: y,
|
|
1758
|
-
orientation:
|
|
1759
|
-
index:
|
|
1761
|
+
orientation: S,
|
|
1762
|
+
index: b
|
|
1760
1763
|
}) => {
|
|
1761
|
-
c.use(), f.use(),
|
|
1764
|
+
c.use(), f.use(), l.set(u), h.set(T), d.set(A), m.set(R), E.set(w), v.set(y), x.set(S), M.set(b), e.activeTexture(e.TEXTURE0), p.set(0), g.use(), i.use(), e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0);
|
|
1762
1765
|
} };
|
|
1763
1766
|
}, o = r(), s = r(!0);
|
|
1764
1767
|
return { renderProgram: o, depthProgram: s };
|
|
1765
|
-
},
|
|
1768
|
+
}, ri = (e) => {
|
|
1766
1769
|
const t = e.createTexture();
|
|
1767
1770
|
if (!t)
|
|
1768
1771
|
throw new Error("Texture creation failed");
|
|
@@ -1774,7 +1777,7 @@ const Ni = (e, t = {}) => {
|
|
|
1774
1777
|
use: n,
|
|
1775
1778
|
dispose: () => e.deleteTexture(t)
|
|
1776
1779
|
};
|
|
1777
|
-
},
|
|
1780
|
+
}, ke = (e, t = 0) => ({
|
|
1778
1781
|
get: ([n = 0, i = 0, r = 0]) => {
|
|
1779
1782
|
for (let o = Math.min(r, t); o <= r; o++) {
|
|
1780
1783
|
const s = 2 ** o, a = [
|
|
@@ -1786,12 +1789,12 @@ const Ni = (e, t = {}) => {
|
|
|
1786
1789
|
return { texture: c, downsample: o };
|
|
1787
1790
|
}
|
|
1788
1791
|
}
|
|
1789
|
-
}),
|
|
1790
|
-
typeof
|
|
1792
|
+
}), ce = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, Mt = /* @__PURE__ */ new Set(), $e = typeof process == "object" && process ? process : {}, At = (e, t, n, i) => {
|
|
1793
|
+
typeof $e.emitWarning == "function" ? $e.emitWarning(e, t, n, i) : console.error(`[${n}] ${t}: ${e}`);
|
|
1791
1794
|
};
|
|
1792
|
-
let
|
|
1793
|
-
if (typeof
|
|
1794
|
-
|
|
1795
|
+
let Ce = globalThis.AbortController, lt = globalThis.AbortSignal;
|
|
1796
|
+
if (typeof Ce > "u") {
|
|
1797
|
+
lt = class {
|
|
1795
1798
|
onabort;
|
|
1796
1799
|
_onabort = [];
|
|
1797
1800
|
reason;
|
|
@@ -1799,11 +1802,11 @@ if (typeof De > "u") {
|
|
|
1799
1802
|
addEventListener(i, r) {
|
|
1800
1803
|
this._onabort.push(r);
|
|
1801
1804
|
}
|
|
1802
|
-
},
|
|
1805
|
+
}, Ce = class {
|
|
1803
1806
|
constructor() {
|
|
1804
1807
|
t();
|
|
1805
1808
|
}
|
|
1806
|
-
signal = new
|
|
1809
|
+
signal = new lt();
|
|
1807
1810
|
abort(i) {
|
|
1808
1811
|
if (!this.signal.aborted) {
|
|
1809
1812
|
this.signal.reason = i, this.signal.aborted = !0;
|
|
@@ -1813,32 +1816,32 @@ if (typeof De > "u") {
|
|
|
1813
1816
|
}
|
|
1814
1817
|
}
|
|
1815
1818
|
};
|
|
1816
|
-
let e =
|
|
1819
|
+
let e = $e.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
1817
1820
|
const t = () => {
|
|
1818
|
-
e && (e = !1,
|
|
1821
|
+
e && (e = !1, At("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
|
|
1819
1822
|
};
|
|
1820
1823
|
}
|
|
1821
|
-
const
|
|
1824
|
+
const oi = (e) => !Mt.has(e), te = (e) => e && e === Math.floor(e) && e > 0 && isFinite(e), St = (e) => te(e) ? e <= Math.pow(2, 8) ? Uint8Array : e <= Math.pow(2, 16) ? Uint16Array : e <= Math.pow(2, 32) ? Uint32Array : e <= Number.MAX_SAFE_INTEGER ? Ie : null : null;
|
|
1822
1825
|
class Ie extends Array {
|
|
1823
1826
|
constructor(t) {
|
|
1824
1827
|
super(t), this.fill(0);
|
|
1825
1828
|
}
|
|
1826
1829
|
}
|
|
1827
|
-
class
|
|
1830
|
+
class fe {
|
|
1828
1831
|
heap;
|
|
1829
1832
|
length;
|
|
1830
1833
|
// private constructor
|
|
1831
1834
|
static #a = !1;
|
|
1832
1835
|
static create(t) {
|
|
1833
|
-
const n =
|
|
1836
|
+
const n = St(t);
|
|
1834
1837
|
if (!n)
|
|
1835
1838
|
return [];
|
|
1836
|
-
|
|
1837
|
-
const i = new
|
|
1838
|
-
return
|
|
1839
|
+
fe.#a = !0;
|
|
1840
|
+
const i = new fe(t, n);
|
|
1841
|
+
return fe.#a = !1, i;
|
|
1839
1842
|
}
|
|
1840
1843
|
constructor(t, n) {
|
|
1841
|
-
if (!
|
|
1844
|
+
if (!fe.#a)
|
|
1842
1845
|
throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
1843
1846
|
this.heap = new n(t), this.length = 0;
|
|
1844
1847
|
}
|
|
@@ -1849,14 +1852,14 @@ class de {
|
|
|
1849
1852
|
return this.heap[--this.length];
|
|
1850
1853
|
}
|
|
1851
1854
|
}
|
|
1852
|
-
class
|
|
1855
|
+
class Qe {
|
|
1853
1856
|
// properties coming in from the options of these, only max and maxSize
|
|
1854
1857
|
// really *need* to be protected. The rest can be modified, as they just
|
|
1855
1858
|
// set defaults for various methods.
|
|
1856
1859
|
#a;
|
|
1857
1860
|
#u;
|
|
1858
|
-
#v;
|
|
1859
1861
|
#p;
|
|
1862
|
+
#v;
|
|
1860
1863
|
#U;
|
|
1861
1864
|
/**
|
|
1862
1865
|
* {@link LRUCache.OptionsBase.ttl}
|
|
@@ -1966,9 +1969,9 @@ class He {
|
|
|
1966
1969
|
// methods
|
|
1967
1970
|
isBackgroundFetch: (n) => t.#t(n),
|
|
1968
1971
|
backgroundFetch: (n, i, r, o) => t.#z(n, i, r, o),
|
|
1969
|
-
moveToTail: (n) => t.#
|
|
1970
|
-
indexes: (n) => t.#
|
|
1971
|
-
rindexes: (n) => t.#
|
|
1972
|
+
moveToTail: (n) => t.#b(n),
|
|
1973
|
+
indexes: (n) => t.#g(n),
|
|
1974
|
+
rindexes: (n) => t.#w(n),
|
|
1972
1975
|
isStale: (n) => t.#m(n)
|
|
1973
1976
|
};
|
|
1974
1977
|
}
|
|
@@ -2007,38 +2010,38 @@ class He {
|
|
|
2007
2010
|
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
2008
2011
|
*/
|
|
2009
2012
|
get dispose() {
|
|
2010
|
-
return this.#
|
|
2013
|
+
return this.#p;
|
|
2011
2014
|
}
|
|
2012
2015
|
/**
|
|
2013
2016
|
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
2014
2017
|
*/
|
|
2015
2018
|
get disposeAfter() {
|
|
2016
|
-
return this.#
|
|
2019
|
+
return this.#v;
|
|
2017
2020
|
}
|
|
2018
2021
|
constructor(t) {
|
|
2019
|
-
const { max: n = 0, ttl: i, ttlResolution: r = 1, ttlAutopurge: o, updateAgeOnGet: s, updateAgeOnHas: a, allowStale: c, dispose: f, disposeAfter:
|
|
2020
|
-
if (n !== 0 && !
|
|
2022
|
+
const { max: n = 0, ttl: i, ttlResolution: r = 1, ttlAutopurge: o, updateAgeOnGet: s, updateAgeOnHas: a, allowStale: c, dispose: f, disposeAfter: l, noDisposeOnSet: h, noUpdateTTL: d, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: E, fetchMethod: v, noDeleteOnFetchRejection: x, noDeleteOnStaleGet: M, allowStaleOnFetchRejection: _, allowStaleOnFetchAbort: u, ignoreFetchAbort: T } = t;
|
|
2023
|
+
if (n !== 0 && !te(n))
|
|
2021
2024
|
throw new TypeError("max option must be a nonnegative integer");
|
|
2022
|
-
const A = n ?
|
|
2025
|
+
const A = n ? St(n) : Array;
|
|
2023
2026
|
if (!A)
|
|
2024
2027
|
throw new Error("invalid max value: " + n);
|
|
2025
|
-
if (this.#a = n, this.#u =
|
|
2028
|
+
if (this.#a = n, this.#u = m, this.maxEntrySize = p || this.#u, this.sizeCalculation = E, this.sizeCalculation) {
|
|
2026
2029
|
if (!this.#u && !this.maxEntrySize)
|
|
2027
2030
|
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
2028
2031
|
if (typeof this.sizeCalculation != "function")
|
|
2029
2032
|
throw new TypeError("sizeCalculation set to non-function");
|
|
2030
2033
|
}
|
|
2031
|
-
if (
|
|
2034
|
+
if (v !== void 0 && typeof v != "function")
|
|
2032
2035
|
throw new TypeError("fetchMethod must be a function if specified");
|
|
2033
|
-
if (this.#U =
|
|
2034
|
-
if (this.#u !== 0 && !
|
|
2036
|
+
if (this.#U = v, this.#M = !!v, this.#i = /* @__PURE__ */ new Map(), this.#n = new Array(n).fill(void 0), this.#e = new Array(n).fill(void 0), this.#f = new A(n), this.#h = new A(n), this.#c = 0, this.#o = 0, this.#E = fe.create(n), this.#r = 0, this.#x = 0, typeof f == "function" && (this.#p = f), typeof l == "function" ? (this.#v = l, this.#s = []) : (this.#v = void 0, this.#s = void 0), this.#y = !!this.#p, this.#l = !!this.#v, this.noDisposeOnSet = !!h, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!x, this.allowStaleOnFetchRejection = !!_, this.allowStaleOnFetchAbort = !!u, this.ignoreFetchAbort = !!T, this.maxEntrySize !== 0) {
|
|
2037
|
+
if (this.#u !== 0 && !te(this.#u))
|
|
2035
2038
|
throw new TypeError("maxSize must be a positive integer if specified");
|
|
2036
|
-
if (!
|
|
2039
|
+
if (!te(this.maxEntrySize))
|
|
2037
2040
|
throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
2038
2041
|
this.#C();
|
|
2039
2042
|
}
|
|
2040
|
-
if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!M, this.updateAgeOnGet = !!s, this.updateAgeOnHas = !!a, this.ttlResolution =
|
|
2041
|
-
if (!
|
|
2043
|
+
if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!M, this.updateAgeOnGet = !!s, this.updateAgeOnHas = !!a, this.ttlResolution = te(r) || r === 0 ? r : 1, this.ttlAutopurge = !!o, this.ttl = i || 0, this.ttl) {
|
|
2044
|
+
if (!te(this.ttl))
|
|
2042
2045
|
throw new TypeError("ttl must be a positive integer if specified");
|
|
2043
2046
|
this.#L();
|
|
2044
2047
|
}
|
|
@@ -2046,7 +2049,7 @@ class He {
|
|
|
2046
2049
|
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
2047
2050
|
if (!this.ttlAutopurge && !this.#a && !this.#u) {
|
|
2048
2051
|
const R = "LRU_CACHE_UNBOUNDED";
|
|
2049
|
-
|
|
2052
|
+
oi(R) && (Mt.add(R), At("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", R, Qe));
|
|
2050
2053
|
}
|
|
2051
2054
|
}
|
|
2052
2055
|
/**
|
|
@@ -2057,7 +2060,7 @@ class He {
|
|
|
2057
2060
|
}
|
|
2058
2061
|
#L() {
|
|
2059
2062
|
const t = new Ie(this.#a), n = new Ie(this.#a);
|
|
2060
|
-
this.#d = t, this.#T = n, this.#N = (o, s, a =
|
|
2063
|
+
this.#d = t, this.#T = n, this.#N = (o, s, a = ce.now()) => {
|
|
2061
2064
|
if (n[o] = s !== 0 ? a : 0, t[o] = s, s !== 0 && this.ttlAutopurge) {
|
|
2062
2065
|
const c = setTimeout(() => {
|
|
2063
2066
|
this.#m(o) && this.delete(this.#n[o]);
|
|
@@ -2065,7 +2068,7 @@ class He {
|
|
|
2065
2068
|
c.unref && c.unref();
|
|
2066
2069
|
}
|
|
2067
2070
|
}, this.#A = (o) => {
|
|
2068
|
-
n[o] = t[o] !== 0 ?
|
|
2071
|
+
n[o] = t[o] !== 0 ? ce.now() : 0;
|
|
2069
2072
|
}, this.#R = (o, s) => {
|
|
2070
2073
|
if (t[s]) {
|
|
2071
2074
|
const a = t[s], c = n[s];
|
|
@@ -2078,7 +2081,7 @@ class He {
|
|
|
2078
2081
|
};
|
|
2079
2082
|
let i = 0;
|
|
2080
2083
|
const r = () => {
|
|
2081
|
-
const o =
|
|
2084
|
+
const o = ce.now();
|
|
2082
2085
|
if (this.ttlResolution > 0) {
|
|
2083
2086
|
i = o;
|
|
2084
2087
|
const s = setTimeout(() => i = 0, this.ttlResolution);
|
|
@@ -2111,16 +2114,16 @@ class He {
|
|
|
2111
2114
|
#m = () => !1;
|
|
2112
2115
|
#C() {
|
|
2113
2116
|
const t = new Ie(this.#a);
|
|
2114
|
-
this.#x = 0, this.#_ = t, this.#
|
|
2117
|
+
this.#x = 0, this.#_ = t, this.#S = (n) => {
|
|
2115
2118
|
this.#x -= t[n], t[n] = 0;
|
|
2116
2119
|
}, this.#I = (n, i, r, o) => {
|
|
2117
2120
|
if (this.#t(i))
|
|
2118
2121
|
return 0;
|
|
2119
|
-
if (!
|
|
2122
|
+
if (!te(r))
|
|
2120
2123
|
if (o) {
|
|
2121
2124
|
if (typeof o != "function")
|
|
2122
2125
|
throw new TypeError("sizeCalculation must be a function");
|
|
2123
|
-
if (r = o(i, n), !
|
|
2126
|
+
if (r = o(i, n), !te(r))
|
|
2124
2127
|
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
2125
2128
|
} else
|
|
2126
2129
|
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
@@ -2134,7 +2137,7 @@ class He {
|
|
|
2134
2137
|
this.#x += t[n], r && (r.entrySize = i, r.totalCalculatedSize = this.#x);
|
|
2135
2138
|
};
|
|
2136
2139
|
}
|
|
2137
|
-
#
|
|
2140
|
+
#S = (t) => {
|
|
2138
2141
|
};
|
|
2139
2142
|
#F = (t, n, i) => {
|
|
2140
2143
|
};
|
|
@@ -2143,12 +2146,12 @@ class He {
|
|
|
2143
2146
|
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
2144
2147
|
return 0;
|
|
2145
2148
|
};
|
|
2146
|
-
*#
|
|
2149
|
+
*#g({ allowStale: t = this.allowStale } = {}) {
|
|
2147
2150
|
if (this.#r)
|
|
2148
2151
|
for (let n = this.#o; !(!this.#O(n) || ((t || !this.#m(n)) && (yield n), n === this.#c)); )
|
|
2149
2152
|
n = this.#h[n];
|
|
2150
2153
|
}
|
|
2151
|
-
*#
|
|
2154
|
+
*#w({ allowStale: t = this.allowStale } = {}) {
|
|
2152
2155
|
if (this.#r)
|
|
2153
2156
|
for (let n = this.#c; !(!this.#O(n) || ((t || !this.#m(n)) && (yield n), n === this.#o)); )
|
|
2154
2157
|
n = this.#f[n];
|
|
@@ -2161,7 +2164,7 @@ class He {
|
|
|
2161
2164
|
* in order from most recently used to least recently used.
|
|
2162
2165
|
*/
|
|
2163
2166
|
*entries() {
|
|
2164
|
-
for (const t of this.#
|
|
2167
|
+
for (const t of this.#g())
|
|
2165
2168
|
this.#e[t] !== void 0 && this.#n[t] !== void 0 && !this.#t(this.#e[t]) && (yield [this.#n[t], this.#e[t]]);
|
|
2166
2169
|
}
|
|
2167
2170
|
/**
|
|
@@ -2171,7 +2174,7 @@ class He {
|
|
|
2171
2174
|
* in order from least recently used to most recently used.
|
|
2172
2175
|
*/
|
|
2173
2176
|
*rentries() {
|
|
2174
|
-
for (const t of this.#
|
|
2177
|
+
for (const t of this.#w())
|
|
2175
2178
|
this.#e[t] !== void 0 && this.#n[t] !== void 0 && !this.#t(this.#e[t]) && (yield [this.#n[t], this.#e[t]]);
|
|
2176
2179
|
}
|
|
2177
2180
|
/**
|
|
@@ -2179,7 +2182,7 @@ class He {
|
|
|
2179
2182
|
* in order from most recently used to least recently used.
|
|
2180
2183
|
*/
|
|
2181
2184
|
*keys() {
|
|
2182
|
-
for (const t of this.#
|
|
2185
|
+
for (const t of this.#g()) {
|
|
2183
2186
|
const n = this.#n[t];
|
|
2184
2187
|
n !== void 0 && !this.#t(this.#e[t]) && (yield n);
|
|
2185
2188
|
}
|
|
@@ -2191,7 +2194,7 @@ class He {
|
|
|
2191
2194
|
* in order from least recently used to most recently used.
|
|
2192
2195
|
*/
|
|
2193
2196
|
*rkeys() {
|
|
2194
|
-
for (const t of this.#
|
|
2197
|
+
for (const t of this.#w()) {
|
|
2195
2198
|
const n = this.#n[t];
|
|
2196
2199
|
n !== void 0 && !this.#t(this.#e[t]) && (yield n);
|
|
2197
2200
|
}
|
|
@@ -2201,7 +2204,7 @@ class He {
|
|
|
2201
2204
|
* in order from most recently used to least recently used.
|
|
2202
2205
|
*/
|
|
2203
2206
|
*values() {
|
|
2204
|
-
for (const t of this.#
|
|
2207
|
+
for (const t of this.#g())
|
|
2205
2208
|
this.#e[t] !== void 0 && !this.#t(this.#e[t]) && (yield this.#e[t]);
|
|
2206
2209
|
}
|
|
2207
2210
|
/**
|
|
@@ -2211,7 +2214,7 @@ class He {
|
|
|
2211
2214
|
* in order from least recently used to most recently used.
|
|
2212
2215
|
*/
|
|
2213
2216
|
*rvalues() {
|
|
2214
|
-
for (const t of this.#
|
|
2217
|
+
for (const t of this.#w())
|
|
2215
2218
|
this.#e[t] !== void 0 && !this.#t(this.#e[t]) && (yield this.#e[t]);
|
|
2216
2219
|
}
|
|
2217
2220
|
/**
|
|
@@ -2231,7 +2234,7 @@ class He {
|
|
|
2231
2234
|
* similar to Array.find(). fn is called as fn(value, key, cache).
|
|
2232
2235
|
*/
|
|
2233
2236
|
find(t, n = {}) {
|
|
2234
|
-
for (const i of this.#
|
|
2237
|
+
for (const i of this.#g()) {
|
|
2235
2238
|
const r = this.#e[i], o = this.#t(r) ? r.__staleWhileFetching : r;
|
|
2236
2239
|
if (o !== void 0 && t(o, this.#n[i], this))
|
|
2237
2240
|
return this.get(this.#n[i], n);
|
|
@@ -2244,7 +2247,7 @@ class He {
|
|
|
2244
2247
|
* Does not iterate over stale values.
|
|
2245
2248
|
*/
|
|
2246
2249
|
forEach(t, n = this) {
|
|
2247
|
-
for (const i of this.#
|
|
2250
|
+
for (const i of this.#g()) {
|
|
2248
2251
|
const r = this.#e[i], o = this.#t(r) ? r.__staleWhileFetching : r;
|
|
2249
2252
|
o !== void 0 && t.call(n, o, this.#n[i], this);
|
|
2250
2253
|
}
|
|
@@ -2254,7 +2257,7 @@ class He {
|
|
|
2254
2257
|
* reverse order. (ie, less recently used items are iterated over first.)
|
|
2255
2258
|
*/
|
|
2256
2259
|
rforEach(t, n = this) {
|
|
2257
|
-
for (const i of this.#
|
|
2260
|
+
for (const i of this.#w()) {
|
|
2258
2261
|
const r = this.#e[i], o = this.#t(r) ? r.__staleWhileFetching : r;
|
|
2259
2262
|
o !== void 0 && t.call(n, o, this.#n[i], this);
|
|
2260
2263
|
}
|
|
@@ -2265,7 +2268,7 @@ class He {
|
|
|
2265
2268
|
*/
|
|
2266
2269
|
purgeStale() {
|
|
2267
2270
|
let t = !1;
|
|
2268
|
-
for (const n of this.#
|
|
2271
|
+
for (const n of this.#w({ allowStale: !0 }))
|
|
2269
2272
|
this.#m(n) && (this.delete(this.#n[n]), t = !0);
|
|
2270
2273
|
return t;
|
|
2271
2274
|
}
|
|
@@ -2286,7 +2289,7 @@ class He {
|
|
|
2286
2289
|
if (this.#d && this.#T) {
|
|
2287
2290
|
const s = this.#d[n], a = this.#T[n];
|
|
2288
2291
|
if (s && a) {
|
|
2289
|
-
const c = s - (
|
|
2292
|
+
const c = s - (ce.now() - a);
|
|
2290
2293
|
o.ttl = c, o.start = Date.now();
|
|
2291
2294
|
}
|
|
2292
2295
|
}
|
|
@@ -2298,14 +2301,14 @@ class He {
|
|
|
2298
2301
|
*/
|
|
2299
2302
|
dump() {
|
|
2300
2303
|
const t = [];
|
|
2301
|
-
for (const n of this.#
|
|
2304
|
+
for (const n of this.#g({ allowStale: !0 })) {
|
|
2302
2305
|
const i = this.#n[n], r = this.#e[n], o = this.#t(r) ? r.__staleWhileFetching : r;
|
|
2303
2306
|
if (o === void 0 || i === void 0)
|
|
2304
2307
|
continue;
|
|
2305
2308
|
const s = { value: o };
|
|
2306
2309
|
if (this.#d && this.#T) {
|
|
2307
2310
|
s.ttl = this.#d[n];
|
|
2308
|
-
const a =
|
|
2311
|
+
const a = ce.now() - this.#T[n];
|
|
2309
2312
|
s.start = Math.floor(Date.now() - a);
|
|
2310
2313
|
}
|
|
2311
2314
|
this.#_ && (s.size = this.#_[n]), t.unshift([i, s]);
|
|
@@ -2322,7 +2325,7 @@ class He {
|
|
|
2322
2325
|
for (const [n, i] of t) {
|
|
2323
2326
|
if (i.start) {
|
|
2324
2327
|
const r = Date.now() - i.start;
|
|
2325
|
-
i.start =
|
|
2328
|
+
i.start = ce.now() - r;
|
|
2326
2329
|
}
|
|
2327
2330
|
this.set(n, i.value, i);
|
|
2328
2331
|
}
|
|
@@ -2338,35 +2341,35 @@ class He {
|
|
|
2338
2341
|
return this.delete(t), this;
|
|
2339
2342
|
const { ttl: r = this.ttl, start: o, noDisposeOnSet: s = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: c } = i;
|
|
2340
2343
|
let { noUpdateTTL: f = this.noUpdateTTL } = i;
|
|
2341
|
-
const
|
|
2342
|
-
if (this.maxEntrySize &&
|
|
2344
|
+
const l = this.#I(t, n, i.size || 0, a);
|
|
2345
|
+
if (this.maxEntrySize && l > this.maxEntrySize)
|
|
2343
2346
|
return c && (c.set = "miss", c.maxEntrySizeExceeded = !0), this.delete(t), this;
|
|
2344
2347
|
let h = this.#r === 0 ? void 0 : this.#i.get(t);
|
|
2345
2348
|
if (h === void 0)
|
|
2346
|
-
h = this.#r === 0 ? this.#o : this.#E.length !== 0 ? this.#E.pop() : this.#r === this.#a ? this.#P(!1) : this.#r, this.#n[h] = t, this.#e[h] = n, this.#i.set(t, h), this.#f[this.#o] = h, this.#h[h] = this.#o, this.#o = h, this.#r++, this.#F(h,
|
|
2349
|
+
h = this.#r === 0 ? this.#o : this.#E.length !== 0 ? this.#E.pop() : this.#r === this.#a ? this.#P(!1) : this.#r, this.#n[h] = t, this.#e[h] = n, this.#i.set(t, h), this.#f[this.#o] = h, this.#h[h] = this.#o, this.#o = h, this.#r++, this.#F(h, l, c), c && (c.set = "add"), f = !1;
|
|
2347
2350
|
else {
|
|
2348
|
-
this.#
|
|
2349
|
-
const
|
|
2350
|
-
if (n !==
|
|
2351
|
-
if (this.#M && this.#t(
|
|
2352
|
-
|
|
2353
|
-
const { __staleWhileFetching:
|
|
2354
|
-
|
|
2351
|
+
this.#b(h);
|
|
2352
|
+
const d = this.#e[h];
|
|
2353
|
+
if (n !== d) {
|
|
2354
|
+
if (this.#M && this.#t(d)) {
|
|
2355
|
+
d.__abortController.abort(new Error("replaced"));
|
|
2356
|
+
const { __staleWhileFetching: m } = d;
|
|
2357
|
+
m !== void 0 && !s && (this.#y && this.#p?.(m, t, "set"), this.#l && this.#s?.push([m, t, "set"]));
|
|
2355
2358
|
} else
|
|
2356
|
-
s || (this.#y && this.#
|
|
2357
|
-
if (this.#
|
|
2359
|
+
s || (this.#y && this.#p?.(d, t, "set"), this.#l && this.#s?.push([d, t, "set"]));
|
|
2360
|
+
if (this.#S(h), this.#F(h, l, c), this.#e[h] = n, c) {
|
|
2358
2361
|
c.set = "replace";
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2362
|
+
const m = d && this.#t(d) ? d.__staleWhileFetching : d;
|
|
2363
|
+
m !== void 0 && (c.oldValue = m);
|
|
2361
2364
|
}
|
|
2362
2365
|
} else
|
|
2363
2366
|
c && (c.set = "update");
|
|
2364
2367
|
}
|
|
2365
2368
|
if (r !== 0 && !this.#d && this.#L(), this.#d && (f || this.#N(h, r, o), c && this.#R(c, h)), !s && this.#l && this.#s) {
|
|
2366
|
-
const
|
|
2367
|
-
let
|
|
2368
|
-
for (;
|
|
2369
|
-
this.#
|
|
2369
|
+
const d = this.#s;
|
|
2370
|
+
let m;
|
|
2371
|
+
for (; m = d?.shift(); )
|
|
2372
|
+
this.#v?.(...m);
|
|
2370
2373
|
}
|
|
2371
2374
|
return this;
|
|
2372
2375
|
}
|
|
@@ -2389,13 +2392,13 @@ class He {
|
|
|
2389
2392
|
const t = this.#s;
|
|
2390
2393
|
let n;
|
|
2391
2394
|
for (; n = t?.shift(); )
|
|
2392
|
-
this.#
|
|
2395
|
+
this.#v?.(...n);
|
|
2393
2396
|
}
|
|
2394
2397
|
}
|
|
2395
2398
|
}
|
|
2396
2399
|
#P(t) {
|
|
2397
2400
|
const n = this.#c, i = this.#n[n], r = this.#e[n];
|
|
2398
|
-
return this.#M && this.#t(r) ? r.__abortController.abort(new Error("evicted")) : (this.#y || this.#l) && (this.#y && this.#
|
|
2401
|
+
return this.#M && this.#t(r) ? r.__abortController.abort(new Error("evicted")) : (this.#y || this.#l) && (this.#y && this.#p?.(r, i, "evict"), this.#l && this.#s?.push([r, i, "evict"])), this.#S(n), t && (this.#n[n] = void 0, this.#e[n] = void 0, this.#E.push(n)), this.#r === 1 ? (this.#c = this.#o = 0, this.#E.length = 0) : this.#c = this.#f[n], this.#i.delete(i), this.#r--, n;
|
|
2399
2402
|
}
|
|
2400
2403
|
/**
|
|
2401
2404
|
* Check if a key is in the cache, without updating the recency of use.
|
|
@@ -2437,7 +2440,7 @@ class He {
|
|
|
2437
2440
|
const o = n === void 0 ? void 0 : this.#e[n];
|
|
2438
2441
|
if (this.#t(o))
|
|
2439
2442
|
return o;
|
|
2440
|
-
const s = new
|
|
2443
|
+
const s = new Ce(), { signal: a } = i;
|
|
2441
2444
|
a?.addEventListener("abort", () => s.abort(a.reason), {
|
|
2442
2445
|
signal: s.signal
|
|
2443
2446
|
});
|
|
@@ -2445,26 +2448,26 @@ class He {
|
|
|
2445
2448
|
signal: s.signal,
|
|
2446
2449
|
options: i,
|
|
2447
2450
|
context: r
|
|
2448
|
-
}, f = (E,
|
|
2451
|
+
}, f = (E, v = !1) => {
|
|
2449
2452
|
const { aborted: x } = s.signal, M = i.ignoreFetchAbort && E !== void 0;
|
|
2450
|
-
if (i.status && (x && !
|
|
2453
|
+
if (i.status && (x && !v ? (i.status.fetchAborted = !0, i.status.fetchError = s.signal.reason, M && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), x && !M && !v)
|
|
2451
2454
|
return h(s.signal.reason);
|
|
2452
|
-
const _ =
|
|
2453
|
-
return this.#e[n] ===
|
|
2454
|
-
},
|
|
2455
|
-
const { aborted:
|
|
2456
|
-
if (this.#e[n] ===
|
|
2457
|
-
return i.status &&
|
|
2458
|
-
if (
|
|
2455
|
+
const _ = m;
|
|
2456
|
+
return this.#e[n] === m && (E === void 0 ? _.__staleWhileFetching ? this.#e[n] = _.__staleWhileFetching : this.delete(t) : (i.status && (i.status.fetchUpdated = !0), this.set(t, E, c.options))), E;
|
|
2457
|
+
}, l = (E) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = E), h(E)), h = (E) => {
|
|
2458
|
+
const { aborted: v } = s.signal, x = v && i.allowStaleOnFetchAbort, M = x || i.allowStaleOnFetchRejection, _ = M || i.noDeleteOnFetchRejection, u = m;
|
|
2459
|
+
if (this.#e[n] === m && (!_ || u.__staleWhileFetching === void 0 ? this.delete(t) : x || (this.#e[n] = u.__staleWhileFetching)), M)
|
|
2460
|
+
return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), u.__staleWhileFetching;
|
|
2461
|
+
if (u.__returned === u)
|
|
2459
2462
|
throw E;
|
|
2460
|
-
},
|
|
2463
|
+
}, d = (E, v) => {
|
|
2461
2464
|
const x = this.#U?.(t, o, c);
|
|
2462
|
-
x && x instanceof Promise && x.then((M) => E(M === void 0 ? void 0 : M),
|
|
2465
|
+
x && x instanceof Promise && x.then((M) => E(M === void 0 ? void 0 : M), v), s.signal.addEventListener("abort", () => {
|
|
2463
2466
|
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (E(void 0), i.allowStaleOnFetchAbort && (E = (M) => f(M, !0)));
|
|
2464
2467
|
});
|
|
2465
2468
|
};
|
|
2466
2469
|
i.status && (i.status.fetchDispatched = !0);
|
|
2467
|
-
const
|
|
2470
|
+
const m = new Promise(d).then(f, l), p = Object.assign(m, {
|
|
2468
2471
|
__abortController: s,
|
|
2469
2472
|
__staleWhileFetching: o,
|
|
2470
2473
|
__returned: void 0
|
|
@@ -2475,7 +2478,7 @@ class He {
|
|
|
2475
2478
|
if (!this.#M)
|
|
2476
2479
|
return !1;
|
|
2477
2480
|
const n = t;
|
|
2478
|
-
return !!n && n instanceof Promise && n.hasOwnProperty("__staleWhileFetching") && n.__abortController instanceof
|
|
2481
|
+
return !!n && n instanceof Promise && n.hasOwnProperty("__staleWhileFetching") && n.__abortController instanceof Ce;
|
|
2479
2482
|
}
|
|
2480
2483
|
async fetch(t, n = {}) {
|
|
2481
2484
|
const {
|
|
@@ -2488,14 +2491,14 @@ class He {
|
|
|
2488
2491
|
noDisposeOnSet: a = this.noDisposeOnSet,
|
|
2489
2492
|
size: c = 0,
|
|
2490
2493
|
sizeCalculation: f = this.sizeCalculation,
|
|
2491
|
-
noUpdateTTL:
|
|
2494
|
+
noUpdateTTL: l = this.noUpdateTTL,
|
|
2492
2495
|
// fetch exclusive options
|
|
2493
2496
|
noDeleteOnFetchRejection: h = this.noDeleteOnFetchRejection,
|
|
2494
|
-
allowStaleOnFetchRejection:
|
|
2495
|
-
ignoreFetchAbort:
|
|
2497
|
+
allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection,
|
|
2498
|
+
ignoreFetchAbort: m = this.ignoreFetchAbort,
|
|
2496
2499
|
allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort,
|
|
2497
2500
|
context: E,
|
|
2498
|
-
forceRefresh:
|
|
2501
|
+
forceRefresh: v = !1,
|
|
2499
2502
|
status: x,
|
|
2500
2503
|
signal: M
|
|
2501
2504
|
} = n;
|
|
@@ -2514,30 +2517,30 @@ class He {
|
|
|
2514
2517
|
noDisposeOnSet: a,
|
|
2515
2518
|
size: c,
|
|
2516
2519
|
sizeCalculation: f,
|
|
2517
|
-
noUpdateTTL:
|
|
2520
|
+
noUpdateTTL: l,
|
|
2518
2521
|
noDeleteOnFetchRejection: h,
|
|
2519
|
-
allowStaleOnFetchRejection:
|
|
2522
|
+
allowStaleOnFetchRejection: d,
|
|
2520
2523
|
allowStaleOnFetchAbort: p,
|
|
2521
|
-
ignoreFetchAbort:
|
|
2524
|
+
ignoreFetchAbort: m,
|
|
2522
2525
|
status: x,
|
|
2523
2526
|
signal: M
|
|
2524
2527
|
};
|
|
2525
|
-
let
|
|
2526
|
-
if (
|
|
2528
|
+
let u = this.#i.get(t);
|
|
2529
|
+
if (u === void 0) {
|
|
2527
2530
|
x && (x.fetch = "miss");
|
|
2528
|
-
const T = this.#z(t,
|
|
2531
|
+
const T = this.#z(t, u, _, E);
|
|
2529
2532
|
return T.__returned = T;
|
|
2530
2533
|
} else {
|
|
2531
|
-
const T = this.#e[
|
|
2534
|
+
const T = this.#e[u];
|
|
2532
2535
|
if (this.#t(T)) {
|
|
2533
2536
|
const y = i && T.__staleWhileFetching !== void 0;
|
|
2534
2537
|
return x && (x.fetch = "inflight", y && (x.returnedStale = !0)), y ? T.__staleWhileFetching : T.__returned = T;
|
|
2535
2538
|
}
|
|
2536
|
-
const A = this.#m(
|
|
2537
|
-
if (!
|
|
2538
|
-
return x && (x.fetch = "hit"), this.#
|
|
2539
|
-
const R = this.#z(t,
|
|
2540
|
-
return x && (x.fetch = A ? "stale" : "refresh",
|
|
2539
|
+
const A = this.#m(u);
|
|
2540
|
+
if (!v && !A)
|
|
2541
|
+
return x && (x.fetch = "hit"), this.#b(u), r && this.#A(u), x && this.#R(x, u), T;
|
|
2542
|
+
const R = this.#z(t, u, _, E), w = R.__staleWhileFetching !== void 0 && i;
|
|
2543
|
+
return x && (x.fetch = A ? "stale" : "refresh", w && A && (x.returnedStale = !0)), w ? R.__staleWhileFetching : R.__returned = R;
|
|
2541
2544
|
}
|
|
2542
2545
|
}
|
|
2543
2546
|
/**
|
|
@@ -2550,14 +2553,14 @@ class He {
|
|
|
2550
2553
|
const { allowStale: i = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: o = this.noDeleteOnStaleGet, status: s } = n, a = this.#i.get(t);
|
|
2551
2554
|
if (a !== void 0) {
|
|
2552
2555
|
const c = this.#e[a], f = this.#t(c);
|
|
2553
|
-
return s && this.#R(s, a), this.#m(a) ? (s && (s.get = "stale"), f ? (s && i && c.__staleWhileFetching !== void 0 && (s.returnedStale = !0), i ? c.__staleWhileFetching : void 0) : (o || this.delete(t), s && i && (s.returnedStale = !0), i ? c : void 0)) : (s && (s.get = "hit"), f ? c.__staleWhileFetching : (this.#
|
|
2556
|
+
return s && this.#R(s, a), this.#m(a) ? (s && (s.get = "stale"), f ? (s && i && c.__staleWhileFetching !== void 0 && (s.returnedStale = !0), i ? c.__staleWhileFetching : void 0) : (o || this.delete(t), s && i && (s.returnedStale = !0), i ? c : void 0)) : (s && (s.get = "hit"), f ? c.__staleWhileFetching : (this.#b(a), r && this.#A(a), c));
|
|
2554
2557
|
} else
|
|
2555
2558
|
s && (s.get = "miss");
|
|
2556
2559
|
}
|
|
2557
2560
|
#D(t, n) {
|
|
2558
2561
|
this.#h[n] = t, this.#f[t] = n;
|
|
2559
2562
|
}
|
|
2560
|
-
#
|
|
2563
|
+
#b(t) {
|
|
2561
2564
|
t !== this.#o && (t === this.#c ? this.#c = this.#f[t] : this.#D(this.#h[t], this.#f[t]), this.#D(this.#o, t), this.#o = t);
|
|
2562
2565
|
}
|
|
2563
2566
|
/**
|
|
@@ -2572,9 +2575,9 @@ class He {
|
|
|
2572
2575
|
if (n = !0, this.#r === 1)
|
|
2573
2576
|
this.clear();
|
|
2574
2577
|
else {
|
|
2575
|
-
this.#
|
|
2578
|
+
this.#S(i);
|
|
2576
2579
|
const r = this.#e[i];
|
|
2577
|
-
if (this.#t(r) ? r.__abortController.abort(new Error("deleted")) : (this.#y || this.#l) && (this.#y && this.#
|
|
2580
|
+
if (this.#t(r) ? r.__abortController.abort(new Error("deleted")) : (this.#y || this.#l) && (this.#y && this.#p?.(r, t, "delete"), this.#l && this.#s?.push([r, t, "delete"])), this.#i.delete(t), this.#n[i] = void 0, this.#e[i] = void 0, i === this.#o)
|
|
2578
2581
|
this.#o = this.#h[i];
|
|
2579
2582
|
else if (i === this.#c)
|
|
2580
2583
|
this.#c = this.#f[i];
|
|
@@ -2591,7 +2594,7 @@ class He {
|
|
|
2591
2594
|
const i = this.#s;
|
|
2592
2595
|
let r;
|
|
2593
2596
|
for (; r = i?.shift(); )
|
|
2594
|
-
this.#
|
|
2597
|
+
this.#v?.(...r);
|
|
2595
2598
|
}
|
|
2596
2599
|
return n;
|
|
2597
2600
|
}
|
|
@@ -2599,25 +2602,25 @@ class He {
|
|
|
2599
2602
|
* Clear the cache entirely, throwing away all values.
|
|
2600
2603
|
*/
|
|
2601
2604
|
clear() {
|
|
2602
|
-
for (const t of this.#
|
|
2605
|
+
for (const t of this.#w({ allowStale: !0 })) {
|
|
2603
2606
|
const n = this.#e[t];
|
|
2604
2607
|
if (this.#t(n))
|
|
2605
2608
|
n.__abortController.abort(new Error("deleted"));
|
|
2606
2609
|
else {
|
|
2607
2610
|
const i = this.#n[t];
|
|
2608
|
-
this.#y && this.#
|
|
2611
|
+
this.#y && this.#p?.(n, i, "delete"), this.#l && this.#s?.push([n, i, "delete"]);
|
|
2609
2612
|
}
|
|
2610
2613
|
}
|
|
2611
2614
|
if (this.#i.clear(), this.#e.fill(void 0), this.#n.fill(void 0), this.#d && this.#T && (this.#d.fill(0), this.#T.fill(0)), this.#_ && this.#_.fill(0), this.#c = 0, this.#o = 0, this.#E.length = 0, this.#x = 0, this.#r = 0, this.#l && this.#s) {
|
|
2612
2615
|
const t = this.#s;
|
|
2613
2616
|
let n;
|
|
2614
2617
|
for (; n = t?.shift(); )
|
|
2615
|
-
this.#
|
|
2618
|
+
this.#v?.(...n);
|
|
2616
2619
|
}
|
|
2617
2620
|
}
|
|
2618
2621
|
}
|
|
2619
|
-
const
|
|
2620
|
-
const t = new
|
|
2622
|
+
const Xe = (e) => {
|
|
2623
|
+
const t = new Qe({
|
|
2621
2624
|
...e,
|
|
2622
2625
|
ttlResolution: 0,
|
|
2623
2626
|
dispose: (r, o) => e.dispose?.(r, i(o))
|
|
@@ -2634,40 +2637,40 @@ const Ce = (e) => {
|
|
|
2634
2637
|
clear: () => t.clear(),
|
|
2635
2638
|
purgeStale: () => t.purgeStale()
|
|
2636
2639
|
};
|
|
2637
|
-
},
|
|
2640
|
+
}, si = 15, re = 256, ci = ({
|
|
2638
2641
|
gl: e,
|
|
2639
2642
|
terrainCache: t
|
|
2640
2643
|
}) => {
|
|
2641
|
-
const n =
|
|
2644
|
+
const n = Xe({
|
|
2642
2645
|
max: 1e3
|
|
2643
|
-
}), i =
|
|
2646
|
+
}), i = ke(t), r = e.createFramebuffer();
|
|
2644
2647
|
if (!r)
|
|
2645
2648
|
throw new Error("Framebuffer creation failed");
|
|
2646
|
-
const o = ([c = 0, f = 0,
|
|
2647
|
-
const h = i.get([c, f,
|
|
2649
|
+
const o = ([c = 0, f = 0, l = 0]) => {
|
|
2650
|
+
const h = i.get([c, f, l]);
|
|
2648
2651
|
if (!h)
|
|
2649
2652
|
return;
|
|
2650
|
-
const { texture:
|
|
2651
|
-
if (
|
|
2652
|
-
return { buffer:
|
|
2653
|
-
const x = new Uint8Array(4 *
|
|
2654
|
-
return e.bindFramebuffer(e.FRAMEBUFFER, r),
|
|
2653
|
+
const { texture: d, downsample: m } = h, p = 2 ** m, E = [Math.floor(c / p), Math.floor(f / p), l - m], v = n.get(E);
|
|
2654
|
+
if (v)
|
|
2655
|
+
return { buffer: v, downsample: m };
|
|
2656
|
+
const x = new Uint8Array(4 * re * re);
|
|
2657
|
+
return e.bindFramebuffer(e.FRAMEBUFFER, r), d.attach(), e.readPixels(0, 0, re, re, e.RGBA, e.UNSIGNED_BYTE, x), e.bindFramebuffer(e.FRAMEBUFFER, null), n.set(E, x), { buffer: x, downsample: m };
|
|
2655
2658
|
};
|
|
2656
|
-
return { get: ([c = 0, f = 0],
|
|
2657
|
-
const h = 2 **
|
|
2658
|
-
let [E = 0,
|
|
2659
|
-
const x = o([
|
|
2659
|
+
return { get: ([c = 0, f = 0], l = si) => {
|
|
2660
|
+
const h = 2 ** l, d = L([c, f, 0]).map((y) => y * h), [m = 0, p = 0] = d.map((y) => Math.floor(y % h));
|
|
2661
|
+
let [E = 0, v = 0] = d.map((y) => y % 1);
|
|
2662
|
+
const x = o([m, p, l]);
|
|
2660
2663
|
if (!x)
|
|
2661
2664
|
return 0;
|
|
2662
|
-
const { buffer: M, downsample: _ } = x,
|
|
2663
|
-
[E,
|
|
2664
|
-
const T = 4 *
|
|
2665
|
-
return (A * 65536 + R * 256 +
|
|
2665
|
+
const { buffer: M, downsample: _ } = x, u = 2 ** _;
|
|
2666
|
+
[E, v] = [(m % u + E) / u, (p % u + v) / u];
|
|
2667
|
+
const T = 4 * re * Math.floor(v * re) + 4 * Math.floor(E * re), [A = 0, R = 0, g = 0] = M.slice(T, T + 4);
|
|
2668
|
+
return (A * 65536 + R * 256 + g) / 10 - 1e4;
|
|
2666
2669
|
}, dispose: () => {
|
|
2667
2670
|
e.deleteFramebuffer(r);
|
|
2668
2671
|
} };
|
|
2669
2672
|
};
|
|
2670
|
-
var
|
|
2673
|
+
var ai = `#version 300 es
|
|
2671
2674
|
|
|
2672
2675
|
precision highp float;
|
|
2673
2676
|
|
|
@@ -2679,20 +2682,20 @@ out vec4 result;
|
|
|
2679
2682
|
void main(void) {
|
|
2680
2683
|
result = texture(imagery, uv) * color_out;
|
|
2681
2684
|
}`;
|
|
2682
|
-
const
|
|
2685
|
+
const ut = ({
|
|
2683
2686
|
gl: e,
|
|
2684
2687
|
urlPattern: t,
|
|
2685
2688
|
onLoad: n
|
|
2686
2689
|
}) => {
|
|
2687
|
-
const i =
|
|
2690
|
+
const i = Xe({
|
|
2688
2691
|
max: 2e3,
|
|
2689
2692
|
dispose: (c) => c.dispose()
|
|
2690
|
-
}), r =
|
|
2693
|
+
}), r = Xe({
|
|
2691
2694
|
max: 1e4,
|
|
2692
2695
|
ttl: 200,
|
|
2693
2696
|
dispose: (c, f) => {
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2697
|
+
const l = i.get(f);
|
|
2698
|
+
l && !l.loaded && i.delete(f);
|
|
2696
2699
|
}
|
|
2697
2700
|
}), o = (c) => {
|
|
2698
2701
|
const f = i.get(c);
|
|
@@ -2701,21 +2704,21 @@ const at = ({
|
|
|
2701
2704
|
return r.delete(c), f;
|
|
2702
2705
|
r.set(c, !0);
|
|
2703
2706
|
} else {
|
|
2704
|
-
const [
|
|
2705
|
-
let
|
|
2706
|
-
if (
|
|
2707
|
-
const [E = 0,
|
|
2707
|
+
const [l = 0, h = 0, d = 0] = c;
|
|
2708
|
+
let m = t.replace("{x}", `${l}`).replace("{y}", `${h}`).replace("{z}", `${d}`);
|
|
2709
|
+
if (m.includes("{bbox}")) {
|
|
2710
|
+
const [E = 0, v = 0, x = 0] = c, M = 2 ** x - v - 1, [[_, u] = [], [T, A] = []] = [
|
|
2708
2711
|
[0, 0],
|
|
2709
2712
|
[1, 1]
|
|
2710
|
-
].map(([R = 0,
|
|
2713
|
+
].map(([R = 0, g = 0]) => [E + R, M + g, x]).map((R) => pt(R, R)).map(([R = 0, g = 0]) => [
|
|
2711
2714
|
(R - 0.5) * 2 * Math.PI * 6378137,
|
|
2712
|
-
(
|
|
2715
|
+
(g - 0.5) * 2 * Math.PI * 6378137
|
|
2713
2716
|
]);
|
|
2714
|
-
|
|
2717
|
+
m = m.replace("{bbox}", [_, u, T, A].join(","));
|
|
2715
2718
|
}
|
|
2716
|
-
const p =
|
|
2719
|
+
const p = Tt({
|
|
2717
2720
|
gl: e,
|
|
2718
|
-
url:
|
|
2721
|
+
url: m,
|
|
2719
2722
|
onLoad: () => {
|
|
2720
2723
|
r.delete(c), n?.();
|
|
2721
2724
|
}
|
|
@@ -2726,8 +2729,8 @@ const at = ({
|
|
|
2726
2729
|
return { get: o, dispose: () => {
|
|
2727
2730
|
clearInterval(s), i.clear();
|
|
2728
2731
|
} };
|
|
2729
|
-
},
|
|
2730
|
-
const t =
|
|
2732
|
+
}, fi = (e) => {
|
|
2733
|
+
const t = Xe({
|
|
2731
2734
|
max: 1e4,
|
|
2732
2735
|
ttl: 1e3
|
|
2733
2736
|
}), n = [
|
|
@@ -2740,18 +2743,18 @@ const at = ({
|
|
|
2740
2743
|
const o = t.get(r);
|
|
2741
2744
|
if (o)
|
|
2742
2745
|
return o;
|
|
2743
|
-
const [s = 0, a = 0, c = 0] = r, f = Math.max(c - 5, 0),
|
|
2744
|
-
for (let
|
|
2745
|
-
const [
|
|
2746
|
-
|
|
2746
|
+
const [s = 0, a = 0, c = 0] = r, f = Math.max(c - 5, 0), l = new Array(4), h = N();
|
|
2747
|
+
for (let d = 0; d < n.length; d++) {
|
|
2748
|
+
const [m = 0, p = 0] = n[d] ?? [], [E = 0, v = 0] = K(
|
|
2749
|
+
pt([s + m, a + p, c], h),
|
|
2747
2750
|
h
|
|
2748
2751
|
);
|
|
2749
|
-
|
|
2752
|
+
l[d] = L([E, v, e.get([E, v], f)]);
|
|
2750
2753
|
}
|
|
2751
|
-
return t.set(r,
|
|
2754
|
+
return t.set(r, l), l;
|
|
2752
2755
|
} };
|
|
2753
2756
|
};
|
|
2754
|
-
var
|
|
2757
|
+
var li = `#version 300 es
|
|
2755
2758
|
|
|
2756
2759
|
precision highp float;
|
|
2757
2760
|
|
|
@@ -2788,8 +2791,8 @@ void main(void) {
|
|
|
2788
2791
|
uv = downsample(downsample_imagery);
|
|
2789
2792
|
color_out = color;
|
|
2790
2793
|
}`;
|
|
2791
|
-
const B = 34,
|
|
2792
|
-
(e) =>
|
|
2794
|
+
const B = 34, ui = 22, hi = ue(0, B).flatMap(
|
|
2795
|
+
(e) => ue(0, B).flatMap((t) => [
|
|
2793
2796
|
e * (B + 1) + t,
|
|
2794
2797
|
e * (B + 1) + t + 1,
|
|
2795
2798
|
(e + 1) * (B + 1) + t + 1,
|
|
@@ -2797,22 +2800,22 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2797
2800
|
(e + 1) * (B + 1) + t + 1,
|
|
2798
2801
|
(e + 1) * (B + 1) + t
|
|
2799
2802
|
])
|
|
2800
|
-
),
|
|
2801
|
-
(e) =>
|
|
2803
|
+
), Pe = 0.1, di = ue(0, B + 1).flatMap(
|
|
2804
|
+
(e) => ue(0, B + 1).map((t) => {
|
|
2802
2805
|
let n = (t - 1) / (B - 2), i = (e - 1) / (B - 2), r = 0;
|
|
2803
|
-
return t === 0 && (n = 0, r = -
|
|
2806
|
+
return t === 0 && (n = 0, r = -Pe), t === B && (n = 1, r = -Pe), e === 0 && (i = 0, r = -Pe), e === B && (i = 1, r = -Pe), [n, i, r];
|
|
2804
2807
|
})
|
|
2805
|
-
),
|
|
2808
|
+
), Ci = (e, t = {}) => {
|
|
2806
2809
|
const { gl: n } = e;
|
|
2807
2810
|
let i, r;
|
|
2808
2811
|
const o = n.getExtension(
|
|
2809
2812
|
"EXT_texture_filter_anisotropic"
|
|
2810
|
-
), s = o ? n.getParameter(o.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : void 0, a =
|
|
2813
|
+
), s = o ? n.getParameter(o.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : void 0, a = se(
|
|
2811
2814
|
() => t.imageryUrl?.() ?? "",
|
|
2812
|
-
(
|
|
2813
|
-
i?.dispose(), i =
|
|
2815
|
+
(w) => {
|
|
2816
|
+
i?.dispose(), i = ut({
|
|
2814
2817
|
gl: n,
|
|
2815
|
-
urlPattern:
|
|
2818
|
+
urlPattern: w,
|
|
2816
2819
|
onLoad: () => {
|
|
2817
2820
|
o && s && n.texParameterf(
|
|
2818
2821
|
n.TEXTURE_2D,
|
|
@@ -2824,119 +2827,119 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2824
2827
|
n.LINEAR_MIPMAP_LINEAR
|
|
2825
2828
|
), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), n.generateMipmap(n.TEXTURE_2D);
|
|
2826
2829
|
}
|
|
2827
|
-
}), r =
|
|
2830
|
+
}), r = ke(i);
|
|
2828
2831
|
}
|
|
2829
|
-
), c = t.terrainUrl?.() ?? "", f =
|
|
2832
|
+
), c = t.terrainUrl?.() ?? "", f = ut({
|
|
2830
2833
|
gl: n,
|
|
2831
2834
|
urlPattern: c,
|
|
2832
2835
|
onLoad: () => {
|
|
2833
2836
|
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.NEAREST), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.NEAREST), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE);
|
|
2834
2837
|
}
|
|
2835
|
-
}),
|
|
2836
|
-
|
|
2837
|
-
const p =
|
|
2838
|
-
p.set(
|
|
2839
|
-
const { renderProgram: E, depthProgram:
|
|
2840
|
-
uvwBuffer:
|
|
2838
|
+
}), l = ke(f, 3), h = ci({ gl: n, terrainCache: f }), d = fi(h), m = j({ gl: n, type: "f32", target: "array" });
|
|
2839
|
+
m.set(di.flatMap(([w = 0, y = 0, S = 0]) => [w, y, S]));
|
|
2840
|
+
const p = j({ gl: n, type: "u16", target: "element" });
|
|
2841
|
+
p.set(hi);
|
|
2842
|
+
const { renderProgram: E, depthProgram: v } = mi(e, {
|
|
2843
|
+
uvwBuffer: m,
|
|
2841
2844
|
indexBuffer: p
|
|
2842
|
-
}), x = [0, 1, 2, 3], M = x.map(
|
|
2843
|
-
const y = new Array([0, 0, 0]),
|
|
2845
|
+
}), x = [0, 1, 2, 3], M = x.map(N), _ = x.map(ie), u = x.map(le), T = (w) => {
|
|
2846
|
+
const y = new Array([0, 0, 0]), S = new Array(), { worldToLocal: b, localToClip: U, clipToScreen: F } = w, z = 384 * Math.pow(2, t.downsample?.() ?? 0);
|
|
2844
2847
|
for (; ; ) {
|
|
2845
2848
|
const P = y.pop();
|
|
2846
2849
|
if (!P)
|
|
2847
2850
|
break;
|
|
2848
|
-
const [X = 0, C = 0, O = 0] = P, $ =
|
|
2849
|
-
if (
|
|
2851
|
+
const [X = 0, C = 0, O = 0] = P, $ = d.get(P).map((Y, ee) => b(Y, M[ee])).map((Y, ee) => U(Y, _[ee]));
|
|
2852
|
+
if (pi($))
|
|
2850
2853
|
continue;
|
|
2851
2854
|
vi(
|
|
2852
|
-
|
|
2853
|
-
) > z && O <
|
|
2855
|
+
xi($).map((Y, ee) => F(Y, u[ee]))
|
|
2856
|
+
) > z && O < ui ? y.push(
|
|
2854
2857
|
[2 * X, 2 * C, O + 1],
|
|
2855
2858
|
[2 * X + 1, 2 * C, O + 1],
|
|
2856
2859
|
[2 * X, 2 * C + 1, O + 1],
|
|
2857
2860
|
[2 * X + 1, 2 * C + 1, O + 1]
|
|
2858
|
-
) :
|
|
2861
|
+
) : S.push(P);
|
|
2859
2862
|
}
|
|
2860
|
-
return
|
|
2863
|
+
return S;
|
|
2861
2864
|
}, A = ({
|
|
2862
|
-
viewport:
|
|
2865
|
+
viewport: w,
|
|
2863
2866
|
depth: y = !1,
|
|
2864
|
-
index:
|
|
2867
|
+
index: S = 0
|
|
2865
2868
|
}) => {
|
|
2866
|
-
const
|
|
2867
|
-
if (a(),
|
|
2869
|
+
const b = t.color?.() ?? [1, 1, 1, 1];
|
|
2870
|
+
if (a(), me(n, y, t))
|
|
2868
2871
|
return;
|
|
2869
|
-
const U = y ?
|
|
2872
|
+
const U = y ? v : E, { projection: F, modelView: z, camera: P } = w, X = T(w);
|
|
2870
2873
|
for (const C of X) {
|
|
2871
|
-
const O = y ? void 0 : r?.get(C), G =
|
|
2874
|
+
const O = y ? void 0 : r?.get(C), G = l.get(C);
|
|
2872
2875
|
if (!y && !O || !G)
|
|
2873
2876
|
continue;
|
|
2874
|
-
const { texture: $, downsample:
|
|
2877
|
+
const { texture: $, downsample: Q } = G, { texture: q = $, downsample: Y = 0 } = O ?? {};
|
|
2875
2878
|
U.execute({
|
|
2876
2879
|
projection: F,
|
|
2877
2880
|
modelView: z,
|
|
2878
2881
|
camera: J(P),
|
|
2879
2882
|
xyz: C,
|
|
2880
|
-
imagery:
|
|
2883
|
+
imagery: q,
|
|
2881
2884
|
terrain: $,
|
|
2882
2885
|
downsampleImagery: Y,
|
|
2883
|
-
downsampleTerrain:
|
|
2884
|
-
color:
|
|
2885
|
-
index:
|
|
2886
|
+
downsampleTerrain: Q,
|
|
2887
|
+
color: b,
|
|
2888
|
+
index: S
|
|
2886
2889
|
});
|
|
2887
2890
|
}
|
|
2888
2891
|
}, R = () => {
|
|
2889
2892
|
i?.dispose(), f.dispose(), h.dispose();
|
|
2890
|
-
},
|
|
2893
|
+
}, g = ve(t);
|
|
2891
2894
|
return {
|
|
2892
2895
|
render: A,
|
|
2893
2896
|
dispose: R,
|
|
2894
|
-
...
|
|
2897
|
+
...g,
|
|
2895
2898
|
elevation: h.get
|
|
2896
2899
|
};
|
|
2897
|
-
},
|
|
2900
|
+
}, mi = ({ gl: e, programs: t }, { uvwBuffer: n, indexBuffer: i }) => {
|
|
2898
2901
|
const r = (a = !1) => {
|
|
2899
2902
|
const c = t.get({
|
|
2900
|
-
vertexSource:
|
|
2901
|
-
fragmentSource: a ?
|
|
2902
|
-
}), f = c.attribute3f("uvw", n),
|
|
2903
|
+
vertexSource: li,
|
|
2904
|
+
fragmentSource: a ? pe : ai
|
|
2905
|
+
}), f = c.attribute3f("uvw", n), l = c.uniformMatrix4f("projection"), h = c.uniformMatrix4f("model_view"), d = c.uniform1i("imagery"), m = c.uniform1i("terrain"), p = c.uniform1i("downsample_imagery"), E = c.uniform1i("downsample_terrain"), v = c.uniform4f("color"), x = c.uniform3i("xyz"), M = c.uniform3i("camera"), _ = c.uniform1i("index");
|
|
2903
2906
|
return { execute: ({
|
|
2904
2907
|
projection: T,
|
|
2905
2908
|
modelView: A,
|
|
2906
2909
|
camera: R,
|
|
2907
|
-
xyz:
|
|
2908
|
-
imagery:
|
|
2910
|
+
xyz: g,
|
|
2911
|
+
imagery: w,
|
|
2909
2912
|
terrain: y,
|
|
2910
|
-
downsampleImagery:
|
|
2911
|
-
downsampleTerrain:
|
|
2913
|
+
downsampleImagery: S,
|
|
2914
|
+
downsampleTerrain: b,
|
|
2912
2915
|
color: U,
|
|
2913
2916
|
index: F
|
|
2914
2917
|
}) => {
|
|
2915
|
-
c.use(), f.use(),
|
|
2918
|
+
c.use(), f.use(), l.set(T), h.set(A), x.set(g), M.set(R), p.set(S), E.set(b), v.set(U), _.set(F), e.activeTexture(e.TEXTURE0), d.set(0), w.use(), e.activeTexture(e.TEXTURE1), m.set(1), y.use(), i.use(), e.drawElements(e.TRIANGLES, B * B * 2 * 3, e.UNSIGNED_SHORT, 0);
|
|
2916
2919
|
} };
|
|
2917
2920
|
}, o = r(), s = r(!0);
|
|
2918
2921
|
return { renderProgram: o, depthProgram: s };
|
|
2919
|
-
},
|
|
2922
|
+
}, pi = (e) => e.every(([t = 0, , , n = 0]) => t > n) || e.every(([t = 0, , , n = 0]) => t < -n) || e.every(([, t = 0, , n = 0]) => t > n) || e.every(([, t = 0, , n = 0]) => t < -n) || e.every(([, , t = 0, n = 0]) => t > n) || e.every(([, , t = 0]) => t < 0), vi = (e) => Math.sqrt(
|
|
2920
2923
|
e.map(
|
|
2921
|
-
(t, n) =>
|
|
2924
|
+
(t, n) => pn(
|
|
2922
2925
|
e[n] ?? [0, 0],
|
|
2923
2926
|
e[(n + 1) % e.length] ?? [0, 0]
|
|
2924
2927
|
)
|
|
2925
2928
|
).reduce((t, n) => t + n, 0) / e.length
|
|
2926
|
-
),
|
|
2927
|
-
const [n = 0, i = 0, r = 0, o = 0] = t, s = ([
|
|
2928
|
-
const M = n *
|
|
2929
|
-
return [T, A, R,
|
|
2929
|
+
), ht = (e, t) => {
|
|
2930
|
+
const [n = 0, i = 0, r = 0, o = 0] = t, s = ([l = 0, h = 0, d = 0, m = 0]) => n * l + i * h + r * d + o * m >= 0, a = ([l = 0, h = 0, d = 0, m = 0], [p = 0, E = 0, v = 0, x = 0]) => {
|
|
2931
|
+
const M = n * l + i * h + r * d + o * m, _ = n * p + i * E + r * v + o * x, u = M / (M - _), T = l + u * (p - l), A = h + u * (E - h), R = d + u * (v - d), g = m + u * (x - m);
|
|
2932
|
+
return [T, A, R, g];
|
|
2930
2933
|
}, c = [];
|
|
2931
2934
|
let f = e[e.length - 1] ?? [0, 0, 0, 0];
|
|
2932
|
-
for (const
|
|
2933
|
-
s(
|
|
2935
|
+
for (const l of e)
|
|
2936
|
+
s(l) ? (s(f) || c.push(a(f, l)), c.push(l)) : s(f) && c.push(a(f, l)), f = l;
|
|
2934
2937
|
return c;
|
|
2935
|
-
},
|
|
2938
|
+
}, xi = (e) => ht(ht(e, [0, 0, 1, 0]), [0, 0, -1, 1]), Xi = {
|
|
2936
2939
|
pickable: !0,
|
|
2937
2940
|
depth: !0,
|
|
2938
2941
|
polygonOffset: 0
|
|
2939
|
-
},
|
|
2942
|
+
}, Wi = (e, t) => {
|
|
2940
2943
|
let n;
|
|
2941
2944
|
return () => {
|
|
2942
2945
|
const i = e.map((o) => o());
|
|
@@ -2948,7 +2951,7 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2948
2951
|
const r = t(i);
|
|
2949
2952
|
return n = [i, r], r;
|
|
2950
2953
|
};
|
|
2951
|
-
},
|
|
2954
|
+
}, se = (e, t) => {
|
|
2952
2955
|
let n;
|
|
2953
2956
|
return () => {
|
|
2954
2957
|
const i = e();
|
|
@@ -2960,7 +2963,7 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2960
2963
|
const r = t(i);
|
|
2961
2964
|
return n = [i, r], r;
|
|
2962
2965
|
};
|
|
2963
|
-
},
|
|
2966
|
+
}, ve = (e) => {
|
|
2964
2967
|
const {
|
|
2965
2968
|
onClick: t,
|
|
2966
2969
|
onRightClick: n,
|
|
@@ -2981,7 +2984,7 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2981
2984
|
onDragEnd: a,
|
|
2982
2985
|
onMouseMove: c
|
|
2983
2986
|
};
|
|
2984
|
-
},
|
|
2987
|
+
}, Me = 8, Ae = 1e-3, xe = (e) => (t) => {
|
|
2985
2988
|
let n, i;
|
|
2986
2989
|
return () => {
|
|
2987
2990
|
const r = performance.now(), o = (r - (i ?? r)) / 1e3;
|
|
@@ -2989,113 +2992,96 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
2989
2992
|
const s = t();
|
|
2990
2993
|
return n = n ?? s, n = e({ time: o, current: n, target: s }), n;
|
|
2991
2994
|
};
|
|
2992
|
-
},
|
|
2993
|
-
({ time: e, current: t, target: n }) => (Math.abs(n - t) <
|
|
2994
|
-
),
|
|
2995
|
-
|
|
2995
|
+
}, Ei = xe(
|
|
2996
|
+
({ time: e, current: t, target: n }) => (Math.abs(n - t) < Ae ? t = n : t = t + (n - t) * (1 - Math.exp(-Me * e)), t)
|
|
2997
|
+
), _i = (e) => xe(({ time: t, current: n, target: i }) => (mn(n, i) < Ae ? fn(n, i) : n = un(
|
|
2998
|
+
le(),
|
|
2996
2999
|
n,
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
vn(
|
|
3000
|
-
1 - Math.exp(-
|
|
3000
|
+
dn(
|
|
3001
|
+
le(),
|
|
3002
|
+
vn(le(), i, n),
|
|
3003
|
+
1 - Math.exp(-Me * t)
|
|
3001
3004
|
)
|
|
3002
|
-
), n))(() =>
|
|
3003
|
-
|
|
3005
|
+
), n))(() => an(e())), Gi = (e) => xe(({ time: t, current: n, target: i }) => (Qt(n, i) < Ae ? $t(n, i) : n = Ht(
|
|
3006
|
+
ie(),
|
|
3004
3007
|
n,
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
1 - Math.exp(-
|
|
3008
|
+
Kt(
|
|
3009
|
+
ie(),
|
|
3010
|
+
tn(ie(), i, n),
|
|
3011
|
+
1 - Math.exp(-Me * t)
|
|
3009
3012
|
)
|
|
3010
|
-
), n))(() =>
|
|
3011
|
-
const r =
|
|
3012
|
-
return r * k <
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
1 - Math.exp(-
|
|
3013
|
+
), n))(() => dt(e())), Bi = (e) => xe(({ time: t, current: n, target: i }) => {
|
|
3014
|
+
const r = Re(L(n), L(i));
|
|
3015
|
+
return r * k < Ae || r > 1e5 / k ? ze(n, i) : n = K(
|
|
3016
|
+
Je(
|
|
3017
|
+
N(),
|
|
3018
|
+
L(n),
|
|
3019
|
+
Ke(
|
|
3020
|
+
N(),
|
|
3021
|
+
De(N(), L(i), L(n)),
|
|
3022
|
+
1 - Math.exp(-Me * t)
|
|
3020
3023
|
)
|
|
3021
3024
|
)
|
|
3022
3025
|
), n;
|
|
3023
|
-
})(() =>
|
|
3024
|
-
let
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
const
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
)
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
re(L(), t, u),
|
|
3052
|
-
0.5 * s
|
|
3053
|
-
),
|
|
3054
|
-
he(
|
|
3055
|
-
L(),
|
|
3056
|
-
oe(L(), N(c), N(a)),
|
|
3057
|
-
s
|
|
3058
|
-
)
|
|
3059
|
-
)
|
|
3060
|
-
)
|
|
3061
|
-
), t = u, a;
|
|
3062
|
-
})(() => lt(e()));
|
|
3063
|
-
}, _i = (e) => {
|
|
3064
|
-
const t = Ti(() => mt(e()));
|
|
3065
|
-
return () => _n(t());
|
|
3066
|
-
}, Ti = (e) => fe(({ time: t, current: n, target: i }) => {
|
|
3067
|
-
let r = nn(n, i);
|
|
3026
|
+
})(() => Bt(e())), ji = (e) => {
|
|
3027
|
+
let n = !1, i = N();
|
|
3028
|
+
const r = N(), o = N(), s = N(), a = N(), c = N(), f = N();
|
|
3029
|
+
let l = 0, h = 0;
|
|
3030
|
+
return () => {
|
|
3031
|
+
const d = performance.now() / 1e3;
|
|
3032
|
+
if (d === l)
|
|
3033
|
+
return K(r);
|
|
3034
|
+
const m = e();
|
|
3035
|
+
if (!n || d - l > 1 || Re(L(r), L(s)) > 1e3 / k)
|
|
3036
|
+
return n = !0, i = m, l = d, h = d, ze(r, L(i)), he(o, 0, 0, 0), ze(s, r), he(a, 0, 0, 0), K(r);
|
|
3037
|
+
if (i !== m) {
|
|
3038
|
+
i = m;
|
|
3039
|
+
const x = L(m);
|
|
3040
|
+
Ke(
|
|
3041
|
+
a,
|
|
3042
|
+
je(a, x, s),
|
|
3043
|
+
1 / (d - h)
|
|
3044
|
+
), ze(s, x), h = d;
|
|
3045
|
+
}
|
|
3046
|
+
const p = d - l, E = 1 - Math.exp(-p / 0.5), v = E * (2 - E) / 1e3;
|
|
3047
|
+
return Se(r, r, o, p), Se(f, s, a, p), je(c, f, r), Se(r, r, c, E), Se(o, o, c, v / p), l = d, K(r);
|
|
3048
|
+
};
|
|
3049
|
+
}, Ti = (e) => {
|
|
3050
|
+
const t = yi(() => vt(e()));
|
|
3051
|
+
return () => Tn(t());
|
|
3052
|
+
}, yi = (e) => xe(({ time: t, current: n, target: i }) => {
|
|
3053
|
+
let r = rn(n, i);
|
|
3068
3054
|
return isNaN(r) && (r = 0), n = Le(
|
|
3069
3055
|
Ve(),
|
|
3070
3056
|
n,
|
|
3071
3057
|
i,
|
|
3072
|
-
|
|
3073
|
-
), r <
|
|
3074
|
-
})(() =>
|
|
3075
|
-
const t =
|
|
3076
|
-
return
|
|
3077
|
-
let c =
|
|
3058
|
+
Me * Math.max(0.5, r) * t
|
|
3059
|
+
), r < Ae && (n = i), n;
|
|
3060
|
+
})(() => sn(e())), gi = 8, Vi = (e) => {
|
|
3061
|
+
const t = Ti(() => e().orientation), n = _i(() => e().offset), i = Ei(() => e().fieldOfView);
|
|
3062
|
+
return xe(({ time: o, current: s, target: a }) => {
|
|
3063
|
+
let c = Re(L(s.target), L(a.target)) * k;
|
|
3078
3064
|
c < 1e3 && (c = 0);
|
|
3079
|
-
const f = Math.max(a.distance, c),
|
|
3080
|
-
Math.log(s.distance) + (Math.log(f) - Math.log(s.distance)) *
|
|
3081
|
-
),
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3065
|
+
const f = Math.max(a.distance, c), l = 1 - Math.exp(-gi * o), h = Math.exp(
|
|
3066
|
+
Math.log(s.distance) + (Math.log(f) - Math.log(s.distance)) * l
|
|
3067
|
+
), d = s.distance > c ? 1 : s.distance / c, m = K(
|
|
3068
|
+
Je(
|
|
3069
|
+
N(),
|
|
3070
|
+
L(s.target),
|
|
3071
|
+
Ke(
|
|
3072
|
+
N(),
|
|
3073
|
+
De(
|
|
3074
|
+
N(),
|
|
3075
|
+
L(a.target),
|
|
3076
|
+
L(s.target)
|
|
3091
3077
|
),
|
|
3092
|
-
|
|
3078
|
+
l * d
|
|
3093
3079
|
)
|
|
3094
3080
|
)
|
|
3095
3081
|
);
|
|
3096
3082
|
return {
|
|
3097
3083
|
...s,
|
|
3098
|
-
target:
|
|
3084
|
+
target: m,
|
|
3099
3085
|
distance: h,
|
|
3100
3086
|
orientation: t(),
|
|
3101
3087
|
offset: n(),
|
|
@@ -3121,12 +3107,12 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
3121
3107
|
n
|
|
3122
3108
|
), e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
3123
3109
|
let o = 0;
|
|
3124
|
-
const s = ([
|
|
3110
|
+
const s = ([l = 0, h = 0]) => {
|
|
3125
3111
|
o = h, e.bindTexture(e.TEXTURE_2D, t), e.texImage2D(
|
|
3126
3112
|
e.TEXTURE_2D,
|
|
3127
3113
|
0,
|
|
3128
3114
|
e.RGBA,
|
|
3129
|
-
|
|
3115
|
+
l,
|
|
3130
3116
|
o,
|
|
3131
3117
|
0,
|
|
3132
3118
|
e.RGBA,
|
|
@@ -3135,23 +3121,23 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
3135
3121
|
), e.bindRenderbuffer(e.RENDERBUFFER, n), e.renderbufferStorage(
|
|
3136
3122
|
e.RENDERBUFFER,
|
|
3137
3123
|
e.DEPTH_COMPONENT16,
|
|
3138
|
-
|
|
3124
|
+
l,
|
|
3139
3125
|
o
|
|
3140
3126
|
);
|
|
3141
3127
|
}, a = new Uint8Array(4);
|
|
3142
3128
|
return {
|
|
3143
3129
|
use: r,
|
|
3144
3130
|
resize: s,
|
|
3145
|
-
read: ([
|
|
3146
|
-
r(), e.readPixels(
|
|
3147
|
-
const [
|
|
3131
|
+
read: ([l = 0, h = 0]) => {
|
|
3132
|
+
r(), e.readPixels(l, o - h, 1, 1, e.RGBA, e.UNSIGNED_BYTE, a), e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
3133
|
+
const [d = 0, m = 0, p = 0, E = 0] = a, x = 2 * ((d * 256 + m) / (256 * 256 - 1)) - 1, M = p * 256 + E;
|
|
3148
3134
|
return [x, M];
|
|
3149
3135
|
},
|
|
3150
3136
|
dispose: () => {
|
|
3151
3137
|
e.deleteTexture(t), e.deleteFramebuffer(i), e.deleteRenderbuffer(n);
|
|
3152
3138
|
}
|
|
3153
3139
|
};
|
|
3154
|
-
},
|
|
3140
|
+
}, Ri = (e, {
|
|
3155
3141
|
view: t,
|
|
3156
3142
|
screen: n,
|
|
3157
3143
|
pick: i
|
|
@@ -3161,110 +3147,110 @@ const B = 34, li = 22, ui = ve(0, B).flatMap(
|
|
|
3161
3147
|
const c = () => {
|
|
3162
3148
|
o = !0;
|
|
3163
3149
|
}, f = (p) => {
|
|
3164
|
-
const { x: E, y:
|
|
3150
|
+
const { x: E, y: v, movementX: x, movementY: M } = p;
|
|
3165
3151
|
if (s) {
|
|
3166
3152
|
if (s.onDrag) {
|
|
3167
|
-
const { point: A, position: R, layer:
|
|
3168
|
-
s.onDrag({ point: A, position: R, layer:
|
|
3153
|
+
const { point: A, position: R, layer: g } = i([E, v], { terrain: !0 });
|
|
3154
|
+
s.onDrag({ point: A, position: R, layer: g });
|
|
3169
3155
|
}
|
|
3170
3156
|
if (s.onDragFlat) {
|
|
3171
|
-
const R =
|
|
3172
|
-
s.onDragFlat({ point: [E,
|
|
3157
|
+
const R = ne(t(), n()).unproject([E, v], { targetZ: a });
|
|
3158
|
+
s.onDragFlat({ point: [E, v], position: R, layer: void 0 });
|
|
3173
3159
|
}
|
|
3174
3160
|
return;
|
|
3175
3161
|
}
|
|
3176
3162
|
if (o && Math.hypot(x, M) > 2 && (o = !1, p.buttons === 1)) {
|
|
3177
|
-
const { point: A, position: R, layer:
|
|
3178
|
-
(
|
|
3163
|
+
const { point: A, position: R, layer: g } = i([E, v]);
|
|
3164
|
+
(g?.onDrag || g?.onDragFlat) && (s = g, s.onDragStart?.({ point: A, position: R, layer: g }), [, , a] = R);
|
|
3179
3165
|
}
|
|
3180
|
-
const { point: _, position:
|
|
3181
|
-
T?.onMouseMove?.({ point: _, position:
|
|
3182
|
-
},
|
|
3166
|
+
const { point: _, position: u, layer: T } = i([E, v]);
|
|
3167
|
+
T?.onMouseMove?.({ point: _, position: u, layer: T });
|
|
3168
|
+
}, l = (p) => {
|
|
3183
3169
|
if (o && h(p), o = !1, s) {
|
|
3184
|
-
const { x: E, y:
|
|
3170
|
+
const { x: E, y: v } = p, { point: x, position: M, layer: _ } = i([E, v]);
|
|
3185
3171
|
s.onDragEnd?.({ point: x, position: M, layer: _ });
|
|
3186
3172
|
}
|
|
3187
3173
|
s = void 0;
|
|
3188
3174
|
}, h = (p) => {
|
|
3189
|
-
const { x: E, y:
|
|
3190
|
-
(x === 2 ?
|
|
3191
|
-
{ point: M, position: _, layer:
|
|
3175
|
+
const { x: E, y: v, button: x } = p, { point: M, position: _, layer: u } = i([E, v]);
|
|
3176
|
+
(x === 2 ? u?.onRightClick : u?.onClick)?.(
|
|
3177
|
+
{ point: M, position: _, layer: u },
|
|
3192
3178
|
p
|
|
3193
3179
|
);
|
|
3194
|
-
},
|
|
3195
|
-
const { point:
|
|
3196
|
-
M?.onDoubleClick?.({ point:
|
|
3180
|
+
}, d = ({ x: p, y: E }) => {
|
|
3181
|
+
const { point: v, position: x, layer: M } = i([p, E]);
|
|
3182
|
+
M?.onDoubleClick?.({ point: v, position: x, layer: M });
|
|
3197
3183
|
};
|
|
3198
|
-
return r?.addEventListener("mousedown", c), r?.addEventListener("mousemove", f), r?.addEventListener("dblclick",
|
|
3184
|
+
return r?.addEventListener("mousedown", c), r?.addEventListener("mousemove", f), r?.addEventListener("dblclick", d), window.addEventListener("mouseup", l), {
|
|
3199
3185
|
get dragging() {
|
|
3200
3186
|
return !!s;
|
|
3201
3187
|
},
|
|
3202
3188
|
dispose: () => {
|
|
3203
|
-
r?.removeEventListener("mousedown", c), r?.removeEventListener("mousemove", f), r?.removeEventListener("dblclick",
|
|
3189
|
+
r?.removeEventListener("mousedown", c), r?.removeEventListener("mousemove", f), r?.removeEventListener("dblclick", d), window.removeEventListener("mouseup", l);
|
|
3204
3190
|
}
|
|
3205
3191
|
};
|
|
3206
3192
|
};
|
|
3207
|
-
|
|
3208
|
-
const
|
|
3193
|
+
Nt(Array);
|
|
3194
|
+
const Zi = ({ gl: e }, t) => {
|
|
3209
3195
|
const { view: n, layers: i } = t;
|
|
3210
3196
|
let r = !0, o = [0, 0];
|
|
3211
3197
|
e.enable(e.CULL_FACE), e.cullFace(e.FRONT), e.depthFunc(e.LEQUAL);
|
|
3212
|
-
const s = wi(e), { canvas: a } = e, c = ([
|
|
3213
|
-
|
|
3198
|
+
const s = wi(e), { canvas: a } = e, c = ([u = 0, T = 0]) => {
|
|
3199
|
+
u = u || 1, T = T || 1, o = [u, T], a.width = u * devicePixelRatio, a.height = T * devicePixelRatio, s.resize([a.width, a.height]);
|
|
3214
3200
|
};
|
|
3215
3201
|
c([a.width, a.height]);
|
|
3216
|
-
const f = new ResizeObserver(([
|
|
3217
|
-
if (!
|
|
3202
|
+
const f = new ResizeObserver(([u]) => {
|
|
3203
|
+
if (!u)
|
|
3218
3204
|
return;
|
|
3219
|
-
const { contentRect: T } =
|
|
3205
|
+
const { contentRect: T } = u, { width: A, height: R } = T;
|
|
3220
3206
|
c([A, R]);
|
|
3221
3207
|
});
|
|
3222
3208
|
a instanceof HTMLCanvasElement && f.observe(a);
|
|
3223
|
-
const
|
|
3224
|
-
e.viewport(0, 0,
|
|
3209
|
+
const l = ([u = 0, T = 0]) => {
|
|
3210
|
+
e.viewport(0, 0, u * devicePixelRatio, T * devicePixelRatio), e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
|
|
3225
3211
|
}, h = () => {
|
|
3226
|
-
const
|
|
3227
|
-
|
|
3228
|
-
},
|
|
3229
|
-
const T =
|
|
3230
|
-
|
|
3212
|
+
const u = ne(n(), o);
|
|
3213
|
+
l(o), Oe(i()).forEach((T) => T.render?.({ viewport: u }));
|
|
3214
|
+
}, d = (u) => {
|
|
3215
|
+
const T = ne(n(), o);
|
|
3216
|
+
l(o), (u ? [u] : Oe(i())).forEach(
|
|
3231
3217
|
(A, R) => A.render?.({ viewport: T, depth: !0, index: R + 1 })
|
|
3232
3218
|
);
|
|
3233
|
-
},
|
|
3234
|
-
r && (h(), requestAnimationFrame(
|
|
3219
|
+
}, m = () => {
|
|
3220
|
+
r && (h(), requestAnimationFrame(m));
|
|
3235
3221
|
};
|
|
3236
|
-
requestAnimationFrame(
|
|
3237
|
-
const p = (
|
|
3238
|
-
const { screenToClip: A, clipToLocal: R, localToWorld:
|
|
3222
|
+
requestAnimationFrame(m);
|
|
3223
|
+
const p = (u) => ne(n(), o).project(u), E = (u) => ne(n(), o).unproject(u), v = (u, { terrain: T } = {}) => {
|
|
3224
|
+
const { screenToClip: A, clipToLocal: R, localToWorld: g } = ne(
|
|
3239
3225
|
n(),
|
|
3240
3226
|
o
|
|
3241
3227
|
);
|
|
3242
3228
|
s.use();
|
|
3243
|
-
const [
|
|
3244
|
-
|
|
3245
|
-
const [y = 0,
|
|
3229
|
+
const [w] = T ? i() : [];
|
|
3230
|
+
d(w);
|
|
3231
|
+
const [y = 0, S = 0] = u, [b, U] = s.read([
|
|
3246
3232
|
y * devicePixelRatio,
|
|
3247
|
-
|
|
3248
|
-
]), [F = 0, z = 0] = A(
|
|
3249
|
-
let P =
|
|
3250
|
-
const X = U === 0 ? void 0 :
|
|
3233
|
+
S * devicePixelRatio
|
|
3234
|
+
]), [F = 0, z = 0] = A(u);
|
|
3235
|
+
let P = K(g(R([F, z, b, 1])));
|
|
3236
|
+
const X = U === 0 ? void 0 : w ?? Oe(i())[U - 1];
|
|
3251
3237
|
if (T) {
|
|
3252
|
-
const [C = 0, O = 0] = P, G =
|
|
3238
|
+
const [C = 0, O = 0] = P, G = w?.elevation([C, O]) ?? 0;
|
|
3253
3239
|
P = [C, O, G];
|
|
3254
3240
|
}
|
|
3255
|
-
return { point:
|
|
3256
|
-
}, x =
|
|
3241
|
+
return { point: u, position: P, layer: X };
|
|
3242
|
+
}, x = Ri(e, {
|
|
3257
3243
|
view: n,
|
|
3258
3244
|
screen: () => o,
|
|
3259
|
-
pick:
|
|
3245
|
+
pick: v
|
|
3260
3246
|
});
|
|
3261
3247
|
return {
|
|
3262
3248
|
project: p,
|
|
3263
3249
|
unproject: E,
|
|
3264
|
-
pick:
|
|
3265
|
-
elevation: (
|
|
3250
|
+
pick: v,
|
|
3251
|
+
elevation: (u) => {
|
|
3266
3252
|
const [T] = i();
|
|
3267
|
-
return T.elevation(
|
|
3253
|
+
return T.elevation(u);
|
|
3268
3254
|
},
|
|
3269
3255
|
get dragging() {
|
|
3270
3256
|
return x.dragging;
|
|
@@ -3275,44 +3261,44 @@ const ji = ({ gl: e }, t) => {
|
|
|
3275
3261
|
};
|
|
3276
3262
|
}, Oe = (e, t = []) => e.reduce((n, i) => (Oe(i.children ?? [], n), n.push(i), n), t);
|
|
3277
3263
|
export {
|
|
3278
|
-
|
|
3279
|
-
|
|
3264
|
+
se as cache,
|
|
3265
|
+
Wi as cacheAll,
|
|
3280
3266
|
k as circumference,
|
|
3281
|
-
|
|
3267
|
+
Si as createBillboardLayer,
|
|
3282
3268
|
bi as createContainer,
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3269
|
+
Mi as createContext,
|
|
3270
|
+
Ui as createDynamicContainer,
|
|
3271
|
+
Pi as createEmptyLayer,
|
|
3272
|
+
zi as createLineLayer,
|
|
3273
|
+
ri as createMemoryTexture,
|
|
3274
|
+
Ai as createMouseControl,
|
|
3275
|
+
ve as createMouseEvents,
|
|
3276
|
+
Ei as createNumberTransition,
|
|
3277
|
+
Li as createObjectLayer,
|
|
3278
|
+
Ti as createOrientationTransition,
|
|
3279
|
+
Ni as createPolygonLayer,
|
|
3280
|
+
Bi as createPositionTransition,
|
|
3281
|
+
ji as createPositionVelocityTransition,
|
|
3282
|
+
yi as createQuaternionTransition,
|
|
3283
|
+
Ii as createRadarLayer,
|
|
3284
|
+
Fi as createRenderLayer,
|
|
3285
|
+
Ci as createTerrainLayer,
|
|
3286
|
+
xe as createTransition,
|
|
3287
|
+
_i as createVec2Transition,
|
|
3288
|
+
Gi as createVec4Transition,
|
|
3303
3289
|
Vi as createViewTransition,
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3290
|
+
Zi as createWorld,
|
|
3291
|
+
Ft as debounce,
|
|
3292
|
+
Xi as defaultLayerOptions,
|
|
3293
|
+
xt as defaultView,
|
|
3294
|
+
xn as degrees,
|
|
3295
|
+
K as geodetic,
|
|
3296
|
+
L as mercator,
|
|
3297
|
+
En as quadratic,
|
|
3312
3298
|
Ne as radians,
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3299
|
+
ue as range,
|
|
3300
|
+
pt as tileToMercator,
|
|
3301
|
+
Tn as toOrientation,
|
|
3302
|
+
vt as toQuaternion
|
|
3317
3303
|
};
|
|
3318
3304
|
//# sourceMappingURL=index.js.map
|