@loaders.gl/3d-tiles 3.1.0-beta.2 → 3.1.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 (120) hide show
  1. package/dist/bundle.js +2399 -193
  2. package/dist/es5/bundle.js +1 -1
  3. package/dist/es5/bundle.js.map +1 -1
  4. package/dist/es5/cesium-ion-loader.js +78 -23
  5. package/dist/es5/cesium-ion-loader.js.map +1 -1
  6. package/dist/es5/index.js +8 -8
  7. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +42 -30
  8. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  9. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +59 -57
  10. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  11. package/dist/es5/lib/classes/tile-3d-batch-table.js +238 -201
  12. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
  13. package/dist/es5/lib/classes/tile-3d-feature-table.js +78 -62
  14. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
  15. package/dist/es5/lib/constants.js +6 -5
  16. package/dist/es5/lib/constants.js.map +1 -1
  17. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +22 -15
  18. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
  19. package/dist/es5/lib/encoders/encode-3d-tile-composite.js +13 -6
  20. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
  21. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +23 -14
  22. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
  23. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +22 -15
  24. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
  25. package/dist/es5/lib/encoders/encode-3d-tile.js +3 -3
  26. package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
  27. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +6 -6
  28. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
  29. package/dist/es5/lib/ion/ion.js +197 -69
  30. package/dist/es5/lib/ion/ion.js.map +1 -1
  31. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +18 -17
  32. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  33. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +3 -3
  34. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  35. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +3 -3
  36. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  37. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +270 -0
  38. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  39. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +66 -26
  40. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  41. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +4 -3
  42. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  43. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +141 -53
  44. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  45. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +17 -19
  46. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  47. package/dist/es5/lib/parsers/helpers/parse-utils.js +8 -7
  48. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
  49. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +36 -10
  50. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  51. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +48 -12
  52. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  53. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +45 -0
  54. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  55. package/dist/es5/lib/parsers/parse-3d-tile-header.js +161 -14
  56. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  57. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +63 -38
  58. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  59. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +198 -117
  60. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  61. package/dist/es5/lib/parsers/parse-3d-tile.js +74 -15
  62. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  63. package/dist/es5/lib/utils/version.js +1 -1
  64. package/dist/es5/lib/utils/version.js.map +1 -1
  65. package/dist/es5/tile-3d-subtree-loader.js +1 -1
  66. package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
  67. package/dist/es5/tile-3d-writer.js +5 -5
  68. package/dist/es5/tile-3d-writer.js.map +1 -1
  69. package/dist/es5/tiles-3d-loader.js +142 -37
  70. package/dist/es5/tiles-3d-loader.js.map +1 -1
  71. package/dist/esm/lib/constants.js +2 -1
  72. package/dist/esm/lib/constants.js.map +1 -1
  73. package/dist/esm/lib/ion/ion.js.map +1 -1
  74. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +173 -0
  75. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  76. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  77. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +10 -0
  78. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  79. package/dist/esm/lib/parsers/parse-3d-tile-header.js +67 -0
  80. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  81. package/dist/esm/lib/parsers/parse-3d-tile.js +4 -0
  82. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  83. package/dist/esm/lib/utils/version.js +1 -1
  84. package/dist/esm/lib/utils/version.js.map +1 -1
  85. package/dist/esm/tiles-3d-loader.js +9 -2
  86. package/dist/esm/tiles-3d-loader.js.map +1 -1
  87. package/dist/lib/constants.d.ts +1 -0
  88. package/dist/lib/constants.d.ts.map +1 -1
  89. package/dist/lib/constants.js +2 -1
  90. package/dist/lib/ion/ion.d.ts +3 -3
  91. package/dist/lib/ion/ion.d.ts.map +1 -1
  92. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +39 -0
  93. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -0
  94. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +189 -0
  95. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +2 -2
  96. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
  97. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -0
  98. package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
  99. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -0
  100. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -0
  101. package/dist/lib/parsers/parse-3d-tile-gltf.js +18 -0
  102. package/dist/lib/parsers/parse-3d-tile-header.d.ts +16 -0
  103. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  104. package/dist/lib/parsers/parse-3d-tile-header.js +67 -1
  105. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  106. package/dist/lib/parsers/parse-3d-tile.js +3 -0
  107. package/dist/tiles-3d-loader.d.ts.map +1 -1
  108. package/dist/tiles-3d-loader.js +8 -1
  109. package/dist/types.d.ts +6 -2
  110. package/dist/types.d.ts.map +1 -1
  111. package/package.json +8 -8
  112. package/src/lib/constants.ts +2 -1
  113. package/src/lib/ion/{ion.js → ion.ts} +0 -0
  114. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +255 -0
  115. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +4 -3
  116. package/src/lib/parsers/parse-3d-tile-gltf.js +16 -0
  117. package/src/lib/parsers/parse-3d-tile-header.ts +82 -1
  118. package/src/lib/parsers/parse-3d-tile.ts +4 -0
  119. package/src/tiles-3d-loader.ts +17 -2
  120. package/src/types.ts +7 -2
package/dist/bundle.js CHANGED
@@ -1,5 +1,10 @@
1
1
  (() => {
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
8
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
4
9
  var __esm = (fn, res) => function __init() {
5
10
  return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
@@ -12,6 +17,17 @@
12
17
  for (var name8 in all)
13
18
  __defProp(target, name8, { get: all[name8], enumerable: true });
14
19
  };
20
+ var __reExport = (target, module2, desc) => {
21
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
22
+ for (let key of __getOwnPropNames(module2))
23
+ if (!__hasOwnProp.call(target, key) && key !== "default")
24
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
25
+ }
26
+ return target;
27
+ };
28
+ var __toModule = (module2) => {
29
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
30
+ };
15
31
 
16
32
  // ../loader-utils/src/lib/env-utils/assert.ts
17
33
  function assert2(condition, message) {
@@ -48,7 +64,7 @@
48
64
  var DEFAULT_VERSION, VERSION;
49
65
  var init_version = __esm({
50
66
  "../worker-utils/src/lib/env-utils/version.ts"() {
51
- DEFAULT_VERSION = "beta";
67
+ DEFAULT_VERSION = "latest";
52
68
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
53
69
  if (typeof __VERSION__ === "undefined") {
54
70
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
@@ -89,8 +105,423 @@
89
105
  }
90
106
  });
91
107
 
108
+ // ../worker-utils/src/lib/worker-farm/worker-job.ts
109
+ var WorkerJob;
110
+ var init_worker_job = __esm({
111
+ "../worker-utils/src/lib/worker-farm/worker-job.ts"() {
112
+ init_assert2();
113
+ WorkerJob = class {
114
+ constructor(jobName, workerThread) {
115
+ this.name = jobName;
116
+ this.workerThread = workerThread;
117
+ this.isRunning = true;
118
+ this._resolve = () => {
119
+ };
120
+ this._reject = () => {
121
+ };
122
+ this.result = new Promise((resolve, reject) => {
123
+ this._resolve = resolve;
124
+ this._reject = reject;
125
+ });
126
+ }
127
+ postMessage(type, payload) {
128
+ this.workerThread.postMessage({
129
+ source: "loaders.gl",
130
+ type,
131
+ payload
132
+ });
133
+ }
134
+ done(value) {
135
+ assert3(this.isRunning);
136
+ this.isRunning = false;
137
+ this._resolve(value);
138
+ }
139
+ error(error) {
140
+ assert3(this.isRunning);
141
+ this.isRunning = false;
142
+ this._reject(error);
143
+ }
144
+ };
145
+ }
146
+ });
147
+
148
+ // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
149
+ function getLoadableWorkerURL(props) {
150
+ assert3(props.source && !props.url || !props.source && props.url);
151
+ let workerURL = workerURLCache.get(props.source || props.url);
152
+ if (!workerURL) {
153
+ if (props.url) {
154
+ workerURL = getLoadableWorkerURLFromURL(props.url);
155
+ workerURLCache.set(props.url, workerURL);
156
+ }
157
+ if (props.source) {
158
+ workerURL = getLoadableWorkerURLFromSource(props.source);
159
+ workerURLCache.set(props.source, workerURL);
160
+ }
161
+ }
162
+ assert3(workerURL);
163
+ return workerURL;
164
+ }
165
+ function getLoadableWorkerURLFromURL(url) {
166
+ if (!url.startsWith("http")) {
167
+ return url;
168
+ }
169
+ const workerSource = buildScriptSource(url);
170
+ return getLoadableWorkerURLFromSource(workerSource);
171
+ }
172
+ function getLoadableWorkerURLFromSource(workerSource) {
173
+ const blob = new Blob([workerSource], { type: "application/javascript" });
174
+ return URL.createObjectURL(blob);
175
+ }
176
+ function buildScriptSource(workerUrl) {
177
+ return `try {
178
+ importScripts('${workerUrl}');
179
+ } catch (error) {
180
+ console.error(error);
181
+ throw error;
182
+ }`;
183
+ }
184
+ var workerURLCache;
185
+ var init_get_loadable_worker_url = __esm({
186
+ "../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts"() {
187
+ init_assert2();
188
+ workerURLCache = new Map();
189
+ }
190
+ });
191
+
192
+ // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
193
+ function getTransferList(object, recursive = true, transfers) {
194
+ const transfersSet = transfers || new Set();
195
+ if (!object) {
196
+ } else if (isTransferable(object)) {
197
+ transfersSet.add(object);
198
+ } else if (isTransferable(object.buffer)) {
199
+ transfersSet.add(object.buffer);
200
+ } else if (ArrayBuffer.isView(object)) {
201
+ } else if (recursive && typeof object === "object") {
202
+ for (const key in object) {
203
+ getTransferList(object[key], recursive, transfersSet);
204
+ }
205
+ }
206
+ return transfers === void 0 ? Array.from(transfersSet) : [];
207
+ }
208
+ function isTransferable(object) {
209
+ if (!object) {
210
+ return false;
211
+ }
212
+ if (object instanceof ArrayBuffer) {
213
+ return true;
214
+ }
215
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
216
+ return true;
217
+ }
218
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
219
+ return true;
220
+ }
221
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
222
+ return true;
223
+ }
224
+ return false;
225
+ }
226
+ var init_get_transfer_list = __esm({
227
+ "../worker-utils/src/lib/worker-utils/get-transfer-list.ts"() {
228
+ }
229
+ });
230
+
231
+ // ../worker-utils/src/lib/worker-farm/worker-thread.ts
232
+ var NOOP, WorkerThread;
233
+ var init_worker_thread = __esm({
234
+ "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
235
+ init_assert2();
236
+ init_get_loadable_worker_url();
237
+ init_get_transfer_list();
238
+ NOOP = () => {
239
+ };
240
+ WorkerThread = class {
241
+ constructor(props) {
242
+ this.terminated = false;
243
+ this._loadableURL = "";
244
+ const { name: name8, source, url } = props;
245
+ assert3(source || url);
246
+ this.name = name8;
247
+ this.source = source;
248
+ this.url = url;
249
+ this.onMessage = NOOP;
250
+ this.onError = (error) => console.log(error);
251
+ this.worker = this._createBrowserWorker();
252
+ }
253
+ static isSupported() {
254
+ return typeof Worker !== "undefined";
255
+ }
256
+ destroy() {
257
+ this.onMessage = NOOP;
258
+ this.onError = NOOP;
259
+ this.worker.terminate();
260
+ this.terminated = true;
261
+ }
262
+ get isRunning() {
263
+ return Boolean(this.onMessage);
264
+ }
265
+ postMessage(data, transferList) {
266
+ transferList = transferList || getTransferList(data);
267
+ this.worker.postMessage(data, transferList);
268
+ }
269
+ _getErrorFromErrorEvent(event) {
270
+ let message = "Failed to load ";
271
+ message += `worker ${this.name} from ${this.url}. `;
272
+ if (event.message) {
273
+ message += `${event.message} in `;
274
+ }
275
+ if (event.lineno) {
276
+ message += `:${event.lineno}:${event.colno}`;
277
+ }
278
+ return new Error(message);
279
+ }
280
+ _createBrowserWorker() {
281
+ this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
282
+ const worker = new Worker(this._loadableURL, { name: this.name });
283
+ worker.onmessage = (event) => {
284
+ if (!event.data) {
285
+ this.onError(new Error("No data received"));
286
+ } else {
287
+ this.onMessage(event.data);
288
+ }
289
+ };
290
+ worker.onerror = (error) => {
291
+ this.onError(this._getErrorFromErrorEvent(error));
292
+ this.terminated = true;
293
+ };
294
+ worker.onmessageerror = (event) => console.error(event);
295
+ return worker;
296
+ }
297
+ };
298
+ }
299
+ });
300
+
301
+ // ../worker-utils/src/lib/worker-farm/worker-pool.ts
302
+ var WorkerPool;
303
+ var init_worker_pool = __esm({
304
+ "../worker-utils/src/lib/worker-farm/worker-pool.ts"() {
305
+ init_globals2();
306
+ init_worker_thread();
307
+ init_worker_job();
308
+ WorkerPool = class {
309
+ constructor(props) {
310
+ this.name = "unnamed";
311
+ this.maxConcurrency = 1;
312
+ this.maxMobileConcurrency = 1;
313
+ this.onDebug = () => {
314
+ };
315
+ this.reuseWorkers = true;
316
+ this.props = {};
317
+ this.jobQueue = [];
318
+ this.idleQueue = [];
319
+ this.count = 0;
320
+ this.isDestroyed = false;
321
+ this.source = props.source;
322
+ this.url = props.url;
323
+ this.setProps(props);
324
+ }
325
+ destroy() {
326
+ this.idleQueue.forEach((worker) => worker.destroy());
327
+ this.isDestroyed = true;
328
+ }
329
+ setProps(props) {
330
+ this.props = { ...this.props, ...props };
331
+ if (props.name !== void 0) {
332
+ this.name = props.name;
333
+ }
334
+ if (props.maxConcurrency !== void 0) {
335
+ this.maxConcurrency = props.maxConcurrency;
336
+ }
337
+ if (props.maxMobileConcurrency !== void 0) {
338
+ this.maxMobileConcurrency = props.maxMobileConcurrency;
339
+ }
340
+ if (props.reuseWorkers !== void 0) {
341
+ this.reuseWorkers = props.reuseWorkers;
342
+ }
343
+ if (props.onDebug !== void 0) {
344
+ this.onDebug = props.onDebug;
345
+ }
346
+ }
347
+ async startJob(name8, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
348
+ const startPromise = new Promise((onStart) => {
349
+ this.jobQueue.push({ name: name8, onMessage: onMessage2, onError, onStart });
350
+ return this;
351
+ });
352
+ this._startQueuedJob();
353
+ return await startPromise;
354
+ }
355
+ async _startQueuedJob() {
356
+ if (!this.jobQueue.length) {
357
+ return;
358
+ }
359
+ const workerThread = this._getAvailableWorker();
360
+ if (!workerThread) {
361
+ return;
362
+ }
363
+ const queuedJob = this.jobQueue.shift();
364
+ if (queuedJob) {
365
+ this.onDebug({
366
+ message: "Starting job",
367
+ name: queuedJob.name,
368
+ workerThread,
369
+ backlog: this.jobQueue.length
370
+ });
371
+ const job = new WorkerJob(queuedJob.name, workerThread);
372
+ workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
373
+ workerThread.onError = (error) => queuedJob.onError(job, error);
374
+ queuedJob.onStart(job);
375
+ try {
376
+ await job.result;
377
+ } finally {
378
+ this.returnWorkerToQueue(workerThread);
379
+ }
380
+ }
381
+ }
382
+ returnWorkerToQueue(worker) {
383
+ const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
384
+ if (shouldDestroyWorker) {
385
+ worker.destroy();
386
+ this.count--;
387
+ } else {
388
+ this.idleQueue.push(worker);
389
+ }
390
+ if (!this.isDestroyed) {
391
+ this._startQueuedJob();
392
+ }
393
+ }
394
+ _getAvailableWorker() {
395
+ if (this.idleQueue.length > 0) {
396
+ return this.idleQueue.shift() || null;
397
+ }
398
+ if (this.count < this._getMaxConcurrency()) {
399
+ this.count++;
400
+ const name8 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
401
+ return new WorkerThread({ name: name8, source: this.source, url: this.url });
402
+ }
403
+ return null;
404
+ }
405
+ _getMaxConcurrency() {
406
+ return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
407
+ }
408
+ };
409
+ }
410
+ });
411
+
412
+ // ../worker-utils/src/lib/worker-farm/worker-farm.ts
413
+ var DEFAULT_PROPS, WorkerFarm;
414
+ var init_worker_farm = __esm({
415
+ "../worker-utils/src/lib/worker-farm/worker-farm.ts"() {
416
+ init_worker_pool();
417
+ init_worker_thread();
418
+ DEFAULT_PROPS = {
419
+ maxConcurrency: 3,
420
+ maxMobileConcurrency: 1,
421
+ onDebug: () => {
422
+ },
423
+ reuseWorkers: true
424
+ };
425
+ WorkerFarm = class {
426
+ constructor(props) {
427
+ this.workerPools = new Map();
428
+ this.props = { ...DEFAULT_PROPS };
429
+ this.setProps(props);
430
+ this.workerPools = new Map();
431
+ }
432
+ static isSupported() {
433
+ return WorkerThread.isSupported();
434
+ }
435
+ static getWorkerFarm(props = {}) {
436
+ WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
437
+ WorkerFarm._workerFarm.setProps(props);
438
+ return WorkerFarm._workerFarm;
439
+ }
440
+ destroy() {
441
+ for (const workerPool of this.workerPools.values()) {
442
+ workerPool.destroy();
443
+ }
444
+ }
445
+ setProps(props) {
446
+ this.props = { ...this.props, ...props };
447
+ for (const workerPool of this.workerPools.values()) {
448
+ workerPool.setProps(this._getWorkerPoolProps());
449
+ }
450
+ }
451
+ getWorkerPool(options) {
452
+ const { name: name8, source, url } = options;
453
+ let workerPool = this.workerPools.get(name8);
454
+ if (!workerPool) {
455
+ workerPool = new WorkerPool({
456
+ name: name8,
457
+ source,
458
+ url
459
+ });
460
+ workerPool.setProps(this._getWorkerPoolProps());
461
+ this.workerPools.set(name8, workerPool);
462
+ }
463
+ return workerPool;
464
+ }
465
+ _getWorkerPoolProps() {
466
+ return {
467
+ maxConcurrency: this.props.maxConcurrency,
468
+ maxMobileConcurrency: this.props.maxMobileConcurrency,
469
+ reuseWorkers: this.props.reuseWorkers,
470
+ onDebug: this.props.onDebug
471
+ };
472
+ }
473
+ };
474
+ }
475
+ });
476
+
477
+ // ../worker-utils/src/lib/worker-api/get-worker-url.ts
478
+ function getWorkerURL(worker, options = {}) {
479
+ const workerOptions = options[worker.id] || {};
480
+ const workerFile = `${worker.id}-worker.js`;
481
+ let url = workerOptions.workerUrl;
482
+ if (!url && worker.id === "compression") {
483
+ url = options.workerUrl;
484
+ }
485
+ if (options._workerType === "test") {
486
+ url = `modules/${worker.module}/dist/${workerFile}`;
487
+ }
488
+ if (!url) {
489
+ let version = worker.version;
490
+ if (version === "latest") {
491
+ version = NPM_TAG;
492
+ }
493
+ const versionTag = version ? `@${version}` : "";
494
+ url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
495
+ }
496
+ assert3(url);
497
+ return url;
498
+ }
499
+ var NPM_TAG;
500
+ var init_get_worker_url = __esm({
501
+ "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
502
+ init_assert2();
503
+ NPM_TAG = "latest";
504
+ }
505
+ });
506
+
507
+ // ../worker-utils/src/lib/worker-api/validate-worker-version.ts
508
+ function validateWorkerVersion(worker, coreVersion = VERSION) {
509
+ assert3(worker, "no worker provided");
510
+ const workerVersion = worker.version;
511
+ if (!coreVersion || !workerVersion) {
512
+ return false;
513
+ }
514
+ return true;
515
+ }
516
+ var init_validate_worker_version = __esm({
517
+ "../worker-utils/src/lib/worker-api/validate-worker-version.ts"() {
518
+ init_assert2();
519
+ init_version();
520
+ }
521
+ });
522
+
92
523
  // (disabled):../worker-utils/src/lib/node/require-utils.node
