@loaders.gl/3d-tiles 3.1.0-beta.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/bundle.js +2418 -232
  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
@@ -89,6 +89,421 @@
89
89
  }
90
90
  });
91
91
 
92
+ // ../worker-utils/src/lib/worker-farm/worker-job.ts
93
+ var WorkerJob;
94
+ var init_worker_job = __esm({
95
+ "../worker-utils/src/lib/worker-farm/worker-job.ts"() {
96
+ init_assert2();
97
+ WorkerJob = class {
98
+ constructor(jobName, workerThread) {
99
+ this.name = jobName;
100
+ this.workerThread = workerThread;
101
+ this.isRunning = true;
102
+ this._resolve = () => {
103
+ };
104
+ this._reject = () => {
105
+ };
106
+ this.result = new Promise((resolve, reject) => {
107
+ this._resolve = resolve;
108
+ this._reject = reject;
109
+ });
110
+ }
111
+ postMessage(type, payload) {
112
+ this.workerThread.postMessage({
113
+ source: "loaders.gl",
114
+ type,
115
+ payload
116
+ });
117
+ }
118
+ done(value) {
119
+ assert3(this.isRunning);
120
+ this.isRunning = false;
121
+ this._resolve(value);
122
+ }
123
+ error(error) {
124
+ assert3(this.isRunning);
125
+ this.isRunning = false;
126
+ this._reject(error);
127
+ }
128
+ };
129
+ }
130
+ });
131
+
132
+ // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
133
+ function getLoadableWorkerURL(props) {
134
+ assert3(props.source && !props.url || !props.source && props.url);
135
+ let workerURL = workerURLCache.get(props.source || props.url);
136
+ if (!workerURL) {
137
+ if (props.url) {
138
+ workerURL = getLoadableWorkerURLFromURL(props.url);
139
+ workerURLCache.set(props.url, workerURL);
140
+ }
141
+ if (props.source) {
142
+ workerURL = getLoadableWorkerURLFromSource(props.source);
143
+ workerURLCache.set(props.source, workerURL);
144
+ }
145
+ }
146
+ assert3(workerURL);
147
+ return workerURL;
148
+ }
149
+ function getLoadableWorkerURLFromURL(url) {
150
+ if (!url.startsWith("http")) {
151
+ return url;
152
+ }
153
+ const workerSource = buildScriptSource(url);
154
+ return getLoadableWorkerURLFromSource(workerSource);
155
+ }
156
+ function getLoadableWorkerURLFromSource(workerSource) {
157
+ const blob = new Blob([workerSource], { type: "application/javascript" });
158
+ return URL.createObjectURL(blob);
159
+ }
160
+ function buildScriptSource(workerUrl) {
161
+ return `try {
162
+ importScripts('${workerUrl}');
163
+ } catch (error) {
164
+ console.error(error);
165
+ throw error;
166
+ }`;
167
+ }
168
+ var workerURLCache;
169
+ var init_get_loadable_worker_url = __esm({
170
+ "../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts"() {
171
+ init_assert2();
172
+ workerURLCache = new Map();
173
+ }
174
+ });
175
+
176
+ // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
177
+ function getTransferList(object, recursive = true, transfers) {
178
+ const transfersSet = transfers || new Set();
179
+ if (!object) {
180
+ } else if (isTransferable(object)) {
181
+ transfersSet.add(object);
182
+ } else if (isTransferable(object.buffer)) {
183
+ transfersSet.add(object.buffer);
184
+ } else if (ArrayBuffer.isView(object)) {
185
+ } else if (recursive && typeof object === "object") {
186
+ for (const key in object) {
187
+ getTransferList(object[key], recursive, transfersSet);
188
+ }
189
+ }
190
+ return transfers === void 0 ? Array.from(transfersSet) : [];
191
+ }
192
+ function isTransferable(object) {
193
+ if (!object) {
194
+ return false;
195
+ }
196
+ if (object instanceof ArrayBuffer) {
197
+ return true;
198
+ }
199
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
200
+ return true;
201
+ }
202
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
203
+ return true;
204
+ }
205
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
206
+ return true;
207
+ }
208
+ return false;
209
+ }
210
+ var init_get_transfer_list = __esm({
211
+ "../worker-utils/src/lib/worker-utils/get-transfer-list.ts"() {
212
+ }
213
+ });
214
+
215
+ // ../worker-utils/src/lib/worker-farm/worker-thread.ts
216
+ var NOOP, WorkerThread;
217
+ var init_worker_thread = __esm({
218
+ "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
219
+ init_assert2();
220
+ init_get_loadable_worker_url();
221
+ init_get_transfer_list();
222
+ NOOP = () => {
223
+ };
224
+ WorkerThread = class {
225
+ constructor(props) {
226
+ this.terminated = false;
227
+ this._loadableURL = "";
228
+ const { name: name8, source, url } = props;
229
+ assert3(source || url);
230
+ this.name = name8;
231
+ this.source = source;
232
+ this.url = url;
233
+ this.onMessage = NOOP;
234
+ this.onError = (error) => console.log(error);
235
+ this.worker = this._createBrowserWorker();
236
+ }
237
+ static isSupported() {
238
+ return typeof Worker !== "undefined";
239
+ }
240
+ destroy() {
241
+ this.onMessage = NOOP;
242
+ this.onError = NOOP;
243
+ this.worker.terminate();
244
+ this.terminated = true;
245
+ }
246
+ get isRunning() {
247
+ return Boolean(this.onMessage);
248
+ }
249
+ postMessage(data, transferList) {
250
+ transferList = transferList || getTransferList(data);
251
+ this.worker.postMessage(data, transferList);
252
+ }
253
+ _getErrorFromErrorEvent(event) {
254
+ let message = "Failed to load ";
255
+ message += `worker ${this.name} from ${this.url}. `;
256
+ if (event.message) {
257
+ message += `${event.message} in `;
258
+ }
259
+ if (event.lineno) {
260
+ message += `:${event.lineno}:${event.colno}`;
261
+ }
262
+ return new Error(message);
263
+ }
264
+ _createBrowserWorker() {
265
+ this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
266
+ const worker = new Worker(this._loadableURL, { name: this.name });
267
+ worker.onmessage = (event) => {
268
+ if (!event.data) {
269
+ this.onError(new Error("No data received"));
270
+ } else {
271
+ this.onMessage(event.data);
272
+ }
273
+ };
274
+ worker.onerror = (error) => {
275
+ this.onError(this._getErrorFromErrorEvent(error));
276
+ this.terminated = true;
277
+ };
278
+ worker.onmessageerror = (event) => console.error(event);
279
+ return worker;
280
+ }
281
+ };
282
+ }
283
+ });
284
+
285
+ // ../worker-utils/src/lib/worker-farm/worker-pool.ts
286
+ var WorkerPool;
287
+ var init_worker_pool = __esm({
288
+ "../worker-utils/src/lib/worker-farm/worker-pool.ts"() {
289
+ init_globals2();
290
+ init_worker_thread();
291
+ init_worker_job();
292
+ WorkerPool = class {
293
+ constructor(props) {
294
+ this.name = "unnamed";
295
+ this.maxConcurrency = 1;
296
+ this.maxMobileConcurrency = 1;
297
+ this.onDebug = () => {
298
+ };
299
+ this.reuseWorkers = true;
300
+ this.props = {};
301
+ this.jobQueue = [];
302
+ this.idleQueue = [];
303
+ this.count = 0;
304
+ this.isDestroyed = false;
305
+ this.source = props.source;
306
+ this.url = props.url;
307
+ this.setProps(props);
308
+ }
309
+ destroy() {
310
+ this.idleQueue.forEach((worker) => worker.destroy());
311
+ this.isDestroyed = true;
312
+ }
313
+ setProps(props) {
314
+ this.props = { ...this.props, ...props };
315
+ if (props.name !== void 0) {
316
+ this.name = props.name;
317
+ }
318
+ if (props.maxConcurrency !== void 0) {
319
+ this.maxConcurrency = props.maxConcurrency;
320
+ }
321
+ if (props.maxMobileConcurrency !== void 0) {
322
+ this.maxMobileConcurrency = props.maxMobileConcurrency;
323
+ }
324
+ if (props.reuseWorkers !== void 0) {
325
+ this.reuseWorkers = props.reuseWorkers;
326
+ }
327
+ if (props.onDebug !== void 0) {
328
+ this.onDebug = props.onDebug;
329
+ }
330
+ }
331
+ async startJob(name8, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
332
+ const startPromise = new Promise((onStart) => {
333
+ this.jobQueue.push({ name: name8, onMessage: onMessage2, onError, onStart });
334
+ return this;
335
+ });
336
+ this._startQueuedJob();
337
+ return await startPromise;
338
+ }
339
+ async _startQueuedJob() {
340
+ if (!this.jobQueue.length) {
341
+ return;
342
+ }
343
+ const workerThread = this._getAvailableWorker();
344
+ if (!workerThread) {
345
+ return;
346
+ }
347
+ const queuedJob = this.jobQueue.shift();
348
+ if (queuedJob) {
349
+ this.onDebug({
350
+ message: "Starting job",
351
+ name: queuedJob.name,
352
+ workerThread,
353
+ backlog: this.jobQueue.length
354
+ });
355
+ const job = new WorkerJob(queuedJob.name, workerThread);
356
+ workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
357
+ workerThread.onError = (error) => queuedJob.onError(job, error);
358
+ queuedJob.onStart(job);
359
+ try {
360
+ await job.result;
361
+ } finally {
362
+ this.returnWorkerToQueue(workerThread);
363
+ }
364
+ }
365
+ }
366
+ returnWorkerToQueue(worker) {
367
+ const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
368
+ if (shouldDestroyWorker) {
369
+ worker.destroy();
370
+ this.count--;
371
+ } else {
372
+ this.idleQueue.push(worker);
373
+ }
374
+ if (!this.isDestroyed) {
375
+ this._startQueuedJob();
376
+ }
377
+ }
378
+ _getAvailableWorker() {
379
+ if (this.idleQueue.length > 0) {
380
+ return this.idleQueue.shift() || null;
381
+ }
382
+ if (this.count < this._getMaxConcurrency()) {
383
+ this.count++;
384
+ const name8 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
385
+ return new WorkerThread({ name: name8, source: this.source, url: this.url });
386
+ }
387
+ return null;
388
+ }
389
+ _getMaxConcurrency() {
390
+ return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
391
+ }
392
+ };
393
+ }
394
+ });
395
+
396
+ // ../worker-utils/src/lib/worker-farm/worker-farm.ts
397
+ var DEFAULT_PROPS, WorkerFarm;
398
+ var init_worker_farm = __esm({
399
+ "../worker-utils/src/lib/worker-farm/worker-farm.ts"() {
400
+ init_worker_pool();
401
+ init_worker_thread();
402
+ DEFAULT_PROPS = {
403
+ maxConcurrency: 3,
404
+ maxMobileConcurrency: 1,
405
+ onDebug: () => {
406
+ },
407
+ reuseWorkers: true
408
+ };
409
+ WorkerFarm = class {
410
+ constructor(props) {
411
+ this.workerPools = new Map();
412
+ this.props = { ...DEFAULT_PROPS };
413
+ this.setProps(props);
414
+ this.workerPools = new Map();
415
+ }
416
+ static isSupported() {
417
+ return WorkerThread.isSupported();
418
+ }
419
+ static getWorkerFarm(props = {}) {
420
+ WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
421
+ WorkerFarm._workerFarm.setProps(props);
422
+ return WorkerFarm._workerFarm;
423
+ }
424
+ destroy() {
425
+ for (const workerPool of this.workerPools.values()) {
426
+ workerPool.destroy();
427
+ }
428
+ }
429
+ setProps(props) {
430
+ this.props = { ...this.props, ...props };
431
+ for (const workerPool of this.workerPools.values()) {
432
+ workerPool.setProps(this._getWorkerPoolProps());
433
+ }
434
+ }
435
+ getWorkerPool(options) {
436
+ const { name: name8, source, url } = options;
437
+ let workerPool = this.workerPools.get(name8);
438
+ if (!workerPool) {
439
+ workerPool = new WorkerPool({
440
+ name: name8,
441
+ source,
442
+ url
443
+ });
444
+ workerPool.setProps(this._getWorkerPoolProps());
445
+ this.workerPools.set(name8, workerPool);
446
+ }
447
+ return workerPool;
448
+ }
449
+ _getWorkerPoolProps() {
450
+ return {
451
+ maxConcurrency: this.props.maxConcurrency,
452
+ maxMobileConcurrency: this.props.maxMobileConcurrency,
453
+ reuseWorkers: this.props.reuseWorkers,
454
+ onDebug: this.props.onDebug
455
+ };
456
+ }
457
+ };
458
+ }
459
+ });
460
+
461
+ // ../worker-utils/src/lib/worker-api/get-worker-url.ts
462
+ function getWorkerURL(worker, options = {}) {
463
+ const workerOptions = options[worker.id] || {};
464
+ const workerFile = `${worker.id}-worker.js`;
465
+ let url = workerOptions.workerUrl;
466
+ if (!url && worker.id === "compression") {
467
+ url = options.workerUrl;
468
+ }
469
+ if (options._workerType === "test") {
470
+ url = `modules/${worker.module}/dist/${workerFile}`;
471
+ }
472
+ if (!url) {
473
+ let version = worker.version;
474
+ if (version === "latest") {
475
+ version = NPM_TAG;
476
+ }
477
+ const versionTag = version ? `@${version}` : "";
478
+ url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
479
+ }
480
+ assert3(url);
481
+ return url;
482
+ }
483
+ var NPM_TAG;
484
+ var init_get_worker_url = __esm({
485
+ "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
486
+ init_assert2();
487
+ NPM_TAG = "beta";
488
+ }
489
+ });
490
+
491
+ // ../worker-utils/src/lib/worker-api/validate-worker-version.ts
492
+ function validateWorkerVersion(worker, coreVersion = VERSION) {
493
+ assert3(worker, "no worker provided");
494
+ const workerVersion = worker.version;
495
+ if (!coreVersion || !workerVersion) {
496
+ return false;
497
+ }
498
+ return true;
499
+ }
500
+ var init_validate_worker_version = __esm({
501
+ "../worker-utils/src/lib/worker-api/validate-worker-version.ts"() {
502
+ init_assert2();
503
+ init_version();
504
+ }
505
+ });
506
+
92
507
  // (disabled):../worker-utils/src/lib/node/require-utils.node
93
508
  var init_require_utils = __esm({
94
509
  "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
@@ -172,10 +587,63 @@
172
587
  // ../worker-utils/src/index.ts
173
588
  var init_src = __esm({
174
589
  "../worker-utils/src/index.ts"() {
590
+ init_assert2();
591
+ init_worker_farm();
592
+ init_get_worker_url();
593
+ init_validate_worker_version();
175
594
  init_library_utils();
176
595
  }
177
596
  });
178
597
 
598
+ // ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
599
+ function canParseWithWorker(loader, options) {
600
+ if (!WorkerFarm.isSupported()) {
601
+ return false;
602
+ }
603
+ return loader.worker && options?.worker;
604
+ }
605
+ async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
606
+ const name8 = loader.id;
607
+ const url = getWorkerURL(loader, options);
608
+ const workerFarm = WorkerFarm.getWorkerFarm(options);
609
+ const workerPool = workerFarm.getWorkerPool({ name: name8, url });
610
+ options = JSON.parse(JSON.stringify(options));
611
+ const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
612
+ job.postMessage("process", {
613
+ input: data,
614
+ options
615
+ });
616
+ const result = await job.result;
617
+ return await result.result;
618
+ }
619
+ async function onMessage(parseOnMainThread, job, type, payload) {
620
+ switch (type) {
621
+ case "done":
622
+ job.done(payload);
623
+ break;
624
+ case "error":
625
+ job.error(new Error(payload.error));
626
+ break;
627
+ case "process":
628
+ const { id, input, options } = payload;
629
+ try {
630
+ const result = await parseOnMainThread(input, options);
631
+ job.postMessage("done", { id, result });
632
+ } catch (error) {
633
+ const message = error instanceof Error ? error.message : "unknown error";
634
+ job.postMessage("error", { id, error: message });
635
+ }
636
+ break;
637
+ default:
638
+ console.warn(`parse-with-worker unknown message ${type}`);
639
+ }
640
+ }
641
+ var init_parse_with_worker = __esm({
642
+ "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
643
+ init_src();
644
+ }
645
+ });
646
+
179
647
  // ../loader-utils/src/lib/binary-utils/get-first-characters.ts
