@takram/three-geospatial 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +15 -0
  2. package/build/index.cjs +43 -0
  3. package/build/index.js +932 -0
  4. package/build/r3f.cjs +1 -0
  5. package/build/r3f.js +38 -0
  6. package/build/shared.cjs +1 -0
  7. package/build/shared.js +198 -0
  8. package/package.json +42 -0
  9. package/src/ArrayBufferLoader.ts +35 -0
  10. package/src/DataLoader.ts +114 -0
  11. package/src/Ellipsoid.ts +128 -0
  12. package/src/EllipsoidGeometry.ts +107 -0
  13. package/src/Geodetic.ts +160 -0
  14. package/src/PointOfView.ts +169 -0
  15. package/src/Rectangle.ts +97 -0
  16. package/src/TileCoordinate.test.ts +38 -0
  17. package/src/TileCoordinate.ts +112 -0
  18. package/src/TilingScheme.test.ts +63 -0
  19. package/src/TilingScheme.ts +76 -0
  20. package/src/TypedArrayLoader.ts +53 -0
  21. package/src/assertions.ts +13 -0
  22. package/src/bufferGeometry.ts +62 -0
  23. package/src/helpers/projectOnEllipsoidSurface.ts +72 -0
  24. package/src/index.ts +25 -0
  25. package/src/math.ts +41 -0
  26. package/src/r3f/EastNorthUpFrame.tsx +52 -0
  27. package/src/r3f/EllipsoidMesh.tsx +36 -0
  28. package/src/r3f/index.ts +2 -0
  29. package/src/shaders/depth.glsl +15 -0
  30. package/src/shaders/packing.glsl +20 -0
  31. package/src/shaders/transform.glsl +12 -0
  32. package/src/typedArray.ts +76 -0
  33. package/src/types.ts +54 -0
  34. package/types/ArrayBufferLoader.d.ts +5 -0
  35. package/types/DataLoader.d.ts +67 -0
  36. package/types/Ellipsoid.d.ts +18 -0
  37. package/types/EllipsoidGeometry.d.ts +13 -0
  38. package/types/Geodetic.d.ts +37 -0
  39. package/types/PointOfView.d.ts +20 -0
  40. package/types/Rectangle.d.ts +27 -0
  41. package/types/TileCoordinate.d.ts +21 -0
  42. package/types/TilingScheme.d.ts +21 -0
  43. package/types/TypedArrayLoader.d.ts +16 -0
  44. package/types/assertions.d.ts +4 -0
  45. package/types/bufferGeometry.d.ts +5 -0
  46. package/types/helpers/projectOnEllipsoidSurface.d.ts +6 -0
  47. package/types/index.d.ts +18 -0
  48. package/types/math.d.ts +13 -0
  49. package/types/r3f/EastNorthUpFrame.d.ts +15 -0
  50. package/types/r3f/EllipsoidMesh.d.ts +13 -0
  51. package/types/r3f/index.d.ts +2 -0
  52. package/types/typedArray.d.ts +10 -0
  53. package/types/types.d.ts +22 -0