93
- var init_require_utils = __esm({
524
+ var require_require_utils = __commonJS({
94
525
  "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
95
526
  }
96
527
  });
@@ -129,7 +560,11 @@
129
560
  return await response2.arrayBuffer();
130
561
  }
131
562
  if (!isBrowser2) {
132
- return node.requireFromFile && await node.requireFromFile(libraryUrl);
563
+ try {
564
+ return node && node.requireFromFile && await node.requireFromFile(libraryUrl);
565
+ } catch {
566
+ return null;
567
+ }
133
568
  }
134
569
  if (isWorker) {
135
570
  return importScripts(libraryUrl);
@@ -156,14 +591,14 @@
156
591
  document.body.appendChild(script);
157
592
  return null;
158
593
  }
159
- var LATEST, VERSION2, loadLibraryPromises;
594
+ var node, LATEST, VERSION2, loadLibraryPromises;
160
595
  var init_library_utils = __esm({
161
596
  "../worker-utils/src/lib/library-utils/library-utils.ts"() {
162
597
  init_globals2();
163
- init_require_utils();
598
+ node = __toModule(require_require_utils());
164
599
  init_assert2();
165
600
  init_version();
166
- LATEST = "beta";
601
+ LATEST = "latest";
167
602
  VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
168
603
  loadLibraryPromises = {};
169
604
  }
@@ -172,10 +607,63 @@
172
607
  // ../worker-utils/src/index.ts
173
608
  var init_src = __esm({
174
609
  "../worker-utils/src/index.ts"() {
610
+ init_assert2();
611
+ init_worker_farm();
612
+ init_get_worker_url();
613
+ init_validate_worker_version();
175
614
  init_library_utils();
176
615
  }
177
616
  });
178
617
 
618
+ // ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
619
+ function canParseWithWorker(loader, options) {
620
+ if (!WorkerFarm.isSupported()) {
621
+ return false;
622
+ }
623
+ return loader.worker && options?.worker;
624
+ }
625
+ async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
626
+ const name8 = loader.id;
627
+ const url = getWorkerURL(loader, options);
628
+ const workerFarm = WorkerFarm.getWorkerFarm(options);
629
+ const workerPool = workerFarm.getWorkerPool({ name: name8, url });
630
+ options = JSON.parse(JSON.stringify(options));
631
+ const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
632
+ job.postMessage("process", {
633
+ input: data,
634
+ options
635
+ });
636
+ const result = await job.result;
637
+ return await result.result;
638
+ }
639
+ async function onMessage(parseOnMainThread, job, type, payload) {
640
+ switch (type) {
641
+ case "done":
642
+ job.done(payload);
643
+ break;
644
+ case "error":
645
+ job.error(new Error(payload.error));
646
+ break;
647
+ case "process":
648
+ const { id, input, options } = payload;
649
+ try {
650
+ const result = await parseOnMainThread(input, options);
651
+ job.postMessage("done", { id, result });
652
+ } catch (error) {
653
+ const message = error instanceof Error ? error.message : "unknown error";
654
+ job.postMessage("error", { id, error: message });
655
+ }
656
+ break;
657
+ default:
658
+ console.warn(`parse-with-worker unknown message ${type}`);
659
+ }
660
+ }
661
+ var init_parse_with_worker = __esm({
662
+ "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
663
+ init_src();
664
+ }
665
+ });
666
+
179
667
  // ../loader-utils/src/lib/binary-utils/get-first-characters.ts
180
668
  function getFirstCharacters(data, length4 = 5) {
181
669
  if (typeof data === "string") {
@@ -218,7 +706,71 @@
218
706
  }
219
707
  });
220
708
 
709
+ // ../loader-utils/src/lib/binary-utils/buffer-utils.ts
710
+ function isBuffer(value) {
711
+ return value && typeof value === "object" && value.isBuffer;
712
+ }
713
+ function bufferToArrayBuffer(buffer) {
714
+ if (isBuffer(buffer)) {
715
+ const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
716
+ return typedArray.slice().buffer;
717
+ }
718
+ return buffer;
719
+ }
720
+ var init_buffer_utils = __esm({
721
+ "../loader-utils/src/lib/binary-utils/buffer-utils.ts"() {
722
+ }
723
+ });
724
+
221
725
  // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
726
+ function toArrayBuffer(data) {
727
+ if (isBuffer(data)) {
728
+ return bufferToArrayBuffer(data);
729
+ }
730
+ if (data instanceof ArrayBuffer) {
731
+ return data;
732
+ }
733
+ if (ArrayBuffer.isView(data)) {
734
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
735
+ return data.buffer;
736
+ }
737
+ return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
738
+ }
739
+ if (typeof data === "string") {
740
+ const text = data;
741
+ const uint8Array = new TextEncoder().encode(text);
742
+ return uint8Array.buffer;
743
+ }
744
+ if (data && typeof data === "object" && data._toArrayBuffer) {
745
+ return data._toArrayBuffer();
746
+ }
747
+ throw new Error("toArrayBuffer");
748
+ }
749
+ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
750
+ byteLength = byteLength || arrayBuffer1.byteLength;
751
+ if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
752
+ return false;
753
+ }
754
+ const array1 = new Uint8Array(arrayBuffer1);
755
+ const array2 = new Uint8Array(arrayBuffer2);
756
+ for (let i2 = 0; i2 < array1.length; ++i2) {
757
+ if (array1[i2] !== array2[i2]) {
758
+ return false;
759
+ }
760
+ }
761
+ return true;
762
+ }
763
+ function concatenateArrayBuffers(...sources) {
764
+ const sourceArrays = sources.map((source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
765
+ const byteLength = sourceArrays.reduce((length4, typedArray) => length4 + typedArray.byteLength, 0);
766
+ const result = new Uint8Array(byteLength);
767
+ let offset = 0;
768
+ for (const sourceArray of sourceArrays) {
769
+ result.set(sourceArray, offset);
770
+ offset += sourceArray.byteLength;
771
+ }
772
+ return result.buffer;
773
+ }
222
774
  function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
223
775
  const subArray = byteLength !== void 0 ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
224
776
  const arrayCopy = new Uint8Array(subArray);
@@ -226,6 +778,7 @@
226
778
  }
227
779
  var init_array_buffer_utils = __esm({
228
780
  "../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
781
+ init_buffer_utils();
229
782
  }
230
783
  });
231
784
 
@@ -312,6 +865,20 @@
312
865
  }
313
866
  });
314
867
 
