cool-globe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/cool-globe.cjs +9 -0
- package/dist/cool-globe.js +2532 -0
- package/dist/index.d.ts +3 -0
- package/dist/lib/CoolGlobe.constants.d.ts +6 -0
- package/dist/lib/CoolGlobe.d.ts +3 -0
- package/dist/lib/CoolGlobe.types.d.ts +28 -0
- package/dist/lib/dashboardGlobe.types.d.ts +12 -0
- package/dist/lib/dashboardGlobe.utils.d.ts +5 -0
- package/dist/lib/types.d.ts +9 -0
- package/package.json +64 -0
|
@@ -0,0 +1,2532 @@
|
|
|
1
|
+
import Lt, { useRef as oe, useState as K, useMemo as Fe, useEffect as ee } from "react";
|
|
2
|
+
import Dt from "react-globe.gl";
|
|
3
|
+
var Ee = { exports: {} }, fe = {};
|
|
4
|
+
var Ke;
|
|
5
|
+
function Ot() {
|
|
6
|
+
if (Ke) return fe;
|
|
7
|
+
Ke = 1;
|
|
8
|
+
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
|
+
function r(n, i, o) {
|
|
10
|
+
var s = null;
|
|
11
|
+
if (o !== void 0 && (s = "" + o), i.key !== void 0 && (s = "" + i.key), "key" in i) {
|
|
12
|
+
o = {};
|
|
13
|
+
for (var a in i)
|
|
14
|
+
a !== "key" && (o[a] = i[a]);
|
|
15
|
+
} else o = i;
|
|
16
|
+
return i = o.ref, {
|
|
17
|
+
$$typeof: t,
|
|
18
|
+
type: n,
|
|
19
|
+
key: s,
|
|
20
|
+
ref: i !== void 0 ? i : null,
|
|
21
|
+
props: o
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return fe.Fragment = e, fe.jsx = r, fe.jsxs = r, fe;
|
|
25
|
+
}
|
|
26
|
+
var he = {};
|
|
27
|
+
var et;
|
|
28
|
+
function Bt() {
|
|
29
|
+
return et || (et = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
|
+
function t(c) {
|
|
31
|
+
if (c == null) return null;
|
|
32
|
+
if (typeof c == "function")
|
|
33
|
+
return c.$$typeof === Q ? null : c.displayName || c.name || null;
|
|
34
|
+
if (typeof c == "string") return c;
|
|
35
|
+
switch (c) {
|
|
36
|
+
case A:
|
|
37
|
+
return "Fragment";
|
|
38
|
+
case I:
|
|
39
|
+
return "Profiler";
|
|
40
|
+
case T:
|
|
41
|
+
return "StrictMode";
|
|
42
|
+
case _:
|
|
43
|
+
return "Suspense";
|
|
44
|
+
case P:
|
|
45
|
+
return "SuspenseList";
|
|
46
|
+
case ie:
|
|
47
|
+
return "Activity";
|
|
48
|
+
}
|
|
49
|
+
if (typeof c == "object")
|
|
50
|
+
switch (typeof c.tag == "number" && console.error(
|
|
51
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
52
|
+
), c.$$typeof) {
|
|
53
|
+
case v:
|
|
54
|
+
return "Portal";
|
|
55
|
+
case R:
|
|
56
|
+
return c.displayName || "Context";
|
|
57
|
+
case B:
|
|
58
|
+
return (c._context.displayName || "Context") + ".Consumer";
|
|
59
|
+
case q:
|
|
60
|
+
var w = c.render;
|
|
61
|
+
return c = c.displayName, c || (c = w.displayName || w.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
|
|
62
|
+
case ne:
|
|
63
|
+
return w = c.displayName || null, w !== null ? w : t(c.type) || "Memo";
|
|
64
|
+
case X:
|
|
65
|
+
w = c._payload, c = c._init;
|
|
66
|
+
try {
|
|
67
|
+
return t(c(w));
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function e(c) {
|
|
74
|
+
return "" + c;
|
|
75
|
+
}
|
|
76
|
+
function r(c) {
|
|
77
|
+
try {
|
|
78
|
+
e(c);
|
|
79
|
+
var w = !1;
|
|
80
|
+
} catch {
|
|
81
|
+
w = !0;
|
|
82
|
+
}
|
|
83
|
+
if (w) {
|
|
84
|
+
w = console;
|
|
85
|
+
var k = w.error, M = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
|
|
86
|
+
return k.call(
|
|
87
|
+
w,
|
|
88
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
+
M
|
|
90
|
+
), e(c);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function n(c) {
|
|
94
|
+
if (c === A) return "<>";
|
|
95
|
+
if (typeof c == "object" && c !== null && c.$$typeof === X)
|
|
96
|
+
return "<...>";
|
|
97
|
+
try {
|
|
98
|
+
var w = t(c);
|
|
99
|
+
return w ? "<" + w + ">" : "<...>";
|
|
100
|
+
} catch {
|
|
101
|
+
return "<...>";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function i() {
|
|
105
|
+
var c = y.A;
|
|
106
|
+
return c === null ? null : c.getOwner();
|
|
107
|
+
}
|
|
108
|
+
function o() {
|
|
109
|
+
return Error("react-stack-top-frame");
|
|
110
|
+
}
|
|
111
|
+
function s(c) {
|
|
112
|
+
if (j.call(c, "key")) {
|
|
113
|
+
var w = Object.getOwnPropertyDescriptor(c, "key").get;
|
|
114
|
+
if (w && w.isReactWarning) return !1;
|
|
115
|
+
}
|
|
116
|
+
return c.key !== void 0;
|
|
117
|
+
}
|
|
118
|
+
function a(c, w) {
|
|
119
|
+
function k() {
|
|
120
|
+
Z || (Z = !0, console.error(
|
|
121
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
122
|
+
w
|
|
123
|
+
));
|
|
124
|
+
}
|
|
125
|
+
k.isReactWarning = !0, Object.defineProperty(c, "key", {
|
|
126
|
+
get: k,
|
|
127
|
+
configurable: !0
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function l() {
|
|
131
|
+
var c = t(this.type);
|
|
132
|
+
return W[c] || (W[c] = !0, console.error(
|
|
133
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
134
|
+
)), c = this.props.ref, c !== void 0 ? c : null;
|
|
135
|
+
}
|
|
136
|
+
function u(c, w, k, M, d, m) {
|
|
137
|
+
var x = k.ref;
|
|
138
|
+
return c = {
|
|
139
|
+
$$typeof: E,
|
|
140
|
+
type: c,
|
|
141
|
+
key: w,
|
|
142
|
+
props: k,
|
|
143
|
+
_owner: M
|
|
144
|
+
}, (x !== void 0 ? x : null) !== null ? Object.defineProperty(c, "ref", {
|
|
145
|
+
enumerable: !1,
|
|
146
|
+
get: l
|
|
147
|
+
}) : Object.defineProperty(c, "ref", { enumerable: !1, value: null }), c._store = {}, Object.defineProperty(c._store, "validated", {
|
|
148
|
+
configurable: !1,
|
|
149
|
+
enumerable: !1,
|
|
150
|
+
writable: !0,
|
|
151
|
+
value: 0
|
|
152
|
+
}), Object.defineProperty(c, "_debugInfo", {
|
|
153
|
+
configurable: !1,
|
|
154
|
+
enumerable: !1,
|
|
155
|
+
writable: !0,
|
|
156
|
+
value: null
|
|
157
|
+
}), Object.defineProperty(c, "_debugStack", {
|
|
158
|
+
configurable: !1,
|
|
159
|
+
enumerable: !1,
|
|
160
|
+
writable: !0,
|
|
161
|
+
value: d
|
|
162
|
+
}), Object.defineProperty(c, "_debugTask", {
|
|
163
|
+
configurable: !1,
|
|
164
|
+
enumerable: !1,
|
|
165
|
+
writable: !0,
|
|
166
|
+
value: m
|
|
167
|
+
}), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
|
|
168
|
+
}
|
|
169
|
+
function f(c, w, k, M, d, m) {
|
|
170
|
+
var x = w.children;
|
|
171
|
+
if (x !== void 0)
|
|
172
|
+
if (M)
|
|
173
|
+
if (N(x)) {
|
|
174
|
+
for (M = 0; M < x.length; M++)
|
|
175
|
+
h(x[M]);
|
|
176
|
+
Object.freeze && Object.freeze(x);
|
|
177
|
+
} else
|
|
178
|
+
console.error(
|
|
179
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
180
|
+
);
|
|
181
|
+
else h(x);
|
|
182
|
+
if (j.call(w, "key")) {
|
|
183
|
+
x = t(c);
|
|
184
|
+
var p = Object.keys(w).filter(function(C) {
|
|
185
|
+
return C !== "key";
|
|
186
|
+
});
|
|
187
|
+
M = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", L[x + M] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
189
|
+
let props = %s;
|
|
190
|
+
<%s {...props} />
|
|
191
|
+
React keys must be passed directly to JSX without using spread:
|
|
192
|
+
let props = %s;
|
|
193
|
+
<%s key={someKey} {...props} />`,
|
|
194
|
+
M,
|
|
195
|
+
x,
|
|
196
|
+
p,
|
|
197
|
+
x
|
|
198
|
+
), L[x + M] = !0);
|
|
199
|
+
}
|
|
200
|
+
if (x = null, k !== void 0 && (r(k), x = "" + k), s(w) && (r(w.key), x = "" + w.key), "key" in w) {
|
|
201
|
+
k = {};
|
|
202
|
+
for (var b in w)
|
|
203
|
+
b !== "key" && (k[b] = w[b]);
|
|
204
|
+
} else k = w;
|
|
205
|
+
return x && a(
|
|
206
|
+
k,
|
|
207
|
+
typeof c == "function" ? c.displayName || c.name || "Unknown" : c
|
|
208
|
+
), u(
|
|
209
|
+
c,
|
|
210
|
+
x,
|
|
211
|
+
k,
|
|
212
|
+
i(),
|
|
213
|
+
d,
|
|
214
|
+
m
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function h(c) {
|
|
218
|
+
g(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === X && (c._payload.status === "fulfilled" ? g(c._payload.value) && c._payload.value._store && (c._payload.value._store.validated = 1) : c._store && (c._store.validated = 1));
|
|
219
|
+
}
|
|
220
|
+
function g(c) {
|
|
221
|
+
return typeof c == "object" && c !== null && c.$$typeof === E;
|
|
222
|
+
}
|
|
223
|
+
var F = Lt, E = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), A = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), I = /* @__PURE__ */ Symbol.for("react.profiler"), B = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), q = /* @__PURE__ */ Symbol.for("react.forward_ref"), _ = /* @__PURE__ */ Symbol.for("react.suspense"), P = /* @__PURE__ */ Symbol.for("react.suspense_list"), ne = /* @__PURE__ */ Symbol.for("react.memo"), X = /* @__PURE__ */ Symbol.for("react.lazy"), ie = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), y = F.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, N = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
224
|
+
return null;
|
|
225
|
+
};
|
|
226
|
+
F = {
|
|
227
|
+
react_stack_bottom_frame: function(c) {
|
|
228
|
+
return c();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var Z, W = {}, z = F.react_stack_bottom_frame.bind(
|
|
232
|
+
F,
|
|
233
|
+
o
|
|
234
|
+
)(), U = $(n(o)), L = {};
|
|
235
|
+
he.Fragment = A, he.jsx = function(c, w, k) {
|
|
236
|
+
var M = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return f(
|
|
238
|
+
c,
|
|
239
|
+
w,
|
|
240
|
+
k,
|
|
241
|
+
!1,
|
|
242
|
+
M ? Error("react-stack-top-frame") : z,
|
|
243
|
+
M ? $(n(c)) : U
|
|
244
|
+
);
|
|
245
|
+
}, he.jsxs = function(c, w, k) {
|
|
246
|
+
var M = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return f(
|
|
248
|
+
c,
|
|
249
|
+
w,
|
|
250
|
+
k,
|
|
251
|
+
!0,
|
|
252
|
+
M ? Error("react-stack-top-frame") : z,
|
|
253
|
+
M ? $(n(c)) : U
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
})()), he;
|
|
257
|
+
}
|
|
258
|
+
var tt;
|
|
259
|
+
function Pt() {
|
|
260
|
+
return tt || (tt = 1, process.env.NODE_ENV === "production" ? Ee.exports = Ot() : Ee.exports = Bt()), Ee.exports;
|
|
261
|
+
}
|
|
262
|
+
var rt = Pt();
|
|
263
|
+
function jt(t) {
|
|
264
|
+
return t;
|
|
265
|
+
}
|
|
266
|
+
function It(t) {
|
|
267
|
+
if (t == null) return jt;
|
|
268
|
+
var e, r, n = t.scale[0], i = t.scale[1], o = t.translate[0], s = t.translate[1];
|
|
269
|
+
return function(a, l) {
|
|
270
|
+
l || (e = r = 0);
|
|
271
|
+
var u = 2, f = a.length, h = new Array(f);
|
|
272
|
+
for (h[0] = (e += a[0]) * n + o, h[1] = (r += a[1]) * i + s; u < f; ) h[u] = a[u], ++u;
|
|
273
|
+
return h;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function Ht(t, e) {
|
|
277
|
+
for (var r, n = t.length, i = n - e; i < --n; ) r = t[i], t[i++] = t[n], t[n] = r;
|
|
278
|
+
}
|
|
279
|
+
function Gt(t, e) {
|
|
280
|
+
return typeof e == "string" && (e = t.objects[e]), e.type === "GeometryCollection" ? { type: "FeatureCollection", features: e.geometries.map(function(r) {
|
|
281
|
+
return nt(t, r);
|
|
282
|
+
}) } : nt(t, e);
|
|
283
|
+
}
|
|
284
|
+
function nt(t, e) {
|
|
285
|
+
var r = e.id, n = e.bbox, i = e.properties == null ? {} : e.properties, o = Yt(t, e);
|
|
286
|
+
return r == null && n == null ? { type: "Feature", properties: i, geometry: o } : n == null ? { type: "Feature", id: r, properties: i, geometry: o } : { type: "Feature", id: r, bbox: n, properties: i, geometry: o };
|
|
287
|
+
}
|
|
288
|
+
function Yt(t, e) {
|
|
289
|
+
var r = It(t.transform), n = t.arcs;
|
|
290
|
+
function i(f, h) {
|
|
291
|
+
h.length && h.pop();
|
|
292
|
+
for (var g = n[f < 0 ? ~f : f], F = 0, E = g.length; F < E; ++F)
|
|
293
|
+
h.push(r(g[F], F));
|
|
294
|
+
f < 0 && Ht(h, E);
|
|
295
|
+
}
|
|
296
|
+
function o(f) {
|
|
297
|
+
return r(f);
|
|
298
|
+
}
|
|
299
|
+
function s(f) {
|
|
300
|
+
for (var h = [], g = 0, F = f.length; g < F; ++g) i(f[g], h);
|
|
301
|
+
return h.length < 2 && h.push(h[0]), h;
|
|
302
|
+
}
|
|
303
|
+
function a(f) {
|
|
304
|
+
for (var h = s(f); h.length < 4; ) h.push(h[0]);
|
|
305
|
+
return h;
|
|
306
|
+
}
|
|
307
|
+
function l(f) {
|
|
308
|
+
return f.map(a);
|
|
309
|
+
}
|
|
310
|
+
function u(f) {
|
|
311
|
+
var h = f.type, g;
|
|
312
|
+
switch (h) {
|
|
313
|
+
case "GeometryCollection":
|
|
314
|
+
return { type: h, geometries: f.geometries.map(u) };
|
|
315
|
+
case "Point":
|
|
316
|
+
g = o(f.coordinates);
|
|
317
|
+
break;
|
|
318
|
+
case "MultiPoint":
|
|
319
|
+
g = f.coordinates.map(o);
|
|
320
|
+
break;
|
|
321
|
+
case "LineString":
|
|
322
|
+
g = s(f.arcs);
|
|
323
|
+
break;
|
|
324
|
+
case "MultiLineString":
|
|
325
|
+
g = f.arcs.map(s);
|
|
326
|
+
break;
|
|
327
|
+
case "Polygon":
|
|
328
|
+
g = l(f.arcs);
|
|
329
|
+
break;
|
|
330
|
+
case "MultiPolygon":
|
|
331
|
+
g = f.arcs.map(l);
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
return { type: h, coordinates: g };
|
|
337
|
+
}
|
|
338
|
+
return u(e);
|
|
339
|
+
}
|
|
340
|
+
const Ct = "180", qt = "", G = "srgb", it = "srgb-linear", ot = "linear", Oe = "srgb";
|
|
341
|
+
function de(t, e, r) {
|
|
342
|
+
return Math.max(e, Math.min(r, t));
|
|
343
|
+
}
|
|
344
|
+
function zt(t, e) {
|
|
345
|
+
return (t % e + e) % e;
|
|
346
|
+
}
|
|
347
|
+
function Be(t, e, r) {
|
|
348
|
+
return (1 - r) * t + r * e;
|
|
349
|
+
}
|
|
350
|
+
class be {
|
|
351
|
+
/**
|
|
352
|
+
* Constructs a new 3x3 matrix. The arguments are supposed to be
|
|
353
|
+
* in row-major order. If no arguments are provided, the constructor
|
|
354
|
+
* initializes the matrix as an identity matrix.
|
|
355
|
+
*
|
|
356
|
+
* @param {number} [n11] - 1-1 matrix element.
|
|
357
|
+
* @param {number} [n12] - 1-2 matrix element.
|
|
358
|
+
* @param {number} [n13] - 1-3 matrix element.
|
|
359
|
+
* @param {number} [n21] - 2-1 matrix element.
|
|
360
|
+
* @param {number} [n22] - 2-2 matrix element.
|
|
361
|
+
* @param {number} [n23] - 2-3 matrix element.
|
|
362
|
+
* @param {number} [n31] - 3-1 matrix element.
|
|
363
|
+
* @param {number} [n32] - 3-2 matrix element.
|
|
364
|
+
* @param {number} [n33] - 3-3 matrix element.
|
|
365
|
+
*/
|
|
366
|
+
constructor(e, r, n, i, o, s, a, l, u) {
|
|
367
|
+
be.prototype.isMatrix3 = !0, this.elements = [
|
|
368
|
+
1,
|
|
369
|
+
0,
|
|
370
|
+
0,
|
|
371
|
+
0,
|
|
372
|
+
1,
|
|
373
|
+
0,
|
|
374
|
+
0,
|
|
375
|
+
0,
|
|
376
|
+
1
|
|
377
|
+
], e !== void 0 && this.set(e, r, n, i, o, s, a, l, u);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Sets the elements of the matrix.The arguments are supposed to be
|
|
381
|
+
* in row-major order.
|
|
382
|
+
*
|
|
383
|
+
* @param {number} [n11] - 1-1 matrix element.
|
|
384
|
+
* @param {number} [n12] - 1-2 matrix element.
|
|
385
|
+
* @param {number} [n13] - 1-3 matrix element.
|
|
386
|
+
* @param {number} [n21] - 2-1 matrix element.
|
|
387
|
+
* @param {number} [n22] - 2-2 matrix element.
|
|
388
|
+
* @param {number} [n23] - 2-3 matrix element.
|
|
389
|
+
* @param {number} [n31] - 3-1 matrix element.
|
|
390
|
+
* @param {number} [n32] - 3-2 matrix element.
|
|
391
|
+
* @param {number} [n33] - 3-3 matrix element.
|
|
392
|
+
* @return {Matrix3} A reference to this matrix.
|
|
393
|
+
*/
|
|
394
|
+
set(e, r, n, i, o, s, a, l, u) {
|
|
395
|
+
const f = this.elements;
|
|
396
|
+
return f[0] = e, f[1] = i, f[2] = a, f[3] = r, f[4] = o, f[5] = l, f[6] = n, f[7] = s, f[8] = u, this;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Sets this matrix to the 3x3 identity matrix.
|
|
400
|
+
*
|
|
401
|
+
* @return {Matrix3} A reference to this matrix.
|
|
402
|
+
*/
|
|
403
|
+
identity() {
|
|
404
|
+
return this.set(
|
|
405
|
+
1,
|
|
406
|
+
0,
|
|
407
|
+
0,
|
|
408
|
+
0,
|
|
409
|
+
1,
|
|
410
|
+
0,
|
|
411
|
+
0,
|
|
412
|
+
0,
|
|
413
|
+
1
|
|
414
|
+
), this;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Copies the values of the given matrix to this instance.
|
|
418
|
+
*
|
|
419
|
+
* @param {Matrix3} m - The matrix to copy.
|
|
420
|
+
* @return {Matrix3} A reference to this matrix.
|
|
421
|
+
*/
|
|
422
|
+
copy(e) {
|
|
423
|
+
const r = this.elements, n = e.elements;
|
|
424
|
+
return r[0] = n[0], r[1] = n[1], r[2] = n[2], r[3] = n[3], r[4] = n[4], r[5] = n[5], r[6] = n[6], r[7] = n[7], r[8] = n[8], this;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Extracts the basis of this matrix into the three axis vectors provided.
|
|
428
|
+
*
|
|
429
|
+
* @param {Vector3} xAxis - The basis's x axis.
|
|
430
|
+
* @param {Vector3} yAxis - The basis's y axis.
|
|
431
|
+
* @param {Vector3} zAxis - The basis's z axis.
|
|
432
|
+
* @return {Matrix3} A reference to this matrix.
|
|
433
|
+
*/
|
|
434
|
+
extractBasis(e, r, n) {
|
|
435
|
+
return e.setFromMatrix3Column(this, 0), r.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.
|
|
439
|
+
*
|
|
440
|
+
* @param {Matrix4} m - The 4x4 matrix.
|
|
441
|
+
* @return {Matrix3} A reference to this matrix.
|
|
442
|
+
*/
|
|
443
|
+
setFromMatrix4(e) {
|
|
444
|
+
const r = e.elements;
|
|
445
|
+
return this.set(
|
|
446
|
+
r[0],
|
|
447
|
+
r[4],
|
|
448
|
+
r[8],
|
|
449
|
+
r[1],
|
|
450
|
+
r[5],
|
|
451
|
+
r[9],
|
|
452
|
+
r[2],
|
|
453
|
+
r[6],
|
|
454
|
+
r[10]
|
|
455
|
+
), this;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Post-multiplies this matrix by the given 3x3 matrix.
|
|
459
|
+
*
|
|
460
|
+
* @param {Matrix3} m - The matrix to multiply with.
|
|
461
|
+
* @return {Matrix3} A reference to this matrix.
|
|
462
|
+
*/
|
|
463
|
+
multiply(e) {
|
|
464
|
+
return this.multiplyMatrices(this, e);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Pre-multiplies this matrix by the given 3x3 matrix.
|
|
468
|
+
*
|
|
469
|
+
* @param {Matrix3} m - The matrix to multiply with.
|
|
470
|
+
* @return {Matrix3} A reference to this matrix.
|
|
471
|
+
*/
|
|
472
|
+
premultiply(e) {
|
|
473
|
+
return this.multiplyMatrices(e, this);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Multiples the given 3x3 matrices and stores the result
|
|
477
|
+
* in this matrix.
|
|
478
|
+
*
|
|
479
|
+
* @param {Matrix3} a - The first matrix.
|
|
480
|
+
* @param {Matrix3} b - The second matrix.
|
|
481
|
+
* @return {Matrix3} A reference to this matrix.
|
|
482
|
+
*/
|
|
483
|
+
multiplyMatrices(e, r) {
|
|
484
|
+
const n = e.elements, i = r.elements, o = this.elements, s = n[0], a = n[3], l = n[6], u = n[1], f = n[4], h = n[7], g = n[2], F = n[5], E = n[8], v = i[0], A = i[3], T = i[6], I = i[1], B = i[4], R = i[7], q = i[2], _ = i[5], P = i[8];
|
|
485
|
+
return o[0] = s * v + a * I + l * q, o[3] = s * A + a * B + l * _, o[6] = s * T + a * R + l * P, o[1] = u * v + f * I + h * q, o[4] = u * A + f * B + h * _, o[7] = u * T + f * R + h * P, o[2] = g * v + F * I + E * q, o[5] = g * A + F * B + E * _, o[8] = g * T + F * R + E * P, this;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Multiplies every component of the matrix by the given scalar.
|
|
489
|
+
*
|
|
490
|
+
* @param {number} s - The scalar.
|
|
491
|
+
* @return {Matrix3} A reference to this matrix.
|
|
492
|
+
*/
|
|
493
|
+
multiplyScalar(e) {
|
|
494
|
+
const r = this.elements;
|
|
495
|
+
return r[0] *= e, r[3] *= e, r[6] *= e, r[1] *= e, r[4] *= e, r[7] *= e, r[2] *= e, r[5] *= e, r[8] *= e, this;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Computes and returns the determinant of this matrix.
|
|
499
|
+
*
|
|
500
|
+
* @return {number} The determinant.
|
|
501
|
+
*/
|
|
502
|
+
determinant() {
|
|
503
|
+
const e = this.elements, r = e[0], n = e[1], i = e[2], o = e[3], s = e[4], a = e[5], l = e[6], u = e[7], f = e[8];
|
|
504
|
+
return r * s * f - r * a * u - n * o * f + n * a * l + i * o * u - i * s * l;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Inverts this matrix, using the [analytic method]{@link https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution}.
|
|
508
|
+
* You can not invert with a determinant of zero. If you attempt this, the method produces
|
|
509
|
+
* a zero matrix instead.
|
|
510
|
+
*
|
|
511
|
+
* @return {Matrix3} A reference to this matrix.
|
|
512
|
+
*/
|
|
513
|
+
invert() {
|
|
514
|
+
const e = this.elements, r = e[0], n = e[1], i = e[2], o = e[3], s = e[4], a = e[5], l = e[6], u = e[7], f = e[8], h = f * s - a * u, g = a * l - f * o, F = u * o - s * l, E = r * h + n * g + i * F;
|
|
515
|
+
if (E === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
516
|
+
const v = 1 / E;
|
|
517
|
+
return e[0] = h * v, e[1] = (i * u - f * n) * v, e[2] = (a * n - i * s) * v, e[3] = g * v, e[4] = (f * r - i * l) * v, e[5] = (i * o - a * r) * v, e[6] = F * v, e[7] = (n * l - u * r) * v, e[8] = (s * r - n * o) * v, this;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Transposes this matrix in place.
|
|
521
|
+
*
|
|
522
|
+
* @return {Matrix3} A reference to this matrix.
|
|
523
|
+
*/
|
|
524
|
+
transpose() {
|
|
525
|
+
let e;
|
|
526
|
+
const r = this.elements;
|
|
527
|
+
return e = r[1], r[1] = r[3], r[3] = e, e = r[2], r[2] = r[6], r[6] = e, e = r[5], r[5] = r[7], r[7] = e, this;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Computes the normal matrix which is the inverse transpose of the upper
|
|
531
|
+
* left 3x3 portion of the given 4x4 matrix.
|
|
532
|
+
*
|
|
533
|
+
* @param {Matrix4} matrix4 - The 4x4 matrix.
|
|
534
|
+
* @return {Matrix3} A reference to this matrix.
|
|
535
|
+
*/
|
|
536
|
+
getNormalMatrix(e) {
|
|
537
|
+
return this.setFromMatrix4(e).invert().transpose();
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Transposes this matrix into the supplied array, and returns itself unchanged.
|
|
541
|
+
*
|
|
542
|
+
* @param {Array<number>} r - An array to store the transposed matrix elements.
|
|
543
|
+
* @return {Matrix3} A reference to this matrix.
|
|
544
|
+
*/
|
|
545
|
+
transposeIntoArray(e) {
|
|
546
|
+
const r = this.elements;
|
|
547
|
+
return e[0] = r[0], e[1] = r[3], e[2] = r[6], e[3] = r[1], e[4] = r[4], e[5] = r[7], e[6] = r[2], e[7] = r[5], e[8] = r[8], this;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Sets the UV transform matrix from offset, repeat, rotation, and center.
|
|
551
|
+
*
|
|
552
|
+
* @param {number} tx - Offset x.
|
|
553
|
+
* @param {number} ty - Offset y.
|
|
554
|
+
* @param {number} sx - Repeat x.
|
|
555
|
+
* @param {number} sy - Repeat y.
|
|
556
|
+
* @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.
|
|
557
|
+
* @param {number} cx - Center x of rotation.
|
|
558
|
+
* @param {number} cy - Center y of rotation
|
|
559
|
+
* @return {Matrix3} A reference to this matrix.
|
|
560
|
+
*/
|
|
561
|
+
setUvTransform(e, r, n, i, o, s, a) {
|
|
562
|
+
const l = Math.cos(o), u = Math.sin(o);
|
|
563
|
+
return this.set(
|
|
564
|
+
n * l,
|
|
565
|
+
n * u,
|
|
566
|
+
-n * (l * s + u * a) + s + e,
|
|
567
|
+
-i * u,
|
|
568
|
+
i * l,
|
|
569
|
+
-i * (-u * s + l * a) + a + r,
|
|
570
|
+
0,
|
|
571
|
+
0,
|
|
572
|
+
1
|
|
573
|
+
), this;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Scales this matrix with the given scalar values.
|
|
577
|
+
*
|
|
578
|
+
* @param {number} sx - The amount to scale in the X axis.
|
|
579
|
+
* @param {number} sy - The amount to scale in the Y axis.
|
|
580
|
+
* @return {Matrix3} A reference to this matrix.
|
|
581
|
+
*/
|
|
582
|
+
scale(e, r) {
|
|
583
|
+
return this.premultiply(Pe.makeScale(e, r)), this;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Rotates this matrix by the given angle.
|
|
587
|
+
*
|
|
588
|
+
* @param {number} theta - The rotation in radians.
|
|
589
|
+
* @return {Matrix3} A reference to this matrix.
|
|
590
|
+
*/
|
|
591
|
+
rotate(e) {
|
|
592
|
+
return this.premultiply(Pe.makeRotation(-e)), this;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Translates this matrix by the given scalar values.
|
|
596
|
+
*
|
|
597
|
+
* @param {number} tx - The amount to translate in the X axis.
|
|
598
|
+
* @param {number} ty - The amount to translate in the Y axis.
|
|
599
|
+
* @return {Matrix3} A reference to this matrix.
|
|
600
|
+
*/
|
|
601
|
+
translate(e, r) {
|
|
602
|
+
return this.premultiply(Pe.makeTranslation(e, r)), this;
|
|
603
|
+
}
|
|
604
|
+
// for 2D Transforms
|
|
605
|
+
/**
|
|
606
|
+
* Sets this matrix as a 2D translation transform.
|
|
607
|
+
*
|
|
608
|
+
* @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.
|
|
609
|
+
* @param {number} y - The amount to translate in the Y axis.
|
|
610
|
+
* @return {Matrix3} A reference to this matrix.
|
|
611
|
+
*/
|
|
612
|
+
makeTranslation(e, r) {
|
|
613
|
+
return e.isVector2 ? this.set(
|
|
614
|
+
1,
|
|
615
|
+
0,
|
|
616
|
+
e.x,
|
|
617
|
+
0,
|
|
618
|
+
1,
|
|
619
|
+
e.y,
|
|
620
|
+
0,
|
|
621
|
+
0,
|
|
622
|
+
1
|
|
623
|
+
) : this.set(
|
|
624
|
+
1,
|
|
625
|
+
0,
|
|
626
|
+
e,
|
|
627
|
+
0,
|
|
628
|
+
1,
|
|
629
|
+
r,
|
|
630
|
+
0,
|
|
631
|
+
0,
|
|
632
|
+
1
|
|
633
|
+
), this;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Sets this matrix as a 2D rotational transformation.
|
|
637
|
+
*
|
|
638
|
+
* @param {number} theta - The rotation in radians.
|
|
639
|
+
* @return {Matrix3} A reference to this matrix.
|
|
640
|
+
*/
|
|
641
|
+
makeRotation(e) {
|
|
642
|
+
const r = Math.cos(e), n = Math.sin(e);
|
|
643
|
+
return this.set(
|
|
644
|
+
r,
|
|
645
|
+
-n,
|
|
646
|
+
0,
|
|
647
|
+
n,
|
|
648
|
+
r,
|
|
649
|
+
0,
|
|
650
|
+
0,
|
|
651
|
+
0,
|
|
652
|
+
1
|
|
653
|
+
), this;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Sets this matrix as a 2D scale transform.
|
|
657
|
+
*
|
|
658
|
+
* @param {number} x - The amount to scale in the X axis.
|
|
659
|
+
* @param {number} y - The amount to scale in the Y axis.
|
|
660
|
+
* @return {Matrix3} A reference to this matrix.
|
|
661
|
+
*/
|
|
662
|
+
makeScale(e, r) {
|
|
663
|
+
return this.set(
|
|
664
|
+
e,
|
|
665
|
+
0,
|
|
666
|
+
0,
|
|
667
|
+
0,
|
|
668
|
+
r,
|
|
669
|
+
0,
|
|
670
|
+
0,
|
|
671
|
+
0,
|
|
672
|
+
1
|
|
673
|
+
), this;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Returns `true` if this matrix is equal with the given one.
|
|
677
|
+
*
|
|
678
|
+
* @param {Matrix3} matrix - The matrix to test for equality.
|
|
679
|
+
* @return {boolean} Whether this matrix is equal with the given one.
|
|
680
|
+
*/
|
|
681
|
+
equals(e) {
|
|
682
|
+
const r = this.elements, n = e.elements;
|
|
683
|
+
for (let i = 0; i < 9; i++)
|
|
684
|
+
if (r[i] !== n[i]) return !1;
|
|
685
|
+
return !0;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Sets the elements of the matrix from the given array.
|
|
689
|
+
*
|
|
690
|
+
* @param {Array<number>} array - The matrix elements in column-major order.
|
|
691
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
692
|
+
* @return {Matrix3} A reference to this matrix.
|
|
693
|
+
*/
|
|
694
|
+
fromArray(e, r = 0) {
|
|
695
|
+
for (let n = 0; n < 9; n++)
|
|
696
|
+
this.elements[n] = e[n + r];
|
|
697
|
+
return this;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Writes the elements of this matrix to the given array. If no array is provided,
|
|
701
|
+
* the method returns a new instance.
|
|
702
|
+
*
|
|
703
|
+
* @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.
|
|
704
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
705
|
+
* @return {Array<number>} The matrix elements in column-major order.
|
|
706
|
+
*/
|
|
707
|
+
toArray(e = [], r = 0) {
|
|
708
|
+
const n = this.elements;
|
|
709
|
+
return e[r] = n[0], e[r + 1] = n[1], e[r + 2] = n[2], e[r + 3] = n[3], e[r + 4] = n[4], e[r + 5] = n[5], e[r + 6] = n[6], e[r + 7] = n[7], e[r + 8] = n[8], e;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Returns a matrix with copied values from this instance.
|
|
713
|
+
*
|
|
714
|
+
* @return {Matrix3} A clone of this instance.
|
|
715
|
+
*/
|
|
716
|
+
clone() {
|
|
717
|
+
return new this.constructor().fromArray(this.elements);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
const Pe = /* @__PURE__ */ new be(), st = {};
|
|
721
|
+
function at(t) {
|
|
722
|
+
t in st || (st[t] = !0, console.warn(t));
|
|
723
|
+
}
|
|
724
|
+
const ut = /* @__PURE__ */ new be().set(
|
|
725
|
+
0.4123908,
|
|
726
|
+
0.3575843,
|
|
727
|
+
0.1804808,
|
|
728
|
+
0.212639,
|
|
729
|
+
0.7151687,
|
|
730
|
+
0.0721923,
|
|
731
|
+
0.0193308,
|
|
732
|
+
0.1191948,
|
|
733
|
+
0.9505322
|
|
734
|
+
), ct = /* @__PURE__ */ new be().set(
|
|
735
|
+
3.2409699,
|
|
736
|
+
-1.5373832,
|
|
737
|
+
-0.4986108,
|
|
738
|
+
-0.9692436,
|
|
739
|
+
1.8759675,
|
|
740
|
+
0.0415551,
|
|
741
|
+
0.0556301,
|
|
742
|
+
-0.203977,
|
|
743
|
+
1.0569715
|
|
744
|
+
);
|
|
745
|
+
function Ut() {
|
|
746
|
+
const t = {
|
|
747
|
+
enabled: !0,
|
|
748
|
+
workingColorSpace: it,
|
|
749
|
+
/**
|
|
750
|
+
* Implementations of supported color spaces.
|
|
751
|
+
*
|
|
752
|
+
* Required:
|
|
753
|
+
* - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
|
|
754
|
+
* - whitePoint: reference white [ x y ]
|
|
755
|
+
* - transfer: transfer function (pre-defined)
|
|
756
|
+
* - toXYZ: Matrix3 RGB to XYZ transform
|
|
757
|
+
* - fromXYZ: Matrix3 XYZ to RGB transform
|
|
758
|
+
* - luminanceCoefficients: RGB luminance coefficients
|
|
759
|
+
*
|
|
760
|
+
* Optional:
|
|
761
|
+
* - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
|
|
762
|
+
* - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
|
|
763
|
+
*
|
|
764
|
+
* Reference:
|
|
765
|
+
* - https://www.russellcottrell.com/photo/matrixCalculator.htm
|
|
766
|
+
*/
|
|
767
|
+
spaces: {},
|
|
768
|
+
convert: function(i, o, s) {
|
|
769
|
+
return this.enabled === !1 || o === s || !o || !s || (this.spaces[o].transfer === Oe && (i.r = ae(i.r), i.g = ae(i.g), i.b = ae(i.b)), this.spaces[o].primaries !== this.spaces[s].primaries && (i.applyMatrix3(this.spaces[o].toXYZ), i.applyMatrix3(this.spaces[s].fromXYZ)), this.spaces[s].transfer === Oe && (i.r = ue(i.r), i.g = ue(i.g), i.b = ue(i.b))), i;
|
|
770
|
+
},
|
|
771
|
+
workingToColorSpace: function(i, o) {
|
|
772
|
+
return this.convert(i, this.workingColorSpace, o);
|
|
773
|
+
},
|
|
774
|
+
colorSpaceToWorking: function(i, o) {
|
|
775
|
+
return this.convert(i, o, this.workingColorSpace);
|
|
776
|
+
},
|
|
777
|
+
getPrimaries: function(i) {
|
|
778
|
+
return this.spaces[i].primaries;
|
|
779
|
+
},
|
|
780
|
+
getTransfer: function(i) {
|
|
781
|
+
return i === qt ? ot : this.spaces[i].transfer;
|
|
782
|
+
},
|
|
783
|
+
getToneMappingMode: function(i) {
|
|
784
|
+
return this.spaces[i].outputColorSpaceConfig.toneMappingMode || "standard";
|
|
785
|
+
},
|
|
786
|
+
getLuminanceCoefficients: function(i, o = this.workingColorSpace) {
|
|
787
|
+
return i.fromArray(this.spaces[o].luminanceCoefficients);
|
|
788
|
+
},
|
|
789
|
+
define: function(i) {
|
|
790
|
+
Object.assign(this.spaces, i);
|
|
791
|
+
},
|
|
792
|
+
// Internal APIs
|
|
793
|
+
_getMatrix: function(i, o, s) {
|
|
794
|
+
return i.copy(this.spaces[o].toXYZ).multiply(this.spaces[s].fromXYZ);
|
|
795
|
+
},
|
|
796
|
+
_getDrawingBufferColorSpace: function(i) {
|
|
797
|
+
return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace;
|
|
798
|
+
},
|
|
799
|
+
_getUnpackColorSpace: function(i = this.workingColorSpace) {
|
|
800
|
+
return this.spaces[i].workingColorSpaceConfig.unpackColorSpace;
|
|
801
|
+
},
|
|
802
|
+
// Deprecated
|
|
803
|
+
fromWorkingColorSpace: function(i, o) {
|
|
804
|
+
return at("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), t.workingToColorSpace(i, o);
|
|
805
|
+
},
|
|
806
|
+
toWorkingColorSpace: function(i, o) {
|
|
807
|
+
return at("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), t.colorSpaceToWorking(i, o);
|
|
808
|
+
}
|
|
809
|
+
}, e = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], r = [0.2126, 0.7152, 0.0722], n = [0.3127, 0.329];
|
|
810
|
+
return t.define({
|
|
811
|
+
[it]: {
|
|
812
|
+
primaries: e,
|
|
813
|
+
whitePoint: n,
|
|
814
|
+
transfer: ot,
|
|
815
|
+
toXYZ: ut,
|
|
816
|
+
fromXYZ: ct,
|
|
817
|
+
luminanceCoefficients: r,
|
|
818
|
+
workingColorSpaceConfig: { unpackColorSpace: G },
|
|
819
|
+
outputColorSpaceConfig: { drawingBufferColorSpace: G }
|
|
820
|
+
},
|
|
821
|
+
[G]: {
|
|
822
|
+
primaries: e,
|
|
823
|
+
whitePoint: n,
|
|
824
|
+
transfer: Oe,
|
|
825
|
+
toXYZ: ut,
|
|
826
|
+
fromXYZ: ct,
|
|
827
|
+
luminanceCoefficients: r,
|
|
828
|
+
outputColorSpaceConfig: { drawingBufferColorSpace: G }
|
|
829
|
+
}
|
|
830
|
+
}), t;
|
|
831
|
+
}
|
|
832
|
+
const H = /* @__PURE__ */ Ut();
|
|
833
|
+
function ae(t) {
|
|
834
|
+
return t < 0.04045 ? t * 0.0773993808 : Math.pow(t * 0.9478672986 + 0.0521327014, 2.4);
|
|
835
|
+
}
|
|
836
|
+
function ue(t) {
|
|
837
|
+
return t < 31308e-7 ? t * 12.92 : 1.055 * Math.pow(t, 0.41666) - 0.055;
|
|
838
|
+
}
|
|
839
|
+
const _t = {
|
|
840
|
+
aliceblue: 15792383,
|
|
841
|
+
antiquewhite: 16444375,
|
|
842
|
+
aqua: 65535,
|
|
843
|
+
aquamarine: 8388564,
|
|
844
|
+
azure: 15794175,
|
|
845
|
+
beige: 16119260,
|
|
846
|
+
bisque: 16770244,
|
|
847
|
+
black: 0,
|
|
848
|
+
blanchedalmond: 16772045,
|
|
849
|
+
blue: 255,
|
|
850
|
+
blueviolet: 9055202,
|
|
851
|
+
brown: 10824234,
|
|
852
|
+
burlywood: 14596231,
|
|
853
|
+
cadetblue: 6266528,
|
|
854
|
+
chartreuse: 8388352,
|
|
855
|
+
chocolate: 13789470,
|
|
856
|
+
coral: 16744272,
|
|
857
|
+
cornflowerblue: 6591981,
|
|
858
|
+
cornsilk: 16775388,
|
|
859
|
+
crimson: 14423100,
|
|
860
|
+
cyan: 65535,
|
|
861
|
+
darkblue: 139,
|
|
862
|
+
darkcyan: 35723,
|
|
863
|
+
darkgoldenrod: 12092939,
|
|
864
|
+
darkgray: 11119017,
|
|
865
|
+
darkgreen: 25600,
|
|
866
|
+
darkgrey: 11119017,
|
|
867
|
+
darkkhaki: 12433259,
|
|
868
|
+
darkmagenta: 9109643,
|
|
869
|
+
darkolivegreen: 5597999,
|
|
870
|
+
darkorange: 16747520,
|
|
871
|
+
darkorchid: 10040012,
|
|
872
|
+
darkred: 9109504,
|
|
873
|
+
darksalmon: 15308410,
|
|
874
|
+
darkseagreen: 9419919,
|
|
875
|
+
darkslateblue: 4734347,
|
|
876
|
+
darkslategray: 3100495,
|
|
877
|
+
darkslategrey: 3100495,
|
|
878
|
+
darkturquoise: 52945,
|
|
879
|
+
darkviolet: 9699539,
|
|
880
|
+
deeppink: 16716947,
|
|
881
|
+
deepskyblue: 49151,
|
|
882
|
+
dimgray: 6908265,
|
|
883
|
+
dimgrey: 6908265,
|
|
884
|
+
dodgerblue: 2003199,
|
|
885
|
+
firebrick: 11674146,
|
|
886
|
+
floralwhite: 16775920,
|
|
887
|
+
forestgreen: 2263842,
|
|
888
|
+
fuchsia: 16711935,
|
|
889
|
+
gainsboro: 14474460,
|
|
890
|
+
ghostwhite: 16316671,
|
|
891
|
+
gold: 16766720,
|
|
892
|
+
goldenrod: 14329120,
|
|
893
|
+
gray: 8421504,
|
|
894
|
+
green: 32768,
|
|
895
|
+
greenyellow: 11403055,
|
|
896
|
+
grey: 8421504,
|
|
897
|
+
honeydew: 15794160,
|
|
898
|
+
hotpink: 16738740,
|
|
899
|
+
indianred: 13458524,
|
|
900
|
+
indigo: 4915330,
|
|
901
|
+
ivory: 16777200,
|
|
902
|
+
khaki: 15787660,
|
|
903
|
+
lavender: 15132410,
|
|
904
|
+
lavenderblush: 16773365,
|
|
905
|
+
lawngreen: 8190976,
|
|
906
|
+
lemonchiffon: 16775885,
|
|
907
|
+
lightblue: 11393254,
|
|
908
|
+
lightcoral: 15761536,
|
|
909
|
+
lightcyan: 14745599,
|
|
910
|
+
lightgoldenrodyellow: 16448210,
|
|
911
|
+
lightgray: 13882323,
|
|
912
|
+
lightgreen: 9498256,
|
|
913
|
+
lightgrey: 13882323,
|
|
914
|
+
lightpink: 16758465,
|
|
915
|
+
lightsalmon: 16752762,
|
|
916
|
+
lightseagreen: 2142890,
|
|
917
|
+
lightskyblue: 8900346,
|
|
918
|
+
lightslategray: 7833753,
|
|
919
|
+
lightslategrey: 7833753,
|
|
920
|
+
lightsteelblue: 11584734,
|
|
921
|
+
lightyellow: 16777184,
|
|
922
|
+
lime: 65280,
|
|
923
|
+
limegreen: 3329330,
|
|
924
|
+
linen: 16445670,
|
|
925
|
+
magenta: 16711935,
|
|
926
|
+
maroon: 8388608,
|
|
927
|
+
mediumaquamarine: 6737322,
|
|
928
|
+
mediumblue: 205,
|
|
929
|
+
mediumorchid: 12211667,
|
|
930
|
+
mediumpurple: 9662683,
|
|
931
|
+
mediumseagreen: 3978097,
|
|
932
|
+
mediumslateblue: 8087790,
|
|
933
|
+
mediumspringgreen: 64154,
|
|
934
|
+
mediumturquoise: 4772300,
|
|
935
|
+
mediumvioletred: 13047173,
|
|
936
|
+
midnightblue: 1644912,
|
|
937
|
+
mintcream: 16121850,
|
|
938
|
+
mistyrose: 16770273,
|
|
939
|
+
moccasin: 16770229,
|
|
940
|
+
navajowhite: 16768685,
|
|
941
|
+
navy: 128,
|
|
942
|
+
oldlace: 16643558,
|
|
943
|
+
olive: 8421376,
|
|
944
|
+
olivedrab: 7048739,
|
|
945
|
+
orange: 16753920,
|
|
946
|
+
orangered: 16729344,
|
|
947
|
+
orchid: 14315734,
|
|
948
|
+
palegoldenrod: 15657130,
|
|
949
|
+
palegreen: 10025880,
|
|
950
|
+
paleturquoise: 11529966,
|
|
951
|
+
palevioletred: 14381203,
|
|
952
|
+
papayawhip: 16773077,
|
|
953
|
+
peachpuff: 16767673,
|
|
954
|
+
peru: 13468991,
|
|
955
|
+
pink: 16761035,
|
|
956
|
+
plum: 14524637,
|
|
957
|
+
powderblue: 11591910,
|
|
958
|
+
purple: 8388736,
|
|
959
|
+
rebeccapurple: 6697881,
|
|
960
|
+
red: 16711680,
|
|
961
|
+
rosybrown: 12357519,
|
|
962
|
+
royalblue: 4286945,
|
|
963
|
+
saddlebrown: 9127187,
|
|
964
|
+
salmon: 16416882,
|
|
965
|
+
sandybrown: 16032864,
|
|
966
|
+
seagreen: 3050327,
|
|
967
|
+
seashell: 16774638,
|
|
968
|
+
sienna: 10506797,
|
|
969
|
+
silver: 12632256,
|
|
970
|
+
skyblue: 8900331,
|
|
971
|
+
slateblue: 6970061,
|
|
972
|
+
slategray: 7372944,
|
|
973
|
+
slategrey: 7372944,
|
|
974
|
+
snow: 16775930,
|
|
975
|
+
springgreen: 65407,
|
|
976
|
+
steelblue: 4620980,
|
|
977
|
+
tan: 13808780,
|
|
978
|
+
teal: 32896,
|
|
979
|
+
thistle: 14204888,
|
|
980
|
+
tomato: 16737095,
|
|
981
|
+
turquoise: 4251856,
|
|
982
|
+
violet: 15631086,
|
|
983
|
+
wheat: 16113331,
|
|
984
|
+
white: 16777215,
|
|
985
|
+
whitesmoke: 16119285,
|
|
986
|
+
yellow: 16776960,
|
|
987
|
+
yellowgreen: 10145074
|
|
988
|
+
}, J = { h: 0, s: 0, l: 0 }, ve = { h: 0, s: 0, l: 0 };
|
|
989
|
+
function je(t, e, r) {
|
|
990
|
+
return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? t + (e - t) * 6 * r : r < 1 / 2 ? e : r < 2 / 3 ? t + (e - t) * 6 * (2 / 3 - r) : t;
|
|
991
|
+
}
|
|
992
|
+
let ge = class {
|
|
993
|
+
/**
|
|
994
|
+
* Constructs a new color.
|
|
995
|
+
*
|
|
996
|
+
* Note that standard method of specifying color in three.js is with a hexadecimal triplet,
|
|
997
|
+
* and that method is used throughout the rest of the documentation.
|
|
998
|
+
*
|
|
999
|
+
* @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are
|
|
1000
|
+
* not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.
|
|
1001
|
+
* @param {number} [g] - The green component.
|
|
1002
|
+
* @param {number} [b] - The blue component.
|
|
1003
|
+
*/
|
|
1004
|
+
constructor(e, r, n) {
|
|
1005
|
+
return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, r, n);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Sets the colors's components from the given values.
|
|
1009
|
+
*
|
|
1010
|
+
* @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are
|
|
1011
|
+
* not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.
|
|
1012
|
+
* @param {number} [g] - The green component.
|
|
1013
|
+
* @param {number} [b] - The blue component.
|
|
1014
|
+
* @return {Color} A reference to this color.
|
|
1015
|
+
*/
|
|
1016
|
+
set(e, r, n) {
|
|
1017
|
+
if (r === void 0 && n === void 0) {
|
|
1018
|
+
const i = e;
|
|
1019
|
+
i && i.isColor ? this.copy(i) : typeof i == "number" ? this.setHex(i) : typeof i == "string" && this.setStyle(i);
|
|
1020
|
+
} else
|
|
1021
|
+
this.setRGB(e, r, n);
|
|
1022
|
+
return this;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Sets the colors's components to the given scalar value.
|
|
1026
|
+
*
|
|
1027
|
+
* @param {number} scalar - The scalar value.
|
|
1028
|
+
* @return {Color} A reference to this color.
|
|
1029
|
+
*/
|
|
1030
|
+
setScalar(e) {
|
|
1031
|
+
return this.r = e, this.g = e, this.b = e, this;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Sets this color from a hexadecimal value.
|
|
1035
|
+
*
|
|
1036
|
+
* @param {number} hex - The hexadecimal value.
|
|
1037
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1038
|
+
* @return {Color} A reference to this color.
|
|
1039
|
+
*/
|
|
1040
|
+
setHex(e, r = G) {
|
|
1041
|
+
return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, H.colorSpaceToWorking(this, r), this;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Sets this color from RGB values.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {number} r - Red channel value between `0.0` and `1.0`.
|
|
1047
|
+
* @param {number} g - Green channel value between `0.0` and `1.0`.
|
|
1048
|
+
* @param {number} b - Blue channel value between `0.0` and `1.0`.
|
|
1049
|
+
* @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.
|
|
1050
|
+
* @return {Color} A reference to this color.
|
|
1051
|
+
*/
|
|
1052
|
+
setRGB(e, r, n, i = H.workingColorSpace) {
|
|
1053
|
+
return this.r = e, this.g = r, this.b = n, H.colorSpaceToWorking(this, i), this;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Sets this color from RGB values.
|
|
1057
|
+
*
|
|
1058
|
+
* @param {number} h - Hue value between `0.0` and `1.0`.
|
|
1059
|
+
* @param {number} s - Saturation value between `0.0` and `1.0`.
|
|
1060
|
+
* @param {number} l - Lightness value between `0.0` and `1.0`.
|
|
1061
|
+
* @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.
|
|
1062
|
+
* @return {Color} A reference to this color.
|
|
1063
|
+
*/
|
|
1064
|
+
setHSL(e, r, n, i = H.workingColorSpace) {
|
|
1065
|
+
if (e = zt(e, 1), r = de(r, 0, 1), n = de(n, 0, 1), r === 0)
|
|
1066
|
+
this.r = this.g = this.b = n;
|
|
1067
|
+
else {
|
|
1068
|
+
const o = n <= 0.5 ? n * (1 + r) : n + r - n * r, s = 2 * n - o;
|
|
1069
|
+
this.r = je(s, o, e + 1 / 3), this.g = je(s, o, e), this.b = je(s, o, e - 1 / 3);
|
|
1070
|
+
}
|
|
1071
|
+
return H.colorSpaceToWorking(this, i), this;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Sets this color from a CSS-style string. For example, `rgb(250, 0,0)`,
|
|
1075
|
+
* `rgb(100%, 0%, 0%)`, `hsl(0, 100%, 50%)`, `#ff0000`, `#f00`, or `red` ( or
|
|
1076
|
+
* any [X11 color name]{@link https://en.wikipedia.org/wiki/X11_color_names#Color_name_chart} -
|
|
1077
|
+
* all 140 color names are supported).
|
|
1078
|
+
*
|
|
1079
|
+
* @param {string} style - Color as a CSS-style string.
|
|
1080
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1081
|
+
* @return {Color} A reference to this color.
|
|
1082
|
+
*/
|
|
1083
|
+
setStyle(e, r = G) {
|
|
1084
|
+
function n(o) {
|
|
1085
|
+
o !== void 0 && parseFloat(o) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored.");
|
|
1086
|
+
}
|
|
1087
|
+
let i;
|
|
1088
|
+
if (i = /^(\w+)\(([^\)]*)\)/.exec(e)) {
|
|
1089
|
+
let o;
|
|
1090
|
+
const s = i[1], a = i[2];
|
|
1091
|
+
switch (s) {
|
|
1092
|
+
case "rgb":
|
|
1093
|
+
case "rgba":
|
|
1094
|
+
if (o = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
|
|
1095
|
+
return n(o[4]), this.setRGB(
|
|
1096
|
+
Math.min(255, parseInt(o[1], 10)) / 255,
|
|
1097
|
+
Math.min(255, parseInt(o[2], 10)) / 255,
|
|
1098
|
+
Math.min(255, parseInt(o[3], 10)) / 255,
|
|
1099
|
+
r
|
|
1100
|
+
);
|
|
1101
|
+
if (o = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
|
|
1102
|
+
return n(o[4]), this.setRGB(
|
|
1103
|
+
Math.min(100, parseInt(o[1], 10)) / 100,
|
|
1104
|
+
Math.min(100, parseInt(o[2], 10)) / 100,
|
|
1105
|
+
Math.min(100, parseInt(o[3], 10)) / 100,
|
|
1106
|
+
r
|
|
1107
|
+
);
|
|
1108
|
+
break;
|
|
1109
|
+
case "hsl":
|
|
1110
|
+
case "hsla":
|
|
1111
|
+
if (o = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
|
|
1112
|
+
return n(o[4]), this.setHSL(
|
|
1113
|
+
parseFloat(o[1]) / 360,
|
|
1114
|
+
parseFloat(o[2]) / 100,
|
|
1115
|
+
parseFloat(o[3]) / 100,
|
|
1116
|
+
r
|
|
1117
|
+
);
|
|
1118
|
+
break;
|
|
1119
|
+
default:
|
|
1120
|
+
console.warn("THREE.Color: Unknown color model " + e);
|
|
1121
|
+
}
|
|
1122
|
+
} else if (i = /^\#([A-Fa-f\d]+)$/.exec(e)) {
|
|
1123
|
+
const o = i[1], s = o.length;
|
|
1124
|
+
if (s === 3)
|
|
1125
|
+
return this.setRGB(
|
|
1126
|
+
parseInt(o.charAt(0), 16) / 15,
|
|
1127
|
+
parseInt(o.charAt(1), 16) / 15,
|
|
1128
|
+
parseInt(o.charAt(2), 16) / 15,
|
|
1129
|
+
r
|
|
1130
|
+
);
|
|
1131
|
+
if (s === 6)
|
|
1132
|
+
return this.setHex(parseInt(o, 16), r);
|
|
1133
|
+
console.warn("THREE.Color: Invalid hex color " + e);
|
|
1134
|
+
} else if (e && e.length > 0)
|
|
1135
|
+
return this.setColorName(e, r);
|
|
1136
|
+
return this;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Sets this color from a color name. Faster than {@link Color#setStyle} if
|
|
1140
|
+
* you don't need the other CSS-style formats.
|
|
1141
|
+
*
|
|
1142
|
+
* For convenience, the list of names is exposed in `Color.NAMES` as a hash.
|
|
1143
|
+
* ```js
|
|
1144
|
+
* Color.NAMES.aliceblue // returns 0xF0F8FF
|
|
1145
|
+
* ```
|
|
1146
|
+
*
|
|
1147
|
+
* @param {string} style - The color name.
|
|
1148
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1149
|
+
* @return {Color} A reference to this color.
|
|
1150
|
+
*/
|
|
1151
|
+
setColorName(e, r = G) {
|
|
1152
|
+
const n = _t[e.toLowerCase()];
|
|
1153
|
+
return n !== void 0 ? this.setHex(n, r) : console.warn("THREE.Color: Unknown color " + e), this;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Returns a new color with copied values from this instance.
|
|
1157
|
+
*
|
|
1158
|
+
* @return {Color} A clone of this instance.
|
|
1159
|
+
*/
|
|
1160
|
+
clone() {
|
|
1161
|
+
return new this.constructor(this.r, this.g, this.b);
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Copies the values of the given color to this instance.
|
|
1165
|
+
*
|
|
1166
|
+
* @param {Color} color - The color to copy.
|
|
1167
|
+
* @return {Color} A reference to this color.
|
|
1168
|
+
*/
|
|
1169
|
+
copy(e) {
|
|
1170
|
+
return this.r = e.r, this.g = e.g, this.b = e.b, this;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Copies the given color into this color, and then converts this color from
|
|
1174
|
+
* `SRGBColorSpace` to `LinearSRGBColorSpace`.
|
|
1175
|
+
*
|
|
1176
|
+
* @param {Color} color - The color to copy/convert.
|
|
1177
|
+
* @return {Color} A reference to this color.
|
|
1178
|
+
*/
|
|
1179
|
+
copySRGBToLinear(e) {
|
|
1180
|
+
return this.r = ae(e.r), this.g = ae(e.g), this.b = ae(e.b), this;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Copies the given color into this color, and then converts this color from
|
|
1184
|
+
* `LinearSRGBColorSpace` to `SRGBColorSpace`.
|
|
1185
|
+
*
|
|
1186
|
+
* @param {Color} color - The color to copy/convert.
|
|
1187
|
+
* @return {Color} A reference to this color.
|
|
1188
|
+
*/
|
|
1189
|
+
copyLinearToSRGB(e) {
|
|
1190
|
+
return this.r = ue(e.r), this.g = ue(e.g), this.b = ue(e.b), this;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`.
|
|
1194
|
+
*
|
|
1195
|
+
* @return {Color} A reference to this color.
|
|
1196
|
+
*/
|
|
1197
|
+
convertSRGBToLinear() {
|
|
1198
|
+
return this.copySRGBToLinear(this), this;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`.
|
|
1202
|
+
*
|
|
1203
|
+
* @return {Color} A reference to this color.
|
|
1204
|
+
*/
|
|
1205
|
+
convertLinearToSRGB() {
|
|
1206
|
+
return this.copyLinearToSRGB(this), this;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Returns the hexadecimal value of this color.
|
|
1210
|
+
*
|
|
1211
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1212
|
+
* @return {number} The hexadecimal value.
|
|
1213
|
+
*/
|
|
1214
|
+
getHex(e = G) {
|
|
1215
|
+
return H.workingToColorSpace(S.copy(this), e), Math.round(de(S.r * 255, 0, 255)) * 65536 + Math.round(de(S.g * 255, 0, 255)) * 256 + Math.round(de(S.b * 255, 0, 255));
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Returns the hexadecimal value of this color as a string (for example, 'FFFFFF').
|
|
1219
|
+
*
|
|
1220
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1221
|
+
* @return {string} The hexadecimal value as a string.
|
|
1222
|
+
*/
|
|
1223
|
+
getHexString(e = G) {
|
|
1224
|
+
return ("000000" + this.getHex(e).toString(16)).slice(-6);
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Converts the colors RGB values into the HSL format and stores them into the
|
|
1228
|
+
* given target object.
|
|
1229
|
+
*
|
|
1230
|
+
* @param {{h:number,s:number,l:number}} target - The target object that is used to store the method's result.
|
|
1231
|
+
* @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.
|
|
1232
|
+
* @return {{h:number,s:number,l:number}} The HSL representation of this color.
|
|
1233
|
+
*/
|
|
1234
|
+
getHSL(e, r = H.workingColorSpace) {
|
|
1235
|
+
H.workingToColorSpace(S.copy(this), r);
|
|
1236
|
+
const n = S.r, i = S.g, o = S.b, s = Math.max(n, i, o), a = Math.min(n, i, o);
|
|
1237
|
+
let l, u;
|
|
1238
|
+
const f = (a + s) / 2;
|
|
1239
|
+
if (a === s)
|
|
1240
|
+
l = 0, u = 0;
|
|
1241
|
+
else {
|
|
1242
|
+
const h = s - a;
|
|
1243
|
+
switch (u = f <= 0.5 ? h / (s + a) : h / (2 - s - a), s) {
|
|
1244
|
+
case n:
|
|
1245
|
+
l = (i - o) / h + (i < o ? 6 : 0);
|
|
1246
|
+
break;
|
|
1247
|
+
case i:
|
|
1248
|
+
l = (o - n) / h + 2;
|
|
1249
|
+
break;
|
|
1250
|
+
case o:
|
|
1251
|
+
l = (n - i) / h + 4;
|
|
1252
|
+
break;
|
|
1253
|
+
}
|
|
1254
|
+
l /= 6;
|
|
1255
|
+
}
|
|
1256
|
+
return e.h = l, e.s = u, e.l = f, e;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Returns the RGB values of this color and stores them into the given target object.
|
|
1260
|
+
*
|
|
1261
|
+
* @param {Color} target - The target color that is used to store the method's result.
|
|
1262
|
+
* @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.
|
|
1263
|
+
* @return {Color} The RGB representation of this color.
|
|
1264
|
+
*/
|
|
1265
|
+
getRGB(e, r = H.workingColorSpace) {
|
|
1266
|
+
return H.workingToColorSpace(S.copy(this), r), e.r = S.r, e.g = S.g, e.b = S.b, e;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Returns the value of this color as a CSS style string. Example: `rgb(255,0,0)`.
|
|
1270
|
+
*
|
|
1271
|
+
* @param {string} [colorSpace=SRGBColorSpace] - The color space.
|
|
1272
|
+
* @return {string} The CSS representation of this color.
|
|
1273
|
+
*/
|
|
1274
|
+
getStyle(e = G) {
|
|
1275
|
+
H.workingToColorSpace(S.copy(this), e);
|
|
1276
|
+
const r = S.r, n = S.g, i = S.b;
|
|
1277
|
+
return e !== G ? `color(${e} ${r.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})` : `rgb(${Math.round(r * 255)},${Math.round(n * 255)},${Math.round(i * 255)})`;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Adds the given HSL values to this color's values.
|
|
1281
|
+
* Internally, this converts the color's RGB values to HSL, adds HSL
|
|
1282
|
+
* and then converts the color back to RGB.
|
|
1283
|
+
*
|
|
1284
|
+
* @param {number} h - Hue value between `0.0` and `1.0`.
|
|
1285
|
+
* @param {number} s - Saturation value between `0.0` and `1.0`.
|
|
1286
|
+
* @param {number} l - Lightness value between `0.0` and `1.0`.
|
|
1287
|
+
* @return {Color} A reference to this color.
|
|
1288
|
+
*/
|
|
1289
|
+
offsetHSL(e, r, n) {
|
|
1290
|
+
return this.getHSL(J), this.setHSL(J.h + e, J.s + r, J.l + n);
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Adds the RGB values of the given color to the RGB values of this color.
|
|
1294
|
+
*
|
|
1295
|
+
* @param {Color} color - The color to add.
|
|
1296
|
+
* @return {Color} A reference to this color.
|
|
1297
|
+
*/
|
|
1298
|
+
add(e) {
|
|
1299
|
+
return this.r += e.r, this.g += e.g, this.b += e.b, this;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Adds the RGB values of the given colors and stores the result in this instance.
|
|
1303
|
+
*
|
|
1304
|
+
* @param {Color} color1 - The first color.
|
|
1305
|
+
* @param {Color} color2 - The second color.
|
|
1306
|
+
* @return {Color} A reference to this color.
|
|
1307
|
+
*/
|
|
1308
|
+
addColors(e, r) {
|
|
1309
|
+
return this.r = e.r + r.r, this.g = e.g + r.g, this.b = e.b + r.b, this;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Adds the given scalar value to the RGB values of this color.
|
|
1313
|
+
*
|
|
1314
|
+
* @param {number} s - The scalar to add.
|
|
1315
|
+
* @return {Color} A reference to this color.
|
|
1316
|
+
*/
|
|
1317
|
+
addScalar(e) {
|
|
1318
|
+
return this.r += e, this.g += e, this.b += e, this;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Subtracts the RGB values of the given color from the RGB values of this color.
|
|
1322
|
+
*
|
|
1323
|
+
* @param {Color} color - The color to subtract.
|
|
1324
|
+
* @return {Color} A reference to this color.
|
|
1325
|
+
*/
|
|
1326
|
+
sub(e) {
|
|
1327
|
+
return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Multiplies the RGB values of the given color with the RGB values of this color.
|
|
1331
|
+
*
|
|
1332
|
+
* @param {Color} color - The color to multiply.
|
|
1333
|
+
* @return {Color} A reference to this color.
|
|
1334
|
+
*/
|
|
1335
|
+
multiply(e) {
|
|
1336
|
+
return this.r *= e.r, this.g *= e.g, this.b *= e.b, this;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Multiplies the given scalar value with the RGB values of this color.
|
|
1340
|
+
*
|
|
1341
|
+
* @param {number} s - The scalar to multiply.
|
|
1342
|
+
* @return {Color} A reference to this color.
|
|
1343
|
+
*/
|
|
1344
|
+
multiplyScalar(e) {
|
|
1345
|
+
return this.r *= e, this.g *= e, this.b *= e, this;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Linearly interpolates this color's RGB values toward the RGB values of the
|
|
1349
|
+
* given color. The alpha argument can be thought of as the ratio between
|
|
1350
|
+
* the two colors, where `0.0` is this color and `1.0` is the first argument.
|
|
1351
|
+
*
|
|
1352
|
+
* @param {Color} color - The color to converge on.
|
|
1353
|
+
* @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.
|
|
1354
|
+
* @return {Color} A reference to this color.
|
|
1355
|
+
*/
|
|
1356
|
+
lerp(e, r) {
|
|
1357
|
+
return this.r += (e.r - this.r) * r, this.g += (e.g - this.g) * r, this.b += (e.b - this.b) * r, this;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Linearly interpolates between the given colors and stores the result in this instance.
|
|
1361
|
+
* The alpha argument can be thought of as the ratio between the two colors, where `0.0`
|
|
1362
|
+
* is the first and `1.0` is the second color.
|
|
1363
|
+
*
|
|
1364
|
+
* @param {Color} color1 - The first color.
|
|
1365
|
+
* @param {Color} color2 - The second color.
|
|
1366
|
+
* @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.
|
|
1367
|
+
* @return {Color} A reference to this color.
|
|
1368
|
+
*/
|
|
1369
|
+
lerpColors(e, r, n) {
|
|
1370
|
+
return this.r = e.r + (r.r - e.r) * n, this.g = e.g + (r.g - e.g) * n, this.b = e.b + (r.b - e.b) * n, this;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Linearly interpolates this color's HSL values toward the HSL values of the
|
|
1374
|
+
* given color. It differs from {@link Color#lerp} by not interpolating straight
|
|
1375
|
+
* from one color to the other, but instead going through all the hues in between
|
|
1376
|
+
* those two colors. The alpha argument can be thought of as the ratio between
|
|
1377
|
+
* the two colors, where 0.0 is this color and 1.0 is the first argument.
|
|
1378
|
+
*
|
|
1379
|
+
* @param {Color} color - The color to converge on.
|
|
1380
|
+
* @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.
|
|
1381
|
+
* @return {Color} A reference to this color.
|
|
1382
|
+
*/
|
|
1383
|
+
lerpHSL(e, r) {
|
|
1384
|
+
this.getHSL(J), e.getHSL(ve);
|
|
1385
|
+
const n = Be(J.h, ve.h, r), i = Be(J.s, ve.s, r), o = Be(J.l, ve.l, r);
|
|
1386
|
+
return this.setHSL(n, i, o), this;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Sets the color's RGB components from the given 3D vector.
|
|
1390
|
+
*
|
|
1391
|
+
* @param {Vector3} v - The vector to set.
|
|
1392
|
+
* @return {Color} A reference to this color.
|
|
1393
|
+
*/
|
|
1394
|
+
setFromVector3(e) {
|
|
1395
|
+
return this.r = e.x, this.g = e.y, this.b = e.z, this;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Transforms this color with the given 3x3 matrix.
|
|
1399
|
+
*
|
|
1400
|
+
* @param {Matrix3} m - The matrix.
|
|
1401
|
+
* @return {Color} A reference to this color.
|
|
1402
|
+
*/
|
|
1403
|
+
applyMatrix3(e) {
|
|
1404
|
+
const r = this.r, n = this.g, i = this.b, o = e.elements;
|
|
1405
|
+
return this.r = o[0] * r + o[3] * n + o[6] * i, this.g = o[1] * r + o[4] * n + o[7] * i, this.b = o[2] * r + o[5] * n + o[8] * i, this;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Returns `true` if this color is equal with the given one.
|
|
1409
|
+
*
|
|
1410
|
+
* @param {Color} c - The color to test for equality.
|
|
1411
|
+
* @return {boolean} Whether this bounding color is equal with the given one.
|
|
1412
|
+
*/
|
|
1413
|
+
equals(e) {
|
|
1414
|
+
return e.r === this.r && e.g === this.g && e.b === this.b;
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Sets this color's RGB components from the given array.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {Array<number>} array - An array holding the RGB values.
|
|
1420
|
+
* @param {number} [offset=0] - The offset into the array.
|
|
1421
|
+
* @return {Color} A reference to this color.
|
|
1422
|
+
*/
|
|
1423
|
+
fromArray(e, r = 0) {
|
|
1424
|
+
return this.r = e[r], this.g = e[r + 1], this.b = e[r + 2], this;
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Writes the RGB components of this color to the given array. If no array is provided,
|
|
1428
|
+
* the method returns a new instance.
|
|
1429
|
+
*
|
|
1430
|
+
* @param {Array<number>} [array=[]] - The target array holding the color components.
|
|
1431
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
1432
|
+
* @return {Array<number>} The color components.
|
|
1433
|
+
*/
|
|
1434
|
+
toArray(e = [], r = 0) {
|
|
1435
|
+
return e[r] = this.r, e[r + 1] = this.g, e[r + 2] = this.b, e;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Sets the components of this color from the given buffer attribute.
|
|
1439
|
+
*
|
|
1440
|
+
* @param {BufferAttribute} attribute - The buffer attribute holding color data.
|
|
1441
|
+
* @param {number} index - The index into the attribute.
|
|
1442
|
+
* @return {Color} A reference to this color.
|
|
1443
|
+
*/
|
|
1444
|
+
fromBufferAttribute(e, r) {
|
|
1445
|
+
return this.r = e.getX(r), this.g = e.getY(r), this.b = e.getZ(r), this;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* This methods defines the serialization result of this class. Returns the color
|
|
1449
|
+
* as a hexadecimal value.
|
|
1450
|
+
*
|
|
1451
|
+
* @return {number} The hexadecimal value.
|
|
1452
|
+
*/
|
|
1453
|
+
toJSON() {
|
|
1454
|
+
return this.getHex();
|
|
1455
|
+
}
|
|
1456
|
+
*[Symbol.iterator]() {
|
|
1457
|
+
yield this.r, yield this.g, yield this.b;
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
const S = /* @__PURE__ */ new ge();
|
|
1461
|
+
ge.NAMES = _t;
|
|
1462
|
+
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
|
|
1463
|
+
revision: Ct
|
|
1464
|
+
} }));
|
|
1465
|
+
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = Ct);
|
|
1466
|
+
const Vt = "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_110m_admin_0_countries.geojson", Wt = "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json", Xt = "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_10m_admin_1_states_provinces.geojson", Zt = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4'><rect width='4' height='4' fill='%23f5f5f5'/></svg>", Jt = {
|
|
1467
|
+
minColor: "#f8fafc",
|
|
1468
|
+
maxColor: "#e5e7eb"
|
|
1469
|
+
};
|
|
1470
|
+
function We(t, e, r) {
|
|
1471
|
+
t.prototype = e.prototype = r, r.constructor = t;
|
|
1472
|
+
}
|
|
1473
|
+
function Mt(t, e) {
|
|
1474
|
+
var r = Object.create(t.prototype);
|
|
1475
|
+
for (var n in e) r[n] = e[n];
|
|
1476
|
+
return r;
|
|
1477
|
+
}
|
|
1478
|
+
function we() {
|
|
1479
|
+
}
|
|
1480
|
+
var me = 0.7, Re = 1 / me, ce = "\\s*([+-]?\\d+)\\s*", xe = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", V = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Qt = /^#([0-9a-f]{3,8})$/, Kt = new RegExp(`^rgb\\(${ce},${ce},${ce}\\)$`), er = new RegExp(`^rgb\\(${V},${V},${V}\\)$`), tr = new RegExp(`^rgba\\(${ce},${ce},${ce},${xe}\\)$`), rr = new RegExp(`^rgba\\(${V},${V},${V},${xe}\\)$`), nr = new RegExp(`^hsl\\(${xe},${V},${V}\\)$`), ir = new RegExp(`^hsla\\(${xe},${V},${V},${xe}\\)$`), lt = {
|
|
1481
|
+
aliceblue: 15792383,
|
|
1482
|
+
antiquewhite: 16444375,
|
|
1483
|
+
aqua: 65535,
|
|
1484
|
+
aquamarine: 8388564,
|
|
1485
|
+
azure: 15794175,
|
|
1486
|
+
beige: 16119260,
|
|
1487
|
+
bisque: 16770244,
|
|
1488
|
+
black: 0,
|
|
1489
|
+
blanchedalmond: 16772045,
|
|
1490
|
+
blue: 255,
|
|
1491
|
+
blueviolet: 9055202,
|
|
1492
|
+
brown: 10824234,
|
|
1493
|
+
burlywood: 14596231,
|
|
1494
|
+
cadetblue: 6266528,
|
|
1495
|
+
chartreuse: 8388352,
|
|
1496
|
+
chocolate: 13789470,
|
|
1497
|
+
coral: 16744272,
|
|
1498
|
+
cornflowerblue: 6591981,
|
|
1499
|
+
cornsilk: 16775388,
|
|
1500
|
+
crimson: 14423100,
|
|
1501
|
+
cyan: 65535,
|
|
1502
|
+
darkblue: 139,
|
|
1503
|
+
darkcyan: 35723,
|
|
1504
|
+
darkgoldenrod: 12092939,
|
|
1505
|
+
darkgray: 11119017,
|
|
1506
|
+
darkgreen: 25600,
|
|
1507
|
+
darkgrey: 11119017,
|
|
1508
|
+
darkkhaki: 12433259,
|
|
1509
|
+
darkmagenta: 9109643,
|
|
1510
|
+
darkolivegreen: 5597999,
|
|
1511
|
+
darkorange: 16747520,
|
|
1512
|
+
darkorchid: 10040012,
|
|
1513
|
+
darkred: 9109504,
|
|
1514
|
+
darksalmon: 15308410,
|
|
1515
|
+
darkseagreen: 9419919,
|
|
1516
|
+
darkslateblue: 4734347,
|
|
1517
|
+
darkslategray: 3100495,
|
|
1518
|
+
darkslategrey: 3100495,
|
|
1519
|
+
darkturquoise: 52945,
|
|
1520
|
+
darkviolet: 9699539,
|
|
1521
|
+
deeppink: 16716947,
|
|
1522
|
+
deepskyblue: 49151,
|
|
1523
|
+
dimgray: 6908265,
|
|
1524
|
+
dimgrey: 6908265,
|
|
1525
|
+
dodgerblue: 2003199,
|
|
1526
|
+
firebrick: 11674146,
|
|
1527
|
+
floralwhite: 16775920,
|
|
1528
|
+
forestgreen: 2263842,
|
|
1529
|
+
fuchsia: 16711935,
|
|
1530
|
+
gainsboro: 14474460,
|
|
1531
|
+
ghostwhite: 16316671,
|
|
1532
|
+
gold: 16766720,
|
|
1533
|
+
goldenrod: 14329120,
|
|
1534
|
+
gray: 8421504,
|
|
1535
|
+
green: 32768,
|
|
1536
|
+
greenyellow: 11403055,
|
|
1537
|
+
grey: 8421504,
|
|
1538
|
+
honeydew: 15794160,
|
|
1539
|
+
hotpink: 16738740,
|
|
1540
|
+
indianred: 13458524,
|
|
1541
|
+
indigo: 4915330,
|
|
1542
|
+
ivory: 16777200,
|
|
1543
|
+
khaki: 15787660,
|
|
1544
|
+
lavender: 15132410,
|
|
1545
|
+
lavenderblush: 16773365,
|
|
1546
|
+
lawngreen: 8190976,
|
|
1547
|
+
lemonchiffon: 16775885,
|
|
1548
|
+
lightblue: 11393254,
|
|
1549
|
+
lightcoral: 15761536,
|
|
1550
|
+
lightcyan: 14745599,
|
|
1551
|
+
lightgoldenrodyellow: 16448210,
|
|
1552
|
+
lightgray: 13882323,
|
|
1553
|
+
lightgreen: 9498256,
|
|
1554
|
+
lightgrey: 13882323,
|
|
1555
|
+
lightpink: 16758465,
|
|
1556
|
+
lightsalmon: 16752762,
|
|
1557
|
+
lightseagreen: 2142890,
|
|
1558
|
+
lightskyblue: 8900346,
|
|
1559
|
+
lightslategray: 7833753,
|
|
1560
|
+
lightslategrey: 7833753,
|
|
1561
|
+
lightsteelblue: 11584734,
|
|
1562
|
+
lightyellow: 16777184,
|
|
1563
|
+
lime: 65280,
|
|
1564
|
+
limegreen: 3329330,
|
|
1565
|
+
linen: 16445670,
|
|
1566
|
+
magenta: 16711935,
|
|
1567
|
+
maroon: 8388608,
|
|
1568
|
+
mediumaquamarine: 6737322,
|
|
1569
|
+
mediumblue: 205,
|
|
1570
|
+
mediumorchid: 12211667,
|
|
1571
|
+
mediumpurple: 9662683,
|
|
1572
|
+
mediumseagreen: 3978097,
|
|
1573
|
+
mediumslateblue: 8087790,
|
|
1574
|
+
mediumspringgreen: 64154,
|
|
1575
|
+
mediumturquoise: 4772300,
|
|
1576
|
+
mediumvioletred: 13047173,
|
|
1577
|
+
midnightblue: 1644912,
|
|
1578
|
+
mintcream: 16121850,
|
|
1579
|
+
mistyrose: 16770273,
|
|
1580
|
+
moccasin: 16770229,
|
|
1581
|
+
navajowhite: 16768685,
|
|
1582
|
+
navy: 128,
|
|
1583
|
+
oldlace: 16643558,
|
|
1584
|
+
olive: 8421376,
|
|
1585
|
+
olivedrab: 7048739,
|
|
1586
|
+
orange: 16753920,
|
|
1587
|
+
orangered: 16729344,
|
|
1588
|
+
orchid: 14315734,
|
|
1589
|
+
palegoldenrod: 15657130,
|
|
1590
|
+
palegreen: 10025880,
|
|
1591
|
+
paleturquoise: 11529966,
|
|
1592
|
+
palevioletred: 14381203,
|
|
1593
|
+
papayawhip: 16773077,
|
|
1594
|
+
peachpuff: 16767673,
|
|
1595
|
+
peru: 13468991,
|
|
1596
|
+
pink: 16761035,
|
|
1597
|
+
plum: 14524637,
|
|
1598
|
+
powderblue: 11591910,
|
|
1599
|
+
purple: 8388736,
|
|
1600
|
+
rebeccapurple: 6697881,
|
|
1601
|
+
red: 16711680,
|
|
1602
|
+
rosybrown: 12357519,
|
|
1603
|
+
royalblue: 4286945,
|
|
1604
|
+
saddlebrown: 9127187,
|
|
1605
|
+
salmon: 16416882,
|
|
1606
|
+
sandybrown: 16032864,
|
|
1607
|
+
seagreen: 3050327,
|
|
1608
|
+
seashell: 16774638,
|
|
1609
|
+
sienna: 10506797,
|
|
1610
|
+
silver: 12632256,
|
|
1611
|
+
skyblue: 8900331,
|
|
1612
|
+
slateblue: 6970061,
|
|
1613
|
+
slategray: 7372944,
|
|
1614
|
+
slategrey: 7372944,
|
|
1615
|
+
snow: 16775930,
|
|
1616
|
+
springgreen: 65407,
|
|
1617
|
+
steelblue: 4620980,
|
|
1618
|
+
tan: 13808780,
|
|
1619
|
+
teal: 32896,
|
|
1620
|
+
thistle: 14204888,
|
|
1621
|
+
tomato: 16737095,
|
|
1622
|
+
turquoise: 4251856,
|
|
1623
|
+
violet: 15631086,
|
|
1624
|
+
wheat: 16113331,
|
|
1625
|
+
white: 16777215,
|
|
1626
|
+
whitesmoke: 16119285,
|
|
1627
|
+
yellow: 16776960,
|
|
1628
|
+
yellowgreen: 10145074
|
|
1629
|
+
};
|
|
1630
|
+
We(we, pe, {
|
|
1631
|
+
copy(t) {
|
|
1632
|
+
return Object.assign(new this.constructor(), this, t);
|
|
1633
|
+
},
|
|
1634
|
+
displayable() {
|
|
1635
|
+
return this.rgb().displayable();
|
|
1636
|
+
},
|
|
1637
|
+
hex: ft,
|
|
1638
|
+
// Deprecated! Use color.formatHex.
|
|
1639
|
+
formatHex: ft,
|
|
1640
|
+
formatHex8: or,
|
|
1641
|
+
formatHsl: sr,
|
|
1642
|
+
formatRgb: ht,
|
|
1643
|
+
toString: ht
|
|
1644
|
+
});
|
|
1645
|
+
function ft() {
|
|
1646
|
+
return this.rgb().formatHex();
|
|
1647
|
+
}
|
|
1648
|
+
function or() {
|
|
1649
|
+
return this.rgb().formatHex8();
|
|
1650
|
+
}
|
|
1651
|
+
function sr() {
|
|
1652
|
+
return Rt(this).formatHsl();
|
|
1653
|
+
}
|
|
1654
|
+
function ht() {
|
|
1655
|
+
return this.rgb().formatRgb();
|
|
1656
|
+
}
|
|
1657
|
+
function pe(t) {
|
|
1658
|
+
var e, r;
|
|
1659
|
+
return t = (t + "").trim().toLowerCase(), (e = Qt.exec(t)) ? (r = e[1].length, e = parseInt(e[1], 16), r === 6 ? dt(e) : r === 3 ? new O(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : r === 8 ? ke(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : r === 4 ? ke(e >> 12 & 15 | e >> 8 & 240, e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, ((e & 15) << 4 | e & 15) / 255) : null) : (e = Kt.exec(t)) ? new O(e[1], e[2], e[3], 1) : (e = er.exec(t)) ? new O(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = tr.exec(t)) ? ke(e[1], e[2], e[3], e[4]) : (e = rr.exec(t)) ? ke(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = nr.exec(t)) ? xt(e[1], e[2] / 100, e[3] / 100, 1) : (e = ir.exec(t)) ? xt(e[1], e[2] / 100, e[3] / 100, e[4]) : lt.hasOwnProperty(t) ? dt(lt[t]) : t === "transparent" ? new O(NaN, NaN, NaN, 0) : null;
|
|
1660
|
+
}
|
|
1661
|
+
function dt(t) {
|
|
1662
|
+
return new O(t >> 16 & 255, t >> 8 & 255, t & 255, 1);
|
|
1663
|
+
}
|
|
1664
|
+
function ke(t, e, r, n) {
|
|
1665
|
+
return n <= 0 && (t = e = r = NaN), new O(t, e, r, n);
|
|
1666
|
+
}
|
|
1667
|
+
function ar(t) {
|
|
1668
|
+
return t instanceof we || (t = pe(t)), t ? (t = t.rgb(), new O(t.r, t.g, t.b, t.opacity)) : new O();
|
|
1669
|
+
}
|
|
1670
|
+
function Ye(t, e, r, n) {
|
|
1671
|
+
return arguments.length === 1 ? ar(t) : new O(t, e, r, n ?? 1);
|
|
1672
|
+
}
|
|
1673
|
+
function O(t, e, r, n) {
|
|
1674
|
+
this.r = +t, this.g = +e, this.b = +r, this.opacity = +n;
|
|
1675
|
+
}
|
|
1676
|
+
We(O, Ye, Mt(we, {
|
|
1677
|
+
brighter(t) {
|
|
1678
|
+
return t = t == null ? Re : Math.pow(Re, t), new O(this.r * t, this.g * t, this.b * t, this.opacity);
|
|
1679
|
+
},
|
|
1680
|
+
darker(t) {
|
|
1681
|
+
return t = t == null ? me : Math.pow(me, t), new O(this.r * t, this.g * t, this.b * t, this.opacity);
|
|
1682
|
+
},
|
|
1683
|
+
rgb() {
|
|
1684
|
+
return this;
|
|
1685
|
+
},
|
|
1686
|
+
clamp() {
|
|
1687
|
+
return new O(re(this.r), re(this.g), re(this.b), Ae(this.opacity));
|
|
1688
|
+
},
|
|
1689
|
+
displayable() {
|
|
1690
|
+
return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
|
|
1691
|
+
},
|
|
1692
|
+
hex: gt,
|
|
1693
|
+
// Deprecated! Use color.formatHex.
|
|
1694
|
+
formatHex: gt,
|
|
1695
|
+
formatHex8: ur,
|
|
1696
|
+
formatRgb: mt,
|
|
1697
|
+
toString: mt
|
|
1698
|
+
}));
|
|
1699
|
+
function gt() {
|
|
1700
|
+
return `#${te(this.r)}${te(this.g)}${te(this.b)}`;
|
|
1701
|
+
}
|
|
1702
|
+
function ur() {
|
|
1703
|
+
return `#${te(this.r)}${te(this.g)}${te(this.b)}${te((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
|
|
1704
|
+
}
|
|
1705
|
+
function mt() {
|
|
1706
|
+
const t = Ae(this.opacity);
|
|
1707
|
+
return `${t === 1 ? "rgb(" : "rgba("}${re(this.r)}, ${re(this.g)}, ${re(this.b)}${t === 1 ? ")" : `, ${t})`}`;
|
|
1708
|
+
}
|
|
1709
|
+
function Ae(t) {
|
|
1710
|
+
return isNaN(t) ? 1 : Math.max(0, Math.min(1, t));
|
|
1711
|
+
}
|
|
1712
|
+
function re(t) {
|
|
1713
|
+
return Math.max(0, Math.min(255, Math.round(t) || 0));
|
|
1714
|
+
}
|
|
1715
|
+
function te(t) {
|
|
1716
|
+
return t = re(t), (t < 16 ? "0" : "") + t.toString(16);
|
|
1717
|
+
}
|
|
1718
|
+
function xt(t, e, r, n) {
|
|
1719
|
+
return n <= 0 ? t = e = r = NaN : r <= 0 || r >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new Y(t, e, r, n);
|
|
1720
|
+
}
|
|
1721
|
+
function Rt(t) {
|
|
1722
|
+
if (t instanceof Y) return new Y(t.h, t.s, t.l, t.opacity);
|
|
1723
|
+
if (t instanceof we || (t = pe(t)), !t) return new Y();
|
|
1724
|
+
if (t instanceof Y) return t;
|
|
1725
|
+
t = t.rgb();
|
|
1726
|
+
var e = t.r / 255, r = t.g / 255, n = t.b / 255, i = Math.min(e, r, n), o = Math.max(e, r, n), s = NaN, a = o - i, l = (o + i) / 2;
|
|
1727
|
+
return a ? (e === o ? s = (r - n) / a + (r < n) * 6 : r === o ? s = (n - e) / a + 2 : s = (e - r) / a + 4, a /= l < 0.5 ? o + i : 2 - o - i, s *= 60) : a = l > 0 && l < 1 ? 0 : s, new Y(s, a, l, t.opacity);
|
|
1728
|
+
}
|
|
1729
|
+
function cr(t, e, r, n) {
|
|
1730
|
+
return arguments.length === 1 ? Rt(t) : new Y(t, e, r, n ?? 1);
|
|
1731
|
+
}
|
|
1732
|
+
function Y(t, e, r, n) {
|
|
1733
|
+
this.h = +t, this.s = +e, this.l = +r, this.opacity = +n;
|
|
1734
|
+
}
|
|
1735
|
+
We(Y, cr, Mt(we, {
|
|
1736
|
+
brighter(t) {
|
|
1737
|
+
return t = t == null ? Re : Math.pow(Re, t), new Y(this.h, this.s, this.l * t, this.opacity);
|
|
1738
|
+
},
|
|
1739
|
+
darker(t) {
|
|
1740
|
+
return t = t == null ? me : Math.pow(me, t), new Y(this.h, this.s, this.l * t, this.opacity);
|
|
1741
|
+
},
|
|
1742
|
+
rgb() {
|
|
1743
|
+
var t = this.h % 360 + (this.h < 0) * 360, e = isNaN(t) || isNaN(this.s) ? 0 : this.s, r = this.l, n = r + (r < 0.5 ? r : 1 - r) * e, i = 2 * r - n;
|
|
1744
|
+
return new O(
|
|
1745
|
+
Ie(t >= 240 ? t - 240 : t + 120, i, n),
|
|
1746
|
+
Ie(t, i, n),
|
|
1747
|
+
Ie(t < 120 ? t + 240 : t - 120, i, n),
|
|
1748
|
+
this.opacity
|
|
1749
|
+
);
|
|
1750
|
+
},
|
|
1751
|
+
clamp() {
|
|
1752
|
+
return new Y(pt(this.h), Ce(this.s), Ce(this.l), Ae(this.opacity));
|
|
1753
|
+
},
|
|
1754
|
+
displayable() {
|
|
1755
|
+
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
|
|
1756
|
+
},
|
|
1757
|
+
formatHsl() {
|
|
1758
|
+
const t = Ae(this.opacity);
|
|
1759
|
+
return `${t === 1 ? "hsl(" : "hsla("}${pt(this.h)}, ${Ce(this.s) * 100}%, ${Ce(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`;
|
|
1760
|
+
}
|
|
1761
|
+
}));
|
|
1762
|
+
function pt(t) {
|
|
1763
|
+
return t = (t || 0) % 360, t < 0 ? t + 360 : t;
|
|
1764
|
+
}
|
|
1765
|
+
function Ce(t) {
|
|
1766
|
+
return Math.max(0, Math.min(1, t || 0));
|
|
1767
|
+
}
|
|
1768
|
+
function Ie(t, e, r) {
|
|
1769
|
+
return (t < 60 ? e + (r - e) * t / 60 : t < 180 ? r : t < 240 ? e + (r - e) * (240 - t) / 60 : e) * 255;
|
|
1770
|
+
}
|
|
1771
|
+
const Xe = (t) => () => t;
|
|
1772
|
+
function lr(t, e) {
|
|
1773
|
+
return function(r) {
|
|
1774
|
+
return t + r * e;
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
function fr(t, e, r) {
|
|
1778
|
+
return t = Math.pow(t, r), e = Math.pow(e, r) - t, r = 1 / r, function(n) {
|
|
1779
|
+
return Math.pow(t + n * e, r);
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
function hr(t) {
|
|
1783
|
+
return (t = +t) == 1 ? At : function(e, r) {
|
|
1784
|
+
return r - e ? fr(e, r, t) : Xe(isNaN(e) ? r : e);
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
function At(t, e) {
|
|
1788
|
+
var r = e - t;
|
|
1789
|
+
return r ? lr(t, r) : Xe(isNaN(t) ? e : t);
|
|
1790
|
+
}
|
|
1791
|
+
const qe = (function t(e) {
|
|
1792
|
+
var r = hr(e);
|
|
1793
|
+
function n(i, o) {
|
|
1794
|
+
var s = r((i = Ye(i)).r, (o = Ye(o)).r), a = r(i.g, o.g), l = r(i.b, o.b), u = At(i.opacity, o.opacity);
|
|
1795
|
+
return function(f) {
|
|
1796
|
+
return i.r = s(f), i.g = a(f), i.b = l(f), i.opacity = u(f), i + "";
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
return n.gamma = t, n;
|
|
1800
|
+
})(1);
|
|
1801
|
+
function dr(t, e) {
|
|
1802
|
+
e || (e = []);
|
|
1803
|
+
var r = t ? Math.min(e.length, t.length) : 0, n = e.slice(), i;
|
|
1804
|
+
return function(o) {
|
|
1805
|
+
for (i = 0; i < r; ++i) n[i] = t[i] * (1 - o) + e[i] * o;
|
|
1806
|
+
return n;
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
function gr(t) {
|
|
1810
|
+
return ArrayBuffer.isView(t) && !(t instanceof DataView);
|
|
1811
|
+
}
|
|
1812
|
+
function mr(t, e) {
|
|
1813
|
+
var r = e ? e.length : 0, n = t ? Math.min(r, t.length) : 0, i = new Array(n), o = new Array(r), s;
|
|
1814
|
+
for (s = 0; s < n; ++s) i[s] = Ze(t[s], e[s]);
|
|
1815
|
+
for (; s < r; ++s) o[s] = e[s];
|
|
1816
|
+
return function(a) {
|
|
1817
|
+
for (s = 0; s < n; ++s) o[s] = i[s](a);
|
|
1818
|
+
return o;
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
function xr(t, e) {
|
|
1822
|
+
var r = /* @__PURE__ */ new Date();
|
|
1823
|
+
return t = +t, e = +e, function(n) {
|
|
1824
|
+
return r.setTime(t * (1 - n) + e * n), r;
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
function Ne(t, e) {
|
|
1828
|
+
return t = +t, e = +e, function(r) {
|
|
1829
|
+
return t * (1 - r) + e * r;
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
function pr(t, e) {
|
|
1833
|
+
var r = {}, n = {}, i;
|
|
1834
|
+
(t === null || typeof t != "object") && (t = {}), (e === null || typeof e != "object") && (e = {});
|
|
1835
|
+
for (i in e)
|
|
1836
|
+
i in t ? r[i] = Ze(t[i], e[i]) : n[i] = e[i];
|
|
1837
|
+
return function(o) {
|
|
1838
|
+
for (i in r) n[i] = r[i](o);
|
|
1839
|
+
return n;
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
var ze = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, He = new RegExp(ze.source, "g");
|
|
1843
|
+
function br(t) {
|
|
1844
|
+
return function() {
|
|
1845
|
+
return t;
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
function wr(t) {
|
|
1849
|
+
return function(e) {
|
|
1850
|
+
return t(e) + "";
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
function yr(t, e) {
|
|
1854
|
+
var r = ze.lastIndex = He.lastIndex = 0, n, i, o, s = -1, a = [], l = [];
|
|
1855
|
+
for (t = t + "", e = e + ""; (n = ze.exec(t)) && (i = He.exec(e)); )
|
|
1856
|
+
(o = i.index) > r && (o = e.slice(r, o), a[s] ? a[s] += o : a[++s] = o), (n = n[0]) === (i = i[0]) ? a[s] ? a[s] += i : a[++s] = i : (a[++s] = null, l.push({ i: s, x: Ne(n, i) })), r = He.lastIndex;
|
|
1857
|
+
return r < e.length && (o = e.slice(r), a[s] ? a[s] += o : a[++s] = o), a.length < 2 ? l[0] ? wr(l[0].x) : br(e) : (e = l.length, function(u) {
|
|
1858
|
+
for (var f = 0, h; f < e; ++f) a[(h = l[f]).i] = h.x(u);
|
|
1859
|
+
return a.join("");
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
function Ze(t, e) {
|
|
1863
|
+
var r = typeof e, n;
|
|
1864
|
+
return e == null || r === "boolean" ? Xe(e) : (r === "number" ? Ne : r === "string" ? (n = pe(e)) ? (e = n, qe) : yr : e instanceof pe ? qe : e instanceof Date ? xr : gr(e) ? dr : Array.isArray(e) ? mr : typeof e.valueOf != "function" && typeof e.toString != "function" || isNaN(e) ? pr : Ne)(t, e);
|
|
1865
|
+
}
|
|
1866
|
+
function Fr(t, e) {
|
|
1867
|
+
return t = +t, e = +e, function(r) {
|
|
1868
|
+
return Math.round(t * (1 - r) + e * r);
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function Me(t, e) {
|
|
1872
|
+
return t == null || e == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
|
|
1873
|
+
}
|
|
1874
|
+
function Er(t, e) {
|
|
1875
|
+
return t == null || e == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
|
|
1876
|
+
}
|
|
1877
|
+
function Nt(t) {
|
|
1878
|
+
let e, r, n;
|
|
1879
|
+
t.length !== 2 ? (e = Me, r = (a, l) => Me(t(a), l), n = (a, l) => t(a) - l) : (e = t === Me || t === Er ? t : vr, r = t, n = t);
|
|
1880
|
+
function i(a, l, u = 0, f = a.length) {
|
|
1881
|
+
if (u < f) {
|
|
1882
|
+
if (e(l, l) !== 0) return f;
|
|
1883
|
+
do {
|
|
1884
|
+
const h = u + f >>> 1;
|
|
1885
|
+
r(a[h], l) < 0 ? u = h + 1 : f = h;
|
|
1886
|
+
} while (u < f);
|
|
1887
|
+
}
|
|
1888
|
+
return u;
|
|
1889
|
+
}
|
|
1890
|
+
function o(a, l, u = 0, f = a.length) {
|
|
1891
|
+
if (u < f) {
|
|
1892
|
+
if (e(l, l) !== 0) return f;
|
|
1893
|
+
do {
|
|
1894
|
+
const h = u + f >>> 1;
|
|
1895
|
+
r(a[h], l) <= 0 ? u = h + 1 : f = h;
|
|
1896
|
+
} while (u < f);
|
|
1897
|
+
}
|
|
1898
|
+
return u;
|
|
1899
|
+
}
|
|
1900
|
+
function s(a, l, u = 0, f = a.length) {
|
|
1901
|
+
const h = i(a, l, u, f - 1);
|
|
1902
|
+
return h > u && n(a[h - 1], l) > -n(a[h], l) ? h - 1 : h;
|
|
1903
|
+
}
|
|
1904
|
+
return { left: i, center: s, right: o };
|
|
1905
|
+
}
|
|
1906
|
+
function vr() {
|
|
1907
|
+
return 0;
|
|
1908
|
+
}
|
|
1909
|
+
function kr(t) {
|
|
1910
|
+
return t === null ? NaN : +t;
|
|
1911
|
+
}
|
|
1912
|
+
const Cr = Nt(Me), _r = Cr.right;
|
|
1913
|
+
Nt(kr).center;
|
|
1914
|
+
const Mr = Math.sqrt(50), Rr = Math.sqrt(10), Ar = Math.sqrt(2);
|
|
1915
|
+
function Se(t, e, r) {
|
|
1916
|
+
const n = (e - t) / Math.max(0, r), i = Math.floor(Math.log10(n)), o = n / Math.pow(10, i), s = o >= Mr ? 10 : o >= Rr ? 5 : o >= Ar ? 2 : 1;
|
|
1917
|
+
let a, l, u;
|
|
1918
|
+
return i < 0 ? (u = Math.pow(10, -i) / s, a = Math.round(t * u), l = Math.round(e * u), a / u < t && ++a, l / u > e && --l, u = -u) : (u = Math.pow(10, i) * s, a = Math.round(t / u), l = Math.round(e / u), a * u < t && ++a, l * u > e && --l), l < a && 0.5 <= r && r < 2 ? Se(t, e, r * 2) : [a, l, u];
|
|
1919
|
+
}
|
|
1920
|
+
function Nr(t, e, r) {
|
|
1921
|
+
if (e = +e, t = +t, r = +r, !(r > 0)) return [];
|
|
1922
|
+
if (t === e) return [t];
|
|
1923
|
+
const n = e < t, [i, o, s] = n ? Se(e, t, r) : Se(t, e, r);
|
|
1924
|
+
if (!(o >= i)) return [];
|
|
1925
|
+
const a = o - i + 1, l = new Array(a);
|
|
1926
|
+
if (n)
|
|
1927
|
+
if (s < 0) for (let u = 0; u < a; ++u) l[u] = (o - u) / -s;
|
|
1928
|
+
else for (let u = 0; u < a; ++u) l[u] = (o - u) * s;
|
|
1929
|
+
else if (s < 0) for (let u = 0; u < a; ++u) l[u] = (i + u) / -s;
|
|
1930
|
+
else for (let u = 0; u < a; ++u) l[u] = (i + u) * s;
|
|
1931
|
+
return l;
|
|
1932
|
+
}
|
|
1933
|
+
function Ue(t, e, r) {
|
|
1934
|
+
return e = +e, t = +t, r = +r, Se(t, e, r)[2];
|
|
1935
|
+
}
|
|
1936
|
+
function Sr(t, e, r) {
|
|
1937
|
+
e = +e, t = +t, r = +r;
|
|
1938
|
+
const n = e < t, i = n ? Ue(e, t, r) : Ue(t, e, r);
|
|
1939
|
+
return (n ? -1 : 1) * (i < 0 ? 1 / -i : i);
|
|
1940
|
+
}
|
|
1941
|
+
function Tr(t, e) {
|
|
1942
|
+
switch (arguments.length) {
|
|
1943
|
+
case 0:
|
|
1944
|
+
break;
|
|
1945
|
+
case 1:
|
|
1946
|
+
this.range(t);
|
|
1947
|
+
break;
|
|
1948
|
+
default:
|
|
1949
|
+
this.range(e).domain(t);
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
return this;
|
|
1953
|
+
}
|
|
1954
|
+
function $r(t) {
|
|
1955
|
+
return function() {
|
|
1956
|
+
return t;
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
function Lr(t) {
|
|
1960
|
+
return +t;
|
|
1961
|
+
}
|
|
1962
|
+
var bt = [0, 1];
|
|
1963
|
+
function se(t) {
|
|
1964
|
+
return t;
|
|
1965
|
+
}
|
|
1966
|
+
function Ve(t, e) {
|
|
1967
|
+
return (e -= t = +t) ? function(r) {
|
|
1968
|
+
return (r - t) / e;
|
|
1969
|
+
} : $r(isNaN(e) ? NaN : 0.5);
|
|
1970
|
+
}
|
|
1971
|
+
function Dr(t, e) {
|
|
1972
|
+
var r;
|
|
1973
|
+
return t > e && (r = t, t = e, e = r), function(n) {
|
|
1974
|
+
return Math.max(t, Math.min(e, n));
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
function Or(t, e, r) {
|
|
1978
|
+
var n = t[0], i = t[1], o = e[0], s = e[1];
|
|
1979
|
+
return i < n ? (n = Ve(i, n), o = r(s, o)) : (n = Ve(n, i), o = r(o, s)), function(a) {
|
|
1980
|
+
return o(n(a));
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
function Br(t, e, r) {
|
|
1984
|
+
var n = Math.min(t.length, e.length) - 1, i = new Array(n), o = new Array(n), s = -1;
|
|
1985
|
+
for (t[n] < t[0] && (t = t.slice().reverse(), e = e.slice().reverse()); ++s < n; )
|
|
1986
|
+
i[s] = Ve(t[s], t[s + 1]), o[s] = r(e[s], e[s + 1]);
|
|
1987
|
+
return function(a) {
|
|
1988
|
+
var l = _r(t, a, 1, n) - 1;
|
|
1989
|
+
return o[l](i[l](a));
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
function Pr(t, e) {
|
|
1993
|
+
return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());
|
|
1994
|
+
}
|
|
1995
|
+
function jr() {
|
|
1996
|
+
var t = bt, e = bt, r = Ze, n, i, o, s = se, a, l, u;
|
|
1997
|
+
function f() {
|
|
1998
|
+
var g = Math.min(t.length, e.length);
|
|
1999
|
+
return s !== se && (s = Dr(t[0], t[g - 1])), a = g > 2 ? Br : Or, l = u = null, h;
|
|
2000
|
+
}
|
|
2001
|
+
function h(g) {
|
|
2002
|
+
return g == null || isNaN(g = +g) ? o : (l || (l = a(t.map(n), e, r)))(n(s(g)));
|
|
2003
|
+
}
|
|
2004
|
+
return h.invert = function(g) {
|
|
2005
|
+
return s(i((u || (u = a(e, t.map(n), Ne)))(g)));
|
|
2006
|
+
}, h.domain = function(g) {
|
|
2007
|
+
return arguments.length ? (t = Array.from(g, Lr), f()) : t.slice();
|
|
2008
|
+
}, h.range = function(g) {
|
|
2009
|
+
return arguments.length ? (e = Array.from(g), f()) : e.slice();
|
|
2010
|
+
}, h.rangeRound = function(g) {
|
|
2011
|
+
return e = Array.from(g), r = Fr, f();
|
|
2012
|
+
}, h.clamp = function(g) {
|
|
2013
|
+
return arguments.length ? (s = g ? !0 : se, f()) : s !== se;
|
|
2014
|
+
}, h.interpolate = function(g) {
|
|
2015
|
+
return arguments.length ? (r = g, f()) : r;
|
|
2016
|
+
}, h.unknown = function(g) {
|
|
2017
|
+
return arguments.length ? (o = g, h) : o;
|
|
2018
|
+
}, function(g, F) {
|
|
2019
|
+
return n = g, i = F, f();
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
function Ir() {
|
|
2023
|
+
return jr()(se, se);
|
|
2024
|
+
}
|
|
2025
|
+
function Hr(t) {
|
|
2026
|
+
return Math.abs(t = Math.round(t)) >= 1e21 ? t.toLocaleString("en").replace(/,/g, "") : t.toString(10);
|
|
2027
|
+
}
|
|
2028
|
+
function Te(t, e) {
|
|
2029
|
+
if (!isFinite(t) || t === 0) return null;
|
|
2030
|
+
var r = (t = e ? t.toExponential(e - 1) : t.toExponential()).indexOf("e"), n = t.slice(0, r);
|
|
2031
|
+
return [
|
|
2032
|
+
n.length > 1 ? n[0] + n.slice(2) : n,
|
|
2033
|
+
+t.slice(r + 1)
|
|
2034
|
+
];
|
|
2035
|
+
}
|
|
2036
|
+
function le(t) {
|
|
2037
|
+
return t = Te(Math.abs(t)), t ? t[1] : NaN;
|
|
2038
|
+
}
|
|
2039
|
+
function Gr(t, e) {
|
|
2040
|
+
return function(r, n) {
|
|
2041
|
+
for (var i = r.length, o = [], s = 0, a = t[0], l = 0; i > 0 && a > 0 && (l + a + 1 > n && (a = Math.max(1, n - l)), o.push(r.substring(i -= a, i + a)), !((l += a + 1) > n)); )
|
|
2042
|
+
a = t[s = (s + 1) % t.length];
|
|
2043
|
+
return o.reverse().join(e);
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
function Yr(t) {
|
|
2047
|
+
return function(e) {
|
|
2048
|
+
return e.replace(/[0-9]/g, function(r) {
|
|
2049
|
+
return t[+r];
|
|
2050
|
+
});
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
var qr = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
2054
|
+
function $e(t) {
|
|
2055
|
+
if (!(e = qr.exec(t))) throw new Error("invalid format: " + t);
|
|
2056
|
+
var e;
|
|
2057
|
+
return new Je({
|
|
2058
|
+
fill: e[1],
|
|
2059
|
+
align: e[2],
|
|
2060
|
+
sign: e[3],
|
|
2061
|
+
symbol: e[4],
|
|
2062
|
+
zero: e[5],
|
|
2063
|
+
width: e[6],
|
|
2064
|
+
comma: e[7],
|
|
2065
|
+
precision: e[8] && e[8].slice(1),
|
|
2066
|
+
trim: e[9],
|
|
2067
|
+
type: e[10]
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
2070
|
+
$e.prototype = Je.prototype;
|
|
2071
|
+
function Je(t) {
|
|
2072
|
+
this.fill = t.fill === void 0 ? " " : t.fill + "", this.align = t.align === void 0 ? ">" : t.align + "", this.sign = t.sign === void 0 ? "-" : t.sign + "", this.symbol = t.symbol === void 0 ? "" : t.symbol + "", this.zero = !!t.zero, this.width = t.width === void 0 ? void 0 : +t.width, this.comma = !!t.comma, this.precision = t.precision === void 0 ? void 0 : +t.precision, this.trim = !!t.trim, this.type = t.type === void 0 ? "" : t.type + "";
|
|
2073
|
+
}
|
|
2074
|
+
Je.prototype.toString = function() {
|
|
2075
|
+
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
|
|
2076
|
+
};
|
|
2077
|
+
function zr(t) {
|
|
2078
|
+
e: for (var e = t.length, r = 1, n = -1, i; r < e; ++r)
|
|
2079
|
+
switch (t[r]) {
|
|
2080
|
+
case ".":
|
|
2081
|
+
n = i = r;
|
|
2082
|
+
break;
|
|
2083
|
+
case "0":
|
|
2084
|
+
n === 0 && (n = r), i = r;
|
|
2085
|
+
break;
|
|
2086
|
+
default:
|
|
2087
|
+
if (!+t[r]) break e;
|
|
2088
|
+
n > 0 && (n = 0);
|
|
2089
|
+
break;
|
|
2090
|
+
}
|
|
2091
|
+
return n > 0 ? t.slice(0, n) + t.slice(i + 1) : t;
|
|
2092
|
+
}
|
|
2093
|
+
var Le;
|
|
2094
|
+
function Ur(t, e) {
|
|
2095
|
+
var r = Te(t, e);
|
|
2096
|
+
if (!r) return Le = void 0, t.toPrecision(e);
|
|
2097
|
+
var n = r[0], i = r[1], o = i - (Le = Math.max(-8, Math.min(8, Math.floor(i / 3))) * 3) + 1, s = n.length;
|
|
2098
|
+
return o === s ? n : o > s ? n + new Array(o - s + 1).join("0") : o > 0 ? n.slice(0, o) + "." + n.slice(o) : "0." + new Array(1 - o).join("0") + Te(t, Math.max(0, e + o - 1))[0];
|
|
2099
|
+
}
|
|
2100
|
+
function wt(t, e) {
|
|
2101
|
+
var r = Te(t, e);
|
|
2102
|
+
if (!r) return t + "";
|
|
2103
|
+
var n = r[0], i = r[1];
|
|
2104
|
+
return i < 0 ? "0." + new Array(-i).join("0") + n : n.length > i + 1 ? n.slice(0, i + 1) + "." + n.slice(i + 1) : n + new Array(i - n.length + 2).join("0");
|
|
2105
|
+
}
|
|
2106
|
+
const yt = {
|
|
2107
|
+
"%": (t, e) => (t * 100).toFixed(e),
|
|
2108
|
+
b: (t) => Math.round(t).toString(2),
|
|
2109
|
+
c: (t) => t + "",
|
|
2110
|
+
d: Hr,
|
|
2111
|
+
e: (t, e) => t.toExponential(e),
|
|
2112
|
+
f: (t, e) => t.toFixed(e),
|
|
2113
|
+
g: (t, e) => t.toPrecision(e),
|
|
2114
|
+
o: (t) => Math.round(t).toString(8),
|
|
2115
|
+
p: (t, e) => wt(t * 100, e),
|
|
2116
|
+
r: wt,
|
|
2117
|
+
s: Ur,
|
|
2118
|
+
X: (t) => Math.round(t).toString(16).toUpperCase(),
|
|
2119
|
+
x: (t) => Math.round(t).toString(16)
|
|
2120
|
+
};
|
|
2121
|
+
function Ft(t) {
|
|
2122
|
+
return t;
|
|
2123
|
+
}
|
|
2124
|
+
var Et = Array.prototype.map, vt = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
2125
|
+
function Vr(t) {
|
|
2126
|
+
var e = t.grouping === void 0 || t.thousands === void 0 ? Ft : Gr(Et.call(t.grouping, Number), t.thousands + ""), r = t.currency === void 0 ? "" : t.currency[0] + "", n = t.currency === void 0 ? "" : t.currency[1] + "", i = t.decimal === void 0 ? "." : t.decimal + "", o = t.numerals === void 0 ? Ft : Yr(Et.call(t.numerals, String)), s = t.percent === void 0 ? "%" : t.percent + "", a = t.minus === void 0 ? "−" : t.minus + "", l = t.nan === void 0 ? "NaN" : t.nan + "";
|
|
2127
|
+
function u(h, g) {
|
|
2128
|
+
h = $e(h);
|
|
2129
|
+
var F = h.fill, E = h.align, v = h.sign, A = h.symbol, T = h.zero, I = h.width, B = h.comma, R = h.precision, q = h.trim, _ = h.type;
|
|
2130
|
+
_ === "n" ? (B = !0, _ = "g") : yt[_] || (R === void 0 && (R = 12), q = !0, _ = "g"), (T || F === "0" && E === "=") && (T = !0, F = "0", E = "=");
|
|
2131
|
+
var P = (g && g.prefix !== void 0 ? g.prefix : "") + (A === "$" ? r : A === "#" && /[boxX]/.test(_) ? "0" + _.toLowerCase() : ""), ne = (A === "$" ? n : /[%p]/.test(_) ? s : "") + (g && g.suffix !== void 0 ? g.suffix : ""), X = yt[_], ie = /[defgprs%]/.test(_);
|
|
2132
|
+
R = R === void 0 ? 6 : /[gprs]/.test(_) ? Math.max(1, Math.min(21, R)) : Math.max(0, Math.min(20, R));
|
|
2133
|
+
function Q(y) {
|
|
2134
|
+
var j = P, N = ne, $, Z, W;
|
|
2135
|
+
if (_ === "c")
|
|
2136
|
+
N = X(y) + N, y = "";
|
|
2137
|
+
else {
|
|
2138
|
+
y = +y;
|
|
2139
|
+
var z = y < 0 || 1 / y < 0;
|
|
2140
|
+
if (y = isNaN(y) ? l : X(Math.abs(y), R), q && (y = zr(y)), z && +y == 0 && v !== "+" && (z = !1), j = (z ? v === "(" ? v : a : v === "-" || v === "(" ? "" : v) + j, N = (_ === "s" && !isNaN(y) && Le !== void 0 ? vt[8 + Le / 3] : "") + N + (z && v === "(" ? ")" : ""), ie) {
|
|
2141
|
+
for ($ = -1, Z = y.length; ++$ < Z; )
|
|
2142
|
+
if (W = y.charCodeAt($), 48 > W || W > 57) {
|
|
2143
|
+
N = (W === 46 ? i + y.slice($ + 1) : y.slice($)) + N, y = y.slice(0, $);
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
B && !T && (y = e(y, 1 / 0));
|
|
2149
|
+
var U = j.length + y.length + N.length, L = U < I ? new Array(I - U + 1).join(F) : "";
|
|
2150
|
+
switch (B && T && (y = e(L + y, L.length ? I - N.length : 1 / 0), L = ""), E) {
|
|
2151
|
+
case "<":
|
|
2152
|
+
y = j + y + N + L;
|
|
2153
|
+
break;
|
|
2154
|
+
case "=":
|
|
2155
|
+
y = j + L + y + N;
|
|
2156
|
+
break;
|
|
2157
|
+
case "^":
|
|
2158
|
+
y = L.slice(0, U = L.length >> 1) + j + y + N + L.slice(U);
|
|
2159
|
+
break;
|
|
2160
|
+
default:
|
|
2161
|
+
y = L + j + y + N;
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
return o(y);
|
|
2165
|
+
}
|
|
2166
|
+
return Q.toString = function() {
|
|
2167
|
+
return h + "";
|
|
2168
|
+
}, Q;
|
|
2169
|
+
}
|
|
2170
|
+
function f(h, g) {
|
|
2171
|
+
var F = Math.max(-8, Math.min(8, Math.floor(le(g) / 3))) * 3, E = Math.pow(10, -F), v = u((h = $e(h), h.type = "f", h), { suffix: vt[8 + F / 3] });
|
|
2172
|
+
return function(A) {
|
|
2173
|
+
return v(E * A);
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
return {
|
|
2177
|
+
format: u,
|
|
2178
|
+
formatPrefix: f
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2181
|
+
var _e, St, Tt;
|
|
2182
|
+
Wr({
|
|
2183
|
+
thousands: ",",
|
|
2184
|
+
grouping: [3],
|
|
2185
|
+
currency: ["$", ""]
|
|
2186
|
+
});
|
|
2187
|
+
function Wr(t) {
|
|
2188
|
+
return _e = Vr(t), St = _e.format, Tt = _e.formatPrefix, _e;
|
|
2189
|
+
}
|
|
2190
|
+
function Xr(t) {
|
|
2191
|
+
return Math.max(0, -le(Math.abs(t)));
|
|
2192
|
+
}
|
|
2193
|
+
function Zr(t, e) {
|
|
2194
|
+
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(le(e) / 3))) * 3 - le(Math.abs(t)));
|
|
2195
|
+
}
|
|
2196
|
+
function Jr(t, e) {
|
|
2197
|
+
return t = Math.abs(t), e = Math.abs(e) - t, Math.max(0, le(e) - le(t)) + 1;
|
|
2198
|
+
}
|
|
2199
|
+
function Qr(t, e, r, n) {
|
|
2200
|
+
var i = Sr(t, e, r), o;
|
|
2201
|
+
switch (n = $e(n ?? ",f"), n.type) {
|
|
2202
|
+
case "s": {
|
|
2203
|
+
var s = Math.max(Math.abs(t), Math.abs(e));
|
|
2204
|
+
return n.precision == null && !isNaN(o = Zr(i, s)) && (n.precision = o), Tt(n, s);
|
|
2205
|
+
}
|
|
2206
|
+
case "":
|
|
2207
|
+
case "e":
|
|
2208
|
+
case "g":
|
|
2209
|
+
case "p":
|
|
2210
|
+
case "r": {
|
|
2211
|
+
n.precision == null && !isNaN(o = Jr(i, Math.max(Math.abs(t), Math.abs(e)))) && (n.precision = o - (n.type === "e"));
|
|
2212
|
+
break;
|
|
2213
|
+
}
|
|
2214
|
+
case "f":
|
|
2215
|
+
case "%": {
|
|
2216
|
+
n.precision == null && !isNaN(o = Xr(i)) && (n.precision = o - (n.type === "%") * 2);
|
|
2217
|
+
break;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
return St(n);
|
|
2221
|
+
}
|
|
2222
|
+
function Kr(t) {
|
|
2223
|
+
var e = t.domain;
|
|
2224
|
+
return t.ticks = function(r) {
|
|
2225
|
+
var n = e();
|
|
2226
|
+
return Nr(n[0], n[n.length - 1], r ?? 10);
|
|
2227
|
+
}, t.tickFormat = function(r, n) {
|
|
2228
|
+
var i = e();
|
|
2229
|
+
return Qr(i[0], i[i.length - 1], r ?? 10, n);
|
|
2230
|
+
}, t.nice = function(r) {
|
|
2231
|
+
r == null && (r = 10);
|
|
2232
|
+
var n = e(), i = 0, o = n.length - 1, s = n[i], a = n[o], l, u, f = 10;
|
|
2233
|
+
for (a < s && (u = s, s = a, a = u, u = i, i = o, o = u); f-- > 0; ) {
|
|
2234
|
+
if (u = Ue(s, a, r), u === l)
|
|
2235
|
+
return n[i] = s, n[o] = a, e(n);
|
|
2236
|
+
if (u > 0)
|
|
2237
|
+
s = Math.floor(s / u) * u, a = Math.ceil(a / u) * u;
|
|
2238
|
+
else if (u < 0)
|
|
2239
|
+
s = Math.ceil(s * u) / u, a = Math.floor(a * u) / u;
|
|
2240
|
+
else
|
|
2241
|
+
break;
|
|
2242
|
+
l = u;
|
|
2243
|
+
}
|
|
2244
|
+
return t;
|
|
2245
|
+
}, t;
|
|
2246
|
+
}
|
|
2247
|
+
function $t() {
|
|
2248
|
+
var t = Ir();
|
|
2249
|
+
return t.copy = function() {
|
|
2250
|
+
return Pr(t, $t());
|
|
2251
|
+
}, Tr.apply(t, arguments), Kr(t);
|
|
2252
|
+
}
|
|
2253
|
+
const Ge = (t, e) => {
|
|
2254
|
+
const r = t?.[e];
|
|
2255
|
+
return typeof r == "number" ? r : 0;
|
|
2256
|
+
}, kt = (t, e) => {
|
|
2257
|
+
if (!t.length) return () => e.minColor;
|
|
2258
|
+
const r = Math.min(...t), n = Math.max(...t);
|
|
2259
|
+
if (r === n) return () => e.maxColor;
|
|
2260
|
+
const i = $t().domain([r, n]).range([0, 1]), o = qe(e.minColor, e.maxColor);
|
|
2261
|
+
return (s) => o(i(s));
|
|
2262
|
+
}, en = (t) => t <= 1.35 ? 2 : t <= 2.1 ? 1 : 0, tn = (t) => new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(t), sn = ({
|
|
2263
|
+
statisticsData: t,
|
|
2264
|
+
resetSignal: e,
|
|
2265
|
+
countryNumericToIsoMap: r = {},
|
|
2266
|
+
countryNameToIsoMap: n = {},
|
|
2267
|
+
primaryMetric: i = "visits",
|
|
2268
|
+
colorScale: o = Jt
|
|
2269
|
+
}) => {
|
|
2270
|
+
const s = oe(null), a = oe(null), l = oe(void 0), u = oe({}), f = oe(null), h = oe(e), [g, F] = K(0), [E, v] = K(), [A, T] = K(), [I, B] = K(null), [R, q] = K([]), [_, P] = K([]), [ne, X] = K({
|
|
2271
|
+
width: 900,
|
|
2272
|
+
height: 760
|
|
2273
|
+
}), ie = Fe(
|
|
2274
|
+
() => Object.values(t.countries).map(
|
|
2275
|
+
(d) => Ge(d, i)
|
|
2276
|
+
),
|
|
2277
|
+
[i, t.countries]
|
|
2278
|
+
), Q = Fe(() => E ? Object.values(t.regions[E] ?? {}).map(
|
|
2279
|
+
(d) => Ge(d, i)
|
|
2280
|
+
) : [], [E, i, t.regions]), y = Fe(
|
|
2281
|
+
() => kt(ie, o),
|
|
2282
|
+
[ie, o]
|
|
2283
|
+
), j = Fe(
|
|
2284
|
+
() => kt(Q, o),
|
|
2285
|
+
[Q, o]
|
|
2286
|
+
);
|
|
2287
|
+
ee(() => {
|
|
2288
|
+
(async () => {
|
|
2289
|
+
let m = [];
|
|
2290
|
+
try {
|
|
2291
|
+
m = (await (await fetch(Vt)).json()).features;
|
|
2292
|
+
} catch {
|
|
2293
|
+
const b = await (await fetch(Wt)).json(), C = b.objects.countries, D = Gt(
|
|
2294
|
+
b,
|
|
2295
|
+
C
|
|
2296
|
+
);
|
|
2297
|
+
m = D.type === "FeatureCollection" ? D.features : [D];
|
|
2298
|
+
}
|
|
2299
|
+
const x = m.map((p) => {
|
|
2300
|
+
const b = String(p.id ?? ""), C = p.properties ?? {}, D = String(
|
|
2301
|
+
C.name ?? C.NAME ?? C.name_en ?? C.ADMIN ?? ""
|
|
2302
|
+
).trim() || `Country ${b}`, De = D.toLowerCase(), ye = String(
|
|
2303
|
+
C.iso_a2 ?? C.ISO_A2 ?? C.iso_a2_eh ?? ""
|
|
2304
|
+
).trim().toUpperCase(), Qe = r[b] ?? n[De] ?? (ye && ye !== "-99" ? ye : void 0) ?? (b.length === 2 ? b.toUpperCase() : b);
|
|
2305
|
+
return {
|
|
2306
|
+
...p,
|
|
2307
|
+
properties: {
|
|
2308
|
+
...C,
|
|
2309
|
+
__isoA2: Qe,
|
|
2310
|
+
name: D || Qe || `Country ${b}`
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
});
|
|
2314
|
+
q(x);
|
|
2315
|
+
})();
|
|
2316
|
+
}, []), ee(() => {
|
|
2317
|
+
if (!a.current) return;
|
|
2318
|
+
const d = new ResizeObserver((m) => {
|
|
2319
|
+
const x = m[0];
|
|
2320
|
+
x && X({
|
|
2321
|
+
width: Math.max(360, Math.floor(x.contentRect.width)),
|
|
2322
|
+
height: Math.max(520, Math.floor(x.contentRect.height))
|
|
2323
|
+
});
|
|
2324
|
+
});
|
|
2325
|
+
return d.observe(a.current), () => d.disconnect();
|
|
2326
|
+
}, []), ee(() => {
|
|
2327
|
+
if (!E) {
|
|
2328
|
+
P([]);
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
const d = u.current[E];
|
|
2332
|
+
if (d) {
|
|
2333
|
+
P(d);
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
(async () => {
|
|
2337
|
+
if (!f.current) {
|
|
2338
|
+
const C = await (await fetch(Xt)).json();
|
|
2339
|
+
f.current = C.features;
|
|
2340
|
+
}
|
|
2341
|
+
const p = (f.current ?? []).filter(
|
|
2342
|
+
(b) => (b.properties ?? {}).iso_a2 === E
|
|
2343
|
+
).map((b) => {
|
|
2344
|
+
const C = b.properties ?? {}, D = String(C.name ?? "").trim();
|
|
2345
|
+
return {
|
|
2346
|
+
...b,
|
|
2347
|
+
properties: {
|
|
2348
|
+
...C,
|
|
2349
|
+
__countryCode: E,
|
|
2350
|
+
__regionName: D,
|
|
2351
|
+
name: D
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
});
|
|
2355
|
+
u.current[E] = p, P(p);
|
|
2356
|
+
})();
|
|
2357
|
+
}, [E]), ee(() => {
|
|
2358
|
+
if (A && g < 2) return void F(2);
|
|
2359
|
+
E && g < 1 && F(1);
|
|
2360
|
+
}, [E, A, g]), ee(() => {
|
|
2361
|
+
const d = s.current?.controls?.();
|
|
2362
|
+
if (!d) return;
|
|
2363
|
+
d.autoRotate = !0, d.autoRotateSpeed = 0.45, d.enablePan = !1, d.enableZoom = !0;
|
|
2364
|
+
const m = s.current?.renderer?.();
|
|
2365
|
+
m && m.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
|
|
2366
|
+
}, []), ee(() => {
|
|
2367
|
+
const d = s.current?.controls?.();
|
|
2368
|
+
d && (d.autoRotate = !E && g === 0);
|
|
2369
|
+
}, [E, g]), ee(() => {
|
|
2370
|
+
if (e === h.current) return;
|
|
2371
|
+
h.current = e, F(0), v(void 0), T(void 0), B(null), P([]);
|
|
2372
|
+
const d = s.current?.controls?.();
|
|
2373
|
+
d && (d.autoRotate = !0), s.current?.pointOfView({ lat: 20, lng: 15, altitude: 2.6 }, 650);
|
|
2374
|
+
}, [e]);
|
|
2375
|
+
const N = () => {
|
|
2376
|
+
const d = s.current?.globeMaterial?.();
|
|
2377
|
+
d && (d.map = null, d.color = new ge("#f5f5f5"), d.emissive = new ge("#ffffff"), d.emissiveIntensity = 0.35, d.specular = new ge("#d4d4d8"), d.shininess = 3, d.needsUpdate = !0);
|
|
2378
|
+
}, $ = (d, m, x) => {
|
|
2379
|
+
s.current?.pointOfView({ lat: d, lng: m, altitude: x }, 650);
|
|
2380
|
+
}, Z = () => {
|
|
2381
|
+
const d = s.current?.controls?.();
|
|
2382
|
+
d && (d.autoRotate = !1);
|
|
2383
|
+
}, W = (d) => {
|
|
2384
|
+
if (typeof d != "object" || d === null || !("coordinates" in d))
|
|
2385
|
+
return [];
|
|
2386
|
+
const m = d.coordinates, x = [], p = (b) => {
|
|
2387
|
+
if (Array.isArray(b)) {
|
|
2388
|
+
if (b.length >= 2 && typeof b[0] == "number" && typeof b[1] == "number") {
|
|
2389
|
+
x.push([b[0], b[1]]);
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
b.forEach(p);
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2395
|
+
return p(m), x;
|
|
2396
|
+
}, z = (d) => {
|
|
2397
|
+
const m = W(d.geometry);
|
|
2398
|
+
if (!m.length) return;
|
|
2399
|
+
const x = m.reduce(
|
|
2400
|
+
(p, [b, C]) => ({
|
|
2401
|
+
minLat: Math.min(p.minLat, C),
|
|
2402
|
+
maxLat: Math.max(p.maxLat, C),
|
|
2403
|
+
minLng: Math.min(p.minLng, b),
|
|
2404
|
+
maxLng: Math.max(p.maxLng, b)
|
|
2405
|
+
}),
|
|
2406
|
+
{
|
|
2407
|
+
minLat: Number.POSITIVE_INFINITY,
|
|
2408
|
+
maxLat: Number.NEGATIVE_INFINITY,
|
|
2409
|
+
minLng: Number.POSITIVE_INFINITY,
|
|
2410
|
+
maxLng: Number.NEGATIVE_INFINITY
|
|
2411
|
+
}
|
|
2412
|
+
);
|
|
2413
|
+
if (!(!Number.isFinite(x.minLat) || !Number.isFinite(x.minLng)))
|
|
2414
|
+
return x;
|
|
2415
|
+
}, U = (d) => {
|
|
2416
|
+
const m = Math.max(0.1, d.maxLat - d.minLat), x = Math.max(0.1, d.maxLng - d.minLng), b = Math.max(m, x) / 112;
|
|
2417
|
+
return Math.min(0.9, Math.max(0.14, b));
|
|
2418
|
+
}, L = () => {
|
|
2419
|
+
l.current && window.clearTimeout(l.current), l.current = window.setTimeout(() => {
|
|
2420
|
+
const d = s.current?.pointOfView?.().altitude ?? 2.4, m = en(d);
|
|
2421
|
+
F(m), m <= 0 && T(void 0);
|
|
2422
|
+
}, 120);
|
|
2423
|
+
}, c = (d) => {
|
|
2424
|
+
const m = d.properties ?? {};
|
|
2425
|
+
if (g === 0) {
|
|
2426
|
+
const x = n[String(m.name ?? "").toLowerCase()], p = m.__isoA2 ?? (typeof m.iso_a2 == "string" ? m.iso_a2.toUpperCase() : void 0) ?? x;
|
|
2427
|
+
if (!p) return;
|
|
2428
|
+
Z(), F(1), v(p), T(void 0);
|
|
2429
|
+
const b = z(d);
|
|
2430
|
+
if (b) {
|
|
2431
|
+
$(
|
|
2432
|
+
(b.minLat + b.maxLat) / 2,
|
|
2433
|
+
(b.minLng + b.maxLng) / 2,
|
|
2434
|
+
U(b)
|
|
2435
|
+
);
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
if (g >= 1) {
|
|
2441
|
+
const x = m.__regionName;
|
|
2442
|
+
if (!x) return;
|
|
2443
|
+
Z(), F(2), T(x);
|
|
2444
|
+
const p = z(d);
|
|
2445
|
+
if (p) {
|
|
2446
|
+
$(
|
|
2447
|
+
(p.minLat + p.maxLat) / 2,
|
|
2448
|
+
(p.minLng + p.maxLng) / 2,
|
|
2449
|
+
Math.max(0.2, U(p) * 0.52)
|
|
2450
|
+
);
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}, w = g === 0 ? R : _.length ? [...R, ..._] : R, k = (d, m) => {
|
|
2455
|
+
if (m && d)
|
|
2456
|
+
return t.regions[d]?.[m];
|
|
2457
|
+
if (d) return t.countries[d];
|
|
2458
|
+
}, M = (d) => {
|
|
2459
|
+
if (!d)
|
|
2460
|
+
return "<div>No data</div>";
|
|
2461
|
+
const m = Object.entries(d).filter(
|
|
2462
|
+
([, x]) => typeof x == "number" && Number.isFinite(x)
|
|
2463
|
+
);
|
|
2464
|
+
return m.length ? (m.sort(([x], [p]) => x === i ? -1 : p === i ? 1 : x.localeCompare(p)), m.map(
|
|
2465
|
+
([x, p]) => `<div>${x}: ${tn(p)}</div>`
|
|
2466
|
+
).join("")) : "<div>No data</div>";
|
|
2467
|
+
};
|
|
2468
|
+
return /* @__PURE__ */ rt.jsx(
|
|
2469
|
+
"div",
|
|
2470
|
+
{
|
|
2471
|
+
ref: a,
|
|
2472
|
+
style: {
|
|
2473
|
+
position: "relative",
|
|
2474
|
+
height: "100%",
|
|
2475
|
+
overflow: "hidden",
|
|
2476
|
+
background: "white"
|
|
2477
|
+
},
|
|
2478
|
+
children: /* @__PURE__ */ rt.jsx(
|
|
2479
|
+
Dt,
|
|
2480
|
+
{
|
|
2481
|
+
ref: s,
|
|
2482
|
+
globeImageUrl: Zt,
|
|
2483
|
+
backgroundColor: "#ffffff",
|
|
2484
|
+
polygonsData: w,
|
|
2485
|
+
polygonAltitude: 0.01,
|
|
2486
|
+
polygonsTransitionDuration: 180,
|
|
2487
|
+
polygonCapColor: (d) => {
|
|
2488
|
+
const m = d.properties ?? {}, x = !!m.__regionName;
|
|
2489
|
+
if (g > 0 && !x)
|
|
2490
|
+
return "rgba(148,163,184,0.027)";
|
|
2491
|
+
const p = g === 0 ? m.__isoA2 : m.__countryCode, b = m.__regionName, C = k(p, b), D = Ge(C, i), De = g === 0 ? y(D) : j(D);
|
|
2492
|
+
return I === d ? "#60a5fa" : De;
|
|
2493
|
+
},
|
|
2494
|
+
polygonSideColor: (d) => {
|
|
2495
|
+
const m = d.properties ?? {};
|
|
2496
|
+
return g > 0 && !m.__regionName ? "rgba(148,163,184,0.027)" : m.__regionName ? "rgba(148,163,184,0.22)" : "rgba(226,232,240,0.45)";
|
|
2497
|
+
},
|
|
2498
|
+
polygonStrokeColor: (d) => {
|
|
2499
|
+
const m = d.properties ?? {};
|
|
2500
|
+
return g > 0 && !m.__regionName ? "rgba(100,116,139,0.067)" : m.__regionName ? "rgba(51,65,85,0.98)" : "rgba(156,163,175,0.95)";
|
|
2501
|
+
},
|
|
2502
|
+
polygonLabel: (d) => {
|
|
2503
|
+
const m = d.properties ?? {}, x = g === 0 ? m.__isoA2 : m.__countryCode, p = m.__regionName, b = p ?? m.name ?? "Unknown", C = k(x, p), D = M(C);
|
|
2504
|
+
return `<div style="padding:6px 8px; font-size:12px; background:#111827; color:#f9fafb; border-radius:6px;">
|
|
2505
|
+
<div style="font-weight:700;">${b}</div>
|
|
2506
|
+
${D}
|
|
2507
|
+
</div>`;
|
|
2508
|
+
},
|
|
2509
|
+
onPolygonHover: (d) => {
|
|
2510
|
+
B(d ?? null);
|
|
2511
|
+
},
|
|
2512
|
+
onPolygonClick: (d) => c(d),
|
|
2513
|
+
onZoom: L,
|
|
2514
|
+
onGlobeReady: () => {
|
|
2515
|
+
N(), $(20, 15, 2.6);
|
|
2516
|
+
},
|
|
2517
|
+
onGlobeClick: () => {
|
|
2518
|
+
const d = s.current?.controls?.();
|
|
2519
|
+
d && (d.autoRotate = !1);
|
|
2520
|
+
},
|
|
2521
|
+
lineHoverPrecision: 0,
|
|
2522
|
+
width: ne.width,
|
|
2523
|
+
height: ne.height,
|
|
2524
|
+
showAtmosphere: !1
|
|
2525
|
+
}
|
|
2526
|
+
)
|
|
2527
|
+
}
|
|
2528
|
+
);
|
|
2529
|
+
};
|
|
2530
|
+
export {
|
|
2531
|
+
sn as CoolGlobe
|
|
2532
|
+
};
|