180
648
  function getFirstCharacters(data, length4 = 5) {
181
649
  if (typeof data === "string") {
@@ -218,7 +686,71 @@
218
686
  }
219
687
  });
220
688
 
689
+ // ../loader-utils/src/lib/binary-utils/buffer-utils.ts
690
+ function isBuffer(value) {
691
+ return value && typeof value === "object" && value.isBuffer;
692
+ }
693
+ function bufferToArrayBuffer(buffer) {
694
+ if (isBuffer(buffer)) {
695
+ const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
696
+ return typedArray.slice().buffer;
697
+ }
698
+ return buffer;
699
+ }
700
+ var init_buffer_utils = __esm({
701
+ "../loader-utils/src/lib/binary-utils/buffer-utils.ts"() {
702
+ }
703
+ });
704
+
221
705
  // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
706
+ function toArrayBuffer(data) {
707
+ if (isBuffer(data)) {
708
+ return bufferToArrayBuffer(data);
709
+ }
710
+ if (data instanceof ArrayBuffer) {
711
+ return data;
712
+ }
713
+ if (ArrayBuffer.isView(data)) {
714
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
715
+ return data.buffer;
716
+ }
717
+ return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
718
+ }
719
+ if (typeof data === "string") {
720
+ const text = data;
721
+ const uint8Array = new TextEncoder().encode(text);
722
+ return uint8Array.buffer;
723
+ }
724
+ if (data && typeof data === "object" && data._toArrayBuffer) {
725
+ return data._toArrayBuffer();
726
+ }
727
+ throw new Error("toArrayBuffer");
728
+ }
729
+ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
730
+ byteLength = byteLength || arrayBuffer1.byteLength;
731
+ if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
732
+ return false;
733
+ }
734
+ const array1 = new Uint8Array(arrayBuffer1);
735
+ const array2 = new Uint8Array(arrayBuffer2);
736
+ for (let i2 = 0; i2 < array1.length; ++i2) {
737
+ if (array1[i2] !== array2[i2]) {
738
+ return false;
739
+ }
740
+ }
741
+ return true;
742
+ }
743
+ function concatenateArrayBuffers(...sources) {
744
+ const sourceArrays = sources.map((source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
745
+ const byteLength = sourceArrays.reduce((length4, typedArray) => length4 + typedArray.byteLength, 0);
746
+ const result = new Uint8Array(byteLength);
747
+ let offset = 0;
748
+ for (const sourceArray of sourceArrays) {
749
+ result.set(sourceArray, offset);
750
+ offset += sourceArray.byteLength;
751
+ }
752
+ return result.buffer;
753
+ }
222
754
  function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
223
755
  const subArray = byteLength !== void 0 ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
224
756
  const arrayCopy = new Uint8Array(subArray);
@@ -226,6 +758,7 @@
226
758
  }
227
759
  var init_array_buffer_utils = __esm({
228
760
  "../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
761
+ init_buffer_utils();
229
762
  }
230
763
  });
231
764
 
@@ -312,6 +845,49 @@
312
845
  }
313
846
  });
314
847
 