868
+ // ../loader-utils/src/lib/iterators/async-iteration.ts
869
+ async function concatenateArrayBuffersAsync(asyncIterator) {
870
+ const arrayBuffers = [];
871
+ for await (const chunk of asyncIterator) {
872
+ arrayBuffers.push(chunk);
873
+ }
874
+ return concatenateArrayBuffers(...arrayBuffers);
875
+ }
876
+ var init_async_iteration = __esm({
877
+ "../loader-utils/src/lib/iterators/async-iteration.ts"() {
878
+ init_array_buffer_utils();
879
+ }
880
+ });
881
+
315
882
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
316
883
  function resolvePath(filename2) {
317
884
  for (const alias in fileAliases) {
@@ -371,11 +938,13 @@
371
938
  "../loader-utils/src/index.ts"() {
372
939
  init_assert();
373
940
  init_globals();
941
+ init_parse_with_worker();
374
942
  init_parse_json();
375
943
  init_array_buffer_utils();
376
944
  init_memory_copy_utils();
377
945
  init_binary_copy_utils();
378
946
  init_encode_utils();
947
+ init_async_iteration();
379
948
  init_file_aliases();
380
949
  init_path();
381
950
  }
@@ -904,11 +1473,11 @@
904
1473
  out[1] = m[1] * x + m[5] * y + m[13];
905
1474
  return out;
906
1475
  }
907
- var forEach;
1476
+ var forEach2;
908
1477
  var init_vec2 = __esm({
909
1478
  "../../node_modules/gl-matrix/esm/vec2.js"() {
910
1479
  init_common2();
911
- forEach = function() {
1480
+ forEach2 = function() {
912
1481
  var vec = create();
913
1482
  return function(a2, stride, offset, count, fn, arg) {
914
1483
  var i2, l2;
@@ -1184,12 +1753,12 @@
1184
1753
  var ax = a2[0], ay = a2[1], az = a2[2], bx = b[0], by = b[1], bz = b[2], mag1 = Math.sqrt(ax * ax + ay * ay + az * az), mag2 = Math.sqrt(bx * bx + by * by + bz * bz), mag = mag1 * mag2, cosine = mag && dot(a2, b) / mag;
1185
1754
  return Math.acos(Math.min(Math.max(cosine, -1), 1));
1186
1755
  }
1187
- var len, forEach2;
1756
+ var len, forEach3;
1188
1757
  var init_vec3 = __esm({
1189
1758
  "../../node_modules/gl-matrix/esm/vec3.js"() {
1190
1759
  init_common2();
1191
1760
  len = length;
1192
- forEach2 = function() {
1761
+ forEach3 = function() {
1193
1762
  var vec = create2();
1194
1763
  return function(a2, stride, offset, count, fn, arg) {
1195
1764
  var i2, l2;
@@ -2353,11 +2922,11 @@
2353
2922
  out[3] = a2[3];
2354
2923
  return out;
2355
2924
  }
2356
- var forEach3;
2925
+ var forEach4;
2357
2926
  var init_vec4 = __esm({
2358
2927
  "../../node_modules/gl-matrix/esm/vec4.js"() {
2359
2928
  init_common2();
2360
- forEach3 = function() {
2929
+ forEach4 = function() {
2361
2930
  var vec = create4();
2362
2931
  return function(a2, stride, offset, count, fn, arg) {
2363
2932
  var i2, l2;
@@ -3649,11 +4218,21 @@
3649
4218
  });
3650
4219
 
3651
4220
  // ../core/src/javascript-utils/is-type.ts
3652
- var isResponse, isBlob;
4221
+ var isBoolean, isFunction, isObject, isPureObject, isIterable, isAsyncIterable, isResponse, isBlob, isBuffer2, isReadableDOMStream, isReadableNodeStream, isReadableStream;
3653
4222
  var init_is_type = __esm({
3654
4223
  "../core/src/javascript-utils/is-type.ts"() {
4224
+ isBoolean = (x) => typeof x === "boolean";
4225
+ isFunction = (x) => typeof x === "function";
4226
+ isObject = (x) => x !== null && typeof x === "object";
4227
+ isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
4228
+ isIterable = (x) => x && typeof x[Symbol.iterator] === "function";
4229
+ isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
3655
4230
  isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
3656
4231
  isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
4232
+ isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
4233
+ isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
4234
+ isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
4235
+ isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
3657
4236
  }
3658
4237
  });
3659
4238
 
@@ -3762,6 +4341,26 @@
3762
4341
  Object.defineProperty(response, "url", { value: url });
3763
4342
  return response;
3764
4343
  }
4344
+ async function checkResponse(response) {
4345
+ if (!response.ok) {
4346
+ const message = await getResponseError(response);
4347
+ throw new Error(message);
4348
+ }
4349
+ }
4350
+ async function getResponseError(response) {
4351
+ let message = `Failed to fetch resource ${response.url} (${response.status}): `;
4352
+ try {
4353
+ const contentType = response.headers.get("Content-Type");
4354
+ let text = response.statusText;
4355
+ if (contentType.includes("application/json")) {
4356
+ text += ` ${await response.text()}`;
4357
+ }
4358
+ message += text;
4359
+ message = message.length > 60 ? `${message.slice(60)}...` : message;
4360
+ } catch (error) {
4361
+ }
4362
+ return message;
4363
+ }
3765
4364
  async function getInitialDataUrl(resource) {
3766
4365
  const INITIAL_DATA_LENGTH = 5;
3767
4366
  if (typeof resource === "string") {
@@ -3816,10 +4415,1367 @@
3816
4415
  }
3817
4416
  });
3818
4417
 
4418
+ // ../../node_modules/probe.gl/dist/esm/env/is-electron.js
4419
+ function isElectron(mockUserAgent) {
4420
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
4421
+ return true;
4422
+ }
4423
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions.electron)) {
4424
+ return true;
4425
+ }
4426
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
4427
+ const userAgent = mockUserAgent || realUserAgent;
4428
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
4429
+ return true;
4430
+ }
4431
+ return false;
4432
+ }
4433
+ var init_is_electron = __esm({
4434
+ "../../node_modules/probe.gl/dist/esm/env/is-electron.js"() {
4435
+ }
4436
+ });
4437
+
4438
+ // ../../node_modules/probe.gl/dist/esm/env/is-browser.js
4439
+ function isBrowser3() {
4440
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
4441
+ return !isNode || isElectron();
4442
+ }
4443
+ var init_is_browser = __esm({
4444
+ "../../node_modules/probe.gl/dist/esm/env/is-browser.js"() {
4445
+ init_is_electron();
4446
+ }
4447
+ });
4448
+
4449
+ // ../../node_modules/probe.gl/dist/esm/env/globals.js
4450
+ var globals4, self_3, window_3, global_4, document_3, process_;
4451
+ var init_globals3 = __esm({
4452
+ "../../node_modules/probe.gl/dist/esm/env/globals.js"() {
4453
+ globals4 = {
4454
+ self: typeof self !== "undefined" && self,
4455
+ window: typeof window !== "undefined" && window,
4456
+ global: typeof global !== "undefined" && global,
4457
+ document: typeof document !== "undefined" && document,
4458
+ process: typeof process === "object" && process
4459
+ };
4460
+ self_3 = globals4.self || globals4.window || globals4.global;
4461
+ window_3 = globals4.window || globals4.self || globals4.global;
4462
+ global_4 = globals4.global || globals4.self || globals4.window;
4463
+ document_3 = globals4.document || {};
4464
+ process_ = globals4.process || {};
4465
+ }
4466
+ });
4467
+
4468
+ // ../../node_modules/probe.gl/dist/esm/utils/globals.js
4469
+ var VERSION3, isBrowser4;
4470
+ var init_globals4 = __esm({
4471
+ "../../node_modules/probe.gl/dist/esm/utils/globals.js"() {
4472
+ init_is_browser();
4473
+ init_globals3();
4474
+ VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
4475
+ isBrowser4 = isBrowser3();
4476
+ }
4477
+ });
4478
+
4479
+ // ../../node_modules/probe.gl/dist/esm/utils/local-storage.js
4480
+ function getStorage(type) {
4481
+ try {
4482
+ const storage = window[type];
4483
+ const x = "__storage_test__";
4484
+ storage.setItem(x, x);
4485
+ storage.removeItem(x);
4486
+ return storage;
4487
+ } catch (e) {
4488
+ return null;
4489
+ }
4490
+ }
4491
+ var LocalStorage;
4492
+ var init_local_storage = __esm({
4493
+ "../../node_modules/probe.gl/dist/esm/utils/local-storage.js"() {
4494
+ LocalStorage = class {
4495
+ constructor(id, defaultSettings, type = "sessionStorage") {
4496
+ this.storage = getStorage(type);
4497
+ this.id = id;
4498
+ this.config = {};
4499
+ Object.assign(this.config, defaultSettings);
4500
+ this._loadConfiguration();
4501
+ }
4502
+ getConfiguration() {
4503
+ return this.config;
4504
+ }
4505
+ setConfiguration(configuration) {
4506
+ this.config = {};
4507
+ return this.updateConfiguration(configuration);
4508
+ }
4509
+ updateConfiguration(configuration) {
4510
+ Object.assign(this.config, configuration);
4511
+ if (this.storage) {
4512
+ const serialized = JSON.stringify(this.config);
4513
+ this.storage.setItem(this.id, serialized);
4514
+ }
4515
+ return this;
4516
+ }
4517
+ _loadConfiguration() {
4518
+ let configuration = {};
4519
+ if (this.storage) {
4520
+ const serializedConfiguration = this.storage.getItem(this.id);
4521
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
4522
+ }
4523
+ Object.assign(this.config, configuration);
4524
+ return this;
4525
+ }
4526
+ };
4527
+ }
4528
+ });
4529
+
4530
+ // ../../node_modules/probe.gl/dist/esm/utils/formatters.js
4531
+ function formatTime(ms) {
4532
+ let formatted;
4533
+ if (ms < 10) {
4534
+ formatted = "".concat(ms.toFixed(2), "ms");
4535
+ } else if (ms < 100) {
4536
+ formatted = "".concat(ms.toFixed(1), "ms");
4537
+ } else if (ms < 1e3) {
4538
+ formatted = "".concat(ms.toFixed(0), "ms");
4539
+ } else {
4540
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
4541
+ }
4542
+ return formatted;
4543
+ }
4544
+ function leftPad(string, length4 = 8) {
4545
+ const padLength = Math.max(length4 - string.length, 0);
4546
+ return "".concat(" ".repeat(padLength)).concat(string);
4547
+ }
4548
+ function formatImage(image, message, scale5, maxWidth = 600) {
4549
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
4550
+ if (image.width > maxWidth) {
4551
+ scale5 = Math.min(scale5, maxWidth / image.width);
4552
+ }
4553
+ const width = image.width * scale5;
4554
+ const height = image.height * scale5;
4555
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
4556
+ return ["".concat(message, " %c+"), style];
4557
+ }
4558
+ var init_formatters = __esm({
4559
+ "../../node_modules/probe.gl/dist/esm/utils/formatters.js"() {
4560
+ }
4561
+ });
4562
+
4563
+ // ../../node_modules/probe.gl/dist/esm/utils/color.js
4564
+ function getColor(color) {
4565
+ return typeof color === "string" ? COLOR[color.toUpperCase()] || COLOR.WHITE : color;
4566
+ }
4567
+ function addColor(string, color, background) {
4568
+ if (!isBrowser4 && typeof string === "string") {
4569
+ if (color) {
4570
+ color = getColor(color);
4571
+ string = "[".concat(color, "m").concat(string, "");
4572
+ }
4573
+ if (background) {
4574
+ color = getColor(background);
4575
+ string = "[".concat(background + 10, "m").concat(string, "");
4576
+ }
4577
+ }
4578
+ return string;
4579
+ }
4580
+ var COLOR;
4581
+ var init_color = __esm({
4582
+ "../../node_modules/probe.gl/dist/esm/utils/color.js"() {
4583
+ init_globals4();
4584
+ COLOR = {
4585
+ BLACK: 30,
4586
+ RED: 31,
4587
+ GREEN: 32,
4588
+ YELLOW: 33,
4589
+ BLUE: 34,
4590
+ MAGENTA: 35,
4591
+ CYAN: 36,
4592
+ WHITE: 37,
4593
+ BRIGHT_BLACK: 90,
4594
+ BRIGHT_RED: 91,
4595
+ BRIGHT_GREEN: 92,
4596
+ BRIGHT_YELLOW: 93,
4597
+ BRIGHT_BLUE: 94,
4598
+ BRIGHT_MAGENTA: 95,
4599
+ BRIGHT_CYAN: 96,
4600
+ BRIGHT_WHITE: 97
4601
+ };
4602
+ }
4603
+ });
4604
+
4605
+ // ../../node_modules/probe.gl/dist/esm/utils/autobind.js
4606
+ function autobind(obj, predefined = ["constructor"]) {
4607
+ const proto = Object.getPrototypeOf(obj);
4608
+ const propNames = Object.getOwnPropertyNames(proto);
4609
+ for (const key of propNames) {
4610
+ if (typeof obj[key] === "function") {
4611
+ if (!predefined.find((name8) => key === name8)) {
4612
+ obj[key] = obj[key].bind(obj);
4613
+ }
4614
+ }
4615
+ }
4616
+ }
4617
+ var init_autobind = __esm({
4618
+ "../../node_modules/probe.gl/dist/esm/utils/autobind.js"() {
4619
+ }
4620
+ });
4621
+
4622
+ // ../../node_modules/probe.gl/dist/esm/utils/assert.js
4623
+ function assert5(condition, message) {
4624
+ if (!condition) {
4625
+ throw new Error(message || "Assertion failed");
4626
+ }
4627
+ }
4628
+ var init_assert4 = __esm({
4629
+ "../../node_modules/probe.gl/dist/esm/utils/assert.js"() {
4630
+ }
4631
+ });
4632
+
4633
+ // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
4634
+ function getHiResTimestamp() {
4635
+ let timestamp;
4636
+ if (isBrowser4 && window_3.performance) {
4637
+ timestamp = window_3.performance.now();
4638
+ } else if (process_.hrtime) {
4639
+ const timeParts = process_.hrtime();
4640
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
4641
+ } else {
4642
+ timestamp = Date.now();
4643
+ }
4644
+ return timestamp;
4645
+ }
4646
+ var init_hi_res_timestamp = __esm({
4647
+ "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
4648
+ init_globals4();
4649
+ }
4650
+ });
4651
+
4652
+ // ../../node_modules/probe.gl/dist/esm/lib/log.js
4653
+ function noop2() {
4654
+ }
4655
+ function getTableHeader(table) {
4656
+ for (const key in table) {
4657
+ for (const title in table[key]) {
4658
+ return title || "untitled";
4659
+ }
4660
+ }
4661
+ return "empty";
4662
+ }
4663
+ function normalizeLogLevel(logLevel) {
4664
+ if (!logLevel) {
4665
+ return 0;
4666
+ }
4667
+ let resolvedLevel;
4668
+ switch (typeof logLevel) {
4669
+ case "number":
4670
+ resolvedLevel = logLevel;
4671
+ break;
4672
+ case "object":
4673
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
4674
+ break;
4675
+ default:
4676
+ return 0;
4677
+ }
4678
+ assert5(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
4679
+ return resolvedLevel;
4680
+ }
4681
+ function normalizeArguments(opts) {
4682
+ const {
4683
+ logLevel,
4684
+ message
4685
+ } = opts;
4686
+ opts.logLevel = normalizeLogLevel(logLevel);
4687
+ const args = opts.args ? Array.from(opts.args) : [];
4688
+ while (args.length && args.shift() !== message) {
4689
+ }
4690
+ opts.args = args;
4691
+ switch (typeof logLevel) {
4692
+ case "string":
4693
+ case "function":
4694
+ if (message !== void 0) {
4695
+ args.unshift(message);
4696
+ }
4697
+ opts.message = logLevel;
4698
+ break;
4699
+ case "object":
4700
+ Object.assign(opts, logLevel);
4701
+ break;
4702
+ default:
4703
+ }
4704
+ if (typeof opts.message === "function") {
4705
+ opts.message = opts.message();
4706
+ }
4707
+ const messageType = typeof opts.message;
4708
+ assert5(messageType === "string" || messageType === "object");
4709
+ return Object.assign(opts, opts.opts);
4710
+ }
4711
+ function decorateMessage(id, message, opts) {
4712
+ if (typeof message === "string") {
4713
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
4714
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
4715
+ message = addColor(message, opts.color, opts.background);
4716
+ }
4717
+ return message;
4718
+ }
4719
+ function logImageInNode({
4720
+ image,
4721
+ message = "",
4722
+ scale: scale5 = 1
4723
+ }) {
4724
+ let asciify = null;
4725
+ try {
4726
+ asciify = module.require("asciify-image");
4727
+ } catch (error) {
4728
+ }
4729
+ if (asciify) {
4730
+ return () => asciify(image, {
4731
+ fit: "box",
4732
+ width: "".concat(Math.round(80 * scale5), "%")
4733
+ }).then((data) => console.log(data));
4734
+ }
4735
+ return noop2;
4736
+ }
4737
+ function logImageInBrowser({
4738
+ image,
4739
+ message = "",
4740
+ scale: scale5 = 1
4741
+ }) {
4742
+ if (typeof image === "string") {
4743
+ const img = new Image();
4744
+ img.onload = () => {
4745
+ const args = formatImage(img, message, scale5);
4746
+ console.log(...args);
4747
+ };
4748
+ img.src = image;
4749
+ return noop2;
4750
+ }
4751
+ const element = image.nodeName || "";
4752
+ if (element.toLowerCase() === "img") {
4753
+ console.log(...formatImage(image, message, scale5));
4754
+ return noop2;
4755
+ }
4756
+ if (element.toLowerCase() === "canvas") {
4757
+ const img = new Image();
4758
+ img.onload = () => console.log(...formatImage(img, message, scale5));
4759
+ img.src = image.toDataURL();
4760
+ return noop2;
4761
+ }
4762
+ return noop2;
4763
+ }
4764
+ var originalConsole, DEFAULT_SETTINGS, cache, ONCE, Log;
4765
+ var init_log = __esm({
4766
+ "../../node_modules/probe.gl/dist/esm/lib/log.js"() {
4767
+ init_globals4();
4768
+ init_local_storage();
4769
+ init_formatters();
4770
+ init_color();
4771
+ init_autobind();
4772
+ init_assert4();
4773
+ init_hi_res_timestamp();
4774
+ originalConsole = {
4775
+ debug: isBrowser4 ? console.debug || console.log : console.log,
4776
+ log: console.log,
4777
+ info: console.info,
4778
+ warn: console.warn,
4779
+ error: console.error
4780
+ };
4781
+ DEFAULT_SETTINGS = {
4782
+ enabled: true,
4783
+ level: 0
4784
+ };
4785
+ cache = {};
4786
+ ONCE = {
4787
+ once: true
4788
+ };
4789
+ Log = class {
4790
+ constructor({
4791
+ id
4792
+ } = {
4793
+ id: ""
4794
+ }) {
4795
+ this.id = id;
4796
+ this.VERSION = VERSION3;
4797
+ this._startTs = getHiResTimestamp();
4798
+ this._deltaTs = getHiResTimestamp();
4799
+ this.LOG_THROTTLE_TIMEOUT = 0;
4800
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
4801
+ this.userData = {};
4802
+ this.timeStamp("".concat(this.id, " started"));
4803
+ autobind(this);
4804
+ Object.seal(this);
4805
+ }
4806
+ set level(newLevel) {
4807
+ this.setLevel(newLevel);
4808
+ }
4809
+ get level() {
4810
+ return this.getLevel();
4811
+ }
4812
+ isEnabled() {
4813
+ return this._storage.config.enabled;
4814
+ }
4815
+ getLevel() {
4816
+ return this._storage.config.level;
4817
+ }
4818
+ getTotal() {
4819
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
4820
+ }
4821
+ getDelta() {
4822
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
4823
+ }
4824
+ set priority(newPriority) {
4825
+ this.level = newPriority;
4826
+ }
4827
+ get priority() {
4828
+ return this.level;
4829
+ }
4830
+ getPriority() {
4831
+ return this.level;
4832
+ }
4833
+ enable(enabled = true) {
4834
+ this._storage.updateConfiguration({
4835
+ enabled
4836
+ });
4837
+ return this;
4838
+ }
4839
+ setLevel(level) {
4840
+ this._storage.updateConfiguration({
4841
+ level
4842
+ });
4843
+ return this;
4844
+ }
4845
+ assert(condition, message) {
4846
+ assert5(condition, message);
4847
+ }
4848
+ warn(message) {
4849
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
4850
+ }
4851
+ error(message) {
4852
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
4853
+ }
4854
+ deprecated(oldUsage, newUsage) {
4855
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
4856
+ }
4857
+ removed(oldUsage, newUsage) {
4858
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
4859
+ }
4860
+ probe(logLevel, message) {
4861
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
4862
+ time: true,
4863
+ once: true
4864
+ });
4865
+ }
4866
+ log(logLevel, message) {
4867
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
4868
+ }
4869
+ info(logLevel, message) {
4870
+ return this._getLogFunction(logLevel, message, console.info, arguments);
4871
+ }
4872
+ once(logLevel, message) {
4873
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
4874
+ }
4875
+ table(logLevel, table, columns) {
4876
+ if (table) {
4877
+ return this._getLogFunction(logLevel, table, console.table || noop2, columns && [columns], {
4878
+ tag: getTableHeader(table)
4879
+ });
4880
+ }
4881
+ return noop2;
4882
+ }
4883
+ image({
4884
+ logLevel,
4885
+ priority,
4886
+ image,
4887
+ message = "",
4888
+ scale: scale5 = 1
4889
+ }) {
4890
+ if (!this._shouldLog(logLevel || priority)) {
4891
+ return noop2;
4892
+ }
4893
+ return isBrowser4 ? logImageInBrowser({
4894
+ image,
4895
+ message,
4896
+ scale: scale5
4897
+ }) : logImageInNode({
4898
+ image,
4899
+ message,
4900
+ scale: scale5
4901
+ });
4902
+ }
4903
+ settings() {
4904
+ if (console.table) {
4905
+ console.table(this._storage.config);
4906
+ } else {
4907
+ console.log(this._storage.config);
4908
+ }
4909
+ }
4910
+ get(setting) {
4911
+ return this._storage.config[setting];
4912
+ }
4913
+ set(setting, value) {
4914
+ this._storage.updateConfiguration({
4915
+ [setting]: value
4916
+ });
4917
+ }
4918
+ time(logLevel, message) {
4919
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
4920
+ }
4921
+ timeEnd(logLevel, message) {
4922
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
4923
+ }
4924
+ timeStamp(logLevel, message) {
4925
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop2);
4926
+ }
4927
+ group(logLevel, message, opts = {
4928
+ collapsed: false
4929
+ }) {
4930
+ opts = normalizeArguments({
4931
+ logLevel,
4932
+ message,
4933
+ opts
4934
+ });
4935
+ const {
4936
+ collapsed
4937
+ } = opts;
4938
+ opts.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
4939
+ return this._getLogFunction(opts);
4940
+ }
4941
+ groupCollapsed(logLevel, message, opts = {}) {
4942
+ return this.group(logLevel, message, Object.assign({}, opts, {
4943
+ collapsed: true
4944
+ }));
4945
+ }
4946
+ groupEnd(logLevel) {
4947
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop2);
4948
+ }
4949
+ withGroup(logLevel, message, func) {
4950
+ this.group(logLevel, message)();
4951
+ try {
4952
+ func();
4953
+ } finally {
4954
+ this.groupEnd(logLevel)();
4955
+ }
4956
+ }
4957
+ trace() {
4958
+ if (console.trace) {
4959
+ console.trace();
4960
+ }
4961
+ }
4962
+ _shouldLog(logLevel) {
4963
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
4964
+ }
4965
+ _getLogFunction(logLevel, message, method, args = [], opts) {
4966
+ if (this._shouldLog(logLevel)) {
4967
+ opts = normalizeArguments({
4968
+ logLevel,
4969
+ message,
4970
+ args,
4971
+ opts
4972
+ });
4973
+ method = method || opts.method;
4974
+ assert5(method);
4975
+ opts.total = this.getTotal();
4976
+ opts.delta = this.getDelta();
4977
+ this._deltaTs = getHiResTimestamp();
4978
+ const tag = opts.tag || opts.message;
4979
+ if (opts.once) {
4980
+ if (!cache[tag]) {
4981
+ cache[tag] = getHiResTimestamp();
4982
+ } else {
4983
+ return noop2;
4984
+ }
4985
+ }
4986
+ message = decorateMessage(this.id, opts.message, opts);
4987
+ return method.bind(console, message, ...opts.args);
4988
+ }
4989
+ return noop2;
4990
+ }
4991
+ };
4992
+ Log.VERSION = VERSION3;
4993
+ }
4994
+ });
4995
+
4996
+ // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
4997
+ var init_hi_res_timestamp2 = __esm({
4998
+ "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
4999
+ }
5000
+ });
5001
+
5002
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
5003
+ var init_stat = __esm({
5004
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
5005
+ init_hi_res_timestamp2();
5006
+ }
5007
+ });
5008
+
5009
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
5010
+ var init_stats = __esm({
5011
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
5012
+ init_stat();
5013
+ }
5014
+ });
5015
+
5016
+ // ../../node_modules/@probe.gl/stats/dist/esm/index.js
5017
+ var init_esm3 = __esm({
5018
+ "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
5019
+ init_stats();
5020
+ init_stat();
5021
+ init_hi_res_timestamp2();
5022
+ }
5023
+ });
5024
+
5025
+ // ../../node_modules/probe.gl/dist/esm/index.js
5026
+ var esm_default;
5027
+ var init_esm4 = __esm({
5028
+ "../../node_modules/probe.gl/dist/esm/index.js"() {
5029
+ init_log();
5030
+ init_log();
5031
+ init_esm3();
5032
+ esm_default = new Log({
5033
+ id: "probe.gl"
5034
+ });
5035
+ }
5036
+ });
5037
+
5038
+ // ../core/src/lib/loader-utils/loggers.ts
5039
+ var probeLog, NullLog, ConsoleLog;
5040
+ var init_loggers = __esm({
5041
+ "../core/src/lib/loader-utils/loggers.ts"() {
5042
+ init_esm4();
5043
+ probeLog = new Log({ id: "loaders.gl" });
5044
+ NullLog = class {
5045
+ log() {
5046
+ return () => {
5047
+ };
5048
+ }
5049
+ info() {
5050
+ return () => {
5051
+ };
5052
+ }
5053
+ warn() {
5054
+ return () => {
5055
+ };
5056
+ }
5057
+ error() {
5058
+ return () => {
5059
+ };
5060
+ }
5061
+ };
5062
+ ConsoleLog = class {
5063
+ constructor() {
5064
+ this.console = console;
5065
+ }
5066
+ log(...args) {
5067
+ return this.console.log.bind(this.console, ...args);
5068
+ }
5069
+ info(...args) {
5070
+ return this.console.info.bind(this.console, ...args);
5071
+ }
5072
+ warn(...args) {
5073
+ return this.console.warn.bind(this.console, ...args);
5074
+ }
5075
+ error(...args) {
5076
+ return this.console.error.bind(this.console, ...args);
5077
+ }
5078
+ };
5079
+ }
5080
+ });
5081
+
5082
+ // ../core/src/lib/loader-utils/option-defaults.ts
5083
+ var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
5084
+ var init_option_defaults = __esm({
5085
+ "../core/src/lib/loader-utils/option-defaults.ts"() {
5086
+ init_loggers();
5087
+ DEFAULT_LOADER_OPTIONS = {
5088
+ fetch: null,
5089
+ mimeType: void 0,
5090
+ nothrow: false,
5091
+ log: new ConsoleLog(),
5092
+ CDN: "https://unpkg.com/@loaders.gl",
5093
+ worker: true,
5094
+ maxConcurrency: 3,
5095
+ maxMobileConcurrency: 1,
5096
+ reuseWorkers: true,
5097
+ _workerType: "",
5098
+ limit: 0,
5099
+ _limitMB: 0,
5100
+ batchSize: "auto",
5101
+ batchDebounceMs: 0,
5102
+ metadata: false,
5103
+ transforms: []
5104
+ };
5105
+ REMOVED_LOADER_OPTIONS = {
5106
+ throws: "nothrow",
5107
+ dataType: "(no longer used)",
5108
+ uri: "baseUri",
5109
+ method: "fetch.method",
5110
+ headers: "fetch.headers",
5111
+ body: "fetch.body",
5112
+ mode: "fetch.mode",
5113
+ credentials: "fetch.credentials",
5114
+ cache: "fetch.cache",
5115
+ redirect: "fetch.redirect",
5116
+ referrer: "fetch.referrer",
5117
+ referrerPolicy: "fetch.referrerPolicy",
5118
+ integrity: "fetch.integrity",
5119
+ keepalive: "fetch.keepalive",
5120
+ signal: "fetch.signal"
5121
+ };
5122
+ }
5123
+ });
5124
+
5125
+ // ../core/src/lib/loader-utils/option-utils.ts
5126
+ function getGlobalLoaderState() {
5127
+ globalThis.loaders = globalThis.loaders || {};
5128
+ const { loaders } = globalThis;
5129
+ loaders._state = loaders._state || {};
5130
+ return loaders._state;
5131
+ }
5132
+ function normalizeOptions(options, loader, loaders, url) {
5133
+ loaders = loaders || [];
5134
+ loaders = Array.isArray(loaders) ? loaders : [loaders];
5135
+ validateOptions(options, loaders);
5136
+ return normalizeOptionsInternal(loader, options, url);
5137
+ }
5138
+ function getFetchFunction(options, context) {
5139
+ const globalOptions = getGlobalLoaderOptions();
5140
+ const fetchOptions = options || globalOptions;
5141
+ if (typeof fetchOptions.fetch === "function") {
5142
+ return fetchOptions.fetch;
5143
+ }
5144
+ if (isObject(fetchOptions.fetch)) {
5145
+ return (url) => fetchFile(url, fetchOptions);
5146
+ }
5147
+ if (context?.fetch) {
5148
+ return context?.fetch;
5149
+ }
5150
+ return fetchFile;
5151
+ }
5152
+ function validateOptions(options, loaders) {
5153
+ validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
5154
+ for (const loader of loaders) {
5155
+ const idOptions = options && options[loader.id] || {};
5156
+ const loaderOptions = loader.options && loader.options[loader.id] || {};
5157
+ const deprecatedOptions = loader.deprecatedOptions && loader.deprecatedOptions[loader.id] || {};
5158
+ validateOptionsObject(idOptions, loader.id, loaderOptions, deprecatedOptions, loaders);
5159
+ }
5160
+ }
5161
+ function validateOptionsObject(options, id, defaultOptions, deprecatedOptions, loaders) {
5162
+ const loaderName = id || "Top level";
5163
+ const prefix = id ? `${id}.` : "";
5164
+ for (const key in options) {
5165
+ const isSubOptions = !id && isObject(options[key]);
5166
+ const isBaseUriOption = key === "baseUri" && !id;
5167
+ const isWorkerUrlOption = key === "workerUrl" && id;
5168
+ if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
5169
+ if (key in deprecatedOptions) {
5170
+ probeLog.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
5171
+ } else if (!isSubOptions) {
5172
+ const suggestion = findSimilarOption(key, loaders);
5173
+ probeLog.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
5174
+ }
5175
+ }
5176
+ }
5177
+ }
5178
+ function findSimilarOption(optionKey, loaders) {
5179
+ const lowerCaseOptionKey = optionKey.toLowerCase();
5180
+ let bestSuggestion = "";
5181
+ for (const loader of loaders) {
5182
+ for (const key in loader.options) {
5183
+ if (optionKey === key) {
5184
+ return `Did you mean '${loader.id}.${key}'?`;
5185
+ }
5186
+ const lowerCaseKey = key.toLowerCase();
5187
+ const isPartialMatch = lowerCaseOptionKey.startsWith(lowerCaseKey) || lowerCaseKey.startsWith(lowerCaseOptionKey);
5188
+ if (isPartialMatch) {
5189
+ bestSuggestion = bestSuggestion || `Did you mean '${loader.id}.${key}'?`;
5190
+ }
5191
+ }
5192
+ }
5193
+ return bestSuggestion;
5194
+ }
5195
+ function normalizeOptionsInternal(loader, options, url) {
5196
+ const loaderDefaultOptions = loader.options || {};
5197
+ const mergedOptions = { ...loaderDefaultOptions };
5198
+ addUrlOptions(mergedOptions, url);
5199
+ if (mergedOptions.log === null) {
5200
+ mergedOptions.log = new NullLog();
5201
+ }
5202
+ mergeNestedFields(mergedOptions, getGlobalLoaderOptions());
5203
+ mergeNestedFields(mergedOptions, options);
5204
+ return mergedOptions;
5205
+ }
5206
+ function mergeNestedFields(mergedOptions, options) {
5207
+ for (const key in options) {
5208
+ if (key in options) {
5209
+ const value = options[key];
5210
+ if (isPureObject(value) && isPureObject(mergedOptions[key])) {
5211
+ mergedOptions[key] = {
5212
+ ...mergedOptions[key],
5213
+ ...options[key]
5214
+ };
5215
+ } else {
5216
+ mergedOptions[key] = options[key];
5217
+ }
5218
+ }
5219
+ }
5220
+ }
5221
+ function addUrlOptions(options, url) {
5222
+ if (url && !("baseUri" in options)) {
5223
+ options.baseUri = url;
5224
+ }
5225
+ }
5226
+ var getGlobalLoaderOptions;
5227
+ var init_option_utils = __esm({
5228
+ "../core/src/lib/loader-utils/option-utils.ts"() {
5229
+ init_is_type();
5230
+ init_fetch_file();
5231
+ init_loggers();
5232
+ init_option_defaults();
5233
+ getGlobalLoaderOptions = () => {
5234
+ const state = getGlobalLoaderState();
5235
+ state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
5236
+ return state.globalOptions;
5237
+ };
5238
+ }
5239
+ });
5240
+
5241
+ // ../core/src/lib/loader-utils/normalize-loader.ts
5242
+ function isLoaderObject(loader) {
5243
+ if (!loader) {
5244
+ return false;
5245
+ }
5246
+ if (Array.isArray(loader)) {
5247
+ loader = loader[0];
5248
+ }
5249
+ const hasExtensions = Array.isArray(loader?.extensions);
5250
+ return hasExtensions;
5251
+ }
5252
+ function normalizeLoader(loader) {
5253
+ assert2(loader, "null loader");
5254
+ assert2(isLoaderObject(loader), "invalid loader");
5255
+ let options;
5256
+ if (Array.isArray(loader)) {
5257
+ options = loader[1];
5258
+ loader = loader[0];
5259
+ loader = {
5260
+ ...loader,
5261
+ options: { ...loader.options, ...options }
5262
+ };
5263
+ }
5264
+ if (loader?.parseTextSync || loader?.parseText) {
5265
+ loader.text = true;
5266
+ }
5267
+ if (!loader.text) {
5268
+ loader.binary = true;
5269
+ }
5270
+ return loader;
5271
+ }
5272
+ var init_normalize_loader = __esm({
5273
+ "../core/src/lib/loader-utils/normalize-loader.ts"() {
5274
+ init_src2();
5275
+ }
5276
+ });
5277
+
5278
+ // ../core/src/lib/api/register-loaders.ts
5279
+ function getRegisteredLoaders() {
5280
+ return getGlobalLoaderRegistry();
5281
+ }
5282
+ var getGlobalLoaderRegistry;
5283
+ var init_register_loaders = __esm({
5284
+ "../core/src/lib/api/register-loaders.ts"() {
5285
+ init_option_utils();
5286
+ getGlobalLoaderRegistry = () => {
5287
+ const state = getGlobalLoaderState();
5288
+ state.loaderRegistry = state.loaderRegistry || [];
5289
+ return state.loaderRegistry;
5290
+ };
5291
+ }
5292
+ });
5293
+
5294
+ // ../core/src/lib/api/select-loader.ts
5295
+ async function selectLoader(data, loaders = [], options, context) {
5296
+ if (!validHTTPResponse(data)) {
5297
+ return null;
5298
+ }
5299
+ let loader = selectLoaderSync(data, loaders, { ...options, nothrow: true }, context);
5300
+ if (loader) {
5301
+ return loader;
5302
+ }
5303
+ if (isBlob(data)) {
5304
+ data = await data.slice(0, 10).arrayBuffer();
5305
+ loader = selectLoaderSync(data, loaders, options, context);
5306
+ }
5307
+ if (!loader && !options?.nothrow) {
5308
+ throw new Error(getNoValidLoaderMessage(data));
5309
+ }
5310
+ return loader;
5311
+ }
5312
+ function selectLoaderSync(data, loaders = [], options, context) {
5313
+ if (!validHTTPResponse(data)) {
5314
+ return null;
5315
+ }
5316
+ if (loaders && !Array.isArray(loaders)) {
5317
+ return normalizeLoader(loaders);
5318
+ }
5319
+ let candidateLoaders = [];
5320
+ if (loaders) {
5321
+ candidateLoaders = candidateLoaders.concat(loaders);
5322
+ }
5323
+ if (!options?.ignoreRegisteredLoaders) {
5324
+ candidateLoaders.push(...getRegisteredLoaders());
5325
+ }
5326
+ normalizeLoaders(candidateLoaders);
5327
+ const loader = selectLoaderInternal(data, candidateLoaders, options, context);
5328
+ if (!loader && !options?.nothrow) {
5329
+ throw new Error(getNoValidLoaderMessage(data));
5330
+ }
5331
+ return loader;
5332
+ }
5333
+ function selectLoaderInternal(data, loaders, options, context) {
5334
+ const { url, type } = getResourceUrlAndType(data);
5335
+ const testUrl = url || context?.url;
5336
+ let loader = null;
5337
+ if (options?.mimeType) {
5338
+ loader = findLoaderByMIMEType(loaders, options?.mimeType);
5339
+ }
5340
+ loader = loader || findLoaderByUrl(loaders, testUrl);
5341
+ loader = loader || findLoaderByMIMEType(loaders, type);
5342
+ loader = loader || findLoaderByInitialBytes(loaders, data);
5343
+ loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
5344
+ return loader;
5345
+ }
5346
+ function validHTTPResponse(data) {
5347
+ if (data instanceof Response) {
5348
+ if (data.status === 204) {
5349
+ return false;
5350
+ }
5351
+ }
5352
+ return true;
5353
+ }
5354
+ function getNoValidLoaderMessage(data) {
5355
+ const { url, type } = getResourceUrlAndType(data);
5356
+ let message = "No valid loader found (";
5357
+ message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
5358
+ message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
5359
+ const firstCharacters = data ? getFirstCharacters2(data) : "";
5360
+ message += firstCharacters ? ` first bytes: "${firstCharacters}"` : "first bytes: not available";
5361
+ message += ")";
5362
+ return message;
5363
+ }
5364
+ function normalizeLoaders(loaders) {
5365
+ for (const loader of loaders) {
5366
+ normalizeLoader(loader);
5367
+ }
5368
+ }
5369
+ function findLoaderByUrl(loaders, url) {
5370
+ const match = url && EXT_PATTERN.exec(url);
5371
+ const extension = match && match[1];
5372
+ return extension ? findLoaderByExtension(loaders, extension) : null;
5373
+ }
5374
+ function findLoaderByExtension(loaders, extension) {
5375
+ extension = extension.toLowerCase();
5376
+ for (const loader of loaders) {
5377
+ for (const loaderExtension of loader.extensions) {
5378
+ if (loaderExtension.toLowerCase() === extension) {
5379
+ return loader;
5380
+ }
5381
+ }
5382
+ }
5383
+ return null;
5384
+ }
5385
+ function findLoaderByMIMEType(loaders, mimeType) {
5386
+ for (const loader of loaders) {
5387
+ if (loader.mimeTypes && loader.mimeTypes.includes(mimeType)) {
5388
+ return loader;
5389
+ }
5390
+ if (mimeType === `application/x.${loader.id}`) {
5391
+ return loader;
5392
+ }
5393
+ }
5394
+ return null;
5395
+ }
5396
+ function findLoaderByInitialBytes(loaders, data) {
5397
+ if (!data) {
5398
+ return null;
5399
+ }
5400
+ for (const loader of loaders) {
5401
+ if (typeof data === "string") {
5402
+ if (testDataAgainstText(data, loader)) {
5403
+ return loader;
5404
+ }
5405
+ } else if (ArrayBuffer.isView(data)) {
5406
+ if (testDataAgainstBinary(data.buffer, data.byteOffset, loader)) {
5407
+ return loader;
5408
+ }
5409
+ } else if (data instanceof ArrayBuffer) {
5410
+ const byteOffset = 0;
5411
+ if (testDataAgainstBinary(data, byteOffset, loader)) {
5412
+ return loader;
5413
+ }
5414
+ }
5415
+ }
5416
+ return null;
5417
+ }
5418
+ function testDataAgainstText(data, loader) {
5419
+ if (loader.testText) {
5420
+ return loader.testText(data);
5421
+ }
5422
+ const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
5423
+ return tests.some((test) => data.startsWith(test));
5424
+ }
5425
+ function testDataAgainstBinary(data, byteOffset, loader) {
5426
+ const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
5427
+ return tests.some((test) => testBinary(data, byteOffset, loader, test));
5428
+ }
5429
+ function testBinary(data, byteOffset, loader, test) {
5430
+ if (test instanceof ArrayBuffer) {
5431
+ return compareArrayBuffers(test, data, test.byteLength);
5432
+ }
5433
+ switch (typeof test) {
5434
+ case "function":
5435
+ return test(data, loader);
5436
+ case "string":
5437
+ const magic = getMagicString2(data, byteOffset, test.length);
5438
+ return test === magic;
5439
+ default:
5440
+ return false;
5441
+ }
5442
+ }
5443
+ function getFirstCharacters2(data, length4 = 5) {
5444
+ if (typeof data === "string") {
5445
+ return data.slice(0, length4);
5446
+ } else if (ArrayBuffer.isView(data)) {
5447
+ return getMagicString2(data.buffer, data.byteOffset, length4);
5448
+ } else if (data instanceof ArrayBuffer) {
5449
+ const byteOffset = 0;
5450
+ return getMagicString2(data, byteOffset, length4);
5451
+ }
5452
+ return "";
5453
+ }
5454
+ function getMagicString2(arrayBuffer, byteOffset, length4) {
5455
+ if (arrayBuffer.byteLength < byteOffset + length4) {
5456
+ return "";
5457
+ }
5458
+ const dataView = new DataView(arrayBuffer);
5459
+ let magic = "";
5460
+ for (let i2 = 0; i2 < length4; i2++) {
5461
+ magic += String.fromCharCode(dataView.getUint8(byteOffset + i2));
5462
+ }
5463
+ return magic;
5464
+ }
5465
+ var EXT_PATTERN;
5466
+ var init_select_loader = __esm({
5467
+ "../core/src/lib/api/select-loader.ts"() {
5468
+ init_src2();
5469
+ init_normalize_loader();
5470
+ init_resource_utils();
5471
+ init_register_loaders();
5472
+ init_is_type();
5473
+ EXT_PATTERN = /\.([^.]+)$/;
5474
+ }
5475
+ });
5476
+
5477
+ // ../core/src/iterators/make-iterator/make-string-iterator.ts
5478
+ function* makeStringIterator(string, options) {
5479
+ const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
5480
+ let offset = 0;
5481
+ const textEncoder = new TextEncoder();
5482
+ while (offset < string.length) {
5483
+ const chunkLength = Math.min(string.length - offset, chunkSize);
5484
+ const chunk = string.slice(offset, offset + chunkLength);
5485
+ offset += chunkLength;
5486
+ yield textEncoder.encode(chunk);
5487
+ }
5488
+ }
5489
+ var DEFAULT_CHUNK_SIZE;
5490
+ var init_make_string_iterator = __esm({
5491
+ "../core/src/iterators/make-iterator/make-string-iterator.ts"() {
5492
+ DEFAULT_CHUNK_SIZE = 256 * 1024;
5493
+ }
5494
+ });
5495
+
5496
+ // ../core/src/iterators/make-iterator/make-array-buffer-iterator.ts
5497
+ function* makeArrayBufferIterator(arrayBuffer, options = {}) {
5498
+ const { chunkSize = DEFAULT_CHUNK_SIZE2 } = options;
5499
+ let byteOffset = 0;
5500
+ while (byteOffset < arrayBuffer.byteLength) {
5501
+ const chunkByteLength = Math.min(arrayBuffer.byteLength - byteOffset, chunkSize);
5502
+ const chunk = new ArrayBuffer(chunkByteLength);
5503
+ const sourceArray = new Uint8Array(arrayBuffer, byteOffset, chunkByteLength);
5504
+ const chunkArray = new Uint8Array(chunk);
5505
+ chunkArray.set(sourceArray);
5506
+ byteOffset += chunkByteLength;
5507
+ yield chunk;
5508
+ }
5509
+ }
5510
+ var DEFAULT_CHUNK_SIZE2;
5511
+ var init_make_array_buffer_iterator = __esm({
5512
+ "../core/src/iterators/make-iterator/make-array-buffer-iterator.ts"() {
5513
+ DEFAULT_CHUNK_SIZE2 = 256 * 1024;
5514
+ }
5515
+ });
5516
+
5517
+ // ../core/src/iterators/make-iterator/make-blob-iterator.ts
5518
+ async function* makeBlobIterator(blob, options) {
5519
+ const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE3;
5520
+ let offset = 0;
5521
+ while (offset < blob.size) {
5522
+ const end = offset + chunkSize;
5523
+ const chunk = await blob.slice(offset, end).arrayBuffer();
5524
+ offset = end;
5525
+ yield chunk;
5526
+ }
5527
+ }
5528
+ var DEFAULT_CHUNK_SIZE3;
5529
+ var init_make_blob_iterator = __esm({
5530
+ "../core/src/iterators/make-iterator/make-blob-iterator.ts"() {
5531
+ DEFAULT_CHUNK_SIZE3 = 1024 * 1024;
5532
+ }
5533
+ });
5534
+
5535
+ // ../core/src/iterators/make-iterator/make-stream-iterator.ts
5536
+ function makeStreamIterator(stream, options) {
5537
+ return isBrowser ? makeBrowserStreamIterator(stream, options) : makeNodeStreamIterator(stream, options);
5538
+ }
5539
+ async function* makeBrowserStreamIterator(stream, options) {
5540
+ const reader = stream.getReader();
5541
+ let nextBatchPromise;
5542
+ try {
5543
+ while (true) {
5544
+ const currentBatchPromise = nextBatchPromise || reader.read();
5545
+ if (options?._streamReadAhead) {
5546
+ nextBatchPromise = reader.read();
5547
+ }
5548
+ const { done, value } = await currentBatchPromise;
5549
+ if (done) {
5550
+ return;
5551
+ }
5552
+ yield toArrayBuffer(value);
5553
+ }
5554
+ } catch (error) {
5555
+ reader.releaseLock();
5556
+ }
5557
+ }
5558
+ async function* makeNodeStreamIterator(stream, options) {
5559
+ for await (const chunk of stream) {
5560
+ yield toArrayBuffer(chunk);
5561
+ }
5562
+ }
5563
+ var init_make_stream_iterator = __esm({
5564
+ "../core/src/iterators/make-iterator/make-stream-iterator.ts"() {
5565
+ init_src2();
5566
+ }
5567
+ });
5568
+
5569
+ // ../core/src/iterators/make-iterator/make-iterator.ts
5570
+ function makeIterator(data, options) {
5571
+ if (typeof data === "string") {
5572
+ return makeStringIterator(data, options);
5573
+ }
5574
+ if (data instanceof ArrayBuffer) {
5575
+ return makeArrayBufferIterator(data, options);
5576
+ }
5577
+ if (isBlob(data)) {
5578
+ return makeBlobIterator(data, options);
5579
+ }
5580
+ if (isReadableStream(data)) {
5581
+ return makeStreamIterator(data, options);
5582
+ }
5583
+ if (isResponse(data)) {
5584
+ const response = data;
5585
+ return makeStreamIterator(response.body, options);
5586
+ }
5587
+ throw new Error("makeIterator");
5588
+ }
5589
+ var init_make_iterator = __esm({
5590
+ "../core/src/iterators/make-iterator/make-iterator.ts"() {
5591
+ init_make_string_iterator();
5592
+ init_make_array_buffer_iterator();
5593
+ init_make_blob_iterator();
5594
+ init_make_stream_iterator();
5595
+ init_is_type();
5596
+ }
5597
+ });
5598
+
5599
+ // ../core/src/lib/loader-utils/get-data.ts
5600
+ function getArrayBufferOrStringFromDataSync(data, loader, options) {
5601
+ if (loader.text && typeof data === "string") {
5602
+ return data;
5603
+ }
5604
+ if (isBuffer2(data)) {
5605
+ data = data.buffer;
5606
+ }
5607
+ if (data instanceof ArrayBuffer) {
5608
+ const arrayBuffer = data;
5609
+ if (loader.text && !loader.binary) {
5610
+ const textDecoder = new TextDecoder("utf8");
5611
+ return textDecoder.decode(arrayBuffer);
5612
+ }
5613
+ return arrayBuffer;
5614
+ }
5615
+ if (ArrayBuffer.isView(data)) {
5616
+ if (loader.text && !loader.binary) {
5617
+ const textDecoder = new TextDecoder("utf8");
5618
+ return textDecoder.decode(data);
5619
+ }
5620
+ let arrayBuffer = data.buffer;
5621
+ const byteLength = data.byteLength || data.length;
5622
+ if (data.byteOffset !== 0 || byteLength !== arrayBuffer.byteLength) {
5623
+ arrayBuffer = arrayBuffer.slice(data.byteOffset, data.byteOffset + byteLength);
5624
+ }
5625
+ return arrayBuffer;
5626
+ }
5627
+ throw new Error(ERR_DATA);
5628
+ }
5629
+ async function getArrayBufferOrStringFromData(data, loader, options) {
5630
+ const isArrayBuffer = data instanceof ArrayBuffer || ArrayBuffer.isView(data);
5631
+ if (typeof data === "string" || isArrayBuffer) {
5632
+ return getArrayBufferOrStringFromDataSync(data, loader, options);
5633
+ }
5634
+ if (isBlob(data)) {
5635
+ data = await makeResponse(data);
5636
+ }
5637
+ if (isResponse(data)) {
5638
+ const response = data;
5639
+ await checkResponse(response);
5640
+ return loader.binary ? await response.arrayBuffer() : await response.text();
5641
+ }
5642
+ if (isReadableStream(data)) {
5643
+ data = makeIterator(data, options);
5644
+ }
5645
+ if (isIterable(data) || isAsyncIterable(data)) {
5646
+ return concatenateArrayBuffersAsync(data);
5647
+ }
5648
+ throw new Error(ERR_DATA);
5649
+ }
5650
+ var ERR_DATA;
5651
+ var init_get_data = __esm({
5652
+ "../core/src/lib/loader-utils/get-data.ts"() {
5653
+ init_src2();
5654
+ init_is_type();
5655
+ init_make_iterator();
5656
+ init_response_utils();
5657
+ ERR_DATA = "Cannot convert supplied data type";
5658
+ }
5659
+ });
5660
+
5661
+ // ../core/src/lib/loader-utils/loader-context.ts
5662
+ function getLoaderContext(context, options, previousContext = null) {
5663
+ if (previousContext) {
5664
+ return previousContext;
5665
+ }
5666
+ const resolvedContext = {
5667
+ fetch: getFetchFunction(options, context),
5668
+ ...context
5669
+ };
5670
+ if (!Array.isArray(resolvedContext.loaders)) {
5671
+ resolvedContext.loaders = null;
5672
+ }
5673
+ return resolvedContext;
5674
+ }
5675
+ function getLoadersFromContext(loaders, context) {
5676
+ if (!context && loaders && !Array.isArray(loaders)) {
5677
+ return loaders;
5678
+ }
5679
+ let candidateLoaders;
5680
+ if (loaders) {
5681
+ candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
5682
+ }
5683
+ if (context && context.loaders) {
5684
+ const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
5685
+ candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
5686
+ }
5687
+ return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
5688
+ }
5689
+ var init_loader_context = __esm({
5690
+ "../core/src/lib/loader-utils/loader-context.ts"() {
5691
+ init_option_utils();
5692
+ }
5693
+ });
5694
+
5695
+ // ../core/src/lib/api/parse.ts
5696
+ async function parse(data, loaders, options, context) {
5697
+ assert3(!context || typeof context === "object");
5698
+ if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
5699
+ context = void 0;
5700
+ options = loaders;
5701
+ loaders = void 0;
5702
+ }
5703
+ data = await data;
5704
+ options = options || {};
5705
+ const { url } = getResourceUrlAndType(data);
5706
+ const typedLoaders = loaders;
5707
+ const candidateLoaders = getLoadersFromContext(typedLoaders, context);
5708
+ const loader = await selectLoader(data, candidateLoaders, options);
5709
+ if (!loader) {
5710
+ return null;
5711
+ }
5712
+ options = normalizeOptions(options, loader, candidateLoaders, url);
5713
+ context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
5714
+ return await parseWithLoader(loader, data, options, context);
5715
+ }
5716
+ async function parseWithLoader(loader, data, options, context) {
5717
+ validateWorkerVersion(loader);
5718
+ data = await getArrayBufferOrStringFromData(data, loader, options);
5719
+ if (loader.parseTextSync && typeof data === "string") {
5720
+ options.dataType = "text";
5721
+ return loader.parseTextSync(data, options, context, loader);
5722
+ }
5723
+ if (canParseWithWorker(loader, options)) {
5724
+ return await parseWithWorker(loader, data, options, context, parse);
5725
+ }
5726
+ if (loader.parseText && typeof data === "string") {
5727
+ return await loader.parseText(data, options, context, loader);
5728
+ }
5729
+ if (loader.parse) {
5730
+ return await loader.parse(data, options, context, loader);
5731
+ }
5732
+ assert3(!loader.parseSync);
5733
+ throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
5734
+ }
5735
+ var init_parse = __esm({
5736
+ "../core/src/lib/api/parse.ts"() {
5737
+ init_src();
5738
+ init_src2();
5739
+ init_normalize_loader();
5740
+ init_option_utils();
5741
+ init_get_data();
5742
+ init_loader_context();
5743
+ init_resource_utils();
5744
+ init_select_loader();
5745
+ }
5746
+ });
5747
+
5748
+ // ../core/src/lib/api/load.ts
5749
+ async function load(url, loaders, options, context) {
5750
+ if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
5751
+ context = void 0;
5752
+ options = loaders;
5753
+ loaders = void 0;
5754
+ }
5755
+ const fetch2 = getFetchFunction(options);
5756
+ let data = url;
5757
+ if (typeof url === "string") {
5758
+ data = await fetch2(url);
5759
+ }
5760
+ if (isBlob(url)) {
5761
+ data = await fetch2(url);
5762
+ }
5763
+ return await parse(data, loaders, options);
5764
+ }
5765
+ var init_load = __esm({
5766
+ "../core/src/lib/api/load.ts"() {
5767
+ init_is_type();
5768
+ init_normalize_loader();
5769
+ init_option_utils();
5770
+ init_parse();
5771
+ }
5772
+ });
5773
+
3819
5774
  // ../core/src/index.ts