package/build/index.js ADDED
@@ -0,0 +1,932 @@
1
+ var Tt = Object.defineProperty;
2
+ var St = (e, t, n) => t in e ? Tt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var c = (e, t, n) => St(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { Loader as R, FileLoader as Pt, BufferAttribute as J, Box3 as Ot, Vector3 as f, Sphere as Mt, BufferGeometry as At, DataTexture as H, FloatType as I, Data3DTexture as zt, RGBAFormat as Et, ClampToEdgeWrapping as k, LinearFilter as tt, MathUtils as u, Matrix4 as It, Quaternion as Nt, Ray as Ct, Vector2 as ut } from "three";
5
+ import { E as et, G as m } from "./shared.js";
6
+ import { a as xr } from "./shared.js";
7
+ var Lt = `float reverseLogDepth(const float depth, const float near, const float far) {
8
+ #ifdef USE_LOGDEPTHBUF
9
+ float d = pow(2.0, depth * log2(far + 1.0)) - 1.0;
10
+ float a = far / (far - near);
11
+ float b = far * near / (near - far);
12
+ return a + b / d;
13
+ #else
14
+ return depth;
15
+ #endif
16
+ }
17
+
18
+ float linearizeDepth(const float depth, const float near, const float far) {
19
+ float ndc = depth * 2.0 - 1.0;
20
+ return 2.0 * near * far / (far + near - ndc * (far - near));
21
+ }`, Dt = `vec2 signNotZero(vec2 v) {
22
+ return vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
23
+ }
24
+
25
+ vec2 packNormalToVec2(vec3 v) {
26
+ vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
27
+ return v.z <= 0.0
28
+ ? (1.0 - abs(p.yx)) * signNotZero(p)
29
+ : p;
30
+ }
31
+
32
+ vec3 unpackVec2ToNormal(vec2 e) {
33
+ vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
34
+ if (v.z < 0.0) {
35
+ v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);
36
+ }
37
+ return normalize(v);
38
+ }`, Ft = `vec3 screenToView(
39
+ const vec2 uv,
40
+ const float depth,
41
+ const float viewZ,
42
+ const mat4 projectionMatrix,
43
+ const mat4 inverseProjectionMatrix
44
+ ) {
45
+ vec4 clip = vec4(vec3(uv, depth) * 2.0 - 1.0, 1.0);
46
+ float clipW = projectionMatrix[2][3] * viewZ + projectionMatrix[3][3];
47
+ clip *= clipW;
48
+ return (inverseProjectionMatrix * clip).xyz;
49
+ }`, $t = process.env.NODE_ENV === "production", nt = "Invariant failed";
50
+ function jt(e, t) {
51
+ if (!e) {
52
+ if ($t)
53
+ throw new Error(nt);
54
+ var n = nt;
55
+ throw new Error(n);
56
+ }
57
+ }
58
+ class Ut extends R {
59
+ load(t, n, r, i) {
60
+ const a = new Pt(this.manager);
61
+ a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
62
+ t,
63
+ (s) => {
64
+ jt(s instanceof ArrayBuffer);
65
+ try {
66
+ n(s);
67
+ } catch (o) {
68
+ i != null ? i(o) : console.error(o), this.manager.itemError(t);
69
+ }
70
+ },
71
+ r,
72
+ i
73
+ );
74
+ }
75
+ }
76
+ function Zn(e) {
77
+ }
78
+ function Gt(e) {
79
+ return e != null;
80
+ }
81
+ function Yn(e) {
82
+ return e !== void 0;
83
+ }
84
+ function Kn(e) {
85
+ return e !== !1;
86
+ }
87
+ var Rt = typeof global == "object" && global && global.Object === Object && global, Ht = typeof self == "object" && self && self.Object === Object && self, B = Rt || Ht || Function("return this")(), p = B.Symbol, dt = Object.prototype, Bt = dt.hasOwnProperty, qt = dt.toString, x = p ? p.toStringTag : void 0;
88
+ function Vt(e) {
89
+ var t = Bt.call(e, x), n = e[x];
90
+ try {
91
+ e[x] = void 0;
92
+ var r = !0;
93
+ } catch {
94
+ }
95
+ var i = qt.call(e);
96
+ return r && (t ? e[x] = n : delete e[x]), i;
97
+ }
98
+ var Wt = Object.prototype, Xt = Wt.toString;
99
+ function Zt(e) {
100
+ return Xt.call(e);
101
+ }
102
+ var Yt = "[object Null]", Kt = "[object Undefined]", rt = p ? p.toStringTag : void 0;
103
+ function q(e) {
104
+ return e == null ? e === void 0 ? Kt : Yt : rt && rt in Object(e) ? Vt(e) : Zt(e);
105
+ }
106
+ function V(e) {
107
+ return e != null && typeof e == "object";
108
+ }
109
+ var Qt = "[object Symbol]";
110
+ function W(e) {
111
+ return typeof e == "symbol" || V(e) && q(e) == Qt;
112
+ }
113
+ function Jt(e, t) {
114
+ for (var n = -1, r = e == null ? 0 : e.length, i = Array(r); ++n < r; )
115
+ i[n] = t(e[n], n, e);
116
+ return i;
117
+ }
118
+ var P = Array.isArray, kt = 1 / 0, it = p ? p.prototype : void 0, at = it ? it.toString : void 0;
119
+ function ft(e) {
120
+ if (typeof e == "string")
121
+ return e;
122
+ if (P(e))
123
+ return Jt(e, ft) + "";
124
+ if (W(e))
125
+ return at ? at.call(e) : "";
126
+ var t = e + "";
127
+ return t == "0" && 1 / e == -kt ? "-0" : t;
128
+ }
129
+ function A(e) {
130
+ var t = typeof e;
131
+ return e != null && (t == "object" || t == "function");
132
+ }
133
+ function te(e) {
134
+ return e;
135
+ }
136
+ var ee = "[object AsyncFunction]", ne = "[object Function]", re = "[object GeneratorFunction]", ie = "[object Proxy]";
137
+ function ae(e) {
138
+ if (!A(e))
139
+ return !1;
140
+ var t = q(e);
141
+ return t == ne || t == re || t == ee || t == ie;
142
+ }
143
+ var j = B["__core-js_shared__"], st = function() {
144
+ var e = /[^.]+$/.exec(j && j.keys && j.keys.IE_PROTO || "");
145
+ return e ? "Symbol(src)_1." + e : "";
146
+ }();
147
+ function se(e) {
148
+ return !!st && st in e;
149
+ }
150
+ var oe = Function.prototype, ce = oe.toString;
151
+ function he(e) {
152
+ if (e != null) {
153
+ try {
154
+ return ce.call(e);
155
+ } catch {
156
+ }
157
+ try {
158
+ return e + "";
159
+ } catch {
160
+ }
161
+ }
162
+ return "";
163
+ }
164
+ var le = /[\\^$.*+?()[\]{}|]/g, ue = /^\[object .+?Constructor\]$/, de = Function.prototype, fe = Object.prototype, pe = de.toString, ye = fe.hasOwnProperty, ge = RegExp(
165
+ "^" + pe.call(ye).replace(le, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
166
+ );
167
+ function we(e) {
168
+ if (!A(e) || se(e))
169
+ return !1;
170
+ var t = ae(e) ? ge : ue;
171
+ return t.test(he(e));
172
+ }
173
+ function ve(e, t) {
174
+ return e == null ? void 0 : e[t];
175
+ }
176
+ function X(e, t) {
177
+ var n = ve(e, t);
178
+ return we(n) ? n : void 0;
179
+ }
180
+ function me(e, t, n) {
181
+ switch (n.length) {
182
+ case 0:
183
+ return e.call(t);
184
+ case 1:
185
+ return e.call(t, n[0]);
186
+ case 2:
187
+ return e.call(t, n[0], n[1]);
188
+ case 3:
189
+ return e.call(t, n[0], n[1], n[2]);
190
+ }
191
+ return e.apply(t, n);
192
+ }
193
+ var xe = 800, _e = 16, be = Date.now;
194
+ function Te(e) {
195
+ var t = 0, n = 0;
196
+ return function() {
197
+ var r = be(), i = _e - (r - n);
198
+ if (n = r, i > 0) {
199
+ if (++t >= xe)
200
+ return arguments[0];
201
+ } else
202
+ t = 0;
203
+ return e.apply(void 0, arguments);
204
+ };
205
+ }
206
+ function Se(e) {
207
+ return function() {
208
+ return e;
209
+ };
210
+ }
211
+ var z = function() {
212
+ try {
213
+ var e = X(Object, "defineProperty");
214
+ return e({}, "", {}), e;
215
+ } catch {
216
+ }
217
+ }(), Pe = z ? function(e, t) {
218
+ return z(e, "toString", {
219
+ configurable: !0,
220
+ enumerable: !1,
221
+ value: Se(t),
222
+ writable: !0
223
+ });
224
+ } : te, Oe = Te(Pe), Me = 9007199254740991, Ae = /^(?:0|[1-9]\d*)$/;
225
+ function pt(e, t) {
226
+ var n = typeof e;
227
+ return t = t ?? Me, !!t && (n == "number" || n != "symbol" && Ae.test(e)) && e > -1 && e % 1 == 0 && e < t;
228
+ }
229
+ function ze(e, t, n) {
230
+ t == "__proto__" && z ? z(e, t, {
231
+ configurable: !0,
232
+ enumerable: !0,
233
+ value: n,
234
+ writable: !0
235
+ }) : e[t] = n;
236
+ }
237
+ function yt(e, t) {
238
+ return e === t || e !== e && t !== t;
239
+ }
240
+ var Ee = Object.prototype, Ie = Ee.hasOwnProperty;
241
+ function Ne(e, t, n) {
242
+ var r = e[t];
243
+ (!(Ie.call(e, t) && yt(r, n)) || n === void 0 && !(t in e)) && ze(e, t, n);
244
+ }
245
+ var ot = Math.max;
246
+ function Ce(e, t, n) {
247
+ return t = ot(t === void 0 ? e.length - 1 : t, 0), function() {
248
+ for (var r = arguments, i = -1, a = ot(r.length - t, 0), s = Array(a); ++i < a; )
249
+ s[i] = r[t + i];
250
+ i = -1;
251
+ for (var o = Array(t + 1); ++i < t; )
252
+ o[i] = r[i];
253
+ return o[t] = n(s), me(e, this, o);
254
+ };
255
+ }
256
+ var Le = 9007199254740991;
257
+ function De(e) {
258
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= Le;
259
+ }
260
+ var Fe = "[object Arguments]";
261
+ function ct(e) {
262
+ return V(e) && q(e) == Fe;
263
+ }
264
+ var gt = Object.prototype, $e = gt.hasOwnProperty, je = gt.propertyIsEnumerable, wt = ct(/* @__PURE__ */ function() {
265
+ return arguments;
266
+ }()) ? ct : function(e) {
267
+ return V(e) && $e.call(e, "callee") && !je.call(e, "callee");
268
+ }, Ue = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Ge = /^\w*$/;
269
+ function Re(e, t) {
270
+ if (P(e))
271
+ return !1;
272
+ var n = typeof e;
273
+ return n == "number" || n == "symbol" || n == "boolean" || e == null || W(e) ? !0 : Ge.test(e) || !Ue.test(e) || t != null && e in Object(t);
274
+ }
275
+ var T = X(Object, "create");
276
+ function He() {
277
+ this.__data__ = T ? T(null) : {}, this.size = 0;
278
+ }
279
+ function Be(e) {
280
+ var t = this.has(e) && delete this.__data__[e];
281
+ return this.size -= t ? 1 : 0, t;
282
+ }
283
+ var qe = "__lodash_hash_undefined__", Ve = Object.prototype, We = Ve.hasOwnProperty;
284
+ function Xe(e) {
285
+ var t = this.__data__;
286
+ if (T) {
287
+ var n = t[e];
288
+ return n === qe ? void 0 : n;
289
+ }
290
+ return We.call(t, e) ? t[e] : void 0;
291
+ }
292
+ var Ze = Object.prototype, Ye = Ze.hasOwnProperty;
293
+ function Ke(e) {
294
+ var t = this.__data__;
295
+ return T ? t[e] !== void 0 : Ye.call(t, e);
296
+ }
297
+ var Qe = "__lodash_hash_undefined__";
298
+ function Je(e, t) {
299
+ var n = this.__data__;
300
+ return this.size += this.has(e) ? 0 : 1, n[e] = T && t === void 0 ? Qe : t, this;
301
+ }
302
+ function g(e) {
303
+ var t = -1, n = e == null ? 0 : e.length;
304
+ for (this.clear(); ++t < n; ) {
305
+ var r = e[t];
306
+ this.set(r[0], r[1]);
307
+ }
308
+ }
309
+ g.prototype.clear = He;
310
+ g.prototype.delete = Be;
311
+ g.prototype.get = Xe;
312
+ g.prototype.has = Ke;
313
+ g.prototype.set = Je;
314
+ function ke() {
315
+ this.__data__ = [], this.size = 0;
316
+ }
317
+ function N(e, t) {
318
+ for (var n = e.length; n--; )
319
+ if (yt(e[n][0], t))
320
+ return n;
321
+ return -1;
322
+ }
323
+ var tn = Array.prototype, en = tn.splice;
324
+ function nn(e) {
325
+ var t = this.__data__, n = N(t, e);
326
+ if (n < 0)
327
+ return !1;
328
+ var r = t.length - 1;
329
+ return n == r ? t.pop() : en.call(t, n, 1), --this.size, !0;
330
+ }
331
+ function rn(e) {
332
+ var t = this.__data__, n = N(t, e);
333
+ return n < 0 ? void 0 : t[n][1];
334
+ }
335
+ function an(e) {
336
+ return N(this.__data__, e) > -1;
337
+ }
338
+ function sn(e, t) {
339
+ var n = this.__data__, r = N(n, e);
340
+ return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
341
+ }
342
+ function v(e) {
343
+ var t = -1, n = e == null ? 0 : e.length;
344
+ for (this.clear(); ++t < n; ) {
345
+ var r = e[t];
346
+ this.set(r[0], r[1]);
347
+ }
348
+ }
349
+ v.prototype.clear = ke;
350
+ v.prototype.delete = nn;
351
+ v.prototype.get = rn;
352
+ v.prototype.has = an;
353
+ v.prototype.set = sn;
354
+ var on = X(B, "Map");
355
+ function cn() {
356
+ this.size = 0, this.__data__ = {
357
+ hash: new g(),
358
+ map: new (on || v)(),
359
+ string: new g()
360
+ };
361
+ }
362
+ function hn(e) {
363
+ var t = typeof e;
364
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
365
+ }
366
+ function C(e, t) {
367
+ var n = e.__data__;
368
+ return hn(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
369
+ }
370
+ function ln(e) {
371
+ var t = C(this, e).delete(e);
372
+ return this.size -= t ? 1 : 0, t;
373
+ }
374
+ function un(e) {
375
+ return C(this, e).get(e);
376
+ }
377
+ function dn(e) {
378
+ return C(this, e).has(e);
379
+ }
380
+ function fn(e, t) {
381
+ var n = C(this, e), r = n.size;
382
+ return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
383
+ }
384
+ function w(e) {
385
+ var t = -1, n = e == null ? 0 : e.length;
386
+ for (this.clear(); ++t < n; ) {
387
+ var r = e[t];
388
+ this.set(r[0], r[1]);
389
+ }
390
+ }
391
+ w.prototype.clear = cn;
392
+ w.prototype.delete = ln;
393
+ w.prototype.get = un;
394
+ w.prototype.has = dn;
395
+ w.prototype.set = fn;
396
+ var pn = "Expected a function";
397
+ function Z(e, t) {
398
+ if (typeof e != "function" || t != null && typeof t != "function")
399
+ throw new TypeError(pn);
400
+ var n = function() {
401
+ var r = arguments, i = t ? t.apply(this, r) : r[0], a = n.cache;
402
+ if (a.has(i))
403
+ return a.get(i);
404
+ var s = e.apply(this, r);
405
+ return n.cache = a.set(i, s) || a, s;
406
+ };
407
+ return n.cache = new (Z.Cache || w)(), n;
408
+ }
409
+ Z.Cache = w;
410
+ var yn = 500;
411
+ function gn(e) {
412
+ var t = Z(e, function(r) {
413
+ return n.size === yn && n.clear(), r;
414
+ }), n = t.cache;
415
+ return t;
416
+ }
417
+ var wn = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, vn = /\\(\\)?/g, mn = gn(function(e) {
418
+ var t = [];
419
+ return e.charCodeAt(0) === 46 && t.push(""), e.replace(wn, function(n, r, i, a) {
420
+ t.push(i ? a.replace(vn, "$1") : r || n);
421
+ }), t;
422
+ });
423
+ function xn(e) {
424
+ return e == null ? "" : ft(e);
425
+ }
426
+ function L(e, t) {
427
+ return P(e) ? e : Re(e, t) ? [e] : mn(xn(e));
428
+ }
429
+ var _n = 1 / 0;
430
+ function Y(e) {
431
+ if (typeof e == "string" || W(e))
432
+ return e;
433
+ var t = e + "";
434
+ return t == "0" && 1 / e == -_n ? "-0" : t;
435
+ }
436
+ function bn(e, t) {
437
+ t = L(t, e);
438
+ for (var n = 0, r = t.length; e != null && n < r; )
439
+ e = e[Y(t[n++])];
440
+ return n && n == r ? e : void 0;
441
+ }
442
+ function Tn(e, t) {
443
+ for (var n = -1, r = t.length, i = e.length; ++n < r; )
444
+ e[i + n] = t[n];
445
+ return e;
446
+ }
447
+ var ht = p ? p.isConcatSpreadable : void 0;
448
+ function Sn(e) {
449
+ return P(e) || wt(e) || !!(ht && e && e[ht]);
450
+ }
451
+ function Pn(e, t, n, r, i) {
452
+ var a = -1, s = e.length;
453
+ for (n || (n = Sn), i || (i = []); ++a < s; ) {
454
+ var o = e[a];
455
+ n(o) ? Tn(i, o) : i[i.length] = o;
456
+ }
457
+ return i;
458
+ }
459
+ function On(e) {
460
+ var t = e == null ? 0 : e.length;
461
+ return t ? Pn(e) : [];
462
+ }
463
+ function Mn(e) {
464
+ return Oe(Ce(e, void 0, On), e + "");
465
+ }
466
+ function An(e, t) {
467
+ return e != null && t in Object(e);
468
+ }
469
+ function zn(e, t, n) {
470
+ t = L(t, e);
471
+ for (var r = -1, i = t.length, a = !1; ++r < i; ) {
472
+ var s = Y(t[r]);
473
+ if (!(a = e != null && n(e, s)))
474
+ break;
475
+ e = e[s];
476
+ }
477
+ return a || ++r != i ? a : (i = e == null ? 0 : e.length, !!i && De(i) && pt(s, i) && (P(e) || wt(e)));
478
+ }
479
+ function En(e, t) {
480
+ return e != null && zn(e, t, An);
481
+ }
482
+ function In(e, t, n, r) {
483
+ if (!A(e))
484
+ return e;
485
+ t = L(t, e);
486
+ for (var i = -1, a = t.length, s = a - 1, o = e; o != null && ++i < a; ) {
487
+ var h = Y(t[i]), l = n;
488
+ if (h === "__proto__" || h === "constructor" || h === "prototype")
489
+ return e;
490
+ if (i != s) {
491
+ var y = o[h];
492
+ l = void 0, l === void 0 && (l = A(y) ? y : pt(t[i + 1]) ? [] : {});
493
+ }
494
+ Ne(o, h, l), o = o[h];
495
+ }
496
+ return e;
497
+ }
498
+ function Nn(e, t, n) {
499
+ for (var r = -1, i = t.length, a = {}; ++r < i; ) {
500
+ var s = t[r], o = bn(e, s);
501
+ n(o, s) && In(a, L(s, e), o);
502
+ }
503
+ return a;
504
+ }
505
+ function Cn(e, t) {
506
+ return Nn(e, t, function(n, r) {
507
+ return En(e, r);
508
+ });
509
+ }
510
+ var Ln = Mn(function(e, t) {
511
+ return e == null ? {} : Cn(e, t);
512
+ });
513
+ function Qn(e) {
514
+ var t;
515
+ return [
516
+ Ln(e, ["attributes", "index", "boundingBox", "boundingSphere"]),
517
+ [
518
+ ...Object.values(e.attributes).map(
519
+ (n) => n.array.buffer
520
+ ),
521
+ (t = e.index) == null ? void 0 : t.array.buffer
522
+ ].filter(Gt)
523
+ ];
524
+ }
525
+ function Jn(e, t = new At()) {
526
+ for (const [n, r] of Object.entries(e.attributes))
527
+ t.setAttribute(
528
+ n,
529
+ new J(
530
+ r.array,
531
+ r.itemSize,
532
+ r.normalized
533
+ )
534
+ );
535
+ if (t.index = e.index != null ? new J(
536
+ e.index.array,
537
+ e.index.itemSize,
538
+ e.index.normalized
539
+ ) : null, e.boundingBox != null) {
540
+ const { min: n, max: r } = e.boundingBox;
541
+ t.boundingBox = new Ot(
542
+ new f(n.x, n.y, n.z),
543
+ new f(r.x, r.y, r.z)
544
+ );
545
+ }
546
+ if (e.boundingSphere != null) {
547
+ const { center: n, radius: r } = e.boundingSphere;
548
+ t.boundingSphere = new Mt(
549
+ new f(n.x, n.y, n.z),
550
+ r
551
+ );
552
+ }
553
+ return t;
554
+ }
555
+ function K(e, t, n, r = !0) {
556
+ const i = new DataView(e), a = new t(i.byteLength / t.BYTES_PER_ELEMENT);
557
+ for (let s = 0, o = 0; s < a.length; ++s, o += t.BYTES_PER_ELEMENT)
558
+ a[s] = i[n](o, r);
559
+ return a;
560
+ }
561
+ function Dn(e, t) {
562
+ return K(e, Int16Array, "getInt16", t);
563
+ }
564
+ function Fn(e, t) {
565
+ return K(e, Uint16Array, "getUint16", t);
566
+ }
567
+ function $n(e, t) {
568
+ return K(e, Float32Array, "getFloat32", t);
569
+ }
570
+ class Q extends R {
571
+ load(t, n, r, i) {
572
+ const a = new Ut(this.manager);
573
+ a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
574
+ t,
575
+ (s) => {
576
+ try {
577
+ n(this.parseTypedArray(s));
578
+ } catch (o) {
579
+ i != null ? i(o) : console.error(o), this.manager.itemError(t);
580
+ }
581
+ },
582
+ r,
583
+ i
584
+ );
585
+ }
586
+ }
587
+ class jn extends Q {
588
+ constructor() {
589
+ super(...arguments);
590
+ c(this, "parseTypedArray", Dn);
591
+ }
592
+ }
593
+ class Un extends Q {
594
+ constructor() {
595
+ super(...arguments);
596
+ c(this, "parseTypedArray", Fn);
597
+ }
598
+ }
599
+ class vt extends Q {
600
+ constructor() {
601
+ super(...arguments);
602
+ c(this, "parseTypedArray", $n);
603
+ }
604
+ }
605
+ const D = {
606
+ format: Et,
607
+ wrapS: k,
608
+ wrapT: k,
609
+ minFilter: tt,
610
+ magFilter: tt
611
+ };
612
+ class F extends R {
613
+ constructor() {
614
+ super(...arguments);
615
+ c(this, "parameters");
616
+ }
617
+ load(n, r, i, a) {
618
+ const s = new this.Texture(), o = new this.TypedArrayLoader(this.manager);
619
+ o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
620
+ n,
621
+ (h) => {
622
+ s.image.data = h, Object.assign(s, this.parameters), s.needsUpdate = !0, r(s);
623
+ },
624
+ i,
625
+ a
626
+ );
627
+ }
628
+ }
629
+ class kn extends F {
630
+ constructor() {
631
+ super(...arguments);
632
+ c(this, "Texture", H);
633
+ c(this, "TypedArrayLoader", jn);
634
+ c(this, "parameters", {
635
+ ...D,
636
+ type: I
637
+ });
638
+ }
639
+ }
640
+ class tr extends F {
641
+ constructor() {
642
+ super(...arguments);
643
+ c(this, "Texture", H);
644
+ c(this, "TypedArrayLoader", Un);
645
+ c(this, "parameters", {
646
+ ...D,
647
+ type: I
648
+ });
649
+ }
650
+ }
651
+ class er extends F {
652
+ constructor() {
653
+ super(...arguments);
654
+ c(this, "Texture", H);
655
+ c(this, "TypedArrayLoader", vt);
656
+ c(this, "parameters", {
657
+ ...D,
658
+ type: I
659
+ });
660
+ }
661
+ }
662
+ class nr extends F {
663
+ constructor() {
664
+ super(...arguments);
665
+ c(this, "Texture", zt);
666
+ c(this, "TypedArrayLoader", vt);
667
+ c(this, "parameters", {
668
+ ...D,
669
+ type: I
670
+ });
671
+ }
672
+ }
673
+ const Gn = u.clamp, rr = u.euclideanModulo, ir = u.inverseLerp, ar = u.lerp, sr = u.degToRad, or = u.radToDeg, cr = u.isPowerOfTwo, hr = u.ceilPowerOfTwo, lr = u.floorPowerOfTwo, ur = u.normalize;
674
+ function dr(e, t, n) {
675
+ return n <= e ? 0 : n >= t ? 1 : (n = (n - e) / (t - e), n * n * (3 - 2 * n));
676
+ }
677
+ function fr(e) {
678
+ return Math.min(Math.max(e, 0), 1);
679
+ }
680
+ function pr(e, t, n, r = n) {
681
+ const i = Math.abs(e - t);
682
+ return i <= r || i <= n * Math.max(Math.abs(e), Math.abs(t));
683
+ }
684
+ const U = 1e-6, O = /* @__PURE__ */ new f(), M = /* @__PURE__ */ new f(), d = /* @__PURE__ */ new f(), _ = /* @__PURE__ */ new f(), G = /* @__PURE__ */ new f(), Rn = /* @__PURE__ */ new f(), Hn = /* @__PURE__ */ new It(), Bn = /* @__PURE__ */ new Nt(), qn = /* @__PURE__ */ new Ct();
685
+ class mt {
686
+ constructor(t = 0, n = 0, r = 0, i = 0) {
687
+ // Distance from the target.
688
+ c(this, "_distance");
689
+ // Radians from the local east direction relative from true north, measured
690
+ // clockwise (90 degrees is true north, and -90 is true south).
691
+ c(this, "heading");
692
+ // Radians from the local horizon plane, measured with positive values looking
693
+ // up (90 degrees is straight up, -90 is straight down).
694
+ c(this, "_pitch");
695
+ c(this, "roll");
696
+ this.distance = t, this.heading = n, this.pitch = r, this.roll = i;
697
+ }
698
+ get distance() {
699
+ return this._distance;
700
+ }
701
+ set distance(t) {
702
+ this._distance = Math.max(t, U);
703
+ }
704
+ get pitch() {
705
+ return this._pitch;
706
+ }
707
+ set pitch(t) {
708
+ this._pitch = Gn(t, -Math.PI / 2 + U, Math.PI / 2 - U);
709
+ }
710
+ set(t, n, r, i) {
711
+ return this.distance = t, this.heading = n, this.pitch = r, i != null && (this.roll = i), this;
712
+ }
713
+ clone() {
714
+ return new mt(this.distance, this.heading, this.pitch, this.roll);
715
+ }
716
+ copy(t) {
717
+ return this.distance = t.distance, this.heading = t.heading, this.pitch = t.pitch, this.roll = t.roll, this;
718
+ }
719
+ equals(t) {
720
+ return t.distance === this.distance && t.heading === this.heading && t.pitch === this.pitch && t.roll === this.roll;
721
+ }
722
+ decompose(t, n, r, i, a = et.WGS84) {
723
+ a.getEastNorthUpVectors(
724
+ t,
725
+ O,
726
+ M,
727
+ d
728
+ ), i == null || i.copy(d);
729
+ const s = _.copy(O).multiplyScalar(Math.cos(this.heading)).add(
730
+ G.copy(M).multiplyScalar(Math.sin(this.heading))
731
+ ).multiplyScalar(Math.cos(this.pitch)).add(G.copy(d).multiplyScalar(Math.sin(this.pitch))).normalize().multiplyScalar(this.distance);
732
+ if (n.copy(t).sub(s), this.roll !== 0) {
733
+ const o = _.copy(t).sub(n).normalize();
734
+ d.applyQuaternion(
735
+ Bn.setFromAxisAngle(o, this.roll)
736
+ );
737
+ }
738
+ r.setFromRotationMatrix(
739
+ Hn.lookAt(n, t, d)
740
+ );
741
+ }
742
+ setFromCamera(t, n = et.WGS84) {
743
+ const r = _.setFromMatrixPosition(t.matrixWorld), i = G.set(0, 0, 0.5).unproject(t).sub(r).normalize(), a = n.getIntersection(qn.set(r, i));
744
+ if (a == null)
745
+ return;
746
+ this.distance = r.distanceTo(a), n.getEastNorthUpVectors(
747
+ a,
748
+ O,
749
+ M,
750
+ d
751
+ ), this.heading = Math.atan2(
752
+ M.dot(i),
753
+ O.dot(i)
754
+ ), this.pitch = Math.asin(d.dot(i));
755
+ const s = _.copy(t.up).applyQuaternion(t.quaternion), o = Rn.copy(i).multiplyScalar(-s.dot(i)).add(s).normalize(), h = _.copy(i).multiplyScalar(-d.dot(i)).add(d).normalize(), l = h.dot(o), y = i.dot(h.cross(o));
756
+ return this.roll = Math.atan2(y, l), this;
757
+ }
758
+ }
759
+ const b = class b {
760
+ constructor(t = 0, n = 0, r = 0, i = 0) {
761
+ this.west = t, this.south = n, this.east = r, this.north = i;
762
+ }
763
+ get width() {
764
+ let t = this.east;
765
+ return t < this.west && (t += Math.PI * 2), t - this.west;
766
+ }
767
+ get height() {
768
+ return this.north - this.south;
769
+ }
770
+ set(t, n, r, i) {
771
+ return this.west = t, this.south = n, this.east = r, this.north = i, this;
772
+ }
773
+ clone() {
774
+ return new b(this.west, this.south, this.east, this.north);
775
+ }
776
+ copy(t) {
777
+ return this.west = t.west, this.south = t.south, this.east = t.east, this.north = t.north, this;
778
+ }
779
+ equals(t) {
780
+ return t.west === this.west && t.south === this.south && t.east === this.east && t.north === this.north;
781
+ }
782
+ at(t, n, r = new m()) {
783
+ return r.set(
784
+ this.west + (this.east - this.west) * t,
785
+ this.north + (this.south - this.north) * n
786
+ );
787
+ }
788
+ fromArray(t, n = 0) {
789
+ return this.west = t[n], this.south = t[n + 1], this.east = t[n + 2], this.north = t[n + 3], this;
790
+ }
791
+ toArray(t = [], n = 0) {
792
+ return t[n] = this.west, t[n + 1] = this.south, t[n + 2] = this.east, t[n + 3] = this.north, t;
793
+ }
794
+ *[Symbol.iterator]() {
795
+ yield this.west, yield this.south, yield this.east, yield this.north;
796
+ }
797
+ };
798
+ c(b, "MAX", /* @__PURE__ */ new b(
799
+ m.MIN_LONGITUDE,
800
+ m.MIN_LATITUDE,
801
+ m.MAX_LONGITUDE,
802
+ m.MAX_LATITUDE
803
+ ));
804
+ let E = b;
805
+ function* xt(e, t, n, r, i) {
806
+ if (n >= r)
807
+ return;
808
+ const a = 2 ** n, s = n + 1, o = 2 ** s, h = Math.floor(e / a * o), l = Math.floor(t / a * o), y = [
809
+ [h, l, s],
810
+ [h + 1, l, s],
811
+ [h, l + 1, s],
812
+ [h + 1, l + 1, s]
813
+ ];
814
+ if (s < r)
815
+ for (const $ of y)
816
+ for (const bt of xt(...$, r, i))
817
+ yield bt;
818
+ else
819
+ for (const $ of y)
820
+ yield (i ?? new S()).set(...$);
821
+ }
822
+ class S {
823
+ constructor(t = 0, n = 0, r = 0) {
824
+ this.x = t, this.y = n, this.z = r;
825
+ }
826
+ set(t, n, r) {
827
+ return this.x = t, this.y = n, r != null && (this.z = r), this;
828
+ }
829
+ clone() {
830
+ return new S(this.x, this.y, this.z);
831
+ }
832
+ copy(t) {
833
+ return this.x = t.x, this.y = t.y, this.z = t.z, this;
834
+ }
835
+ equals(t) {
836
+ return t.x === this.x && t.y === this.y && t.z === this.z;
837
+ }
838
+ getParent(t = new S()) {
839
+ const n = 2 ** this.z, r = this.x / n, i = this.y / n, a = this.z - 1, s = 2 ** a;
840
+ return t.set(Math.floor(r * s), Math.floor(i * s), a);
841
+ }
842
+ *traverseChildren(t, n) {
843
+ const { x: r, y: i, z: a } = this;
844
+ for (const s of xt(r, i, a, a + t, n))
845
+ yield s;
846
+ }
847
+ fromArray(t, n = 0) {
848
+ return this.x = t[n], this.y = t[n + 1], this.z = t[n + 2], this;
849
+ }
850
+ toArray(t = [], n = 0) {
851
+ return t[n] = this.x, t[n + 1] = this.y, t[n + 2] = this.z, t;
852
+ }
853
+ *[Symbol.iterator]() {
854
+ yield this.x, yield this.y, yield this.z;
855
+ }
856
+ }
857
+ const lt = /* @__PURE__ */ new ut();
858
+ class _t {
859
+ constructor(t = 2, n = 1, r = E.MAX) {
860
+ this.width = t, this.height = n, this.rectangle = r;
861
+ }
862
+ clone() {
863
+ return new _t(this.width, this.height, this.rectangle.clone());
864
+ }
865
+ copy(t) {
866
+ return this.width = t.width, this.height = t.height, this.rectangle.copy(t.rectangle), this;
867
+ }
868
+ getSize(t, n = new ut()) {
869
+ return n.set(this.width << t, this.height << t);
870
+ }
871
+ // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/GeographicTilingScheme.js#L210
872
+ getTile(t, n, r = new S()) {
873
+ const i = this.getSize(n, lt), a = this.rectangle.width / i.x, s = this.rectangle.height / i.y;
874
+ let o = t.longitude;
875
+ this.rectangle.east < this.rectangle.west && (o += Math.PI * 2);
876
+ let h = Math.floor((o - this.rectangle.west) / a);
877
+ h >= i.x && (h = i.x - 1);
878
+ let l = Math.floor((t.latitude - this.rectangle.south) / s);
879
+ return l >= i.y && (l = i.y - 1), r.x = h, r.y = l, r.z = n, r;
880
+ }
881
+ // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/GeographicTilingScheme.js#L169
882
+ getRectangle(t, n = new E()) {
883
+ const r = this.getSize(t.z, lt), i = this.rectangle.width / r.x, a = this.rectangle.height / r.y;
884
+ return n.west = t.x * i + this.rectangle.west, n.east = (t.x + 1) * i + this.rectangle.west, n.north = this.rectangle.north - (r.y - t.y - 1) * a, n.south = this.rectangle.north - (r.y - t.y) * a, n;
885
+ }
886
+ }
887
+ const yr = Lt, gr = Dt, wr = Ft;
888
+ export {
889
+ Ut as ArrayBufferLoader,
890
+ F as DataLoader,
891
+ et as Ellipsoid,
892
+ xr as EllipsoidGeometry,
893
+ vt as Float32ArrayLoader,
894
+ er as Float32Data2DLoader,
895
+ nr as Float32Data3DLoader,
896
+ m as Geodetic,
897
+ jn as Int16ArrayLoader,
898
+ kn as Int16Data2DLoader,
899
+ mt as PointOfView,
900
+ E as Rectangle,
901
+ S as TileCoordinate,
902
+ _t as TilingScheme,
903
+ Q as TypedArrayLoader,
904
+ Un as Uint16ArrayLoader,
905
+ tr as Uint16Data2DLoader,
906
+ Zn as assertType,
907
+ hr as ceilPowerOfTwo,
908
+ Gn as clamp,
909
+ pr as closeTo,
910
+ or as degrees,
911
+ yr as depthShader,
912
+ rr as euclideanModulo,
913
+ lr as floorPowerOfTwo,
914
+ Jn as fromBufferGeometryLike,
915
+ ir as inverseLerp,
916
+ Kn as isNotFalse,
917
+ Gt as isNotNullish,
918
+ Yn as isNotUndefined,
919
+ cr as isPowerOfTwo,
920
+ ar as lerp,
921
+ ur as normalize,
922
+ gr as packingShader,
923
+ $n as parseFloat32Array,
924
+ Dn as parseInt16Array,
925
+ K as parseTypedArray,
926
+ Fn as parseUint16Array,
927
+ sr as radians,
928
+ fr as saturate,
929
+ dr as smoothstep,
930
+ Qn as toBufferGeometryLike,
931
+ wr as transformShader
932
+ };