848
+ // ../loader-utils/src/lib/iterators/async-iteration.ts
849
+ async function concatenateArrayBuffersAsync(asyncIterator) {
850
+ const arrayBuffers = [];
851
+ for await (const chunk of asyncIterator) {
852
+ arrayBuffers.push(chunk);
853
+ }
854
+ return concatenateArrayBuffers(...arrayBuffers);
855
+ }
856
+ var init_async_iteration = __esm({
857
+ "../loader-utils/src/lib/iterators/async-iteration.ts"() {
858
+ init_array_buffer_utils();
859
+ }
860
+ });
861
+
862
+ // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
863
+ var init_hi_res_timestamp = __esm({
864
+ "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
865
+ }
866
+ });
867
+
868
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
869
+ var init_stat = __esm({
870
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
871
+ init_hi_res_timestamp();
872
+ }
873
+ });
874
+
875
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
876
+ var init_stats = __esm({
877
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
878
+ init_stat();
879
+ }
880
+ });
881
+
882
+ // ../../node_modules/@probe.gl/stats/dist/esm/index.js
883
+ var init_esm = __esm({
884
+ "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
885
+ init_stats();
886
+ init_stat();
887
+ init_hi_res_timestamp();
888
+ }
889
+ });
890
+
315
891
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
316
892
  function resolvePath(filename2) {
317
893
  for (const alias in fileAliases) {
@@ -371,11 +947,13 @@
371
947
  "../loader-utils/src/index.ts"() {
372
948
  init_assert();
373
949
  init_globals();
950
+ init_parse_with_worker();
374
951
  init_parse_json();
375
952
  init_array_buffer_utils();
376
953
  init_memory_copy_utils();
377
954
  init_binary_copy_utils();
378
955
  init_encode_utils();
956
+ init_async_iteration();
379
957
  init_file_aliases();
380
958
  init_path();
381
959
  }
@@ -904,11 +1482,11 @@
904
1482
  out[1] = m[1] * x + m[5] * y + m[13];
905
1483
  return out;
906
1484
  }
907
- var forEach;
1485
+ var forEach2;
908
1486
  var init_vec2 = __esm({
909
1487
  "../../node_modules/gl-matrix/esm/vec2.js"() {
910
1488
  init_common2();
911
- forEach = function() {
1489
+ forEach2 = function() {
912
1490
  var vec = create();
913
1491
  return function(a2, stride, offset, count, fn, arg) {
914
1492
  var i2, l2;
@@ -1184,12 +1762,12 @@
1184
1762
  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
1763
  return Math.acos(Math.min(Math.max(cosine, -1), 1));
1186
1764
  }
1187
- var len, forEach2;
1765
+ var len, forEach3;
1188
1766
  var init_vec3 = __esm({
1189
1767
  "../../node_modules/gl-matrix/esm/vec3.js"() {
1190
1768
  init_common2();
1191
1769
  len = length;
1192
- forEach2 = function() {
1770
+ forEach3 = function() {
1193
1771
  var vec = create2();
1194
1772
  return function(a2, stride, offset, count, fn, arg) {
1195
1773
  var i2, l2;
@@ -2353,11 +2931,11 @@
2353
2931
  out[3] = a2[3];
2354
2932
  return out;
2355
2933
  }
2356
- var forEach3;
2934
+ var forEach4;
2357
2935
  var init_vec4 = __esm({
2358
2936
  "../../node_modules/gl-matrix/esm/vec4.js"() {
2359
2937
  init_common2();
2360
- forEach3 = function() {
2938
+ forEach4 = function() {
2361
2939
  var vec = create4();
2362
2940
  return function(a2, stride, offset, count, fn, arg) {
2363
2941
  var i2, l2;
@@ -3234,7 +3812,7 @@
3234
3812
 
3235
3813
  // ../../node_modules/@math.gl/core/dist/esm/index.js
3236
3814
  var globals3, global_3;
3237
- var init_esm = __esm({
3815
+ var init_esm2 = __esm({
3238
3816
  "../../node_modules/@math.gl/core/dist/esm/index.js"() {
3239
3817
  init_common();
3240
3818
  init_vector2();
@@ -3317,7 +3895,7 @@
3317
3895
  var noop, scratchVector;
3318
3896
  var init_type_utils = __esm({
3319
3897
  "../../node_modules/@math.gl/geospatial/dist/esm/type-utils.js"() {
3320
- init_esm();
3898
+ init_esm2();
3321
3899
  init_constants();
3322
3900
  noop = (x) => x;
3323
3901
  scratchVector = new Vector3();
@@ -3383,7 +3961,7 @@
3383
3961
  var scratchVector2, scaleToGeodeticSurfaceIntersection, scaleToGeodeticSurfaceGradient;
3384
3962
  var init_scale_to_geodetic_surface = __esm({
3385
3963
  "../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js"() {
3386
- init_esm();
3964
+ init_esm2();
3387
3965
  scratchVector2 = new Vector3();
3388
3966
  scaleToGeodeticSurfaceIntersection = new Vector3();
3389
3967
  scaleToGeodeticSurfaceGradient = new Vector3();
@@ -3455,7 +4033,7 @@
3455
4033
  var EPSILON14, scratchOrigin, VECTOR_PRODUCT_LOCAL_FRAME, degeneratePositionLocalFrame, scratchAxisVectors, scratchVector1, scratchVector22, scratchVector3;
3456
4034
  var init_ellipsoid_transform = __esm({
3457
4035
  "../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/helpers/ellipsoid-transform.js"() {
3458
- init_esm();
4036
+ init_esm2();
3459
4037
  EPSILON14 = 1e-14;
3460
4038
  scratchOrigin = new Vector3();
3461
4039
  VECTOR_PRODUCT_LOCAL_FRAME = {
@@ -3522,7 +4100,7 @@
3522
4100
  var scratchVector4, scratchNormal, scratchK, scratchPosition, scratchHeight, scratchCartesian, wgs84, Ellipsoid;
3523
4101
  var init_ellipsoid = __esm({
3524
4102
  "../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/ellipsoid.js"() {
3525
- init_esm();
4103
+ init_esm2();
3526
4104
  init_vec3();
3527
4105
  init_constants();
3528
4106
  init_type_utils();
@@ -3641,7 +4219,7 @@
3641
4219
  });
3642
4220
 
3643
4221
  // ../../node_modules/@math.gl/geospatial/dist/esm/index.js
3644
- var init_esm2 = __esm({
4222
+ var init_esm3 = __esm({
3645
4223
  "../../node_modules/@math.gl/geospatial/dist/esm/index.js"() {
3646
4224
  init_ellipsoid();
3647
4225
  init_type_utils();
@@ -3649,11 +4227,21 @@
3649
4227
  });
3650
4228
 
3651
4229
  // ../core/src/javascript-utils/is-type.ts
3652
- var isResponse, isBlob;
4230
+ var isBoolean, isFunction, isObject, isPureObject, isIterable, isAsyncIterable, isResponse, isBlob, isBuffer2, isReadableDOMStream, isReadableNodeStream, isReadableStream;
3653
4231
  var init_is_type = __esm({
3654
4232
  "../core/src/javascript-utils/is-type.ts"() {
4233
+ isBoolean = (x) => typeof x === "boolean";
4234
+ isFunction = (x) => typeof x === "function";
4235
+ isObject = (x) => x !== null && typeof x === "object";
4236
+ isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
4237
+ isIterable = (x) => x && typeof x[Symbol.iterator] === "function";
4238
+ isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
3655
4239
  isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
3656
4240
  isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
4241
+ isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
4242
+ isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
4243
+ isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
4244
+ isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
3657
4245
  }
3658
4246
  });
3659
4247
 
@@ -3762,6 +4350,26 @@
3762
4350
  Object.defineProperty(response, "url", { value: url });
3763
4351
  return response;
3764
4352
  }
4353
+ async function checkResponse(response) {
4354
+ if (!response.ok) {
4355
+ const message = await getResponseError(response);
4356
+ throw new Error(message);
4357
+ }
4358
+ }
4359
+ async function getResponseError(response) {
4360
+ let message = `Failed to fetch resource ${response.url} (${response.status}): `;
4361
+ try {
4362
+ const contentType = response.headers.get("Content-Type");
4363
+ let text = response.statusText;
4364
+ if (contentType.includes("application/json")) {
4365
+ text += ` ${await response.text()}`;
4366
+ }
4367
+ message += text;
4368
+ message = message.length > 60 ? `${message.slice(60)}...` : message;
4369
+ } catch (error) {
4370
+ }
4371
+ return message;
4372
+ }
3765
4373
  async function getInitialDataUrl(resource) {
3766
4374
  const INITIAL_DATA_LENGTH = 5;
3767
4375
  if (typeof resource === "string") {
@@ -3816,50 +4424,1378 @@
3816
4424
  }
3817
4425
  });
3818
4426
 
3819
- // ../core/src/index.ts
3820
- var init_src3 = __esm({
3821
- "../core/src/index.ts"() {
3822
- init_fetch_file();
4427
+ // ../../node_modules/probe.gl/dist/esm/env/is-electron.js
4428
+ function isElectron(mockUserAgent) {
4429
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
4430
+ return true;
3823
4431
  }
3824
- });
3825
-
3826
- // ../tiles/src/constants.ts
3827
- var TILE_REFINEMENT, TILE_TYPE, TILESET_TYPE, LOD_METRIC_TYPE;
3828
- var init_constants2 = __esm({
3829
- "../tiles/src/constants.ts"() {
3830
- TILE_REFINEMENT = {
3831
- ADD: 1,
3832
- REPLACE: 2
3833
- };
3834
- TILE_TYPE = {
3835
- EMPTY: "empty",
3836
- SCENEGRAPH: "scenegraph",
3837
- POINTCLOUD: "pointcloud",
3838
- MESH: "mesh"
3839
- };
3840
- TILESET_TYPE = {
3841
- I3S: "I3S",
3842
- TILES3D: "TILES3D"
3843
- };
3844
- LOD_METRIC_TYPE = {
3845
- GEOMETRIC_ERROR: "geometricError",
3846
- MAX_SCREEN_THRESHOLD: "maxScreenThreshold"
3847
- };
4432
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions.electron)) {
4433
+ return true;
4434
+ }
4435
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
4436
+ const userAgent = mockUserAgent || realUserAgent;
4437
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
4438
+ return true;
4439
+ }
4440
+ return false;
4441
+ }
4442
+ var init_is_electron = __esm({
4443
+ "../../node_modules/probe.gl/dist/esm/env/is-electron.js"() {
3848
4444
  }
3849
4445
  });
3850
4446
 
3851
- // ../tiles/src/index.ts
3852
- var init_src4 = __esm({
3853
- "../tiles/src/index.ts"() {
3854
- init_constants2();
4447
+ // ../../node_modules/probe.gl/dist/esm/env/is-browser.js
4448
+ function isBrowser3() {
4449
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
4450
+ return !isNode || isElectron();
4451
+ }
4452
+ var init_is_browser = __esm({
4453
+ "../../node_modules/probe.gl/dist/esm/env/is-browser.js"() {
4454
+ init_is_electron();
3855
4455
  }
3856
4456
  });
3857
4457
 
3858
- // src/lib/utils/version.ts
3859
- var VERSION3;
3860
- var init_version2 = __esm({
4458
+ // ../../node_modules/probe.gl/dist/esm/env/globals.js
4459
+ var globals4, self_3, window_3, global_4, document_3, process_;
4460
+ var init_globals3 = __esm({
4461
+ "../../node_modules/probe.gl/dist/esm/env/globals.js"() {
4462
+ globals4 = {
4463
+ self: typeof self !== "undefined" && self,
4464
+ window: typeof window !== "undefined" && window,
4465
+ global: typeof global !== "undefined" && global,
4466
+ document: typeof document !== "undefined" && document,
4467
+ process: typeof process === "object" && process
4468
+ };
4469
+ self_3 = globals4.self || globals4.window || globals4.global;
4470
+ window_3 = globals4.window || globals4.self || globals4.global;
4471
+ global_4 = globals4.global || globals4.self || globals4.window;
4472
+ document_3 = globals4.document || {};
4473
+ process_ = globals4.process || {};
4474
+ }
4475
+ });
4476
+
4477
+ // ../../node_modules/probe.gl/dist/esm/utils/globals.js
4478
+ var VERSION3, isBrowser4;
4479
+ var init_globals4 = __esm({
4480
+ "../../node_modules/probe.gl/dist/esm/utils/globals.js"() {
4481
+ init_is_browser();
4482
+ init_globals3();
4483
+ VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
4484
+ isBrowser4 = isBrowser3();
4485
+ }
4486
+ });
4487
+
4488
+ // ../../node_modules/probe.gl/dist/esm/utils/local-storage.js
4489
+ function getStorage(type) {
4490
+ try {
4491
+ const storage = window[type];
4492
+ const x = "__storage_test__";
4493
+ storage.setItem(x, x);
4494
+ storage.removeItem(x);
4495
+ return storage;
4496
+ } catch (e) {
4497
+ return null;
4498
+ }
4499
+ }
4500
+ var LocalStorage;
4501
+ var init_local_storage = __esm({
4502
+ "../../node_modules/probe.gl/dist/esm/utils/local-storage.js"() {
4503
+ LocalStorage = class {
4504
+ constructor(id, defaultSettings, type = "sessionStorage") {
4505
+ this.storage = getStorage(type);
4506
+ this.id = id;
4507
+ this.config = {};
4508
+ Object.assign(this.config, defaultSettings);
4509
+ this._loadConfiguration();
4510
+ }
4511
+ getConfiguration() {
4512
+ return this.config;
4513
+ }
4514
+ setConfiguration(configuration) {
4515
+ this.config = {};
4516
+ return this.updateConfiguration(configuration);
4517
+ }
4518
+ updateConfiguration(configuration) {
4519
+ Object.assign(this.config, configuration);
4520
+ if (this.storage) {
4521
+ const serialized = JSON.stringify(this.config);
4522
+ this.storage.setItem(this.id, serialized);
4523
+ }
4524
+ return this;
4525
+ }
4526
+ _loadConfiguration() {
4527
+ let configuration = {};
4528
+ if (this.storage) {
4529
+ const serializedConfiguration = this.storage.getItem(this.id);
4530
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
4531
+ }
4532
+ Object.assign(this.config, configuration);
4533
+ return this;
4534
+ }
4535
+ };
4536
+ }
4537
+ });
4538
+
4539
+ // ../../node_modules/probe.gl/dist/esm/utils/formatters.js
4540
+ function formatTime(ms) {
4541
+ let formatted;
4542
+ if (ms < 10) {
4543
+ formatted = "".concat(ms.toFixed(2), "ms");
4544
+ } else if (ms < 100) {
4545
+ formatted = "".concat(ms.toFixed(1), "ms");
4546
+ } else if (ms < 1e3) {
4547
+ formatted = "".concat(ms.toFixed(0), "ms");
4548
+ } else {
4549
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
4550
+ }
4551
+ return formatted;
4552
+ }
4553
+ function leftPad(string, length4 = 8) {
4554
+ const padLength = Math.max(length4 - string.length, 0);
4555
+ return "".concat(" ".repeat(padLength)).concat(string);
4556
+ }
4557
+ function formatImage(image, message, scale5, maxWidth = 600) {
4558
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
4559
+ if (image.width > maxWidth) {
4560
+ scale5 = Math.min(scale5, maxWidth / image.width);
4561
+ }
4562
+ const width = image.width * scale5;
4563
+ const height = image.height * scale5;
4564
+ 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("");
4565
+ return ["".concat(message, " %c+"), style];
4566
+ }
4567
+ var init_formatters = __esm({
4568
+ "../../node_modules/probe.gl/dist/esm/utils/formatters.js"() {
4569
+ }
4570
+ });
4571
+
4572
+ // ../../node_modules/probe.gl/dist/esm/utils/color.js
4573
+ function getColor(color) {
4574
+ return typeof color === "string" ? COLOR[color.toUpperCase()] || COLOR.WHITE : color;
4575
+ }
4576
+ function addColor(string, color, background) {
4577
+ if (!isBrowser4 && typeof string === "string") {
4578
+ if (color) {
4579
+ color = getColor(color);
4580
+ string = "[".concat(color, "m").concat(string, "");
4581
+ }
4582
+ if (background) {
4583
+ color = getColor(background);
4584
+ string = "[".concat(background + 10, "m").concat(string, "");
4585
+ }
4586
+ }
4587
+ return string;
4588
+ }
4589
+ var COLOR;
4590
+ var init_color = __esm({
4591
+ "../../node_modules/probe.gl/dist/esm/utils/color.js"() {
4592
+ init_globals4();
4593
+ COLOR = {
4594
+ BLACK: 30,
4595
+ RED: 31,
4596
+ GREEN: 32,
4597
+ YELLOW: 33,
4598
+ BLUE: 34,
4599
+ MAGENTA: 35,
4600
+ CYAN: 36,
4601
+ WHITE: 37,
4602
+ BRIGHT_BLACK: 90,
4603
+ BRIGHT_RED: 91,
4604
+ BRIGHT_GREEN: 92,
4605
+ BRIGHT_YELLOW: 93,
4606
+ BRIGHT_BLUE: 94,
4607
+ BRIGHT_MAGENTA: 95,
4608
+ BRIGHT_CYAN: 96,
4609
+ BRIGHT_WHITE: 97
4610
+ };
4611
+ }
4612
+ });
4613
+
4614
+ // ../../node_modules/probe.gl/dist/esm/utils/autobind.js
4615
+ function autobind(obj, predefined = ["constructor"]) {
4616
+ const proto = Object.getPrototypeOf(obj);
4617
+ const propNames = Object.getOwnPropertyNames(proto);
4618
+ for (const key of propNames) {
4619
+ if (typeof obj[key] === "function") {
4620
+ if (!predefined.find((name8) => key === name8)) {
4621
+ obj[key] = obj[key].bind(obj);
4622
+ }
4623
+ }
4624
+ }
4625
+ }
4626
+ var init_autobind = __esm({
4627
+ "../../node_modules/probe.gl/dist/esm/utils/autobind.js"() {
4628
+ }
4629
+ });
4630
+
4631
+ // ../../node_modules/probe.gl/dist/esm/utils/assert.js
4632
+ function assert5(condition, message) {
4633
+ if (!condition) {
4634
+ throw new Error(message || "Assertion failed");
4635
+ }
4636
+ }
4637
+ var init_assert4 = __esm({
4638
+ "../../node_modules/probe.gl/dist/esm/utils/assert.js"() {
4639
+ }
4640
+ });
4641
+
4642
+ // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
4643
+ function getHiResTimestamp2() {
4644
+ let timestamp;
4645
+ if (isBrowser4 && window_3.performance) {
4646
+ timestamp = window_3.performance.now();
4647
+ } else if (process_.hrtime) {
4648
+ const timeParts = process_.hrtime();
4649
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
4650
+ } else {
4651
+ timestamp = Date.now();
4652
+ }
4653
+ return timestamp;
4654
+ }
4655
+ var init_hi_res_timestamp2 = __esm({
4656
+ "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
4657
+ init_globals4();
4658
+ }
4659
+ });
4660
+
4661
+ // ../../node_modules/probe.gl/dist/esm/lib/log.js
4662
+ function noop2() {
4663
+ }
4664
+ function getTableHeader(table) {
4665
+ for (const key in table) {
4666
+ for (const title in table[key]) {
4667
+ return title || "untitled";
4668
+ }
4669
+ }
4670
+ return "empty";
4671
+ }
4672
+ function normalizeLogLevel(logLevel) {
4673
+ if (!logLevel) {
4674
+ return 0;
4675
+ }
4676
+ let resolvedLevel;
4677
+ switch (typeof logLevel) {
4678
+ case "number":
4679
+ resolvedLevel = logLevel;
4680
+ break;
4681
+ case "object":
4682
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
4683
+ break;
4684
+ default:
4685
+ return 0;
4686
+ }
4687
+ assert5(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
4688
+ return resolvedLevel;
4689
+ }
4690
+ function normalizeArguments(opts) {
4691
+ const {
4692
+ logLevel,
4693
+ message
4694
+ } = opts;
4695
+ opts.logLevel = normalizeLogLevel(logLevel);
4696
+ const args = opts.args ? Array.from(opts.args) : [];
4697
+ while (args.length && args.shift() !== message) {
4698
+ }
4699
+ opts.args = args;
4700
+ switch (typeof logLevel) {
4701
+ case "string":
4702
+ case "function":
4703
+ if (message !== void 0) {
4704
+ args.unshift(message);
4705
+ }
4706
+ opts.message = logLevel;
4707
+ break;
4708
+ case "object":
4709
+ Object.assign(opts, logLevel);
4710
+ break;
4711
+ default:
4712
+ }
4713
+ if (typeof opts.message === "function") {
4714
+ opts.message = opts.message();
4715
+ }
4716
+ const messageType = typeof opts.message;
4717
+ assert5(messageType === "string" || messageType === "object");
4718
+ return Object.assign(opts, opts.opts);
4719
+ }
4720
+ function decorateMessage(id, message, opts) {
4721
+ if (typeof message === "string") {
4722
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
4723
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
4724
+ message = addColor(message, opts.color, opts.background);
4725
+ }
4726
+ return message;
4727
+ }
4728
+ function logImageInNode({
4729
+ image,
4730
+ message = "",
4731
+ scale: scale5 = 1
4732
+ }) {
4733
+ let asciify = null;
4734
+ try {
4735
+ asciify = module.require("asciify-image");
4736
+ } catch (error) {
4737
+ }
4738
+ if (asciify) {
4739
+ return () => asciify(image, {
4740
+ fit: "box",
4741
+ width: "".concat(Math.round(80 * scale5), "%")
4742
+ }).then((data) => console.log(data));
4743
+ }
4744
+ return noop2;
4745
+ }
4746
+ function logImageInBrowser({
4747
+ image,
4748
+ message = "",
4749
+ scale: scale5 = 1
4750
+ }) {
4751
+ if (typeof image === "string") {
4752
+ const img = new Image();
4753
+ img.onload = () => {
4754
+ const args = formatImage(img, message, scale5);
4755
+ console.log(...args);
4756
+ };
4757
+ img.src = image;
4758
+ return noop2;
4759
+ }
4760
+ const element = image.nodeName || "";
4761
+ if (element.toLowerCase() === "img") {
4762
+ console.log(...formatImage(image, message, scale5));
4763
+ return noop2;
4764
+ }
4765
+ if (element.toLowerCase() === "canvas") {
4766
+ const img = new Image();
4767
+ img.onload = () => console.log(...formatImage(img, message, scale5));
4768
+ img.src = image.toDataURL();
4769
+ return noop2;
4770
+ }
4771
+ return noop2;
4772
+ }
4773
+ var originalConsole, DEFAULT_SETTINGS, cache, ONCE, Log;
4774
+ var init_log = __esm({
4775
+ "../../node_modules/probe.gl/dist/esm/lib/log.js"() {
4776
+ init_globals4();
4777
+ init_local_storage();
4778
+ init_formatters();
4779
+ init_color();
4780
+ init_autobind();
4781
+ init_assert4();
4782
+ init_hi_res_timestamp2();
4783
+ originalConsole = {
4784
+ debug: isBrowser4 ? console.debug || console.log : console.log,
4785
+ log: console.log,
4786
+ info: console.info,
4787
+ warn: console.warn,
4788
+ error: console.error
4789
+ };
4790
+ DEFAULT_SETTINGS = {
4791
+ enabled: true,
4792
+ level: 0
4793
+ };
4794
+ cache = {};
4795
+ ONCE = {
4796
+ once: true
4797
+ };
4798
+ Log = class {
4799
+ constructor({
4800
+ id
4801
+ } = {
4802
+ id: ""
4803
+ }) {
4804
+ this.id = id;
4805
+ this.VERSION = VERSION3;
4806
+ this._startTs = getHiResTimestamp2();
4807
+ this._deltaTs = getHiResTimestamp2();
4808
+ this.LOG_THROTTLE_TIMEOUT = 0;
4809
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
4810
+ this.userData = {};
4811
+ this.timeStamp("".concat(this.id, " started"));
4812
+ autobind(this);
4813
+ Object.seal(this);
4814
+ }
4815
+ set level(newLevel) {
4816
+ this.setLevel(newLevel);
4817
+ }
4818
+ get level() {
4819
+ return this.getLevel();
4820
+ }
4821
+ isEnabled() {
4822
+ return this._storage.config.enabled;
4823
+ }
4824
+ getLevel() {
4825
+ return this._storage.config.level;
4826
+ }
4827
+ getTotal() {
4828
+ return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
4829
+ }
4830
+ getDelta() {
4831
+ return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
4832
+ }
4833
+ set priority(newPriority) {
4834
+ this.level = newPriority;
4835
+ }
4836
+ get priority() {
4837
+ return this.level;
4838
+ }
4839
+ getPriority() {
4840
+ return this.level;
4841
+ }
4842
+ enable(enabled = true) {
4843
+ this._storage.updateConfiguration({
4844
+ enabled
4845
+ });
4846
+ return this;
4847
+ }
4848
+ setLevel(level) {
4849
+ this._storage.updateConfiguration({
4850
+ level
4851
+ });
4852
+ return this;
4853
+ }
4854
+ assert(condition, message) {
4855
+ assert5(condition, message);
4856
+ }
4857
+ warn(message) {
4858
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
4859
+ }
4860
+ error(message) {
4861
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
4862
+ }
4863
+ deprecated(oldUsage, newUsage) {
4864
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
4865
+ }
4866
+ removed(oldUsage, newUsage) {
4867
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
4868
+ }
4869
+ probe(logLevel, message) {
4870
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
4871
+ time: true,
4872
+ once: true
4873
+ });
4874
+ }
4875
+ log(logLevel, message) {
4876
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
4877
+ }
4878
+ info(logLevel, message) {
4879
+ return this._getLogFunction(logLevel, message, console.info, arguments);
4880
+ }
4881
+ once(logLevel, message) {
4882
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
4883
+ }
4884
+ table(logLevel, table, columns) {
4885
+ if (table) {
4886
+ return this._getLogFunction(logLevel, table, console.table || noop2, columns && [columns], {
4887
+ tag: getTableHeader(table)
4888
+ });
4889
+ }
4890
+ return noop2;
4891
+ }
4892
+ image({
4893
+ logLevel,
4894
+ priority,
4895
+ image,
4896
+ message = "",
4897
+ scale: scale5 = 1
4898
+ }) {
4899
+ if (!this._shouldLog(logLevel || priority)) {
4900
+ return noop2;
4901
+ }
4902
+ return isBrowser4 ? logImageInBrowser({
4903
+ image,
4904
+ message,
4905
+ scale: scale5
4906
+ }) : logImageInNode({
4907
+ image,
4908
+ message,
4909
+ scale: scale5
4910
+ });
4911
+ }
4912
+ settings() {
4913
+ if (console.table) {
4914
+ console.table(this._storage.config);
4915
+ } else {
4916
+ console.log(this._storage.config);
4917
+ }
4918
+ }
4919
+ get(setting) {
4920
+ return this._storage.config[setting];
4921
+ }
4922
+ set(setting, value) {
4923
+ this._storage.updateConfiguration({
4924
+ [setting]: value
4925
+ });
4926
+ }
4927
+ time(logLevel, message) {
4928
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
4929
+ }
4930
+ timeEnd(logLevel, message) {
4931
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
4932
+ }
4933
+ timeStamp(logLevel, message) {
4934
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop2);
4935
+ }
4936
+ group(logLevel, message, opts = {
4937
+ collapsed: false
4938
+ }) {
4939
+ opts = normalizeArguments({
4940
+ logLevel,
4941
+ message,
4942
+ opts
4943
+ });
4944
+ const {
4945
+ collapsed
4946
+ } = opts;
4947
+ opts.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
4948
+ return this._getLogFunction(opts);
4949
+ }
4950
+ groupCollapsed(logLevel, message, opts = {}) {
4951
+ return this.group(logLevel, message, Object.assign({}, opts, {
4952
+ collapsed: true
4953
+ }));
4954
+ }
4955
+ groupEnd(logLevel) {
4956
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop2);
4957
+ }
4958
+ withGroup(logLevel, message, func) {
4959
+ this.group(logLevel, message)();
4960
+ try {
4961
+ func();
4962
+ } finally {
4963
+ this.groupEnd(logLevel)();
4964
+ }
4965
+ }
4966
+ trace() {
4967
+ if (console.trace) {
4968
+ console.trace();
4969
+ }
4970
+ }
4971
+ _shouldLog(logLevel) {
4972
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
4973
+ }
4974
+ _getLogFunction(logLevel, message, method, args = [], opts) {
4975
+ if (this._shouldLog(logLevel)) {
4976
+ opts = normalizeArguments({
4977
+ logLevel,
4978
+ message,
4979
+ args,
4980
+ opts
4981
+ });
4982
+ method = method || opts.method;
4983
+ assert5(method);
4984
+ opts.total = this.getTotal();
4985
+ opts.delta = this.getDelta();
4986
+ this._deltaTs = getHiResTimestamp2();
4987
+ const tag = opts.tag || opts.message;
4988
+ if (opts.once) {
4989
+ if (!cache[tag]) {
4990
+ cache[tag] = getHiResTimestamp2();
4991
+ } else {
4992
+ return noop2;
4993
+ }
4994
+ }
4995
+ message = decorateMessage(this.id, opts.message, opts);
4996
+ return method.bind(console, message, ...opts.args);
4997
+ }
4998
+ return noop2;
4999
+ }
5000
+ };
5001
+ Log.VERSION = VERSION3;
5002
+ }
5003
+ });
5004
+
5005
+ // ../../node_modules/probe.gl/dist/esm/index.js
5006
+ var esm_default;
5007
+ var init_esm4 = __esm({
5008
+ "../../node_modules/probe.gl/dist/esm/index.js"() {
5009
+ init_log();
5010
+ init_log();
5011
+ init_esm();
5012
+ esm_default = new Log({
5013
+ id: "probe.gl"
5014
+ });
5015
+ }
5016
+ });
5017
+
5018
+ // ../core/src/lib/loader-utils/loggers.ts
5019
+ var probeLog, NullLog, ConsoleLog;
5020
+ var init_loggers = __esm({
5021
+ "../core/src/lib/loader-utils/loggers.ts"() {
5022
+ init_esm4();
5023
+ probeLog = new Log({ id: "loaders.gl" });
5024
+ NullLog = class {
5025
+ log() {
5026
+ return () => {
5027
+ };
5028
+ }
5029
+ info() {
5030
+ return () => {
5031
+ };
5032
+ }
5033
+ warn() {
5034
+ return () => {
5035
+ };
5036
+ }
5037
+ error() {
5038
+ return () => {
5039
+ };
5040
+ }
5041
+ };
5042
+ ConsoleLog = class {
5043
+ constructor() {
5044
+ this.console = console;
5045
+ }
5046
+ log(...args) {
5047
+ return this.console.log.bind(this.console, ...args);
5048
+ }
5049
+ info(...args) {
5050
+ return this.console.info.bind(this.console, ...args);
5051
+ }
5052
+ warn(...args) {
5053
+ return this.console.warn.bind(this.console, ...args);
5054
+ }
5055
+ error(...args) {
5056
+ return this.console.error.bind(this.console, ...args);
5057
+ }
5058
+ };
5059
+ }
5060
+ });
5061
+
5062
+ // ../core/src/lib/loader-utils/option-defaults.ts
5063
+ var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
5064
+ var init_option_defaults = __esm({
5065
+ "../core/src/lib/loader-utils/option-defaults.ts"() {
5066
+ init_loggers();
5067
+ DEFAULT_LOADER_OPTIONS = {
5068
+ fetch: null,
5069
+ mimeType: void 0,
5070
+ nothrow: false,
5071
+ log: new ConsoleLog(),
5072
+ CDN: "https://unpkg.com/@loaders.gl",
5073
+ worker: true,
5074
+ maxConcurrency: 3,
5075
+ maxMobileConcurrency: 1,
5076
+ reuseWorkers: true,
5077
+ _workerType: "",
5078
+ limit: 0,
5079
+ _limitMB: 0,
5080
+ batchSize: "auto",
5081
+ batchDebounceMs: 0,
5082
+ metadata: false,
5083
+ transforms: []
5084
+ };
5085
+ REMOVED_LOADER_OPTIONS = {
5086
+ throws: "nothrow",
5087
+ dataType: "(no longer used)",
5088
+ uri: "baseUri",
5089
+ method: "fetch.method",
5090
+ headers: "fetch.headers",
5091
+ body: "fetch.body",
5092
+ mode: "fetch.mode",
5093
+ credentials: "fetch.credentials",
5094
+ cache: "fetch.cache",
5095
+ redirect: "fetch.redirect",
5096
+ referrer: "fetch.referrer",
5097
+ referrerPolicy: "fetch.referrerPolicy",
5098
+ integrity: "fetch.integrity",
5099
+ keepalive: "fetch.keepalive",
5100
+ signal: "fetch.signal"
5101
+ };
5102
+ }
5103
+ });
5104
+
5105
+ // ../core/src/lib/loader-utils/option-utils.ts
5106
+ function getGlobalLoaderState() {
5107
+ globalThis.loaders = globalThis.loaders || {};
5108
+ const { loaders } = globalThis;
5109
+ loaders._state = loaders._state || {};
5110
+ return loaders._state;
5111
+ }
5112
+ function normalizeOptions(options, loader, loaders, url) {
5113
+ loaders = loaders || [];
5114
+ loaders = Array.isArray(loaders) ? loaders : [loaders];
5115
+ validateOptions(options, loaders);
5116
+ return normalizeOptionsInternal(loader, options, url);
5117
+ }
5118
+ function getFetchFunction(options, context) {
5119
+ const globalOptions = getGlobalLoaderOptions();
5120
+ const fetchOptions = options || globalOptions;
5121
+ if (typeof fetchOptions.fetch === "function") {
5122
+ return fetchOptions.fetch;
5123
+ }
5124
+ if (isObject(fetchOptions.fetch)) {
5125
+ return (url) => fetchFile(url, fetchOptions);
5126
+ }
5127
+ if (context?.fetch) {
5128
+ return context?.fetch;
5129
+ }
5130
+ return fetchFile;
5131
+ }
5132
+ function validateOptions(options, loaders) {
5133
+ validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
5134
+ for (const loader of loaders) {
5135
+ const idOptions = options && options[loader.id] || {};
5136
+ const loaderOptions = loader.options && loader.options[loader.id] || {};
5137
+ const deprecatedOptions = loader.deprecatedOptions && loader.deprecatedOptions[loader.id] || {};
5138
+ validateOptionsObject(idOptions, loader.id, loaderOptions, deprecatedOptions, loaders);
5139
+ }
5140
+ }
5141
+ function validateOptionsObject(options, id, defaultOptions, deprecatedOptions, loaders) {
5142
+ const loaderName = id || "Top level";
5143
+ const prefix = id ? `${id}.` : "";
5144
+ for (const key in options) {
5145
+ const isSubOptions = !id && isObject(options[key]);
5146
+ const isBaseUriOption = key === "baseUri" && !id;
5147
+ const isWorkerUrlOption = key === "workerUrl" && id;
5148
+ if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
5149
+ if (key in deprecatedOptions) {
5150
+ probeLog.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
5151
+ } else if (!isSubOptions) {
5152
+ const suggestion = findSimilarOption(key, loaders);
5153
+ probeLog.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
5154
+ }
5155
+ }
5156
+ }
5157
+ }
5158
+ function findSimilarOption(optionKey, loaders) {
5159
+ const lowerCaseOptionKey = optionKey.toLowerCase();
5160
+ let bestSuggestion = "";
5161
+ for (const loader of loaders) {
5162
+ for (const key in loader.options) {
5163
+ if (optionKey === key) {
5164
+ return `Did you mean '${loader.id}.${key}'?`;
5165
+ }
5166
+ const lowerCaseKey = key.toLowerCase();
5167
+ const isPartialMatch = lowerCaseOptionKey.startsWith(lowerCaseKey) || lowerCaseKey.startsWith(lowerCaseOptionKey);
5168
+ if (isPartialMatch) {
5169
+ bestSuggestion = bestSuggestion || `Did you mean '${loader.id}.${key}'?`;
5170
+ }
5171
+ }
5172
+ }
5173
+ return bestSuggestion;
5174
+ }
5175
+ function normalizeOptionsInternal(loader, options, url) {
5176
+ const loaderDefaultOptions = loader.options || {};
5177
+ const mergedOptions = { ...loaderDefaultOptions };
5178
+ addUrlOptions(mergedOptions, url);
5179
+ if (mergedOptions.log === null) {
5180
+ mergedOptions.log = new NullLog();
5181
+ }
5182
+ mergeNestedFields(mergedOptions, getGlobalLoaderOptions());
5183
+ mergeNestedFields(mergedOptions, options);
5184
+ return mergedOptions;
5185
+ }
5186
+ function mergeNestedFields(mergedOptions, options) {
5187
+ for (const key in options) {
5188
+ if (key in options) {
5189
+ const value = options[key];
5190
+ if (isPureObject(value) && isPureObject(mergedOptions[key])) {
5191
+ mergedOptions[key] = {
5192
+ ...mergedOptions[key],
5193
+ ...options[key]
5194
+ };
5195
+ } else {
5196
+ mergedOptions[key] = options[key];
5197
+ }
5198
+ }
5199
+ }
5200
+ }
5201
+ function addUrlOptions(options, url) {
5202
+ if (url && !("baseUri" in options)) {
5203
+ options.baseUri = url;
5204
+ }
5205
+ }
5206
+ var getGlobalLoaderOptions;
5207
+ var init_option_utils = __esm({
5208
+ "../core/src/lib/loader-utils/option-utils.ts"() {
5209
+ init_is_type();
5210
+ init_fetch_file();
5211
+ init_loggers();
5212
+ init_option_defaults();
5213
+ getGlobalLoaderOptions = () => {
5214
+ const state = getGlobalLoaderState();
5215
+ state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
5216
+ return state.globalOptions;
5217
+ };
5218
+ }
5219
+ });
5220
+
5221
+ // ../core/src/lib/loader-utils/normalize-loader.ts
5222
+ function isLoaderObject(loader) {
5223
+ if (!loader) {
5224
+ return false;
5225
+ }
5226
+ if (Array.isArray(loader)) {
5227
+ loader = loader[0];
5228
+ }
5229
+ const hasExtensions = Array.isArray(loader?.extensions);
5230
+ return hasExtensions;
5231
+ }
5232
+ function normalizeLoader(loader) {
5233
+ assert2(loader, "null loader");
5234
+ assert2(isLoaderObject(loader), "invalid loader");
5235
+ let options;
5236
+ if (Array.isArray(loader)) {
5237
+ options = loader[1];
5238
+ loader = loader[0];
5239
+ loader = {
5240
+ ...loader,
5241
+ options: { ...loader.options, ...options }
5242
+ };
5243
+ }
5244
+ if (loader?.parseTextSync || loader?.parseText) {
5245
+ loader.text = true;
5246
+ }
5247
+ if (!loader.text) {
5248
+ loader.binary = true;
5249
+ }
5250
+ return loader;
5251
+ }
5252
+ var init_normalize_loader = __esm({
5253
+ "../core/src/lib/loader-utils/normalize-loader.ts"() {
5254
+ init_src2();
5255
+ }
5256
+ });
5257
+
5258
+ // ../core/src/lib/api/register-loaders.ts
5259
+ function getRegisteredLoaders() {
5260
+ return getGlobalLoaderRegistry();
5261
+ }
5262
+ var getGlobalLoaderRegistry;
5263
+ var init_register_loaders = __esm({
5264
+ "../core/src/lib/api/register-loaders.ts"() {
5265
+ init_option_utils();
5266
+ getGlobalLoaderRegistry = () => {
5267
+ const state = getGlobalLoaderState();
5268
+ state.loaderRegistry = state.loaderRegistry || [];
5269
+ return state.loaderRegistry;
5270
+ };
5271
+ }
5272
+ });
5273
+
5274
+ // ../core/src/lib/api/select-loader.ts
5275
+ async function selectLoader(data, loaders = [], options, context) {
5276
+ if (!validHTTPResponse(data)) {
5277
+ return null;
5278
+ }
5279
+ let loader = selectLoaderSync(data, loaders, { ...options, nothrow: true }, context);
5280
+ if (loader) {
5281
+ return loader;
5282
+ }
5283
+ if (isBlob(data)) {
5284
+ data = await data.slice(0, 10).arrayBuffer();
5285
+ loader = selectLoaderSync(data, loaders, options, context);
5286
+ }
5287
+ if (!loader && !options?.nothrow) {
5288
+ throw new Error(getNoValidLoaderMessage(data));
5289
+ }
5290
+ return loader;
5291
+ }
5292
+ function selectLoaderSync(data, loaders = [], options, context) {
5293
+ if (!validHTTPResponse(data)) {
5294
+ return null;
5295
+ }
5296
+ if (loaders && !Array.isArray(loaders)) {
5297
+ return normalizeLoader(loaders);
5298
+ }
5299
+ let candidateLoaders = [];
5300
+ if (loaders) {
5301
+ candidateLoaders = candidateLoaders.concat(loaders);
5302
+ }
5303
+ if (!options?.ignoreRegisteredLoaders) {
5304
+ candidateLoaders.push(...getRegisteredLoaders());
5305
+ }
5306
+ normalizeLoaders(candidateLoaders);
5307
+ const loader = selectLoaderInternal(data, candidateLoaders, options, context);
5308
+ if (!loader && !options?.nothrow) {
5309
+ throw new Error(getNoValidLoaderMessage(data));
5310
+ }
5311
+ return loader;
5312
+ }
5313
+ function selectLoaderInternal(data, loaders, options, context) {
5314
+ const { url, type } = getResourceUrlAndType(data);
5315
+ const testUrl = url || context?.url;
5316
+ let loader = null;
5317
+ if (options?.mimeType) {
5318
+ loader = findLoaderByMIMEType(loaders, options?.mimeType);
5319
+ }
5320
+ loader = loader || findLoaderByUrl(loaders, testUrl);
5321
+ loader = loader || findLoaderByMIMEType(loaders, type);
5322
+ loader = loader || findLoaderByInitialBytes(loaders, data);
5323
+ loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
5324
+ return loader;
5325
+ }
5326
+ function validHTTPResponse(data) {
5327
+ if (data instanceof Response) {
5328
+ if (data.status === 204) {
5329
+ return false;
5330
+ }
5331
+ }
5332
+ return true;
5333
+ }
5334
+ function getNoValidLoaderMessage(data) {
5335
+ const { url, type } = getResourceUrlAndType(data);
5336
+ let message = "No valid loader found (";
5337
+ message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
5338
+ message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
5339
+ const firstCharacters = data ? getFirstCharacters2(data) : "";
5340
+ message += firstCharacters ? ` first bytes: "${firstCharacters}"` : "first bytes: not available";
5341
+ message += ")";
5342
+ return message;
5343
+ }
5344
+ function normalizeLoaders(loaders) {
5345
+ for (const loader of loaders) {
5346
+ normalizeLoader(loader);
5347
+ }
5348
+ }
5349
+ function findLoaderByUrl(loaders, url) {
5350
+ const match = url && EXT_PATTERN.exec(url);
5351
+ const extension = match && match[1];
5352
+ return extension ? findLoaderByExtension(loaders, extension) : null;
5353
+ }
5354
+ function findLoaderByExtension(loaders, extension) {
5355
+ extension = extension.toLowerCase();
5356
+ for (const loader of loaders) {
5357
+ for (const loaderExtension of loader.extensions) {
5358
+ if (loaderExtension.toLowerCase() === extension) {
5359
+ return loader;
5360
+ }
5361
+ }
5362
+ }
5363
+ return null;
5364
+ }
5365
+ function findLoaderByMIMEType(loaders, mimeType) {
5366
+ for (const loader of loaders) {
5367
+ if (loader.mimeTypes && loader.mimeTypes.includes(mimeType)) {
5368
+ return loader;
5369
+ }
5370
+ if (mimeType === `application/x.${loader.id}`) {
5371
+ return loader;
5372
+ }
5373
+ }
5374
+ return null;
5375
+ }
5376
+ function findLoaderByInitialBytes(loaders, data) {
5377
+ if (!data) {
5378
+ return null;
5379
+ }
5380
+ for (const loader of loaders) {
5381
+ if (typeof data === "string") {
5382
+ if (testDataAgainstText(data, loader)) {
5383
+ return loader;
5384
+ }
5385
+ } else if (ArrayBuffer.isView(data)) {
5386
+ if (testDataAgainstBinary(data.buffer, data.byteOffset, loader)) {
5387
+ return loader;
5388
+ }
5389
+ } else if (data instanceof ArrayBuffer) {
5390
+ const byteOffset = 0;
5391
+ if (testDataAgainstBinary(data, byteOffset, loader)) {
5392
+ return loader;
5393
+ }
5394
+ }
5395
+ }
5396
+ return null;
5397
+ }
5398
+ function testDataAgainstText(data, loader) {
5399
+ if (loader.testText) {
5400
+ return loader.testText(data);
5401
+ }
5402
+ const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
5403
+ return tests.some((test) => data.startsWith(test));
5404
+ }
5405
+ function testDataAgainstBinary(data, byteOffset, loader) {
5406
+ const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
5407
+ return tests.some((test) => testBinary(data, byteOffset, loader, test));
5408
+ }
5409
+ function testBinary(data, byteOffset, loader, test) {
5410
+ if (test instanceof ArrayBuffer) {
5411
+ return compareArrayBuffers(test, data, test.byteLength);
5412
+ }
5413
+ switch (typeof test) {
5414
+ case "function":
5415
+ return test(data, loader);
5416
+ case "string":
5417
+ const magic = getMagicString2(data, byteOffset, test.length);
5418
+ return test === magic;
5419
+ default:
5420
+ return false;
5421
+ }
5422
+ }
5423
+ function getFirstCharacters2(data, length4 = 5) {
5424
+ if (typeof data === "string") {
5425
+ return data.slice(0, length4);
5426
+ } else if (ArrayBuffer.isView(data)) {
5427
+ return getMagicString2(data.buffer, data.byteOffset, length4);
5428
+ } else if (data instanceof ArrayBuffer) {
5429
+ const byteOffset = 0;
5430
+ return getMagicString2(data, byteOffset, length4);
5431
+ }
5432
+ return "";
5433
+ }
5434
+ function getMagicString2(arrayBuffer, byteOffset, length4) {
5435
+ if (arrayBuffer.byteLength < byteOffset + length4) {
5436
+ return "";
5437
+ }
5438
+ const dataView = new DataView(arrayBuffer);
5439
+ let magic = "";
5440
+ for (let i2 = 0; i2 < length4; i2++) {
5441
+ magic += String.fromCharCode(dataView.getUint8(byteOffset + i2));
5442
+ }
5443
+ return magic;
5444
+ }
5445
+ var EXT_PATTERN;
5446
+ var init_select_loader = __esm({
5447
+ "../core/src/lib/api/select-loader.ts"() {
5448
+ init_src2();
5449
+ init_normalize_loader();
5450
+ init_resource_utils();
5451
+ init_register_loaders();
5452
+ init_is_type();
5453
+ EXT_PATTERN = /\.([^.]+)$/;
5454
+ }
5455
+ });
5456
+
5457
+ // ../core/src/iterators/make-iterator/make-string-iterator.ts
5458
+ function* makeStringIterator(string, options) {
5459
+ const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
5460
+ let offset = 0;
5461
+ const textEncoder = new TextEncoder();
5462
+ while (offset < string.length) {
5463
+ const chunkLength = Math.min(string.length - offset, chunkSize);
5464
+ const chunk = string.slice(offset, offset + chunkLength);
5465
+ offset += chunkLength;
5466
+ yield textEncoder.encode(chunk);
5467
+ }
5468
+ }
5469
+ var DEFAULT_CHUNK_SIZE;
5470
+ var init_make_string_iterator = __esm({
5471
+ "../core/src/iterators/make-iterator/make-string-iterator.ts"() {
5472
+ DEFAULT_CHUNK_SIZE = 256 * 1024;
5473
+ }
5474
+ });
5475
+
5476
+ // ../core/src/iterators/make-iterator/make-array-buffer-iterator.ts
5477
+ function* makeArrayBufferIterator(arrayBuffer, options = {}) {
5478
+ const { chunkSize = DEFAULT_CHUNK_SIZE2 } = options;
5479
+ let byteOffset = 0;
5480
+ while (byteOffset < arrayBuffer.byteLength) {
5481
+ const chunkByteLength = Math.min(arrayBuffer.byteLength - byteOffset, chunkSize);
5482
+ const chunk = new ArrayBuffer(chunkByteLength);
5483
+ const sourceArray = new Uint8Array(arrayBuffer, byteOffset, chunkByteLength);
5484
+ const chunkArray = new Uint8Array(chunk);
5485
+ chunkArray.set(sourceArray);
5486
+ byteOffset += chunkByteLength;
5487
+ yield chunk;
5488
+ }
5489
+ }
5490
+ var DEFAULT_CHUNK_SIZE2;
5491
+ var init_make_array_buffer_iterator = __esm({
5492
+ "../core/src/iterators/make-iterator/make-array-buffer-iterator.ts"() {
5493
+ DEFAULT_CHUNK_SIZE2 = 256 * 1024;
5494
+ }
5495
+ });
5496
+
5497
+ // ../core/src/iterators/make-iterator/make-blob-iterator.ts
5498
+ async function* makeBlobIterator(blob, options) {
5499
+ const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE3;
5500
+ let offset = 0;
5501
+ while (offset < blob.size) {
5502
+ const end = offset + chunkSize;
5503
+ const chunk = await blob.slice(offset, end).arrayBuffer();
5504
+ offset = end;
5505
+ yield chunk;
5506
+ }
5507
+ }
5508
+ var DEFAULT_CHUNK_SIZE3;
5509
+ var init_make_blob_iterator = __esm({
5510
+ "../core/src/iterators/make-iterator/make-blob-iterator.ts"() {
5511
+ DEFAULT_CHUNK_SIZE3 = 1024 * 1024;
5512
+ }
5513
+ });
5514
+
5515
+ // ../core/src/iterators/make-iterator/make-stream-iterator.ts
5516
+ function makeStreamIterator(stream, options) {
5517
+ return isBrowser ? makeBrowserStreamIterator(stream, options) : makeNodeStreamIterator(stream, options);
5518
+ }
5519
+ async function* makeBrowserStreamIterator(stream, options) {
5520
+ const reader = stream.getReader();
5521
+ let nextBatchPromise;
5522
+ try {
5523
+ while (true) {
5524
+ const currentBatchPromise = nextBatchPromise || reader.read();
5525
+ if (options?._streamReadAhead) {
5526
+ nextBatchPromise = reader.read();
5527
+ }
5528
+ const { done, value } = await currentBatchPromise;
5529
+ if (done) {
5530
+ return;
5531
+ }
5532
+ yield toArrayBuffer(value);
5533
+ }
5534
+ } catch (error) {
5535
+ reader.releaseLock();
5536
+ }
5537
+ }
5538
+ async function* makeNodeStreamIterator(stream, options) {
5539
+ for await (const chunk of stream) {
5540
+ yield toArrayBuffer(chunk);
5541
+ }
5542
+ }
5543
+ var init_make_stream_iterator = __esm({
5544
+ "../core/src/iterators/make-iterator/make-stream-iterator.ts"() {
5545
+ init_src2();
5546
+ }
5547
+ });
5548
+
5549
+ // ../core/src/iterators/make-iterator/make-iterator.ts
5550
+ function makeIterator(data, options) {
5551
+ if (typeof data === "string") {
5552
+ return makeStringIterator(data, options);
5553
+ }
5554
+ if (data instanceof ArrayBuffer) {
5555
+ return makeArrayBufferIterator(data, options);
5556
+ }
5557
+ if (isBlob(data)) {
5558
+ return makeBlobIterator(data, options);
5559
+ }
5560
+ if (isReadableStream(data)) {
5561
+ return makeStreamIterator(data, options);
5562
+ }
5563
+ if (isResponse(data)) {
5564
+ const response = data;
5565
+ return makeStreamIterator(response.body, options);
5566
+ }
5567
+ throw new Error("makeIterator");
5568
+ }
5569
+ var init_make_iterator = __esm({
5570
+ "../core/src/iterators/make-iterator/make-iterator.ts"() {
5571
+ init_make_string_iterator();
5572
+ init_make_array_buffer_iterator();
5573
+ init_make_blob_iterator();
5574
+ init_make_stream_iterator();
5575
+ init_is_type();
5576
+ }
5577
+ });
5578
+
5579
+ // ../core/src/lib/loader-utils/get-data.ts
5580
+ function getArrayBufferOrStringFromDataSync(data, loader, options) {
5581
+ if (loader.text && typeof data === "string") {
5582
+ return data;
5583
+ }
5584
+ if (isBuffer2(data)) {
5585
+ data = data.buffer;
5586
+ }
5587
+ if (data instanceof ArrayBuffer) {
5588
+ const arrayBuffer = data;
5589
+ if (loader.text && !loader.binary) {
5590
+ const textDecoder = new TextDecoder("utf8");
5591
+ return textDecoder.decode(arrayBuffer);
5592
+ }
5593
+ return arrayBuffer;
5594
+ }
5595
+ if (ArrayBuffer.isView(data)) {
5596
+ if (loader.text && !loader.binary) {
5597
+ const textDecoder = new TextDecoder("utf8");
5598
+ return textDecoder.decode(data);
5599
+ }
5600
+ let arrayBuffer = data.buffer;
5601
+ const byteLength = data.byteLength || data.length;
5602
+ if (data.byteOffset !== 0 || byteLength !== arrayBuffer.byteLength) {
5603
+ arrayBuffer = arrayBuffer.slice(data.byteOffset, data.byteOffset + byteLength);
5604
+ }
5605
+ return arrayBuffer;
5606
+ }
5607
+ throw new Error(ERR_DATA);
5608
+ }
5609
+ async function getArrayBufferOrStringFromData(data, loader, options) {
5610
+ const isArrayBuffer = data instanceof ArrayBuffer || ArrayBuffer.isView(data);
5611
+ if (typeof data === "string" || isArrayBuffer) {
5612
+ return getArrayBufferOrStringFromDataSync(data, loader, options);
5613
+ }
5614
+ if (isBlob(data)) {
5615
+ data = await makeResponse(data);
5616
+ }
5617
+ if (isResponse(data)) {
5618
+ const response = data;
5619
+ await checkResponse(response);
5620
+ return loader.binary ? await response.arrayBuffer() : await response.text();
5621
+ }
5622
+ if (isReadableStream(data)) {
5623
+ data = makeIterator(data, options);
5624
+ }
5625
+ if (isIterable(data) || isAsyncIterable(data)) {
5626
+ return concatenateArrayBuffersAsync(data);
5627
+ }
5628
+ throw new Error(ERR_DATA);
5629
+ }
5630
+ var ERR_DATA;
5631
+ var init_get_data = __esm({
5632
+ "../core/src/lib/loader-utils/get-data.ts"() {
5633
+ init_src2();
5634
+ init_is_type();
5635
+ init_make_iterator();
5636
+ init_response_utils();
5637
+ ERR_DATA = "Cannot convert supplied data type";
5638
+ }
5639
+ });
5640
+
5641
+ // ../core/src/lib/loader-utils/loader-context.ts
5642
+ function getLoaderContext(context, options, previousContext = null) {
5643
+ if (previousContext) {
5644
+ return previousContext;
5645
+ }
5646
+ const resolvedContext = {
5647
+ fetch: getFetchFunction(options, context),
5648
+ ...context
5649
+ };
5650
+ if (!Array.isArray(resolvedContext.loaders)) {
5651
+ resolvedContext.loaders = null;
5652
+ }
5653
+ return resolvedContext;
5654
+ }
5655
+ function getLoadersFromContext(loaders, context) {
5656
+ if (!context && loaders && !Array.isArray(loaders)) {
5657
+ return loaders;
5658
+ }
5659
+ let candidateLoaders;
5660
+ if (loaders) {
5661
+ candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
5662
+ }
5663
+ if (context && context.loaders) {
5664
+ const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
5665
+ candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
5666
+ }
5667
+ return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
5668
+ }
5669
+ var init_loader_context = __esm({
5670
+ "../core/src/lib/loader-utils/loader-context.ts"() {
5671
+ init_option_utils();
5672
+ }
5673
+ });
5674
+
5675
+ // ../core/src/lib/api/parse.ts
5676
+ async function parse(data, loaders, options, context) {
5677
+ assert3(!context || typeof context === "object");
5678
+ if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
5679
+ context = void 0;
5680
+ options = loaders;
5681
+ loaders = void 0;
5682
+ }
5683
+ data = await data;
5684
+ options = options || {};
5685
+ const { url } = getResourceUrlAndType(data);
5686
+ const typedLoaders = loaders;
5687
+ const candidateLoaders = getLoadersFromContext(typedLoaders, context);
5688
+ const loader = await selectLoader(data, candidateLoaders, options);
5689
+ if (!loader) {
5690
+ return null;
5691
+ }
5692
+ options = normalizeOptions(options, loader, candidateLoaders, url);
5693
+ context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
5694
+ return await parseWithLoader(loader, data, options, context);
5695
+ }
5696
+ async function parseWithLoader(loader, data, options, context) {
5697
+ validateWorkerVersion(loader);
5698
+ data = await getArrayBufferOrStringFromData(data, loader, options);
5699
+ if (loader.parseTextSync && typeof data === "string") {
5700
+ options.dataType = "text";
5701
+ return loader.parseTextSync(data, options, context, loader);
5702
+ }
5703
+ if (canParseWithWorker(loader, options)) {
5704
+ return await parseWithWorker(loader, data, options, context, parse);
5705
+ }
5706
+ if (loader.parseText && typeof data === "string") {
5707
+ return await loader.parseText(data, options, context, loader);
5708
+ }
5709
+ if (loader.parse) {
5710
+ return await loader.parse(data, options, context, loader);
5711
+ }
5712
+ assert3(!loader.parseSync);
5713
+ throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
5714
+ }
5715
+ var init_parse = __esm({
5716
+ "../core/src/lib/api/parse.ts"() {
5717
+ init_src();
5718
+ init_src2();
5719
+ init_normalize_loader();
5720
+ init_option_utils();
5721
+ init_get_data();
5722
+ init_loader_context();
5723
+ init_resource_utils();
5724
+ init_select_loader();
5725
+ }
5726
+ });
5727
+
5728
+ // ../core/src/lib/api/load.ts
5729
+ async function load(url, loaders, options, context) {
5730
+ if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
5731
+ context = void 0;
5732
+ options = loaders;
5733
+ loaders = void 0;
5734
+ }
5735
+ const fetch2 = getFetchFunction(options);
5736
+ let data = url;
5737
+ if (typeof url === "string") {
5738
+ data = await fetch2(url);
5739
+ }
5740
+ if (isBlob(url)) {
5741
+ data = await fetch2(url);
5742
+ }
5743
+ return await parse(data, loaders, options);
5744
+ }
5745
+ var init_load = __esm({
5746
+ "../core/src/lib/api/load.ts"() {
5747
+ init_is_type();
5748
+ init_normalize_loader();
5749
+ init_option_utils();
5750
+ init_parse();
5751
+ }
5752
+ });
5753
+
5754
+ // ../core/src/index.ts
5755
+ var init_src3 = __esm({
5756
+ "../core/src/index.ts"() {
5757
+ init_fetch_file();
5758
+ init_load();
5759
+ }
5760
+ });
5761
+
5762
+ // ../tiles/src/constants.ts
5763
+ var TILE_REFINEMENT, TILE_TYPE, TILESET_TYPE, LOD_METRIC_TYPE;
5764
+ var init_constants2 = __esm({
5765
+ "../tiles/src/constants.ts"() {
5766
+ TILE_REFINEMENT = {
5767
+ ADD: 1,
5768
+ REPLACE: 2
5769
+ };
5770
+ TILE_TYPE = {
5771
+ EMPTY: "empty",
5772
+ SCENEGRAPH: "scenegraph",
5773
+ POINTCLOUD: "pointcloud",
5774
+ MESH: "mesh"
5775
+ };
5776
+ TILESET_TYPE = {
5777
+ I3S: "I3S",
5778
+ TILES3D: "TILES3D"
5779
+ };
5780
+ LOD_METRIC_TYPE = {
5781
+ GEOMETRIC_ERROR: "geometricError",
5782
+ MAX_SCREEN_THRESHOLD: "maxScreenThreshold"
5783
+ };
5784
+ }
5785
+ });
5786
+
5787
+ // ../tiles/src/index.ts
5788
+ var init_src4 = __esm({
5789
+ "../tiles/src/index.ts"() {
5790
+ init_constants2();
5791
+ }
5792
+ });
5793
+
5794
+ // src/lib/utils/version.ts
5795
+ var VERSION4;
5796
+ var init_version2 = __esm({
3861
5797
  "src/lib/utils/version.ts"() {
3862
- VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
5798
+ VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3863
5799
  }
3864
5800
  });
3865
5801
 
@@ -3873,7 +5809,8 @@
3873
5809
  BATCHED_3D_MODEL: "b3dm",
3874
5810
  INSTANCED_3D_MODEL: "i3dm",
3875
5811
  GEOMETRY: "geom",
3876
- VECTOR: "vect"
5812
+ VECTOR: "vect",
5813
+ GLTF: "glTF"
3877
5814
  };
3878
5815
  TILE3D_TYPES = Object.keys(TILE3D_TYPE);
3879
5816
  MAGIC_ARRAY = {
@@ -3893,7 +5830,7 @@
3893
5830
  const string = textDecoder.decode(typedArray);
3894
5831
  return string;
3895
5832
  }
3896
- function getMagicString2(arrayBuffer, byteOffset = 0) {
5833
+ function getMagicString3(arrayBuffer, byteOffset = 0) {
3897
5834
  const dataView = new DataView(arrayBuffer);
3898
5835
  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
5836
  }
@@ -3904,10 +5841,10 @@
3904
5841
  });
3905
5842
 
3906
5843
  // ../draco/src/lib/utils/version.ts
3907
- var VERSION4;
5844
+ var VERSION5;
3908
5845
  var init_version3 = __esm({
3909
5846
  "../draco/src/lib/utils/version.ts"() {
3910
- VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
5847
+ VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3911
5848
  }
3912
5849
  });
3913
5850
 
@@ -3929,7 +5866,7 @@
3929
5866
  id: "draco",
3930
5867
  module: "draco",
3931
5868
  shapes: ["mesh"],
3932
- version: VERSION4,
5869
+ version: VERSION5,
3933
5870
  worker: true,
3934
5871
  extensions: ["drc"],
3935
5872
  mimeTypes: ["application/octet-stream"],
@@ -3972,12 +5909,12 @@
3972
5909
  });
3973
5910
 
3974
5911
  // ../schema/src/lib/utils/assert.ts
3975
- function assert5(condition, message) {
5912
+ function assert6(condition, message) {
3976
5913
  if (!condition) {
3977
5914
  throw new Error(message || "loader assertion failed.");
3978
5915
  }
3979
5916
  }
3980
- var init_assert4 = __esm({
5917
+ var init_assert5 = __esm({
3981
5918
  "../schema/src/lib/utils/assert.ts"() {
3982
5919
  }
3983
5920
  });
@@ -3998,10 +5935,10 @@
3998
5935
  var Schema;
3999
5936
  var init_schema = __esm({
4000
5937
  "../schema/src/lib/schema/impl/schema.ts"() {
4001
- init_assert4();
5938
+ init_assert5();
4002
5939
  Schema = class {
4003
5940
  constructor(fields, metadata) {
4004
- assert5(Array.isArray(fields));
5941
+ assert6(Array.isArray(fields));
4005
5942
  checkNames(fields);
4006
5943
  this.fields = fields;
4007
5944
  this.metadata = metadata || new Map();
@@ -4137,7 +6074,7 @@
4137
6074
  });
4138
6075
 
4139
6076
  // ../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;
6077
+ 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
6078
  var init_type = __esm({
4142
6079
  "../schema/src/lib/schema/impl/type.ts"() {
4143
6080
  init_enum();
@@ -4330,7 +6267,7 @@
4330
6267
  DAY: 0,
4331
6268
  MILLISECOND: 1
4332
6269
  };
4333
- Date = class extends DataType {
6270
+ Date2 = class extends DataType {
4334
6271
  constructor(unit) {
4335
6272
  super();
4336
6273
  this.unit = unit;
@@ -4960,7 +6897,7 @@
4960
6897
  });
4961
6898
 
4962
6899
  // ../draco/src/index.ts
4963
- async function parse(arrayBuffer, options) {
6900
+ async function parse2(arrayBuffer, options) {
4964
6901
  const { draco } = await loadDracoDecoderModule(options);
4965
6902
  const dracoParser = new DracoParser(draco);
4966
6903
  try {
@@ -4977,7 +6914,7 @@
4977
6914
  init_draco_module_loader();
4978
6915
  DracoLoader2 = {
4979
6916
  ...DracoLoader,
4980
- parse
6917
+ parse: parse2
4981
6918
  };
4982
6919
  }
4983
6920
  });
@@ -5089,12 +7026,12 @@
5089
7026
  });
5090
7027
 
5091
7028
  // ../math/src/geometry/utils/assert.ts
5092
- function assert6(condition, message) {
7029
+ function assert7(condition, message) {
5093
7030
  if (!condition) {
5094
7031
  throw new Error(`math.gl assertion failed. ${message}`);
5095
7032
  }
5096
7033
  }
5097
- var init_assert5 = __esm({
7034
+ var init_assert6 = __esm({
5098
7035
  "../math/src/geometry/utils/assert.ts"() {
5099
7036
  }
5100
7037
  });
@@ -5122,7 +7059,7 @@
5122
7059
  return value < 0 ? -1 : 1;
5123
7060
  }
5124
7061
  function octDecodeInRange(x, y, rangeMax, result) {
5125
- assert6(result);
7062
+ assert7(result);
5126
7063
  if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
5127
7064
  throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);
5128
7065
  }
@@ -5142,8 +7079,8 @@
5142
7079
  var RIGHT_SHIFT, scratchVector23, scratchVector32, scratchEncodeVector2, octEncodeScratch, uint8ForceArray;
5143
7080
  var init_attribute_compression = __esm({
5144
7081
  "../math/src/geometry/compression/attribute-compression.ts"() {
5145
- init_esm();
5146
- init_assert5();
7082
+ init_esm2();
7083
+ init_assert6();
5147
7084
  RIGHT_SHIFT = 1 / 256;
5148
7085
  scratchVector23 = new Vector2();
5149
7086
  scratchVector32 = new Vector3();
@@ -5955,7 +7892,7 @@
5955
7892
  var scratchNormal2;
5956
7893
  var init_normalize_3d_tile_normals = __esm({
5957
7894
  "src/lib/parsers/helpers/normalize-3d-tile-normals.ts"() {
5958
- init_esm();
7895
+ init_esm2();
5959
7896
  init_src7();
5960
7897
  scratchNormal2 = new Vector3();
5961
7898
  }
@@ -5987,7 +7924,7 @@
5987
7924
  }
5988
7925
  var init_normalize_3d_tile_positions = __esm({
5989
7926
  "src/lib/parsers/helpers/normalize-3d-tile-positions.ts"() {
5990
- init_esm();
7927
+ init_esm2();
5991
7928
  init_src7();
5992
7929
  }
5993
7930
  });
@@ -6135,7 +8072,7 @@
6135
8072
  return await loadDraco(tile, dracoData, options, context);
6136
8073
  }
6137
8074
  async function loadDraco(tile, dracoData, options, context) {
6138
- const { parse: parse4 } = context;
8075
+ const { parse: parse5 } = context;
6139
8076
  const dracoOptions = {
6140
8077
  ...options,
6141
8078
  draco: {
@@ -6144,7 +8081,7 @@
6144
8081
  }
6145
8082
  };
6146
8083
  delete dracoOptions["3d-tiles"];
6147
- const data = await parse4(dracoData.buffer, DracoLoader2, dracoOptions);
8084
+ const data = await parse5(dracoData.buffer, DracoLoader2, dracoOptions);
6148
8085
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
6149
8086
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
6150
8087
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
@@ -6183,7 +8120,7 @@
6183
8120
  "src/lib/parsers/parse-3d-tile-point-cloud.ts"() {
6184
8121
  init_src6();
6185
8122
  init_src7();
6186
- init_esm();
8123
+ init_esm2();
6187
8124
  init_tile_3d_feature_table();
6188
8125
  init_tile_3d_batch_table();
6189
8126
  init_parse_3d_tile_header();
@@ -6195,18 +8132,18 @@
6195
8132
  });
6196
8133
 
6197
8134
  // ../gltf/src/lib/utils/version.ts
6198
- var VERSION5;
8135
+ var VERSION6;
6199
8136
  var init_version4 = __esm({
6200
8137
  "../gltf/src/lib/utils/version.ts"() {
6201
- VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8138
+ VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6202
8139
  }
6203
8140
  });
6204
8141
 
6205
8142
  // ../textures/src/lib/utils/version.ts
6206
- var VERSION6;
8143
+ var VERSION7;
6207
8144
  var init_version5 = __esm({
6208
8145
  "../textures/src/lib/utils/version.ts"() {
6209
- VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
8146
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
6210
8147
  }
6211
8148
  });
6212
8149
 
@@ -6235,8 +8172,8 @@
6235
8172
  options.wasmBinary = wasmBinary;
6236
8173
  }
6237
8174
  return new Promise((resolve) => {
6238
- BasisModule(options).then((module) => {
6239
- const { BasisFile, initializeBasis } = module;
8175
+ BasisModule(options).then((module2) => {
8176
+ const { BasisFile, initializeBasis } = module2;
6240
8177
  initializeBasis();
6241
8178
  resolve({ BasisFile });
6242
8179
  });
@@ -6266,28 +8203,28 @@
6266
8203
  options.wasmBinary = wasmBinary;
6267
8204
  }
6268
8205
  return new Promise((resolve) => {
6269
- BasisEncoderModule(options).then((module) => {
6270
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
8206
+ BasisEncoderModule(options).then((module2) => {
8207
+ const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module2;
6271
8208
  initializeBasis();
6272
8209
  resolve({ BasisFile, KTX2File, BasisEncoder });
6273
8210
  });
6274
8211
  });
6275
8212
  }
6276
- var VERSION7, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
8213
+ var VERSION8, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
6277
8214
  var init_basis_module_loader = __esm({
6278
8215
  "../textures/src/lib/parsers/basis-module-loader.ts"() {
6279
8216
  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`;
8217
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
8218
+ BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.wasm`;
8219
+ BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.js`;
6283
8220
  }
6284
8221
  });
6285
8222
 
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 = {
8223
+ // ../textures/src/lib/gl-extensions.ts
8224
+ var GL_EXTENSIONS_CONSTANTS;
8225
+ var init_gl_extensions = __esm({
8226
+ "../textures/src/lib/gl-extensions.ts"() {
8227
+ GL_EXTENSIONS_CONSTANTS = {
6291
8228
  COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
6292
8229
  COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
6293
8230
  COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
@@ -6444,7 +8381,7 @@
6444
8381
  }
6445
8382
  });
6446
8383
 
6447
- // ../textures/src/lib/parsers/parse-basis.js
8384
+ // ../textures/src/lib/parsers/parse-basis.ts
6448
8385
  async function parseBasis(data, options) {
6449
8386
  if (options.basis.containerFormat === "auto") {
6450
8387
  if (isKTX(data)) {
@@ -6580,23 +8517,47 @@
6580
8517
  }
6581
8518
  var OutputFormat;
6582
8519
  var init_parse_basis = __esm({
6583
- "../textures/src/lib/parsers/parse-basis.js"() {
8520
+ "../textures/src/lib/parsers/parse-basis.ts"() {
6584
8521
  init_basis_module_loader();
6585
- init_gl_constants();
8522
+ init_gl_extensions();
6586
8523
  init_texture_formats();
6587
8524
  init_parse_ktx();
6588
8525
  OutputFormat = {
6589
- etc1: { basisFormat: 0, compressed: true, format: GL3.COMPRESSED_RGB_ETC1_WEBGL },
8526
+ etc1: {
8527
+ basisFormat: 0,
8528
+ compressed: true,
8529
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
8530
+ },
6590
8531
  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 },
8532
+ bc1: {
8533
+ basisFormat: 2,
8534
+ compressed: true,
8535
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
8536
+ },
8537
+ bc3: {
8538
+ basisFormat: 3,
8539
+ compressed: true,
8540
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
8541
+ },
6593
8542
  bc4: { basisFormat: 4, compressed: true },
6594
8543
  bc5: { basisFormat: 5, compressed: true },
6595
8544
  "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
6596
8545
  "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 },
8546
+ "pvrtc1-4-rgb": {
8547
+ basisFormat: 8,
8548
+ compressed: true,
8549
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
8550
+ },
8551
+ "pvrtc1-4-rgba": {
8552
+ basisFormat: 9,
8553
+ compressed: true,
8554
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
8555
+ },
8556
+ "astc-4x4": {
8557
+ basisFormat: 10,
8558
+ compressed: true,
8559
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
8560
+ },
6600
8561
  "atc-rgb": { basisFormat: 11, compressed: true },
6601
8562
  "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
6602
8563
  rgba32: { basisFormat: 13, compressed: false },
@@ -6617,7 +8578,7 @@
6617
8578
  name: "Basis",
6618
8579
  id: "basis",
6619
8580
  module: "textures",
6620
- version: VERSION6,
8581
+ version: VERSION7,
6621
8582
  worker: true,
6622
8583
  extensions: ["basis", "ktx2"],
6623
8584
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -6640,10 +8601,10 @@
6640
8601
  });
6641
8602
 
6642
8603
  // ../images/src/lib/utils/version.ts
6643
- var VERSION8;
8604
+ var VERSION9;
6644
8605
  var init_version6 = __esm({
6645
8606
  "../images/src/lib/utils/version.ts"() {
6646
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8607
+ VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6647
8608
  }
6648
8609
  });
6649
8610
 
@@ -6767,13 +8728,13 @@
6767
8728
  // ../images/src/lib/parsers/parse-to-image.ts
6768
8729
  async function parseToImage(arrayBuffer, options, url) {
6769
8730
  const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
6770
- const URL = self.URL || self.webkitURL;
6771
- const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
8731
+ const URL2 = self.URL || self.webkitURL;
8732
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
6772
8733
  try {
6773
8734
  return await loadToImage(objectUrl || blobOrDataUrl, options);
6774
8735
  } finally {
6775
8736
  if (objectUrl) {
6776
- URL.revokeObjectURL(objectUrl);
8737
+ URL2.revokeObjectURL(objectUrl);
6777
8738
  }
6778
8739
  }
6779
8740
  }
@@ -7038,7 +8999,7 @@
7038
8999
  id: "image",
7039
9000
  module: "images",
7040
9001
  name: "Images",
7041
- version: VERSION8,
9002
+ version: VERSION9,
7042
9003
  mimeTypes: MIME_TYPES,
7043
9004
  extensions: EXTENSIONS,
7044
9005
  parse: parseImage,
@@ -7107,12 +9068,12 @@
7107
9068
  });
7108
9069
 
7109
9070
  // ../gltf/src/lib/utils/assert.ts
7110
- function assert7(condition, message) {
9071
+ function assert8(condition, message) {
7111
9072
  if (!condition) {
7112
9073
  throw new Error(message || "assert failed: gltf");
7113
9074
  }
7114
9075
  }
7115
- var init_assert6 = __esm({
9076
+ var init_assert7 = __esm({
7116
9077
  "../gltf/src/lib/utils/assert.ts"() {
7117
9078
  }
7118
9079
  });
@@ -7137,16 +9098,16 @@
7137
9098
  // ../gltf/src/lib/gltf-utils/get-typed-array.ts
7138
9099
  function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
7139
9100
  const bufferView = json.bufferViews[bufferViewIndex];
7140
- assert7(bufferView);
9101
+ assert8(bufferView);
7141
9102
  const bufferIndex = bufferView.buffer;
7142
9103
  const binChunk = buffers[bufferIndex];
7143
- assert7(binChunk);
9104
+ assert8(binChunk);
7144
9105
  const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
7145
9106
  return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
7146
9107
  }
7147
9108
  var init_get_typed_array = __esm({
7148
9109
  "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
7149
- init_assert6();
9110
+ init_assert7();
7150
9111
  }
7151
9112
  });
7152
9113
 
@@ -7168,13 +9129,13 @@
7168
9129
  const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
7169
9130
  const length4 = accessor.count * components;
7170
9131
  const byteLength = accessor.count * components * bytesPerComponent;
7171
- assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
9132
+ assert8(byteLength >= 0 && byteLength <= bufferView.byteLength);
7172
9133
  return { ArrayType, length: length4, byteLength };
7173
9134
  }
7174
9135
  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
9136
  var init_gltf_utils = __esm({
7176
9137
  "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
7177
- init_assert6();
9138
+ init_assert7();
7178
9139
  TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
7179
9140
  ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
7180
9141
  [Int8Array, 5120],
@@ -7220,7 +9181,7 @@
7220
9181
  "../gltf/src/lib/api/gltf-scenegraph.ts"() {
7221
9182
  init_src8();
7222
9183
  init_src2();
7223
- init_assert6();
9184
+ init_assert7();
7224
9185
  init_gltf_utils();
7225
9186
  DEFAULT_GLTF_JSON = {
7226
9187
  asset: {
@@ -7319,7 +9280,7 @@
7319
9280
  bufferView = this.getBufferView(bufferView);
7320
9281
  const bufferIndex = bufferView.buffer;
7321
9282
  const binChunk = this.gltf.buffers[bufferIndex];
7322
- assert7(binChunk);
9283
+ assert8(binChunk);
7323
9284
  const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
7324
9285
  return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
7325
9286
  }
@@ -7366,14 +9327,14 @@
7366
9327
  return extension;
7367
9328
  }
7368
9329
  addExtension(extensionName, extensionData = {}) {
7369
- assert7(extensionData);
9330
+ assert8(extensionData);
7370
9331
  this.json.extensions = this.json.extensions || {};
7371
9332
  this.json.extensions[extensionName] = extensionData;
7372
9333
  this.registerUsedExtension(extensionName);
7373
9334
  return extensionData;
7374
9335
  }
7375
9336
  addRequiredExtension(extensionName, extensionData = {}) {
7376
- assert7(extensionData);
9337
+ assert8(extensionData);
7377
9338
  this.addExtension(extensionName, extensionData);
7378
9339
  this.registerRequiredExtension(extensionName);
7379
9340
  return extensionData;
@@ -7471,7 +9432,7 @@
7471
9432
  }
7472
9433
  addBufferView(buffer) {
7473
9434
  const byteLength = buffer.byteLength;
7474
- assert7(Number.isFinite(byteLength));
9435
+ assert8(Number.isFinite(byteLength));
7475
9436
  this.sourceBuffers = this.sourceBuffers || [];
7476
9437
  this.sourceBuffers.push(buffer);
7477
9438
  const glTFBufferView = {
@@ -8021,10 +9982,10 @@
8021
9982
  }
8022
9983
  const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
8023
9984
  const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
8024
- const { parse: parse4 } = context;
9985
+ const { parse: parse5 } = context;
8025
9986
  const dracoOptions = { ...options };
8026
9987
  delete dracoOptions["3d-tiles"];
8027
- const decodedData = await parse4(bufferCopy, DracoLoader2, dracoOptions, context);
9988
+ const decodedData = await parse5(bufferCopy, DracoLoader2, dracoOptions, context);
8028
9989
  const decodedAttributes = getGLTFAccessors(decodedData.attributes);
8029
9990
  for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
8030
9991
  if (attributeName in primitive.attributes) {
@@ -8118,7 +10079,7 @@
8118
10079
  const { json } = gltfScenegraph;
8119
10080
  if (json.lights) {
8120
10081
  const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);
8121
- assert7(!extension.lights);
10082
+ assert8(!extension.lights);
8122
10083
  extension.lights = json.lights;
8123
10084
  delete json.lights;
8124
10085
  }
@@ -8133,7 +10094,7 @@
8133
10094
  var KHR_LIGHTS_PUNCTUAL, name5;
8134
10095
  var init_KHR_lights_punctual = __esm({
8135
10096
  "../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
8136
- init_assert6();
10097
+ init_assert7();
8137
10098
  init_gltf_scenegraph();
8138
10099
  KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
8139
10100
  name5 = KHR_LIGHTS_PUNCTUAL;
@@ -8526,7 +10487,7 @@
8526
10487
  var COMPONENTS, BYTES, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL, DEFAULT_SAMPLER, GLTFPostProcessor;
8527
10488
  var init_post_process_gltf = __esm({
8528
10489
  "../gltf/src/lib/api/post-process-gltf.ts"() {
8529
- init_assert6();
10490
+ init_assert7();
8530
10491
  init_gltf_utils();
8531
10492
  COMPONENTS = {
8532
10493
  SCALAR: 1,
@@ -8575,7 +10536,7 @@
8575
10536
  }
8576
10537
  postProcess(gltf, options = {}) {
8577
10538
  const { json, buffers = [], images = [], baseUri = "" } = gltf;
8578
- assert7(json);
10539
+ assert8(json);
8579
10540
  this.baseUri = baseUri;
8580
10541
  this.json = json;
8581
10542
  this.buffers = buffers;
@@ -8761,11 +10722,22 @@
8761
10722
  const buffer = accessor.bufferView.buffer;
8762
10723
  const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
8763
10724
  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);
10725
+ let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
10726
+ if (accessor.bufferView.byteStride) {
10727
+ cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
10728
+ }
10729
+ accessor.value = new ArrayType(cutBuffer);
8766
10730
  }
8767
10731
  return accessor;
8768
10732
  }
10733
+ _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
10734
+ const result = new Uint8Array(count * bytesPerElement);
10735
+ for (let i2 = 0; i2 < count; i2++) {
10736
+ const elementOffset = byteOffset + i2 * byteStride;
10737
+ result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)), i2 * bytesPerElement);
10738
+ }
10739
+ return result.buffer;
10740
+ }
8769
10741
  _resolveTexture(texture, index) {
8770
10742
  texture.id = texture.id || `texture-${index}`;
8771
10743
  texture.sampler = "sampler" in texture ? this.getSampler(texture.sampler) : DEFAULT_SAMPLER;
@@ -8798,16 +10770,19 @@
8798
10770
  return image;
8799
10771
  }
8800
10772
  _resolveBufferView(bufferView, index) {
8801
- bufferView.id = bufferView.id || `bufferView-${index}`;
8802
10773
  const bufferIndex = bufferView.buffer;
8803
- bufferView.buffer = this.buffers[bufferIndex];
10774
+ const result = {
10775
+ id: `bufferView-${index}`,
10776
+ ...bufferView,
10777
+ buffer: this.buffers[bufferIndex]
10778
+ };
8804
10779
  const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
8805
10780
  let byteOffset = this.buffers[bufferIndex].byteOffset || 0;
8806
10781
  if ("byteOffset" in bufferView) {
8807
10782
  byteOffset += bufferView.byteOffset;
8808
10783
  }
8809
- bufferView.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
8810
- return bufferView;
10784
+ result.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
10785
+ return result;
8811
10786
  }
8812
10787
  _resolveCamera(camera, index) {
8813
10788
  camera.id = camera.id || `camera-${index}`;
@@ -8822,7 +10797,7 @@
8822
10797
  });
8823
10798
 
8824
10799
  // ../gltf/src/lib/parsers/parse-glb.ts
8825
- function getMagicString3(dataView, byteOffset = 0) {
10800
+ function getMagicString4(dataView, byteOffset = 0) {
8826
10801
  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
10802
  }
8828
10803
  function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
@@ -8833,7 +10808,7 @@
8833
10808
  }
8834
10809
  function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
8835
10810
  const dataView = new DataView(arrayBuffer);
8836
- const type = getMagicString3(dataView, byteOffset + 0);
10811
+ const type = getMagicString4(dataView, byteOffset + 0);
8837
10812
  const version = dataView.getUint32(byteOffset + 4, LE);
8838
10813
  const byteLength = dataView.getUint32(byteOffset + 8, LE);
8839
10814
  Object.assign(glb, {
@@ -8965,11 +10940,11 @@
8965
10940
  } else if (data instanceof ArrayBuffer) {
8966
10941
  const glb = {};
8967
10942
  byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
8968
- assert7(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
10943
+ assert8(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
8969
10944
  gltf._glb = glb;
8970
10945
  gltf.json = glb.json;
8971
10946
  } else {
8972
- assert7(false, "GLTF: must be ArrayBuffer or string");
10947
+ assert8(false, "GLTF: must be ArrayBuffer or string");
8973
10948
  }
8974
10949
  const buffers = gltf.json.buffers || [];
8975
10950
  gltf.buffers = new Array(buffers.length).fill(null);
@@ -8990,7 +10965,7 @@
8990
10965
  const buffer = buffers[i2];
8991
10966
  if (buffer.uri) {
8992
10967
  const { fetch: fetch2 } = context;
8993
- assert7(fetch2);
10968
+ assert8(fetch2);
8994
10969
  const uri = resolveUrl(buffer.uri, options);
8995
10970
  const response = await context?.fetch?.(uri);
8996
10971
  const arrayBuffer = await response?.arrayBuffer?.();
@@ -9023,7 +10998,7 @@
9023
10998
  return Array.from(imageIndices).sort();
9024
10999
  }
9025
11000
  async function loadImage(gltf, image, index, options, context) {
9026
- const { fetch: fetch2, parse: parse4 } = context;
11001
+ const { fetch: fetch2, parse: parse5 } = context;
9027
11002
  let arrayBuffer;
9028
11003
  if (image.uri) {
9029
11004
  const uri = resolveUrl(image.uri, options);
@@ -9034,8 +11009,8 @@
9034
11009
  const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
9035
11010
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
9036
11011
  }
9037
- assert7(arrayBuffer, "glTF image has no data");
9038
- let parsedImage = await parse4(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: { format: selectSupportedBasisFormat() } }, context);
11012
+ assert8(arrayBuffer, "glTF image has no data");
11013
+ let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
9039
11014
  if (parsedImage && parsedImage[0]) {
9040
11015
  parsedImage = {
9041
11016
  compressed: true,
@@ -9053,7 +11028,7 @@
9053
11028
  init_src9();
9054
11029
  init_src8();
9055
11030
  init_src2();
9056
- init_assert6();
11031
+ init_assert7();
9057
11032
  init_resolve_url();
9058
11033
  init_get_typed_array();
9059
11034
  init_gltf_extensions();
@@ -9064,7 +11039,7 @@
9064
11039
  });
9065
11040
 
9066
11041
  // ../gltf/src/gltf-loader.ts
9067
- async function parse2(arrayBuffer, options = {}, context) {
11042
+ async function parse3(arrayBuffer, options = {}, context) {
9068
11043
  options = { ...GLTFLoader.options, ...options };
9069
11044
  options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
9070
11045
  const { byteOffset = 0 } = options;
@@ -9080,13 +11055,13 @@
9080
11055
  name: "glTF",
9081
11056
  id: "gltf",
9082
11057
  module: "gltf",
9083
- version: VERSION5,
11058
+ version: VERSION6,
9084
11059
  extensions: ["gltf", "glb"],
9085
11060
  mimeTypes: ["model/gltf+json", "model/gltf-binary"],
9086
11061
  text: true,
9087
11062
  binary: true,
9088
11063
  tests: ["glTF"],
9089
- parse: parse2,
11064
+ parse: parse3,
9090
11065
  options: {
9091
11066
  gltf: {
9092
11067
  normalize: true,
@@ -9138,13 +11113,13 @@
9138
11113
  const tile3DOptions = options["3d-tiles"] || {};
9139
11114
  extractGLTFBufferOrURL(tile, gltfFormat, options);
9140
11115
  if (tile3DOptions.loadGLTF) {
9141
- const { parse: parse4, fetch: fetch2 } = context;
11116
+ const { parse: parse5, fetch: fetch2 } = context;
9142
11117
  if (tile.gltfUrl) {
9143
11118
  tile.gltfArrayBuffer = await fetch2(tile.gltfUrl, options);
9144
11119
  tile.gltfByteOffset = 0;
9145
11120
  }
9146
11121
  if (tile.gltfArrayBuffer) {
9147
- tile.gltf = await parse4(tile.gltfArrayBuffer, GLTFLoader, options, context);
11122
+ tile.gltf = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
9148
11123
  delete tile.gltfArrayBuffer;
9149
11124
  delete tile.gltfByteOffset;
9150
11125
  delete tile.gltfByteLength;
@@ -9350,8 +11325,8 @@
9350
11325
  }
9351
11326
  var init_parse_3d_tile_instanced_model = __esm({
9352
11327
  "src/lib/parsers/parse-3d-tile-instanced-model.ts"() {
9353
- init_esm();
9354
11328
  init_esm2();
11329
+ init_esm3();
9355
11330
  init_src7();
9356
11331
  init_tile_3d_feature_table();
9357
11332
  init_tile_3d_batch_table();
@@ -9381,15 +11356,30 @@
9381
11356
  }
9382
11357
  });
9383
11358
 
11359
+ // src/lib/parsers/parse-3d-tile-gltf.js
11360
+ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
11361
+ tile.rotateYtoZ = true;
11362
+ tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
11363
+ const { parse: parse5 } = context;
11364
+ tile.gltf = await parse5(arrayBuffer, GLTFLoader, options, context);
11365
+ }
11366
+ var init_parse_3d_tile_gltf = __esm({
11367
+ "src/lib/parsers/parse-3d-tile-gltf.js"() {
11368
+ init_src10();
11369
+ }
11370
+ });
11371
+
9384
11372
  // src/lib/parsers/parse-3d-tile.ts
9385
11373
  async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
9386
11374
  tile.byteOffset = byteOffset;
9387
- tile.type = getMagicString2(arrayBuffer, byteOffset);
11375
+ tile.type = getMagicString3(arrayBuffer, byteOffset);
9388
11376
  switch (tile.type) {
9389
11377
  case TILE3D_TYPE.COMPOSITE:
9390
11378
  return await parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
9391
11379
  case TILE3D_TYPE.BATCHED_3D_MODEL:
9392
11380
  return await parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
11381
+ case TILE3D_TYPE.GLTF:
11382
+ return await parseGltf3DTile(tile, arrayBuffer, options, context);
9393
11383
  case TILE3D_TYPE.INSTANCED_3D_MODEL:
9394
11384
  return await parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
9395
11385
  case TILE3D_TYPE.POINT_CLOUD:
@@ -9406,6 +11396,219 @@
9406
11396
  init_parse_3d_tile_batched_model();
9407
11397
  init_parse_3d_tile_instanced_model();
9408
11398
  init_parse_3d_tile_composite();
11399
+ init_parse_3d_tile_gltf();
11400
+ }
11401
+ });
11402
+
11403
+ // src/lib/parsers/helpers/parse-3d-tile-subtree.ts
11404
+ async function parse3DTilesSubtree(data) {
11405
+ const magic = new Uint32Array(data.slice(0, 4));
11406
+ if (magic[0] !== SUBTREE_FILE_MAGIC) {
11407
+ throw new Error("Wrong subtree file magic number");
11408
+ }
11409
+ const version = new Uint32Array(data.slice(4, 8));
11410
+ if (version[0] !== SUBTREE_FILE_VERSION) {
11411
+ throw new Error("Wrong subtree file verson, must be 1");
11412
+ }
11413
+ const jsonByteLength = parseUint64Value(data.slice(8, 16));
11414
+ const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
11415
+ const textDecoder = new TextDecoder("utf8");
11416
+ const string = textDecoder.decode(stringAttribute);
11417
+ const subtree = JSON.parse(string);
11418
+ const binaryByteLength = parseUint64Value(data.slice(16, 24));
11419
+ let internalBinaryBuffer = new ArrayBuffer(0);
11420
+ if (binaryByteLength) {
11421
+ internalBinaryBuffer = data.slice(24 + jsonByteLength);
11422
+ }
11423
+ if ("bufferView" in subtree.tileAvailability) {
11424
+ subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, "tileAvailability", internalBinaryBuffer);
11425
+ }
11426
+ if ("bufferView" in subtree.contentAvailability) {
11427
+ subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, "contentAvailability", internalBinaryBuffer);
11428
+ }
11429
+ if ("bufferView" in subtree.childSubtreeAvailability) {
11430
+ subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, "childSubtreeAvailability", internalBinaryBuffer);
11431
+ }
11432
+ return subtree;
11433
+ }
11434
+ async function getExplicitBitstream(subtree, name8, internalBinaryBuffer) {
11435
+ const bufferViewIndex = subtree[name8].bufferView;
11436
+ const bufferView = subtree.bufferViews[bufferViewIndex];
11437
+ const buffer = subtree.buffers[bufferView.buffer];
11438
+ if (buffer.uri) {
11439
+ const response = await fetchFile(buffer.uri);
11440
+ const data = await response.arrayBuffer();
11441
+ return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
11442
+ }
11443
+ return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
11444
+ }
11445
+ function parseUint64Value(buffer) {
11446
+ const dataView = new DataView(buffer);
11447
+ const left = dataView.getUint32(0, true);
11448
+ const right = dataView.getUint32(4, true);
11449
+ return left + 2 ** 32 * right;
11450
+ }
11451
+ var SUBTREE_FILE_MAGIC, SUBTREE_FILE_VERSION;
11452
+ var init_parse_3d_tile_subtree = __esm({
11453
+ "src/lib/parsers/helpers/parse-3d-tile-subtree.ts"() {
11454
+ init_src3();
11455
+ SUBTREE_FILE_MAGIC = 1952609651;
11456
+ SUBTREE_FILE_VERSION = 1;
11457
+ }
11458
+ });
11459
+
11460
+ // src/tile-3d-subtree-loader.ts
11461
+ var Tile3DSubtreeLoader;
11462
+ var init_tile_3d_subtree_loader = __esm({
11463
+ "src/tile-3d-subtree-loader.ts"() {
11464
+ init_parse_3d_tile_subtree();
11465
+ init_version2();
11466
+ Tile3DSubtreeLoader = {
11467
+ id: "3d-tiles-subtree",
11468
+ name: "3D Tiles Subtree",
11469
+ module: "3d-tiles",
11470
+ version: VERSION4,
11471
+ extensions: ["subtree"],
11472
+ mimeTypes: ["application/octet-stream"],
11473
+ tests: ["subtree"],
11474
+ parse: parse3DTilesSubtree,
11475
+ options: {}
11476
+ };
11477
+ }
11478
+ });
11479
+
11480
+ // src/lib/parsers/helpers/parse-3d-implicit-tiles.ts
11481
+ async function parseImplicitTiles(subtree, options, parentData = {
11482
+ mortonIndex: 0,
11483
+ x: 0,
11484
+ y: 0,
11485
+ z: 0
11486
+ }, childIndex = 0, level = 0, globalData = {
11487
+ level: 0,
11488
+ mortonIndex: 0,
11489
+ x: 0,
11490
+ y: 0,
11491
+ z: 0
11492
+ }) {
11493
+ const {
11494
+ subdivisionScheme,
11495
+ subtreeLevels,
11496
+ maximumLevel,
11497
+ contentUrlTemplate,
11498
+ subtreesUriTemplate,
11499
+ basePath
11500
+ } = options;
11501
+ const tile = { children: [], lodMetricValue: 0, contentUrl: "" };
11502
+ const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
11503
+ const childX = childIndex & 1;
11504
+ const childY = childIndex >> 1 & 1;
11505
+ const childZ = childIndex >> 2 & 1;
11506
+ const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
11507
+ let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
11508
+ let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
11509
+ let childTileX = concatBits(parentData.x, childX);
11510
+ let childTileY = concatBits(parentData.y, childY);
11511
+ let childTileZ = concatBits(parentData.z, childZ);
11512
+ let isChildSubtreeAvailable = false;
11513
+ if (level + 1 > subtreeLevels) {
11514
+ isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
11515
+ }
11516
+ const x = concatBits(globalData.x, childTileX);
11517
+ const y = concatBits(globalData.y, childTileY);
11518
+ const z = concatBits(globalData.z, childTileZ);
11519
+ const lev = level + globalData.level;
11520
+ if (isChildSubtreeAvailable) {
11521
+ const subtreePath = `${basePath}/${subtreesUriTemplate}`;
11522
+ const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
11523
+ const childSubtree = await load(childSubtreeUrl, Tile3DSubtreeLoader);
11524
+ subtree = childSubtree;
11525
+ globalData.mortonIndex = childTileMortonIndex;
11526
+ globalData.x = childTileX;
11527
+ globalData.y = childTileY;
11528
+ globalData.z = childTileZ;
11529
+ globalData.level = level;
11530
+ childTileMortonIndex = 0;
11531
+ tileAvailabilityIndex = 0;
11532
+ childTileX = 0;
11533
+ childTileY = 0;
11534
+ childTileZ = 0;
11535
+ level = 0;
11536
+ }
11537
+ const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
11538
+ if (!isTileAvailable || level > maximumLevel) {
11539
+ return tile;
11540
+ }
11541
+ const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
11542
+ if (isContentAvailable) {
11543
+ tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
11544
+ }
11545
+ const childTileLevel = level + 1;
11546
+ const pData = { mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ };
11547
+ for (let index = 0; index < childrenPerTile; index++) {
11548
+ const currentTile = await parseImplicitTiles(subtree, options, pData, index, childTileLevel, globalData);
11549
+ if (currentTile.contentUrl || currentTile.children.length) {
11550
+ const globalLevel = lev + 1;
11551
+ const formattedTile = formatTileData(currentTile, globalLevel, options);
11552
+ tile.children.push(formattedTile);
11553
+ }
11554
+ }
11555
+ return tile;
11556
+ }
11557
+ function getAvailabilityResult(availabilityData, index) {
11558
+ if ("constant" in availabilityData) {
11559
+ return Boolean(availabilityData.constant);
11560
+ }
11561
+ if (availabilityData.explicitBitstream) {
11562
+ return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);
11563
+ }
11564
+ return false;
11565
+ }
11566
+ function formatTileData(tile, level, options) {
11567
+ const { basePath, refine, getRefine: getRefine2, lodMetricType, getTileType: getTileType2, rootLodMetricValue } = options;
11568
+ const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, "");
11569
+ const lodMetricValue = rootLodMetricValue / 2 ** level;
11570
+ return {
11571
+ children: tile.children,
11572
+ contentUrl: tile.contentUrl,
11573
+ content: { uri },
11574
+ id: tile.contentUrl,
11575
+ refine: getRefine2(refine),
11576
+ type: getTileType2(tile),
11577
+ lodMetricType,
11578
+ lodMetricValue
11579
+ };
11580
+ }
11581
+ function concatBits(first, second) {
11582
+ return parseInt(first.toString(2) + second.toString(2), 2);
11583
+ }
11584
+ function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
11585
+ const mapUrl = generateMapUrl({ level, x, y, z });
11586
+ return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);
11587
+ }
11588
+ function generateMapUrl(items) {
11589
+ const mapUrl = {};
11590
+ for (const key in items) {
11591
+ mapUrl[`{${key}}`] = items[key];
11592
+ }
11593
+ return mapUrl;
11594
+ }
11595
+ function getBooleanValueFromBitstream(availabilityIndex, availabilityBuffer) {
11596
+ const byteIndex = Math.floor(availabilityIndex / 8);
11597
+ const bitIndex = availabilityIndex % 8;
11598
+ const bitValue = availabilityBuffer[byteIndex] >> bitIndex & 1;
11599
+ return bitValue === 1;
11600
+ }
11601
+ var QUADTREE_DEVISION_COUNT, OCTREE_DEVISION_COUNT, SUBDIVISION_COUNT_MAP;
11602
+ var init_parse_3d_implicit_tiles = __esm({
11603
+ "src/lib/parsers/helpers/parse-3d-implicit-tiles.ts"() {
11604
+ init_tile_3d_subtree_loader();
11605
+ init_src3();
11606
+ QUADTREE_DEVISION_COUNT = 4;
11607
+ OCTREE_DEVISION_COUNT = 8;
11608
+ SUBDIVISION_COUNT_MAP = {
11609
+ QUADTREE: QUADTREE_DEVISION_COUNT,
11610
+ OCTREE: OCTREE_DEVISION_COUNT
11611
+ };
9409
11612
  }
9410
11613
  });
9411
11614
 
@@ -9421,6 +11624,8 @@
9421
11624
  return TILE_TYPE.POINTCLOUD;
9422
11625
  case "i3dm":
9423
11626
  case "b3dm":
11627
+ case "glb":
11628
+ case "gltf":
9424
11629
  return TILE_TYPE.SCENEGRAPH;
9425
11630
  default:
9426
11631
  return fileExtension;
@@ -9469,9 +11674,63 @@
9469
11674
  }
9470
11675
  return root;
9471
11676
  }
11677
+ async function normalizeImplicitTileHeaders(tileset) {
11678
+ if (!tileset.root) {
11679
+ return null;
11680
+ }
11681
+ const basePath = tileset.basePath;
11682
+ const implicitTilingExtension = tileset.root.extensions["3DTILES_implicit_tiling"];
11683
+ const {
11684
+ subdivisionScheme,
11685
+ maximumLevel,
11686
+ subtreeLevels,
11687
+ subtrees: { uri: subtreesUriTemplate }
11688
+ } = implicitTilingExtension;
11689
+ const subtreeUrl = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
11690
+ const rootSubtreeUrl = `${basePath}/${subtreeUrl}`;
11691
+ const rootSubtree = await load(rootSubtreeUrl, Tile3DSubtreeLoader);
11692
+ const contentUrlTemplate = `${basePath}/${tileset.root.content.uri}`;
11693
+ const refine = tileset.root.refine;
11694
+ const rootLodMetricValue = tileset.root.geometricError;
11695
+ const options = {
11696
+ contentUrlTemplate,
11697
+ subtreesUriTemplate,
11698
+ subdivisionScheme,
11699
+ subtreeLevels,
11700
+ maximumLevel,
11701
+ refine,
11702
+ basePath,
11703
+ lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
11704
+ rootLodMetricValue,
11705
+ getTileType,
11706
+ getRefine
11707
+ };
11708
+ return await normalizeImplicitTileData(tileset.root, rootSubtree, options);
11709
+ }
11710
+ async function normalizeImplicitTileData(tile, rootSubtree, options) {
11711
+ if (!tile) {
11712
+ return null;
11713
+ }
11714
+ tile.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
11715
+ tile.lodMetricValue = tile.geometricError;
11716
+ tile.transformMatrix = tile.transform;
11717
+ const { children, contentUrl } = await parseImplicitTiles(rootSubtree, options);
11718
+ if (contentUrl) {
11719
+ tile.contentUrl = contentUrl;
11720
+ tile.content = { uri: contentUrl.replace(`${options.basePath}/`, "") };
11721
+ }
11722
+ tile.refine = getRefine(tile.refine);
11723
+ tile.type = getTileType(tile);
11724
+ tile.children = children;
11725
+ tile.id = tile.contentUrl;
11726
+ return tile;
11727
+ }
9472
11728
  var init_parse_3d_tile_header2 = __esm({
9473
11729
  "src/lib/parsers/parse-3d-tile-header.ts"() {
11730
+ init_tile_3d_subtree_loader();
11731
+ init_src3();
9474
11732
  init_src4();
11733
+ init_parse_3d_implicit_tiles();
9475
11734
  }
9476
11735
  });
9477
11736
 
@@ -9494,13 +11753,13 @@
9494
11753
  tilesetJson.loader = options.loader || Tiles3DLoader;
9495
11754
  tilesetJson.url = context.url;
9496
11755
  tilesetJson.basePath = getBaseUri(tilesetJson);
9497
- tilesetJson.root = normalizeTileHeaders(tilesetJson);
11756
+ tilesetJson.root = hasImplicitTilingExtension(tilesetJson) ? await normalizeImplicitTileHeaders(tilesetJson) : normalizeTileHeaders(tilesetJson);
9498
11757
  tilesetJson.type = TILESET_TYPE.TILES3D;
9499
11758
  tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
9500
11759
  tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
9501
11760
  return tilesetJson;
9502
11761
  }
9503
- async function parse3(data, options, context) {
11762
+ async function parse4(data, options, context) {
9504
11763
  const loaderOptions = options["3d-tiles"] || {};
9505
11764
  let isTileset;
9506
11765
  if (loaderOptions.isTileset === "auto") {
@@ -9515,7 +11774,10 @@
9515
11774
  }
9516
11775
  return data;
9517
11776
  }
9518
- var Tiles3DLoader;
11777
+ function hasImplicitTilingExtension(tilesetJson) {
11778
+ return tilesetJson?.extensionsRequired?.includes(IMPLICIT_TILING_EXTENSION_NAME) && tilesetJson?.extensionsUsed?.includes(IMPLICIT_TILING_EXTENSION_NAME);
11779
+ }
11780
+ var IMPLICIT_TILING_EXTENSION_NAME, Tiles3DLoader;
9519
11781
  var init_tiles_3d_loader = __esm({
9520
11782
  "src/tiles-3d-loader.ts"() {
9521
11783
  init_src2();
@@ -9523,15 +11785,16 @@
9523
11785
  init_version2();
9524
11786
  init_parse_3d_tile();
9525
11787
  init_parse_3d_tile_header2();
11788
+ IMPLICIT_TILING_EXTENSION_NAME = "3DTILES_implicit_tiling";
9526
11789
  Tiles3DLoader = {
9527
11790
  id: "3d-tiles",
9528
11791
  name: "3D Tiles",
9529
11792
  module: "3d-tiles",
9530
- version: VERSION3,
11793
+ version: VERSION4,
9531
11794
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
9532
11795
  mimeTypes: ["application/octet-stream"],
9533
11796
  tests: ["cmpt", "pnts", "b3dm", "i3dm"],
9534
- parse: parse3,
11797
+ parse: parse4,
9535
11798
  options: {
9536
11799
  "3d-tiles": {
9537
11800
  loadGLTF: true,
@@ -9544,7 +11807,7 @@
9544
11807
  }
9545
11808
  });
9546
11809
 
9547
- // src/lib/ion/ion.js
11810
+ // src/lib/ion/ion.ts
9548
11811
  async function getIonTilesetMetadata(accessToken, assetId) {
9549
11812
  if (!assetId) {
9550
11813
  const assets = await getIonAssets(accessToken);
@@ -9594,7 +11857,7 @@
9594
11857
  }
9595
11858
  var CESIUM_ION_URL;
9596
11859
  var init_ion = __esm({
9597
- "src/lib/ion/ion.js"() {
11860
+ "src/lib/ion/ion.ts"() {
9598
11861
  init_src3();
9599
11862
  init_src2();
9600
11863
  CESIUM_ION_URL = "https://api.cesium.com/v1/assets";
@@ -9638,83 +11901,6 @@
9638
11901
  }
9639
11902
  });
9640
11903
 
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
11904
  // src/lib/encoders/helpers/encode-3d-tile-header.ts
9719
11905
  function encode3DTileHeader(tile, dataView, byteOffset) {
9720
11906
  const HEADER_SIZE = 12;
@@ -9924,7 +12110,7 @@
9924
12110
  name: "3D Tile",
9925
12111
  id: "3d-tiles",
9926
12112
  module: "3d-tiles",
9927
- version: VERSION3,
12113
+ version: VERSION4,
9928
12114
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
9929
12115
  mimeTypes: ["application/octet-stream"],
9930
12116
  encodeSync,
@@ -9963,10 +12149,10 @@
9963
12149
 
9964
12150
  // src/bundle.ts
9965
12151
  var require_bundle = __commonJS({
9966
- "src/bundle.ts"(exports, module) {
12152
+ "src/bundle.ts"(exports, module2) {
9967
12153
  var moduleExports = (init_src11(), src_exports);
9968
12154
  globalThis.loaders = globalThis.loaders || {};
9969
- module.exports = Object.assign(globalThis.loaders, moduleExports);
12155
+ module2.exports = Object.assign(globalThis.loaders, moduleExports);
9970
12156
  }
9971
12157
  });
9972
12158
  require_bundle();