3820
5775
  var init_src3 = __esm({
3821
5776
  "../core/src/index.ts"() {
3822
5777
  init_fetch_file();
5778
+ init_load();
3823
5779
  }
3824
5780
  });
3825
5781
 
@@ -3856,10 +5812,10 @@
3856
5812
  });
3857
5813
 
3858
5814
  // src/lib/utils/version.ts
3859
- var VERSION3;
5815
+ var VERSION4;
3860
5816
  var init_version2 = __esm({
3861
5817
  "src/lib/utils/version.ts"() {
3862
- VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
5818
+ VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3863
5819
  }
3864
5820
  });
3865
5821
 
@@ -3873,7 +5829,8 @@
3873
5829
  BATCHED_3D_MODEL: "b3dm",
3874
5830
  INSTANCED_3D_MODEL: "i3dm",
3875
5831
  GEOMETRY: "geom",
3876
- VECTOR: "vect"
5832
+ VECTOR: "vect",
5833
+ GLTF: "glTF"
3877
5834
  };
3878
5835
  TILE3D_TYPES = Object.keys(TILE3D_TYPE);
3879
5836
  MAGIC_ARRAY = {
@@ -3893,7 +5850,7 @@
3893
5850
  const string = textDecoder.decode(typedArray);
3894
5851
  return string;
3895
5852
  }
3896
- function getMagicString2(arrayBuffer, byteOffset = 0) {
5853
+ function getMagicString3(arrayBuffer, byteOffset = 0) {
3897
5854
  const dataView = new DataView(arrayBuffer);
3898
5855
  return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
3899
5856
  }
@@ -3904,10 +5861,10 @@
3904
5861
  });
3905
5862
 
3906
5863
  // ../draco/src/lib/utils/version.ts
3907
- var VERSION4;
5864
+ var VERSION5;
3908
5865
  var init_version3 = __esm({
3909
5866
  "../draco/src/lib/utils/version.ts"() {
3910
- VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
5867
+ VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3911
5868
  }
3912
5869
  });
3913
5870
 
@@ -3929,7 +5886,7 @@
3929
5886
  id: "draco",
3930
5887
  module: "draco",
3931
5888
  shapes: ["mesh"],
3932
- version: VERSION4,
5889
+ version: VERSION5,
3933
5890
  worker: true,
3934
5891
  extensions: ["drc"],
3935
5892
  mimeTypes: ["application/octet-stream"],
@@ -3972,12 +5929,12 @@
3972
5929
  });
3973
5930
 
3974
5931
  // ../schema/src/lib/utils/assert.ts
3975
- function assert5(condition, message) {
5932
+ function assert6(condition, message) {
3976
5933
  if (!condition) {
3977
5934
  throw new Error(message || "loader assertion failed.");
3978
5935
  }
3979
5936
  }
3980
- var init_assert4 = __esm({
5937
+ var init_assert5 = __esm({
3981
5938
  "../schema/src/lib/utils/assert.ts"() {
3982
5939
  }
3983
5940
  });
@@ -3998,10 +5955,10 @@
3998
5955
  var Schema;
3999
5956
  var init_schema = __esm({
4000
5957
  "../schema/src/lib/schema/impl/schema.ts"() {
4001
- init_assert4();
5958
+ init_assert5();
4002
5959
  Schema = class {
4003
5960
  constructor(fields, metadata) {
4004
- assert5(Array.isArray(fields));
5961
+ assert6(Array.isArray(fields));
4005
5962
  checkNames(fields);
4006
5963
  this.fields = fields;
4007
5964
  this.metadata = metadata || new Map();
@@ -4137,7 +6094,7 @@
4137
6094
  });
4138
6095
 
4139
6096
  // ../schema/src/lib/schema/impl/type.ts
4140
- var DataType, Null, Bool, Int, Int8, Int16, Int32, Uint8, Uint16, Uint32, Precision, Float, Float32, Float64, Binary, Utf8, DateUnit, Date, TimeUnit, Time, Timestamp, IntervalUnit, Interval, FixedSizeList, Struct;
6097
+ var DataType, Null, Bool, Int, Int8, Int16, Int32, Uint8, Uint16, Uint32, Precision, Float, Float32, Float64, Binary, Utf8, DateUnit, Date2, TimeUnit, Time, Timestamp, IntervalUnit, Interval, FixedSizeList, Struct;
4141
6098
  var init_type = __esm({
4142
6099
  "../schema/src/lib/schema/impl/type.ts"() {
4143
6100
  init_enum();
@@ -4330,7 +6287,7 @@
4330
6287
  DAY: 0,
4331
6288
  MILLISECOND: 1
4332
6289
  };
4333
- Date = class extends DataType {
6290
+ Date2 = class extends DataType {
4334
6291
  constructor(unit) {
4335
6292
  super();
4336
6293
  this.unit = unit;
@@ -4960,7 +6917,7 @@
4960
6917
  });
4961
6918
 
4962
6919
  // ../draco/src/index.ts
4963
- async function parse(arrayBuffer, options) {
6920
+ async function parse2(arrayBuffer, options) {
4964
6921
  const { draco } = await loadDracoDecoderModule(options);
4965
6922
  const dracoParser = new DracoParser(draco);
4966
6923
  try {
@@ -4977,7 +6934,7 @@
4977
6934
  init_draco_module_loader();
4978
6935
  DracoLoader2 = {
4979
6936
  ...DracoLoader,
4980
- parse
6937
+ parse: parse2
4981
6938
  };
4982
6939
  }
4983
6940
  });
@@ -5089,12 +7046,12 @@
5089
7046
  });
5090
7047
 
5091
7048
  // ../math/src/geometry/utils/assert.ts
5092
- function assert6(condition, message) {
7049
+ function assert7(condition, message) {
5093
7050
  if (!condition) {
5094
7051
  throw new Error(`math.gl assertion failed. ${message}`);
5095
7052
  }
5096
7053
  }
5097
- var init_assert5 = __esm({
7054
+ var init_assert6 = __esm({
5098
7055
  "../math/src/geometry/utils/assert.ts"() {
5099
7056
  }
5100
7057
  });
@@ -5122,7 +7079,7 @@
5122
7079
  return value < 0 ? -1 : 1;
5123
7080
  }
5124
7081
  function octDecodeInRange(x, y, rangeMax, result) {
5125
- assert6(result);
7082
+ assert7(result);
5126
7083
  if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
5127
7084
  throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);
5128
7085
  }
@@ -5143,7 +7100,7 @@
5143
7100
  var init_attribute_compression = __esm({
5144
7101
  "../math/src/geometry/compression/attribute-compression.ts"() {
5145
7102
  init_esm();
5146
- init_assert5();
7103
+ init_assert6();
5147
7104
  RIGHT_SHIFT = 1 / 256;
5148
7105
  scratchVector23 = new Vector2();
5149
7106
  scratchVector32 = new Vector3();
@@ -6135,7 +8092,7 @@
6135
8092
  return await loadDraco(tile, dracoData, options, context);
6136
8093
  }
6137
8094
  async function loadDraco(tile, dracoData, options, context) {
6138
- const { parse: parse4 } = context;
8095
+ const { parse: parse5 } = context;
6139
8096
  const dracoOptions = {
6140
8097
  ...options,
6141
8098
  draco: {
@@ -6144,7 +8101,7 @@
6144
8101
  }
6145
8102
  };
6146
8103
  delete dracoOptions["3d-tiles"];
6147
- const data = await parse4(dracoData.buffer, DracoLoader2, dracoOptions);
8104
+ const data = await parse5(dracoData.buffer, DracoLoader2, dracoOptions);
6148
8105
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
6149
8106
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
6150
8107
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
@@ -6195,18 +8152,18 @@
6195
8152
  });
6196
8153
 
6197
8154
  // ../gltf/src/lib/utils/version.ts
6198
- var VERSION5;
8155
+ var VERSION6;
6199
8156
  var init_version4 = __esm({
6200
8157
  "../gltf/src/lib/utils/version.ts"() {
6201
- VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8158
+ VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6202
8159
  }
6203
8160
  });
6204
8161
 
6205
8162
  // ../textures/src/lib/utils/version.ts
6206
- var VERSION6;
8163
+ var VERSION7;
6207
8164
  var init_version5 = __esm({
6208
8165
  "../textures/src/lib/utils/version.ts"() {
6209
- VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
8166
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6210
8167
  }
6211
8168
  });
6212
8169
 
@@ -6235,8 +8192,8 @@
6235
8192
  options.wasmBinary = wasmBinary;
6236
8193
  }
6237
8194
  return new Promise((resolve) => {
6238
- BasisModule(options).then((module) => {
6239
- const { BasisFile, initializeBasis } = module;
8195
+ BasisModule(options).then((module2) => {
8196
+ const { BasisFile, initializeBasis } = module2;
6240
8197
  initializeBasis();
6241
8198
  resolve({ BasisFile });
6242
8199
  });
@@ -6266,28 +8223,28 @@
6266
8223
  options.wasmBinary = wasmBinary;
6267
8224
  }
6268
8225
  return new Promise((resolve) => {
6269
- BasisEncoderModule(options).then((module) => {
6270
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
8226
+ BasisEncoderModule(options).then((module2) => {
8227
+ const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module2;
6271
8228
  initializeBasis();
6272
8229
  resolve({ BasisFile, KTX2File, BasisEncoder });
6273
8230
  });
6274
8231
  });
6275
8232
  }
6276
- var VERSION7, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
8233
+ var VERSION8, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
6277
8234
  var init_basis_module_loader = __esm({
6278
8235
  "../textures/src/lib/parsers/basis-module-loader.ts"() {
6279
8236
  init_src();
6280
- VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
6281
- BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.wasm`;
6282
- BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.js`;
8237
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
8238
+ BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.wasm`;
8239
+ BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.js`;
6283
8240
  }
6284
8241
  });
6285
8242
 
6286
- // ../textures/src/lib/gl-constants.ts
6287
- var GL3;
6288
- var init_gl_constants = __esm({
6289
- "../textures/src/lib/gl-constants.ts"() {
6290
- GL3 = {
8243
+ // ../textures/src/lib/gl-extensions.ts
8244
+ var GL_EXTENSIONS_CONSTANTS;
8245
+ var init_gl_extensions = __esm({
8246
+ "../textures/src/lib/gl-extensions.ts"() {
8247
+ GL_EXTENSIONS_CONSTANTS = {
6291
8248
  COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
6292
8249
  COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
6293
8250
  COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
@@ -6444,7 +8401,7 @@
6444
8401
  }
6445
8402
  });
6446
8403
 
6447
- // ../textures/src/lib/parsers/parse-basis.js
8404
+ // ../textures/src/lib/parsers/parse-basis.ts
6448
8405
  async function parseBasis(data, options) {
6449
8406
  if (options.basis.containerFormat === "auto") {
6450
8407
  if (isKTX(data)) {
@@ -6580,23 +8537,47 @@
6580
8537
  }
6581
8538
  var OutputFormat;
6582
8539
  var init_parse_basis = __esm({
6583
- "../textures/src/lib/parsers/parse-basis.js"() {
8540
+ "../textures/src/lib/parsers/parse-basis.ts"() {
6584
8541
  init_basis_module_loader();
6585
- init_gl_constants();
8542
+ init_gl_extensions();
6586
8543
  init_texture_formats();
6587
8544
  init_parse_ktx();
6588
8545
  OutputFormat = {
6589
- etc1: { basisFormat: 0, compressed: true, format: GL3.COMPRESSED_RGB_ETC1_WEBGL },
8546
+ etc1: {
8547
+ basisFormat: 0,
8548
+ compressed: true,
8549
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
8550
+ },
6590
8551
  etc2: { basisFormat: 1, compressed: true },
6591
- bc1: { basisFormat: 2, compressed: true, format: GL3.COMPRESSED_RGB_S3TC_DXT1_EXT },
6592
- bc3: { basisFormat: 3, compressed: true, format: GL3.COMPRESSED_RGBA_S3TC_DXT5_EXT },
8552
+ bc1: {
8553
+ basisFormat: 2,
8554
+ compressed: true,
8555
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
8556
+ },
8557
+ bc3: {
8558
+ basisFormat: 3,
8559
+ compressed: true,
8560
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
8561
+ },
6593
8562
  bc4: { basisFormat: 4, compressed: true },
6594
8563
  bc5: { basisFormat: 5, compressed: true },
6595
8564
  "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
6596
8565
  "bc7-m5": { basisFormat: 7, compressed: true },
6597
- "pvrtc1-4-rgb": { basisFormat: 8, compressed: true, format: GL3.COMPRESSED_RGB_PVRTC_4BPPV1_IMG },
6598
- "pvrtc1-4-rgba": { basisFormat: 9, compressed: true, format: GL3.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG },
6599
- "astc-4x4": { basisFormat: 10, compressed: true, format: GL3.COMPRESSED_RGBA_ASTC_4X4_KHR },
8566
+ "pvrtc1-4-rgb": {
8567
+ basisFormat: 8,
8568
+ compressed: true,
8569
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
8570
+ },
8571
+ "pvrtc1-4-rgba": {
8572
+ basisFormat: 9,
8573
+ compressed: true,
8574
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
8575
+ },
8576
+ "astc-4x4": {
8577
+ basisFormat: 10,
8578
+ compressed: true,
8579
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
8580
+ },
6600
8581
  "atc-rgb": { basisFormat: 11, compressed: true },
6601
8582
  "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
6602
8583
  rgba32: { basisFormat: 13, compressed: false },
@@ -6617,7 +8598,7 @@
6617
8598
  name: "Basis",
6618
8599
  id: "basis",
6619
8600
  module: "textures",
6620
- version: VERSION6,
8601
+ version: VERSION7,
6621
8602
  worker: true,
6622
8603
  extensions: ["basis", "ktx2"],
6623
8604
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -6640,10 +8621,10 @@
6640
8621
  });
6641
8622
 
6642
8623
  // ../images/src/lib/utils/version.ts
6643
- var VERSION8;
8624
+ var VERSION9;
6644
8625
  var init_version6 = __esm({
6645
8626
  "../images/src/lib/utils/version.ts"() {
6646
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8627
+ VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6647
8628
  }
6648
8629
  });
6649
8630
 
@@ -6767,13 +8748,13 @@
6767
8748
  // ../images/src/lib/parsers/parse-to-image.ts
6768
8749
  async function parseToImage(arrayBuffer, options, url) {
6769
8750
  const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
6770
- const URL = self.URL || self.webkitURL;
6771
- const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
8751
+ const URL2 = self.URL || self.webkitURL;
8752
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
6772
8753
  try {
6773
8754
  return await loadToImage(objectUrl || blobOrDataUrl, options);
6774
8755
  } finally {
6775
8756
  if (objectUrl) {
6776
- URL.revokeObjectURL(objectUrl);
8757
+ URL2.revokeObjectURL(objectUrl);
6777
8758
  }
6778
8759
  }
6779
8760
  }
@@ -7038,7 +9019,7 @@
7038
9019
  id: "image",
7039
9020
  module: "images",
7040
9021
  name: "Images",
7041
- version: VERSION8,
9022
+ version: VERSION9,
7042
9023
  mimeTypes: MIME_TYPES,
7043
9024
  extensions: EXTENSIONS,
7044
9025
  parse: parseImage,
@@ -7107,12 +9088,12 @@
7107
9088
  });
7108
9089
 
7109
9090
  // ../gltf/src/lib/utils/assert.ts
7110
- function assert7(condition, message) {
9091
+ function assert8(condition, message) {
7111
9092
  if (!condition) {
7112
9093
  throw new Error(message || "assert failed: gltf");
7113
9094
  }
7114
9095
  }
7115
- var init_assert6 = __esm({
9096
+ var init_assert7 = __esm({
7116
9097
  "../gltf/src/lib/utils/assert.ts"() {
7117
9098
  }
7118
9099
  });
@@ -7137,16 +9118,16 @@
7137
9118
  // ../gltf/src/lib/gltf-utils/get-typed-array.ts
7138
9119
  function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
7139
9120
  const bufferView = json.bufferViews[bufferViewIndex];
7140
- assert7(bufferView);
9121
+ assert8(bufferView);
7141
9122
  const bufferIndex = bufferView.buffer;
7142
9123
  const binChunk = buffers[bufferIndex];
7143
- assert7(binChunk);
9124
+ assert8(binChunk);
7144
9125
  const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
7145
9126
  return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
7146
9127
  }
7147
9128
  var init_get_typed_array = __esm({
7148
9129
  "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
7149
- init_assert6();
9130
+ init_assert7();
7150
9131
  }
7151
9132
  });
7152
9133
 
@@ -7168,13 +9149,13 @@
7168
9149
  const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
7169
9150
  const length4 = accessor.count * components;
7170
9151
  const byteLength = accessor.count * components * bytesPerComponent;
7171
- assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
9152
+ assert8(byteLength >= 0 && byteLength <= bufferView.byteLength);
7172
9153
  return { ArrayType, length: length4, byteLength };
7173
9154
  }
7174
9155
  var TYPES, ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT, ARRAY_TO_COMPONENT_TYPE, ATTRIBUTE_TYPE_TO_COMPONENTS, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY;
7175
9156
  var init_gltf_utils = __esm({
7176
9157
  "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
7177
- init_assert6();
9158
+ init_assert7();
7178
9159
  TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
7179
9160
  ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
7180
9161
  [Int8Array, 5120],
@@ -7220,7 +9201,7 @@
7220
9201
  "../gltf/src/lib/api/gltf-scenegraph.ts"() {
7221
9202
  init_src8();
7222
9203
  init_src2();
7223
- init_assert6();
9204
+ init_assert7();
7224
9205
  init_gltf_utils();
7225
9206
  DEFAULT_GLTF_JSON = {
7226
9207
  asset: {
@@ -7319,7 +9300,7 @@
7319
9300
  bufferView = this.getBufferView(bufferView);
7320
9301
  const bufferIndex = bufferView.buffer;
7321
9302
  const binChunk = this.gltf.buffers[bufferIndex];
7322
- assert7(binChunk);
9303
+ assert8(binChunk);
7323
9304
  const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
7324
9305
  return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
7325
9306
  }
@@ -7366,14 +9347,14 @@
7366
9347
  return extension;
7367
9348
  }
7368
9349
  addExtension(extensionName, extensionData = {}) {
7369
- assert7(extensionData);
9350
+ assert8(extensionData);
7370
9351
  this.json.extensions = this.json.extensions || {};
7371
9352
  this.json.extensions[extensionName] = extensionData;
7372
9353
  this.registerUsedExtension(extensionName);
7373
9354
  return extensionData;
7374
9355
  }
7375
9356
  addRequiredExtension(extensionName, extensionData = {}) {
7376
- assert7(extensionData);
9357
+ assert8(extensionData);
7377
9358
  this.addExtension(extensionName, extensionData);
7378
9359
  this.registerRequiredExtension(extensionName);
7379
9360
  return extensionData;
@@ -7471,7 +9452,7 @@
7471
9452
  }
7472
9453
  addBufferView(buffer) {
7473
9454
  const byteLength = buffer.byteLength;
7474
- assert7(Number.isFinite(byteLength));
9455
+ assert8(Number.isFinite(byteLength));
7475
9456
  this.sourceBuffers = this.sourceBuffers || [];
7476
9457
  this.sourceBuffers.push(buffer);
7477
9458
  const glTFBufferView = {
@@ -8021,10 +10002,10 @@
8021
10002
  }
8022
10003
  const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
8023
10004
  const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
8024
- const { parse: parse4 } = context;
10005
+ const { parse: parse5 } = context;
8025
10006
  const dracoOptions = { ...options };
8026
10007
  delete dracoOptions["3d-tiles"];
8027
- const decodedData = await parse4(bufferCopy, DracoLoader2, dracoOptions, context);
10008
+ const decodedData = await parse5(bufferCopy, DracoLoader2, dracoOptions, context);
8028
10009
  const decodedAttributes = getGLTFAccessors(decodedData.attributes);
8029
10010
  for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
8030
10011
  if (attributeName in primitive.attributes) {
@@ -8118,7 +10099,7 @@
8118
10099
  const { json } = gltfScenegraph;
8119
10100
  if (json.lights) {
8120
10101
  const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);
8121
- assert7(!extension.lights);
10102
+ assert8(!extension.lights);
8122
10103
  extension.lights = json.lights;
8123
10104
  delete json.lights;
8124
10105
  }
@@ -8133,7 +10114,7 @@
8133
10114
  var KHR_LIGHTS_PUNCTUAL, name5;
8134
10115
  var init_KHR_lights_punctual = __esm({
8135
10116
  "../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
8136
- init_assert6();
10117
+ init_assert7();
8137
10118
  init_gltf_scenegraph();
8138
10119
  KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
8139
10120
  name5 = KHR_LIGHTS_PUNCTUAL;
@@ -8526,7 +10507,7 @@
8526
10507
  var COMPONENTS, BYTES, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL, DEFAULT_SAMPLER, GLTFPostProcessor;
8527
10508
  var init_post_process_gltf = __esm({
8528
10509
  "../gltf/src/lib/api/post-process-gltf.ts"() {
8529
- init_assert6();
10510
+ init_assert7();
8530
10511
  init_gltf_utils();
8531
10512
  COMPONENTS = {
8532
10513
  SCALAR: 1,
@@ -8575,7 +10556,7 @@
8575
10556
  }
8576
10557
  postProcess(gltf, options = {}) {
8577
10558
  const { json, buffers = [], images = [], baseUri = "" } = gltf;
8578
- assert7(json);
10559
+ assert8(json);
8579
10560
  this.baseUri = baseUri;
8580
10561
  this.json = json;
8581
10562
  this.buffers = buffers;
@@ -8761,11 +10742,22 @@
8761
10742
  const buffer = accessor.bufferView.buffer;
8762
10743
  const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
8763
10744
  const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
8764
- const cutBufffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
8765
- accessor.value = new ArrayType(cutBufffer);
10745
+ let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
10746
+ if (accessor.bufferView.byteStride) {
10747
+ cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
10748
+ }
10749
+ accessor.value = new ArrayType(cutBuffer);
8766
10750
  }
8767
10751
  return accessor;
8768
10752
  }
10753
+ _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
10754
+ const result = new Uint8Array(count * bytesPerElement);
10755
+ for (let i2 = 0; i2 < count; i2++) {
10756
+ const elementOffset = byteOffset + i2 * byteStride;
10757
+ result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)), i2 * bytesPerElement);
10758
+ }
10759
+ return result.buffer;
10760
+ }
8769
10761
  _resolveTexture(texture, index) {
8770
10762
  texture.id = texture.id || `texture-${index}`;
8771
10763
  texture.sampler = "sampler" in texture ? this.getSampler(texture.sampler) : DEFAULT_SAMPLER;
@@ -8798,16 +10790,19 @@
8798
10790
  return image;
8799
10791
  }
8800
10792
  _resolveBufferView(bufferView, index) {
8801
- bufferView.id = bufferView.id || `bufferView-${index}`;
8802
10793
  const bufferIndex = bufferView.buffer;
8803
- bufferView.buffer = this.buffers[bufferIndex];
10794
+ const result = {
10795
+ id: `bufferView-${index}`,
10796
+ ...bufferView,
10797
+ buffer: this.buffers[bufferIndex]
10798
+ };
8804
10799
  const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
8805
10800
  let byteOffset = this.buffers[bufferIndex].byteOffset || 0;
8806
10801
  if ("byteOffset" in bufferView) {
8807
10802
  byteOffset += bufferView.byteOffset;
8808
10803
  }
8809
- bufferView.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
8810
- return bufferView;
10804
+ result.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
10805
+ return result;
8811
10806
  }
8812
10807
  _resolveCamera(camera, index) {
8813
10808
  camera.id = camera.id || `camera-${index}`;
@@ -8822,7 +10817,7 @@
8822
10817
  });
8823
10818
 
8824
10819
  // ../gltf/src/lib/parsers/parse-glb.ts
8825
- function getMagicString3(dataView, byteOffset = 0) {
10820
+ function getMagicString4(dataView, byteOffset = 0) {
8826
10821
  return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
8827
10822
  }
8828
10823
  function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
@@ -8833,7 +10828,7 @@
8833
10828
  }
8834
10829
  function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
8835
10830
  const dataView = new DataView(arrayBuffer);
8836
- const type = getMagicString3(dataView, byteOffset + 0);
10831
+ const type = getMagicString4(dataView, byteOffset + 0);
8837
10832
  const version = dataView.getUint32(byteOffset + 4, LE);
8838
10833
  const byteLength = dataView.getUint32(byteOffset + 8, LE);
8839
10834
  Object.assign(glb, {
@@ -8965,11 +10960,11 @@
8965
10960
  } else if (data instanceof ArrayBuffer) {
8966
10961
  const glb = {};
8967
10962
  byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
8968
- assert7(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
10963
+ assert8(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
8969
10964
  gltf._glb = glb;
8970
10965
  gltf.json = glb.json;
8971
10966
  } else {
8972
- assert7(false, "GLTF: must be ArrayBuffer or string");
10967
+ assert8(false, "GLTF: must be ArrayBuffer or string");
8973
10968
  }
8974
10969
  const buffers = gltf.json.buffers || [];
8975
10970
  gltf.buffers = new Array(buffers.length).fill(null);
@@ -8990,7 +10985,7 @@
8990
10985
  const buffer = buffers[i2];
8991
10986
  if (buffer.uri) {
8992
10987
  const { fetch: fetch2 } = context;
8993
- assert7(fetch2);
10988
+ assert8(fetch2);
8994
10989
  const uri = resolveUrl(buffer.uri, options);
8995
10990
  const response = await context?.fetch?.(uri);
8996
10991
  const arrayBuffer = await response?.arrayBuffer?.();
@@ -9023,7 +11018,7 @@
9023
11018
  return Array.from(imageIndices).sort();
9024
11019
  }
9025
11020
  async function loadImage(gltf, image, index, options, context) {
9026
- const { fetch: fetch2, parse: parse4 } = context;
11021
+ const { fetch: fetch2, parse: parse5 } = context;
9027
11022
  let arrayBuffer;
9028
11023
  if (image.uri) {
9029
11024
  const uri = resolveUrl(image.uri, options);
@@ -9034,8 +11029,8 @@
9034
11029
  const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
9035
11030
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
9036
11031
  }
9037
- assert7(arrayBuffer, "glTF image has no data");
9038
- let parsedImage = await parse4(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: { format: selectSupportedBasisFormat() } }, context);
11032
+ assert8(arrayBuffer, "glTF image has no data");
11033
+ let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
9039
11034
  if (parsedImage && parsedImage[0]) {
9040
11035
  parsedImage = {
9041
11036
  compressed: true,
@@ -9053,7 +11048,7 @@
9053
11048
  init_src9();
9054
11049
  init_src8();
9055
11050
  init_src2();
9056
- init_assert6();
11051
+ init_assert7();
9057
11052
  init_resolve_url();
9058
11053
  init_get_typed_array();
9059
11054
  init_gltf_extensions();
@@ -9064,7 +11059,7 @@
9064
11059
  });
9065
11060
 
9066
11061
  // ../gltf/src/gltf-loader.ts
9067
- async function parse2(arrayBuffer, options = {}, context) {
11062
+ async function parse3(arrayBuffer, options = {}, context) {
9068
11063
  options = { ...GLTFLoader.options, ...options };
9069
11064
  options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
9070
11065
  const { byteOffset = 0 } = options;
@@ -9080,13 +11075,13 @@
9080
11075
  name: "glTF",
9081
11076
  id: "gltf",
9082
11077
  module: "gltf",
9083
- version: VERSION5,
11078
+ version: VERSION6,
9084
11079
  extensions: ["gltf", "glb"],
9085
11080
  mimeTypes: ["model/gltf+json", "model/gltf-binary"],
9086
11081
  text: true,
9087
11082
  binary: true,
9088
11083
  tests: ["glTF"],
9089
- parse: parse2,
11084
+ parse: parse3,
9090
11085
  options: {
9091
11086
  gltf: {
9092
11087
  normalize: true,
@@ -9138,13 +11133,13 @@
9138
11133
  const tile3DOptions = options["3d-tiles"] || {};
9139
11134
  extractGLTFBufferOrURL(tile, gltfFormat, options);
9140
11135
  if (tile3DOptions.loadGLTF) {
9141
- const { parse: parse4, fetch: fetch2 } = context;
11136
+ const { parse: parse5, fetch: fetch2 } = context;
9142
11137
  if (tile.gltfUrl) {
9143
11138
  tile.gltfArrayBuffer = await fetch2(tile.gltfUrl, options);
9144
11139
  tile.gltfByteOffset = 0;
9145
11140
  }
9146
11141
  if (tile.gltfArrayBuffer) {
9147
- tile.gltf = await parse4(tile.gltfArrayBuffer, GLTFLoader, options, context);
11142
+ tile.gltf = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
9148
11143
  delete tile.gltfArrayBuffer;
9149
11144
  delete tile.gltfByteOffset;
9150
11145
  delete tile.gltfByteLength;
@@ -9381,15 +11376,30 @@
9381
11376
  }
9382
11377
  });
9383
11378
 
11379
+ // src/lib/parsers/parse-3d-tile-gltf.js
11380
+ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
11381
+ tile.rotateYtoZ = true;
11382
+ tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
11383
+ const { parse: parse5 } = context;
11384
+ tile.gltf = await parse5(arrayBuffer, GLTFLoader, options, context);
11385
+ }
11386
+ var init_parse_3d_tile_gltf = __esm({
11387
+ "src/lib/parsers/parse-3d-tile-gltf.js"() {
11388
+ init_src10();
11389
+ }
11390
+ });
11391
+
9384
11392
  // src/lib/parsers/parse-3d-tile.ts
9385
11393
  async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
9386
11394
  tile.byteOffset = byteOffset;
9387
- tile.type = getMagicString2(arrayBuffer, byteOffset);
11395
+ tile.type = getMagicString3(arrayBuffer, byteOffset);
9388
11396
  switch (tile.type) {
9389
11397
  case TILE3D_TYPE.COMPOSITE:
9390
11398
  return await parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
9391
11399
  case TILE3D_TYPE.BATCHED_3D_MODEL:
9392
11400
  return await parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
11401
+ case TILE3D_TYPE.GLTF:
11402
+ return await parseGltf3DTile(tile, arrayBuffer, options, context);
9393
11403
  case TILE3D_TYPE.INSTANCED_3D_MODEL:
9394
11404
  return await parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
9395
11405
  case TILE3D_TYPE.POINT_CLOUD:
@@ -9406,6 +11416,219 @@
9406
11416
  init_parse_3d_tile_batched_model();
9407
11417
  init_parse_3d_tile_instanced_model();
9408
11418
  init_parse_3d_tile_composite();
11419
+ init_parse_3d_tile_gltf();
11420
+ }
11421
+ });
11422
+
11423
+ // src/lib/parsers/helpers/parse-3d-tile-subtree.ts
11424
+ async function parse3DTilesSubtree(data) {
11425
+ const magic = new Uint32Array(data.slice(0, 4));
11426
+ if (magic[0] !== SUBTREE_FILE_MAGIC) {
11427
+ throw new Error("Wrong subtree file magic number");
11428
+ }
11429
+ const version = new Uint32Array(data.slice(4, 8));
11430
+ if (version[0] !== SUBTREE_FILE_VERSION) {
11431
+ throw new Error("Wrong subtree file verson, must be 1");
11432
+ }
11433
+ const jsonByteLength = parseUint64Value(data.slice(8, 16));
11434
+ const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
11435
+ const textDecoder = new TextDecoder("utf8");
11436
+ const string = textDecoder.decode(stringAttribute);
11437
+ const subtree = JSON.parse(string);
11438
+ const binaryByteLength = parseUint64Value(data.slice(16, 24));
11439
+ let internalBinaryBuffer = new ArrayBuffer(0);
11440
+ if (binaryByteLength) {
11441
+ internalBinaryBuffer = data.slice(24 + jsonByteLength);
11442
+ }
11443
+ if ("bufferView" in subtree.tileAvailability) {
11444
+ subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, "tileAvailability", internalBinaryBuffer);
11445
+ }
11446
+ if ("bufferView" in subtree.contentAvailability) {
11447
+ subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, "contentAvailability", internalBinaryBuffer);
11448
+ }
11449
+ if ("bufferView" in subtree.childSubtreeAvailability) {
11450
+ subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, "childSubtreeAvailability", internalBinaryBuffer);
11451
+ }
11452
+ return subtree;
11453
+ }
11454
+ async function getExplicitBitstream(subtree, name8, internalBinaryBuffer) {
11455
+ const bufferViewIndex = subtree[name8].bufferView;
11456
+ const bufferView = subtree.bufferViews[bufferViewIndex];
11457
+ const buffer = subtree.buffers[bufferView.buffer];
11458
+ if (buffer.uri) {
11459
+ const response = await fetchFile(buffer.uri);
11460
+ const data = await response.arrayBuffer();
11461
+ return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
11462
+ }
11463
+ return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
11464
+ }
11465
+ function parseUint64Value(buffer) {
11466
+ const dataView = new DataView(buffer);
11467
+ const left = dataView.getUint32(0, true);
11468
+ const right = dataView.getUint32(4, true);
11469
+ return left + 2 ** 32 * right;
11470
+ }
11471
+ var SUBTREE_FILE_MAGIC, SUBTREE_FILE_VERSION;
11472
+ var init_parse_3d_tile_subtree = __esm({
11473
+ "src/lib/parsers/helpers/parse-3d-tile-subtree.ts"() {
11474
+ init_src3();
11475
+ SUBTREE_FILE_MAGIC = 1952609651;
11476
+ SUBTREE_FILE_VERSION = 1;
11477
+ }
11478
+ });
11479
+
11480
+ // src/tile-3d-subtree-loader.ts
11481
+ var Tile3DSubtreeLoader;
11482
+ var init_tile_3d_subtree_loader = __esm({
11483
+ "src/tile-3d-subtree-loader.ts"() {
11484
+ init_parse_3d_tile_subtree();
11485
+ init_version2();
11486
+ Tile3DSubtreeLoader = {
11487
+ id: "3d-tiles-subtree",
11488
+ name: "3D Tiles Subtree",
11489
+ module: "3d-tiles",
11490
+ version: VERSION4,
11491
+ extensions: ["subtree"],
11492
+ mimeTypes: ["application/octet-stream"],
11493
+ tests: ["subtree"],
11494
+ parse: parse3DTilesSubtree,
11495
+ options: {}
11496
+ };
11497
+ }
11498
+ });
11499
+
11500
+ // src/lib/parsers/helpers/parse-3d-implicit-tiles.ts
11501
+ async function parseImplicitTiles(subtree, options, parentData = {
11502
+ mortonIndex: 0,
11503
+ x: 0,
11504
+ y: 0,
11505
+ z: 0
11506
+ }, childIndex = 0, level = 0, globalData = {
11507
+ level: 0,
11508
+ mortonIndex: 0,
11509
+ x: 0,
11510
+ y: 0,
11511
+ z: 0
11512
+ }) {
11513
+ const {
11514
+ subdivisionScheme,
11515
+ subtreeLevels,
11516
+ maximumLevel,
11517
+ contentUrlTemplate,
11518
+ subtreesUriTemplate,
11519
+ basePath
11520
+ } = options;
11521
+ const tile = { children: [], lodMetricValue: 0, contentUrl: "" };
11522
+ const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
11523
+ const childX = childIndex & 1;
11524
+ const childY = childIndex >> 1 & 1;
11525
+ const childZ = childIndex >> 2 & 1;
11526
+ const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
11527
+ let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
11528
+ let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
11529
+ let childTileX = concatBits(parentData.x, childX);
11530
+ let childTileY = concatBits(parentData.y, childY);
11531
+ let childTileZ = concatBits(parentData.z, childZ);
11532
+ let isChildSubtreeAvailable = false;
11533
+ if (level + 1 > subtreeLevels) {
11534
+ isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
11535
+ }
11536
+ const x = concatBits(globalData.x, childTileX);
11537
+ const y = concatBits(globalData.y, childTileY);
11538
+ const z = concatBits(globalData.z, childTileZ);
11539
+ const lev = level + globalData.level;
11540
+ if (isChildSubtreeAvailable) {
11541
+ const subtreePath = `${basePath}/${subtreesUriTemplate}`;
11542
+ const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
11543
+ const childSubtree = await load(childSubtreeUrl, Tile3DSubtreeLoader);
11544
+ subtree = childSubtree;
11545
+ globalData.mortonIndex = childTileMortonIndex;
11546
+ globalData.x = childTileX;
11547
+ globalData.y = childTileY;
11548
+ globalData.z = childTileZ;
11549
+ globalData.level = level;
11550
+ childTileMortonIndex = 0;
11551
+ tileAvailabilityIndex = 0;
11552
+ childTileX = 0;
11553
+ childTileY = 0;
11554
+ childTileZ = 0;
11555
+ level = 0;
11556
+ }
11557
+ const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
11558
+ if (!isTileAvailable || level > maximumLevel) {
11559
+ return tile;
11560
+ }
11561
+ const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
11562
+ if (isContentAvailable) {
11563
+ tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
11564
+ }
11565
+ const childTileLevel = level + 1;
11566
+ const pData = { mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ };
11567
+ for (let index = 0; index < childrenPerTile; index++) {
11568
+ const currentTile = await parseImplicitTiles(subtree, options, pData, index, childTileLevel, globalData);
11569
+ if (currentTile.contentUrl || currentTile.children.length) {
11570
+ const globalLevel = lev + 1;
11571
+ const formattedTile = formatTileData(currentTile, globalLevel, options);
11572
+ tile.children.push(formattedTile);
11573
+ }
11574
+ }
11575
+ return tile;
11576
+ }
11577
+ function getAvailabilityResult(availabilityData, index) {
11578
+ if ("constant" in availabilityData) {
11579
+ return Boolean(availabilityData.constant);
11580
+ }
11581
+ if (availabilityData.explicitBitstream) {
11582
+ return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);
11583
+ }
11584
+ return false;
11585
+ }
11586
+ function formatTileData(tile, level, options) {
11587
+ const { basePath, refine, getRefine: getRefine2, lodMetricType, getTileType: getTileType2, rootLodMetricValue } = options;
11588
+ const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, "");
11589
+ const lodMetricValue = rootLodMetricValue / 2 ** level;
11590
+ return {
11591
+ children: tile.children,
11592
+ contentUrl: tile.contentUrl,
11593
+ content: { uri },
11594
+ id: tile.contentUrl,
11595
+ refine: getRefine2(refine),
11596
+ type: getTileType2(tile),
11597
+ lodMetricType,
11598
+ lodMetricValue
11599
+ };
11600
+ }
11601
+ function concatBits(first, second) {
11602
+ return parseInt(first.toString(2) + second.toString(2), 2);
11603
+ }
11604
+ function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
11605
+ const mapUrl = generateMapUrl({ level, x, y, z });
11606
+ return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);
11607
+ }
11608
+ function generateMapUrl(items) {
11609
+ const mapUrl = {};
11610
+ for (const key in items) {
11611
+ mapUrl[`{${key}}`] = items[key];
11612
+ }
11613
+ return mapUrl;
11614
+ }
11615
+ function getBooleanValueFromBitstream(availabilityIndex, availabilityBuffer) {
11616
+ const byteIndex = Math.floor(availabilityIndex / 8);
11617
+ const bitIndex = availabilityIndex % 8;
11618
+ const bitValue = availabilityBuffer[byteIndex] >> bitIndex & 1;
11619
+ return bitValue === 1;
11620
+ }
11621
+ var QUADTREE_DEVISION_COUNT, OCTREE_DEVISION_COUNT, SUBDIVISION_COUNT_MAP;
11622
+ var init_parse_3d_implicit_tiles = __esm({
11623
+ "src/lib/parsers/helpers/parse-3d-implicit-tiles.ts"() {
11624
+ init_tile_3d_subtree_loader();
11625
+ init_src3();
11626
+ QUADTREE_DEVISION_COUNT = 4;
11627
+ OCTREE_DEVISION_COUNT = 8;
11628
+ SUBDIVISION_COUNT_MAP = {
11629
+ QUADTREE: QUADTREE_DEVISION_COUNT,
11630
+ OCTREE: OCTREE_DEVISION_COUNT
11631
+ };
9409
11632
  }
9410
11633
  });
9411
11634
 
@@ -9421,6 +11644,8 @@
9421
11644
  return TILE_TYPE.POINTCLOUD;
9422
11645
  case "i3dm":
9423
11646
  case "b3dm":
11647
+ case "glb":
11648
+ case "gltf":
9424
11649
  return TILE_TYPE.SCENEGRAPH;
9425
11650
  default:
9426
11651
  return fileExtension;
@@ -9469,9 +11694,63 @@
9469
11694
  }
9470
11695
  return root;
9471
11696
  }
11697
+ async function normalizeImplicitTileHeaders(tileset) {
11698
+ if (!tileset.root) {
11699
+ return null;
11700
+ }
11701
+ const basePath = tileset.basePath;
11702
+ const implicitTilingExtension = tileset.root.extensions["3DTILES_implicit_tiling"];
11703
+ const {
11704
+ subdivisionScheme,
11705
+ maximumLevel,
11706
+ subtreeLevels,
11707
+ subtrees: { uri: subtreesUriTemplate }
11708
+ } = implicitTilingExtension;
11709
+ const subtreeUrl = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
11710
+ const rootSubtreeUrl = `${basePath}/${subtreeUrl}`;
11711
+ const rootSubtree = await load(rootSubtreeUrl, Tile3DSubtreeLoader);
11712
+ const contentUrlTemplate = `${basePath}/${tileset.root.content.uri}`;
11713
+ const refine = tileset.root.refine;
11714
+ const rootLodMetricValue = tileset.root.geometricError;
11715
+ const options = {
11716
+ contentUrlTemplate,
11717
+ subtreesUriTemplate,
11718
+ subdivisionScheme,
11719
+ subtreeLevels,
11720
+ maximumLevel,
11721
+ refine,
11722
+ basePath,
11723
+ lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
11724
+ rootLodMetricValue,
11725
+ getTileType,
11726
+ getRefine
11727
+ };
11728
+ return await normalizeImplicitTileData(tileset.root, rootSubtree, options);
11729
+ }
11730
+ async function normalizeImplicitTileData(tile, rootSubtree, options) {
11731
+ if (!tile) {
11732
+ return null;
11733
+ }
11734
+ tile.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
11735
+ tile.lodMetricValue = tile.geometricError;
11736
+ tile.transformMatrix = tile.transform;
11737
+ const { children, contentUrl } = await parseImplicitTiles(rootSubtree, options);
11738
+ if (contentUrl) {
11739
+ tile.contentUrl = contentUrl;
11740
+ tile.content = { uri: contentUrl.replace(`${options.basePath}/`, "") };
11741
+ }
11742
+ tile.refine = getRefine(tile.refine);
11743
+ tile.type = getTileType(tile);
11744
+ tile.children = children;
11745
+ tile.id = tile.contentUrl;
11746
+ return tile;
11747
+ }
9472
11748
  var init_parse_3d_tile_header2 = __esm({
9473
11749
  "src/lib/parsers/parse-3d-tile-header.ts"() {
11750
+ init_tile_3d_subtree_loader();
11751
+ init_src3();
9474
11752
  init_src4();
11753
+ init_parse_3d_implicit_tiles();
9475
11754
  }
9476
11755
  });
9477
11756
 
@@ -9494,13 +11773,13 @@
9494
11773
  tilesetJson.loader = options.loader || Tiles3DLoader;
9495
11774
  tilesetJson.url = context.url;
9496
11775
  tilesetJson.basePath = getBaseUri(tilesetJson);
9497
- tilesetJson.root = normalizeTileHeaders(tilesetJson);
11776
+ tilesetJson.root = hasImplicitTilingExtension(tilesetJson) ? await normalizeImplicitTileHeaders(tilesetJson) : normalizeTileHeaders(tilesetJson);
9498
11777
  tilesetJson.type = TILESET_TYPE.TILES3D;
9499
11778
  tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
9500
11779
  tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
9501
11780
  return tilesetJson;
9502
11781
  }
9503
- async function parse3(data, options, context) {
11782
+ async function parse4(data, options, context) {
9504
11783
  const loaderOptions = options["3d-tiles"] || {};
9505
11784
  let isTileset;
9506
11785
  if (loaderOptions.isTileset === "auto") {
@@ -9515,7 +11794,10 @@
9515
11794
  }
9516
11795
  return data;
9517
11796
  }
9518
- var Tiles3DLoader;
11797
+ function hasImplicitTilingExtension(tilesetJson) {
11798
+ return tilesetJson?.extensionsRequired?.includes(IMPLICIT_TILING_EXTENSION_NAME) && tilesetJson?.extensionsUsed?.includes(IMPLICIT_TILING_EXTENSION_NAME);
11799
+ }
11800
+ var IMPLICIT_TILING_EXTENSION_NAME, Tiles3DLoader;
9519
11801
  var init_tiles_3d_loader = __esm({
9520
11802
  "src/tiles-3d-loader.ts"() {
9521
11803
  init_src2();
@@ -9523,15 +11805,16 @@
9523
11805
  init_version2();
9524
11806
  init_parse_3d_tile();
9525
11807
  init_parse_3d_tile_header2();
11808
+ IMPLICIT_TILING_EXTENSION_NAME = "3DTILES_implicit_tiling";
9526
11809
  Tiles3DLoader = {
9527
11810
  id: "3d-tiles",
9528
11811
  name: "3D Tiles",
9529
11812
  module: "3d-tiles",
9530
- version: VERSION3,
11813
+ version: VERSION4,
9531
11814
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
9532
11815
  mimeTypes: ["application/octet-stream"],
9533
11816
  tests: ["cmpt", "pnts", "b3dm", "i3dm"],
9534
- parse: parse3,
11817
+ parse: parse4,
9535
11818
  options: {
9536
11819
  "3d-tiles": {
9537
11820
  loadGLTF: true,
@@ -9544,7 +11827,7 @@
9544
11827
  }
9545
11828
  });
9546
11829
 
9547
- // src/lib/ion/ion.js
11830
+ // src/lib/ion/ion.ts
9548
11831
  async function getIonTilesetMetadata(accessToken, assetId) {
9549
11832
  if (!assetId) {
9550
11833
  const assets = await getIonAssets(accessToken);
@@ -9594,7 +11877,7 @@
9594
11877
  }
9595
11878
  var CESIUM_ION_URL;
9596
11879
  var init_ion = __esm({
9597
- "src/lib/ion/ion.js"() {
11880
+ "src/lib/ion/ion.ts"() {
9598
11881
  init_src3();
9599
11882
  init_src2();
9600
11883
  CESIUM_ION_URL = "https://api.cesium.com/v1/assets";
@@ -9638,83 +11921,6 @@
9638
11921
  }
9639
11922
  });
9640
11923
 
9641
- // src/lib/parsers/helpers/parse-3d-tile-subtree.ts
9642
- async function parse3DTilesSubtree(data) {
9643
- const magic = new Uint32Array(data.slice(0, 4));
9644
- if (magic[0] !== SUBTREE_FILE_MAGIC) {
9645
- throw new Error("Wrong subtree file magic number");
9646
- }
9647
- const version = new Uint32Array(data.slice(4, 8));
9648
- if (version[0] !== SUBTREE_FILE_VERSION) {
9649
- throw new Error("Wrong subtree file verson, must be 1");
9650
- }
9651
- const jsonByteLength = parseUint64Value(data.slice(8, 16));
9652
- const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
9653
- const textDecoder = new TextDecoder("utf8");
9654
- const string = textDecoder.decode(stringAttribute);
9655
- const subtree = JSON.parse(string);
9656
- const binaryByteLength = parseUint64Value(data.slice(16, 24));
9657
- let internalBinaryBuffer = new ArrayBuffer(0);
9658
- if (binaryByteLength) {
9659
- internalBinaryBuffer = data.slice(24 + jsonByteLength);
9660
- }
9661
- if ("bufferView" in subtree.tileAvailability) {
9662
- subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, "tileAvailability", internalBinaryBuffer);
9663
- }
9664
- if ("bufferView" in subtree.contentAvailability) {
9665
- subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, "contentAvailability", internalBinaryBuffer);
9666
- }
9667
- if ("bufferView" in subtree.childSubtreeAvailability) {
9668
- subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, "childSubtreeAvailability", internalBinaryBuffer);
9669
- }
9670
- return subtree;
9671
- }
9672
- async function getExplicitBitstream(subtree, name8, internalBinaryBuffer) {
9673
- const bufferViewIndex = subtree[name8].bufferView;
9674
- const bufferView = subtree.bufferViews[bufferViewIndex];
9675
- const buffer = subtree.buffers[bufferView.buffer];
9676
- if (buffer.uri) {
9677
- const response = await fetchFile(buffer.uri);
9678
- const data = await response.arrayBuffer();
9679
- return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
9680
- }
9681
- return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
9682
- }
9683
- function parseUint64Value(buffer) {
9684
- const dataView = new DataView(buffer);
9685
- const left = dataView.getUint32(0, true);
9686
- const right = dataView.getUint32(4, true);
9687
- return left + 2 ** 32 * right;
9688
- }
9689
- var SUBTREE_FILE_MAGIC, SUBTREE_FILE_VERSION;
9690
- var init_parse_3d_tile_subtree = __esm({
9691
- "src/lib/parsers/helpers/parse-3d-tile-subtree.ts"() {
9692
- init_src3();
9693
- SUBTREE_FILE_MAGIC = 1952609651;
9694
- SUBTREE_FILE_VERSION = 1;
9695
- }
9696
- });
9697
-
9698
- // src/tile-3d-subtree-loader.ts
9699
- var Tile3DSubtreeLoader;
9700
- var init_tile_3d_subtree_loader = __esm({
9701
- "src/tile-3d-subtree-loader.ts"() {
9702
- init_parse_3d_tile_subtree();
9703
- init_version2();
9704
- Tile3DSubtreeLoader = {
9705
- id: "3d-tiles-subtree",
9706
- name: "3D Tiles Subtree",
9707
- module: "3d-tiles",
9708
- version: VERSION3,
9709
- extensions: ["subtree"],
9710
- mimeTypes: ["application/octet-stream"],
9711
- tests: ["subtree"],
9712
- parse: parse3DTilesSubtree,
9713
- options: {}
9714
- };
9715
- }
9716
- });
9717
-
9718
11924
  // src/lib/encoders/helpers/encode-3d-tile-header.ts
9719
11925
  function encode3DTileHeader(tile, dataView, byteOffset) {
9720
11926
  const HEADER_SIZE = 12;
@@ -9924,7 +12130,7 @@
9924
12130
  name: "3D Tile",
9925
12131
  id: "3d-tiles",
9926
12132
  module: "3d-tiles",
9927
- version: VERSION3,
12133
+ version: VERSION4,
9928
12134
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
9929
12135
  mimeTypes: ["application/octet-stream"],
9930
12136
  encodeSync,
@@ -9963,10 +12169,10 @@
9963
12169
 
9964
12170
  // src/bundle.ts
9965
12171
  var require_bundle = __commonJS({
9966
- "src/bundle.ts"(exports, module) {
12172
+ "src/bundle.ts"(exports, module2) {
9967
12173
  var moduleExports = (init_src11(), src_exports);
9968
12174
  globalThis.loaders = globalThis.loaders || {};
9969
- module.exports = Object.assign(globalThis.loaders, moduleExports);
12175
+ module2.exports = Object.assign(globalThis.loaders, moduleExports);
9970
12176
  }
9971
12177
  });
9972
12178
  require_bundle();