@loaders.gl/3d-tiles 4.0.0-alpha.21 → 4.0.0-alpha.23

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 (123) hide show
  1. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +30 -0
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
  3. package/dist/{tz3/tz3-archive.js → 3d-tiles-archive/3d-tiles-archive-archive.js} +16 -16
  4. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
  5. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
  6. package/dist/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +5 -5
  7. package/dist/3d-tiles-archive-loader.d.ts +13 -0
  8. package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
  9. package/dist/3d-tiles-archive-loader.js +31 -0
  10. package/dist/cesium-ion-loader.d.ts.map +1 -1
  11. package/dist/cesium-ion-loader.js +0 -1
  12. package/dist/dist.min.js +2218 -1370
  13. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
  14. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  15. package/dist/es5/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +7 -7
  16. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  17. package/dist/es5/3d-tiles-archive-loader.js +50 -0
  18. package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
  19. package/dist/es5/cesium-ion-loader.js.map +1 -1
  20. package/dist/es5/index.js +14 -7
  21. package/dist/es5/index.js.map +1 -1
  22. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
  23. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  24. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
  25. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  26. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +3 -1
  27. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  28. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +14 -12
  29. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  30. package/dist/es5/lib/parsers/parse-3d-tile-header.js +2 -1
  31. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  32. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
  33. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  34. package/dist/es5/lib/parsers/parse-3d-tile.js +3 -1
  35. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  36. package/dist/es5/lib/utils/version.js +1 -1
  37. package/dist/es5/tiles-3d-loader.js +2 -0
  38. package/dist/es5/tiles-3d-loader.js.map +1 -1
  39. package/dist/es5/types.js.map +1 -1
  40. package/dist/esm/{tz3/tz3-archive.js → 3d-tiles-archive/3d-tiles-archive-archive.js} +14 -19
  41. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  42. package/dist/esm/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +4 -4
  43. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  44. package/dist/esm/3d-tiles-archive-loader.js +20 -0
  45. package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
  46. package/dist/esm/cesium-ion-loader.js.map +1 -1
  47. package/dist/esm/index.js +2 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
  50. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  51. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
  52. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  53. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +3 -1
  54. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  55. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +7 -8
  56. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  57. package/dist/esm/lib/parsers/parse-3d-tile-header.js +2 -1
  58. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  59. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
  60. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  61. package/dist/esm/lib/parsers/parse-3d-tile.js +3 -1
  62. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  63. package/dist/esm/lib/utils/version.js +1 -1
  64. package/dist/esm/tiles-3d-loader.js +2 -0
  65. package/dist/esm/tiles-3d-loader.js.map +1 -1
  66. package/dist/esm/types.js.map +1 -1
  67. package/dist/index.d.ts +3 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +5 -3
  70. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +32 -0
  71. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
  72. package/dist/lib/filesystems/tiles-3d-archive-file-system.js +75 -0
  73. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  74. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +2 -2
  75. package/dist/lib/parsers/parse-3d-tile-composite.js +1 -1
  76. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -2
  77. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  78. package/dist/lib/parsers/parse-3d-tile-gltf.js +8 -7
  79. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  80. package/dist/lib/parsers/parse-3d-tile-header.js +2 -1
  81. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
  82. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  83. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +10 -2
  84. package/dist/lib/parsers/parse-3d-tile.d.ts +1 -1
  85. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  86. package/dist/lib/parsers/parse-3d-tile.js +1 -1
  87. package/dist/tiles-3d-loader.d.ts +2 -1
  88. package/dist/tiles-3d-loader.d.ts.map +1 -1
  89. package/dist/tiles-3d-loader.js +4 -0
  90. package/dist/types.d.ts +2 -0
  91. package/dist/types.d.ts.map +1 -1
  92. package/package.json +8 -7
  93. package/src/{tz3/tz3-archive.ts → 3d-tiles-archive/3d-tiles-archive-archive.ts} +22 -19
  94. package/src/{tz3/tz3-parser.ts → 3d-tiles-archive/3d-tiles-archive-parser.ts} +5 -5
  95. package/src/3d-tiles-archive-loader.ts +47 -0
  96. package/src/cesium-ion-loader.ts +0 -1
  97. package/src/index.ts +3 -2
  98. package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
  99. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
  100. package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
  101. package/src/lib/parsers/parse-3d-tile-gltf.ts +11 -10
  102. package/src/lib/parsers/parse-3d-tile-header.ts +2 -1
  103. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
  104. package/src/lib/parsers/parse-3d-tile.ts +2 -2
  105. package/src/tiles-3d-loader.ts +16 -4
  106. package/src/types.ts +3 -0
  107. package/dist/es5/tz3/tz3-archive.js +0 -161
  108. package/dist/es5/tz3/tz3-archive.js.map +0 -1
  109. package/dist/es5/tz3/tz3-parser.js.map +0 -1
  110. package/dist/es5/tz3-loader.js +0 -48
  111. package/dist/es5/tz3-loader.js.map +0 -1
  112. package/dist/esm/tz3/tz3-archive.js.map +0 -1
  113. package/dist/esm/tz3/tz3-parser.js.map +0 -1
  114. package/dist/esm/tz3-loader.js +0 -19
  115. package/dist/esm/tz3-loader.js.map +0 -1
  116. package/dist/tz3/tz3-archive.d.ts +0 -23
  117. package/dist/tz3/tz3-archive.d.ts.map +0 -1
  118. package/dist/tz3/tz3-parser.d.ts +0 -10
  119. package/dist/tz3/tz3-parser.d.ts.map +0 -1
  120. package/dist/tz3-loader.d.ts +0 -14
  121. package/dist/tz3-loader.d.ts.map +0 -1
  122. package/dist/tz3-loader.js +0 -30
  123. package/src/tz3-loader.ts +0 -41
package/dist/dist.min.js CHANGED
@@ -14,8 +14,8 @@
14
14
  };
15
15
  var __export = (target, all) => {
16
16
  __markAsModule(target);
17
- for (var name10 in all)
18
- __defProp(target, name10, { get: all[name10], enumerable: true });
17
+ for (var name12 in all)
18
+ __defProp(target, name12, { get: all[name12], enumerable: true });
19
19
  };
20
20
  var __reExport = (target, module, desc) => {
21
21
  if (module && typeof module === "object" || typeof module === "function") {
@@ -29,6 +29,15 @@
29
29
  return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
30
30
  };
31
31
 
32
+ // ../loader-utils/src/loader-types.ts
33
+ async function parseFromContext(data, loaders, options, context) {
34
+ return context._parse(data, loaders, options, context);
35
+ }
36
+ var init_loader_types = __esm({
37
+ "../loader-utils/src/loader-types.ts"() {
38
+ }
39
+ });
40
+
32
41
  // ../loader-utils/src/lib/env-utils/assert.ts
33
42
  function assert2(condition, message) {
34
43
  if (!condition) {
@@ -254,9 +263,9 @@
254
263
  constructor(props) {
255
264
  this.terminated = false;
256
265
  this._loadableURL = "";
257
- const { name: name10, source, url } = props;
266
+ const { name: name12, source, url } = props;
258
267
  assert3(source || url);
259
- this.name = name10;
268
+ this.name = name12;
260
269
  this.source = source;
261
270
  this.url = url;
262
271
  this.onMessage = NOOP;
@@ -381,9 +390,9 @@
381
390
  this.onDebug = props.onDebug;
382
391
  }
383
392
  }
384
- async startJob(name10, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
393
+ async startJob(name12, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
385
394
  const startPromise = new Promise((onStart) => {
386
- this.jobQueue.push({ name: name10, onMessage: onMessage2, onError, onStart });
395
+ this.jobQueue.push({ name: name12, onMessage: onMessage2, onError, onStart });
387
396
  return this;
388
397
  });
389
398
  this._startQueuedJob();
@@ -434,8 +443,8 @@
434
443
  }
435
444
  if (this.count < this._getMaxConcurrency()) {
436
445
  this.count++;
437
- const name10 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
438
- return new WorkerThread({ name: name10, source: this.source, url: this.url });
446
+ const name12 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
447
+ return new WorkerThread({ name: name12, source: this.source, url: this.url });
439
448
  }
440
449
  return null;
441
450
  }
@@ -487,16 +496,16 @@
487
496
  }
488
497
  }
489
498
  getWorkerPool(options) {
490
- const { name: name10, source, url } = options;
491
- let workerPool = this.workerPools.get(name10);
499
+ const { name: name12, source, url } = options;
500
+ let workerPool = this.workerPools.get(name12);
492
501
  if (!workerPool) {
493
502
  workerPool = new WorkerPool({
494
- name: name10,
503
+ name: name12,
495
504
  source,
496
505
  url
497
506
  });
498
507
  workerPool.setProps(this._getWorkerPoolProps());
499
- this.workerPools.set(name10, workerPool);
508
+ this.workerPools.set(name12, workerPool);
500
509
  }
501
510
  return workerPool;
502
511
  }
@@ -679,10 +688,10 @@
679
688
  return loader.worker && options?.worker;
680
689
  }
681
690
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
682
- const name10 = loader.id;
691
+ const name12 = loader.id;
683
692
  const url = getWorkerURL(loader, options);
684
693
  const workerFarm = WorkerFarm.getWorkerFarm(options);
685
- const workerPool = workerFarm.getWorkerPool({ name: name10, url });
694
+ const workerPool = workerFarm.getWorkerPool({ name: name12, url });
686
695
  options = JSON.parse(JSON.stringify(options));
687
696
  context = JSON.parse(JSON.stringify(context || {}));
688
697
  const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
@@ -1181,9 +1190,164 @@
1181
1190
  }
1182
1191
  });
1183
1192
 
1193
+ // (disabled):fs
1194
+ var require_fs = __commonJS({
1195
+ "(disabled):fs"() {
1196
+ }
1197
+ });
1198
+
1199
+ // ../loader-utils/src/lib/file-provider/file-provider.ts
1200
+ var isFileProvider;
1201
+ var init_file_provider = __esm({
1202
+ "../loader-utils/src/lib/file-provider/file-provider.ts"() {
1203
+ isFileProvider = (fileProvider) => {
1204
+ return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
1205
+ };
1206
+ }
1207
+ });
1208
+
1209
+ // ../loader-utils/src/lib/file-provider/file-handle.ts
1210
+ var import_fs, FileHandle;
1211
+ var init_file_handle = __esm({
1212
+ "../loader-utils/src/lib/file-provider/file-handle.ts"() {
1213
+ import_fs = __toModule(require_fs());
1214
+ FileHandle = class {
1215
+ constructor(fileDescriptor, stats) {
1216
+ this.read = (buffer, offset, length4, position) => {
1217
+ return new Promise((s2) => {
1218
+ (0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
1219
+ });
1220
+ };
1221
+ this.fileDescriptor = fileDescriptor;
1222
+ this.stats = stats;
1223
+ }
1224
+ static async open(path) {
1225
+ const [fd, stats] = await Promise.all([
1226
+ new Promise((resolve2, reject) => {
1227
+ (0, import_fs.open)(path, void 0, void 0, (_err, fd2) => _err ? reject(_err) : resolve2(fd2));
1228
+ }),
1229
+ new Promise((resolve2, reject) => {
1230
+ (0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => _err ? reject(_err) : resolve2(stats2));
1231
+ })
1232
+ ]);
1233
+ return new FileHandle(fd, stats);
1234
+ }
1235
+ async close() {
1236
+ return new Promise((resolve2) => {
1237
+ (0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
1238
+ });
1239
+ }
1240
+ get stat() {
1241
+ return this.stats;
1242
+ }
1243
+ };
1244
+ }
1245
+ });
1246
+
1247
+ // ../loader-utils/src/lib/file-provider/file-handle-file.ts
1248
+ var FileHandleFile;
1249
+ var init_file_handle_file = __esm({
1250
+ "../loader-utils/src/lib/file-provider/file-handle-file.ts"() {
1251
+ init_file_handle();
1252
+ init_file_aliases();
1253
+ FileHandleFile = class {
1254
+ static async from(path) {
1255
+ path = resolvePath(path);
1256
+ const fileDescriptor = await FileHandle.open(path);
1257
+ return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
1258
+ }
1259
+ constructor(fileDescriptor, size) {
1260
+ this.fileDescriptor = fileDescriptor;
1261
+ this.size = size;
1262
+ }
1263
+ async destroy() {
1264
+ await this.fileDescriptor.close();
1265
+ }
1266
+ async getUint8(offset) {
1267
+ const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
1268
+ if (val === void 0) {
1269
+ throw new Error("something went wrong");
1270
+ }
1271
+ return val;
1272
+ }
1273
+ async getUint16(offset) {
1274
+ const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
1275
+ if (val === void 0) {
1276
+ throw new Error("something went wrong");
1277
+ }
1278
+ return val;
1279
+ }
1280
+ async getUint32(offset) {
1281
+ const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
1282
+ if (val === void 0) {
1283
+ throw new Error("something went wrong");
1284
+ }
1285
+ return val;
1286
+ }
1287
+ async getBigUint64(offset) {
1288
+ const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
1289
+ if (val === void 0) {
1290
+ throw new Error("something went wrong");
1291
+ }
1292
+ return val;
1293
+ }
1294
+ async slice(startOffsset, endOffset) {
1295
+ const bigLength = endOffset - startOffsset;
1296
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
1297
+ throw new Error("too big slice");
1298
+ }
1299
+ const length4 = Number(bigLength);
1300
+ return (await this.fileDescriptor.read(Buffer.alloc(length4), 0, length4, startOffsset)).buffer.buffer;
1301
+ }
1302
+ get length() {
1303
+ return this.size;
1304
+ }
1305
+ };
1306
+ }
1307
+ });
1308
+
1309
+ // ../loader-utils/src/lib/file-provider/data-view-file.ts
1310
+ var toNumber, DataViewFile;
1311
+ var init_data_view_file = __esm({
1312
+ "../loader-utils/src/lib/file-provider/data-view-file.ts"() {
1313
+ toNumber = (bigint) => {
1314
+ if (bigint > Number.MAX_SAFE_INTEGER) {
1315
+ throw new Error("Offset is out of bounds");
1316
+ }
1317
+ return Number(bigint);
1318
+ };
1319
+ DataViewFile = class {
1320
+ constructor(file) {
1321
+ this.file = file;
1322
+ }
1323
+ async destroy() {
1324
+ }
1325
+ async getUint8(offset) {
1326
+ return this.file.getUint8(toNumber(offset));
1327
+ }
1328
+ async getUint16(offset) {
1329
+ return this.file.getUint16(toNumber(offset), true);
1330
+ }
1331
+ async getUint32(offset) {
1332
+ return this.file.getUint32(toNumber(offset), true);
1333
+ }
1334
+ async getBigUint64(offset) {
1335
+ return this.file.getBigUint64(toNumber(offset), true);
1336
+ }
1337
+ async slice(startOffset, endOffset) {
1338
+ return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
1339
+ }
1340
+ get length() {
1341
+ return BigInt(this.file.byteLength);
1342
+ }
1343
+ };
1344
+ }
1345
+ });
1346
+
1184
1347
  // ../loader-utils/src/index.ts
1185
1348
  var init_src2 = __esm({
1186
1349
  "../loader-utils/src/index.ts"() {
1350
+ init_loader_types();
1187
1351
  init_assert();
1188
1352
  init_globals();
1189
1353
  init_parse_with_worker();
@@ -1196,6 +1360,9 @@
1196
1360
  init_memory_conversion_utils();
1197
1361
  init_promisify();
1198
1362
  init_path();
1363
+ init_file_provider();
1364
+ init_file_handle_file();
1365
+ init_data_view_file();
1199
1366
  }
1200
1367
  });
1201
1368
 
@@ -5759,7 +5926,7 @@
5759
5926
  for (const key of propNames) {
5760
5927
  const value = object[key];
5761
5928
  if (typeof value === "function") {
5762
- if (!predefined.find((name10) => key === name10)) {
5929
+ if (!predefined.find((name12) => key === name12)) {
5763
5930
  object[key] = value.bind(obj);
5764
5931
  }
5765
5932
  }
@@ -6257,6 +6424,11 @@
6257
6424
  loaders._state = loaders._state || {};
6258
6425
  return loaders._state;
6259
6426
  }
6427
+ function getGlobalLoaderOptions() {
6428
+ const state = getGlobalLoaderState();
6429
+ state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6430
+ return state.globalOptions;
6431
+ }
6260
6432
  function normalizeOptions(options, loader, loaders, url) {
6261
6433
  loaders = loaders || [];
6262
6434
  loaders = Array.isArray(loaders) ? loaders : [loaders];
@@ -6337,17 +6509,11 @@
6337
6509
  options.baseUri = url;
6338
6510
  }
6339
6511
  }
6340
- var getGlobalLoaderOptions;
6341
6512
  var init_option_utils = __esm({
6342
6513
  "../core/src/lib/loader-utils/option-utils.ts"() {
6343
6514
  init_is_type();
6344
6515
  init_loggers();
6345
6516
  init_option_defaults();
6346
- getGlobalLoaderOptions = () => {
6347
- const state = getGlobalLoaderState();
6348
- state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6349
- return state.globalOptions;
6350
- };
6351
6517
  }
6352
6518
  });
6353
6519
 
@@ -6468,8 +6634,10 @@
6468
6634
  reason = reason || (loader ? `matched MIME type ${type}` : "");
6469
6635
  loader = loader || findLoaderByInitialBytes(loaders, data);
6470
6636
  reason = reason || (loader ? `matched initial data ${getFirstCharacters2(data)}` : "");
6471
- loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6472
- reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6637
+ if (options?.fallbackMimeType) {
6638
+ loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6639
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6640
+ }
6473
6641
  if (reason) {
6474
6642
  log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
6475
6643
  }
@@ -6565,7 +6733,7 @@
6565
6733
  }
6566
6734
  switch (typeof test) {
6567
6735
  case "function":
6568
- return test(data, loader);
6736
+ return test(data);
6569
6737
  case "string":
6570
6738
  const magic = getMagicString2(data, byteOffset, test.length);
6571
6739
  return test === magic;
@@ -6838,7 +7006,7 @@
6838
7006
  return newContext;
6839
7007
  }
6840
7008
  function getLoadersFromContext(loaders, context) {
6841
- if (!context && loaders && !Array.isArray(loaders)) {
7009
+ if (loaders && !Array.isArray(loaders)) {
6842
7010
  return loaders;
6843
7011
  }
6844
7012
  let candidateLoaders;
@@ -6849,7 +7017,7 @@
6849
7017
  const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
6850
7018
  candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
6851
7019
  }
6852
- return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
7020
+ return candidateLoaders && candidateLoaders.length ? candidateLoaders : void 0;
6853
7021
  }
6854
7022
  var init_loader_context = __esm({
6855
7023
  "../core/src/lib/loader-utils/loader-context.ts"() {
@@ -6861,7 +7029,6 @@
6861
7029
 
6862
7030
  // ../core/src/lib/api/parse.ts
6863
7031
  async function parse(data, loaders, options, context) {
6864
- assert3(!context || typeof context === "object");
6865
7032
  if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
6866
7033
  context = void 0;
6867
7034
  options = loaders;
@@ -6877,7 +7044,7 @@
6877
7044
  return null;
6878
7045
  }
6879
7046
  options = normalizeOptions(options, loader, candidateLoaders, url);
6880
- context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
7047
+ context = getLoaderContext({ url, _parse: parse, loaders: candidateLoaders }, options, context || null);
6881
7048
  return await parseWithLoader(loader, data, options, context);
6882
7049
  }
6883
7050
  async function parseWithLoader(loader, data, options, context) {
@@ -7136,11 +7303,11 @@
7136
7303
  });
7137
7304
 
7138
7305
  // ../schema/src/lib/mesh/deduce-mesh-schema.ts
7139
- function deduceMeshField(name10, attribute, optionalMetadata) {
7306
+ function deduceMeshField(name12, attribute, optionalMetadata) {
7140
7307
  const type = getDataTypeFromTypedArray(attribute.value);
7141
7308
  const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
7142
7309
  return {
7143
- name: name10,
7310
+ name: name12,
7144
7311
  type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
7145
7312
  nullable: false,
7146
7313
  metadata
@@ -7716,8 +7883,8 @@
7716
7883
  }
7717
7884
  throw new Error(ERR_TYPE_CONVERSION);
7718
7885
  }
7719
- static fromName(name10) {
7720
- const glType = NAME_TO_GL_TYPE[name10];
7886
+ static fromName(name12) {
7887
+ const glType = NAME_TO_GL_TYPE[name12];
7721
7888
  if (!glType) {
7722
7889
  throw new Error(ERR_TYPE_CONVERSION);
7723
7890
  }
@@ -7820,6 +7987,15 @@
7820
7987
  }
7821
7988
  });
7822
7989
 
7990
+ // ../math/src/geometry/utils/coordinates.ts
7991
+ function emod(n2) {
7992
+ return (n2 % 1 + 1) % 1;
7993
+ }
7994
+ var init_coordinates = __esm({
7995
+ "../math/src/geometry/utils/coordinates.ts"() {
7996
+ }
7997
+ });
7998
+
7823
7999
  // ../math/src/index.ts
7824
8000
  var init_src7 = __esm({
7825
8001
  "../math/src/index.ts"() {
@@ -7827,6 +8003,7 @@
7827
8003
  init_gl_type();
7828
8004
  init_rgb565();
7829
8005
  init_attribute_compression();
8006
+ init_coordinates();
7830
8007
  }
7831
8008
  });
7832
8009
 
@@ -8276,10 +8453,10 @@
8276
8453
  }
8277
8454
  return void 0;
8278
8455
  }
8279
- hasProperty(batchId, name10) {
8456
+ hasProperty(batchId, name12) {
8280
8457
  this._checkBatchId(batchId);
8281
- assert2(typeof name10 === "string", name10);
8282
- return defined2(this._properties[name10]) || this._hasPropertyInHierarchy(batchId, name10);
8458
+ assert2(typeof name12 === "string", name12);
8459
+ return defined2(this._properties[name12]) || this._hasPropertyInHierarchy(batchId, name12);
8283
8460
  }
8284
8461
  getPropertyNames(batchId, results) {
8285
8462
  this._checkBatchId(batchId);
@@ -8292,47 +8469,47 @@
8292
8469
  }
8293
8470
  return results;
8294
8471
  }
8295
- getProperty(batchId, name10) {
8472
+ getProperty(batchId, name12) {
8296
8473
  this._checkBatchId(batchId);
8297
- assert2(typeof name10 === "string", name10);
8474
+ assert2(typeof name12 === "string", name12);
8298
8475
  if (this._binaryProperties) {
8299
- const binaryProperty = this._binaryProperties[name10];
8476
+ const binaryProperty = this._binaryProperties[name12];
8300
8477
  if (defined2(binaryProperty)) {
8301
8478
  return this._getBinaryProperty(binaryProperty, batchId);
8302
8479
  }
8303
8480
  }
8304
- const propertyValues = this._properties[name10];
8481
+ const propertyValues = this._properties[name12];
8305
8482
  if (defined2(propertyValues)) {
8306
8483
  return clone3(propertyValues[batchId], true);
8307
8484
  }
8308
8485
  if (this._hierarchy) {
8309
- const hierarchyProperty = this._getHierarchyProperty(batchId, name10);
8486
+ const hierarchyProperty = this._getHierarchyProperty(batchId, name12);
8310
8487
  if (defined2(hierarchyProperty)) {
8311
8488
  return hierarchyProperty;
8312
8489
  }
8313
8490
  }
8314
8491
  return void 0;
8315
8492
  }
8316
- setProperty(batchId, name10, value) {
8493
+ setProperty(batchId, name12, value) {
8317
8494
  const featureCount = this.featureCount;
8318
8495
  this._checkBatchId(batchId);
8319
- assert2(typeof name10 === "string", name10);
8496
+ assert2(typeof name12 === "string", name12);
8320
8497
  if (this._binaryProperties) {
8321
- const binaryProperty = this._binaryProperties[name10];
8498
+ const binaryProperty = this._binaryProperties[name12];
8322
8499
  if (binaryProperty) {
8323
8500
  this._setBinaryProperty(binaryProperty, batchId, value);
8324
8501
  return;
8325
8502
  }
8326
8503
  }
8327
8504
  if (this._hierarchy) {
8328
- if (this._setHierarchyProperty(this, batchId, name10, value)) {
8505
+ if (this._setHierarchyProperty(this, batchId, name12, value)) {
8329
8506
  return;
8330
8507
  }
8331
8508
  }
8332
- let propertyValues = this._properties[name10];
8509
+ let propertyValues = this._properties[name12];
8333
8510
  if (!defined2(propertyValues)) {
8334
- this._properties[name10] = new Array(featureCount);
8335
- propertyValues = this._properties[name10];
8511
+ this._properties[name12] = new Array(featureCount);
8512
+ propertyValues = this._properties[name12];
8336
8513
  }
8337
8514
  propertyValues[batchId] = clone3(value, true);
8338
8515
  }
@@ -8350,21 +8527,21 @@
8350
8527
  }
8351
8528
  _initializeBinaryProperties() {
8352
8529
  let binaryProperties = null;
8353
- for (const name10 in this._properties) {
8354
- const property = this._properties[name10];
8355
- const binaryProperty = this._initializeBinaryProperty(name10, property);
8530
+ for (const name12 in this._properties) {
8531
+ const property = this._properties[name12];
8532
+ const binaryProperty = this._initializeBinaryProperty(name12, property);
8356
8533
  if (binaryProperty) {
8357
8534
  binaryProperties = binaryProperties || {};
8358
- binaryProperties[name10] = binaryProperty;
8535
+ binaryProperties[name12] = binaryProperty;
8359
8536
  }
8360
8537
  }
8361
8538
  return binaryProperties;
8362
8539
  }
8363
- _initializeBinaryProperty(name10, property) {
8540
+ _initializeBinaryProperty(name12, property) {
8364
8541
  if ("byteOffset" in property) {
8365
8542
  const tile3DAccessor = property;
8366
- assert2(this.binary, `Property ${name10} requires a batch table binary.`);
8367
- assert2(tile3DAccessor.type, `Property ${name10} requires a type.`);
8543
+ assert2(this.binary, `Property ${name12} requires a batch table binary.`);
8544
+ assert2(tile3DAccessor.type, `Property ${name12} requires a type.`);
8368
8545
  const accessor = createTypedArrayFromAccessor(tile3DAccessor, this.binary.buffer, this.binary.byteOffset | 0, this.featureCount);
8369
8546
  return {
8370
8547
  typedArray: accessor.values,
@@ -8375,14 +8552,14 @@
8375
8552
  }
8376
8553
  return null;
8377
8554
  }
8378
- _hasPropertyInHierarchy(batchId, name10) {
8555
+ _hasPropertyInHierarchy(batchId, name12) {
8379
8556
  if (!this._hierarchy) {
8380
8557
  return false;
8381
8558
  }
8382
8559
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8383
8560
  const classId = hierarchy.classIds[instanceIndex];
8384
8561
  const instances = hierarchy.classes[classId].instances;
8385
- return defined2(instances[name10]);
8562
+ return defined2(instances[name12]);
8386
8563
  });
8387
8564
  return defined2(result);
8388
8565
  }
@@ -8390,21 +8567,21 @@
8390
8567
  traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8391
8568
  const classId = hierarchy.classIds[instanceIndex];
8392
8569
  const instances = hierarchy.classes[classId].instances;
8393
- for (const name10 in instances) {
8394
- if (instances.hasOwnProperty(name10)) {
8395
- if (results.indexOf(name10) === -1) {
8396
- results.push(name10);
8570
+ for (const name12 in instances) {
8571
+ if (instances.hasOwnProperty(name12)) {
8572
+ if (results.indexOf(name12) === -1) {
8573
+ results.push(name12);
8397
8574
  }
8398
8575
  }
8399
8576
  }
8400
8577
  });
8401
8578
  }
8402
- _getHierarchyProperty(batchId, name10) {
8579
+ _getHierarchyProperty(batchId, name12) {
8403
8580
  return traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8404
8581
  const classId = hierarchy.classIds[instanceIndex];
8405
8582
  const instanceClass = hierarchy.classes[classId];
8406
8583
  const indexInClass = hierarchy.classIndexes[instanceIndex];
8407
- const propertyValues = instanceClass.instances[name10];
8584
+ const propertyValues = instanceClass.instances[name12];
8408
8585
  if (defined2(propertyValues)) {
8409
8586
  if (defined2(propertyValues.typedArray)) {
8410
8587
  return this._getBinaryProperty(propertyValues, indexInClass);
@@ -8414,14 +8591,14 @@
8414
8591
  return null;
8415
8592
  });
8416
8593
  }
8417
- _setHierarchyProperty(batchTable, batchId, name10, value) {
8594
+ _setHierarchyProperty(batchTable, batchId, name12, value) {
8418
8595
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8419
8596
  const classId = hierarchy.classIds[instanceIndex];
8420
8597
  const instanceClass = hierarchy.classes[classId];
8421
8598
  const indexInClass = hierarchy.classIndexes[instanceIndex];
8422
- const propertyValues = instanceClass.instances[name10];
8599
+ const propertyValues = instanceClass.instances[name12];
8423
8600
  if (defined2(propertyValues)) {
8424
- assert2(instanceIndex === batchId, `Inherited property "${name10}" is read-only.`);
8601
+ assert2(instanceIndex === batchId, `Inherited property "${name12}" is read-only.`);
8425
8602
  if (defined2(propertyValues.typedArray)) {
8426
8603
  this._setBinaryProperty(propertyValues, indexInClass, value);
8427
8604
  } else {
@@ -8823,7 +9000,6 @@
8823
9000
  if (!context) {
8824
9001
  return;
8825
9002
  }
8826
- const { parse: parse5 } = context;
8827
9003
  const dracoOptions = {
8828
9004
  ...options,
8829
9005
  draco: {
@@ -8832,7 +9008,7 @@
8832
9008
  }
8833
9009
  };
8834
9010
  delete dracoOptions["3d-tiles"];
8835
- const data = await parse5(dracoData.buffer, DracoLoader2, dracoOptions);
9011
+ const data = await parseFromContext(dracoData.buffer, DracoLoader2, dracoOptions, context);
8836
9012
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
8837
9013
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
8838
9014
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
@@ -8870,6 +9046,7 @@
8870
9046
  var init_parse_3d_tile_point_cloud = __esm({
8871
9047
  "src/lib/parsers/parse-3d-tile-point-cloud.ts"() {
8872
9048
  init_src6();
9049
+ init_src2();
8873
9050
  init_src7();
8874
9051
  init_esm();
8875
9052
  init_tile_3d_feature_table();
@@ -8882,19 +9059,11 @@
8882
9059
  }
8883
9060
  });
8884
9061
 
8885
- // ../gltf/src/lib/utils/version.ts
9062
+ // ../images/src/lib/utils/version.ts
8886
9063
  var VERSION6;
8887
9064
  var init_version4 = __esm({
8888
- "../gltf/src/lib/utils/version.ts"() {
8889
- VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8890
- }
8891
- });
8892
-
8893
- // ../images/src/lib/utils/version.ts
8894
- var VERSION7;
8895
- var init_version5 = __esm({
8896
9065
  "../images/src/lib/utils/version.ts"() {
8897
- VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
9066
+ VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8898
9067
  }
8899
9068
  });
8900
9069
 
@@ -9319,7 +9488,7 @@
9319
9488
  var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
9320
9489
  var init_image_loader = __esm({
9321
9490
  "../images/src/image-loader.ts"() {
9322
- init_version5();
9491
+ init_version4();
9323
9492
  init_parse_image();
9324
9493
  init_binary_image_api();
9325
9494
  EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
@@ -9343,7 +9512,7 @@
9343
9512
  id: "image",
9344
9513
  module: "images",
9345
9514
  name: "Images",
9346
- version: VERSION7,
9515
+ version: VERSION6,
9347
9516
  mimeTypes: MIME_TYPES,
9348
9517
  extensions: EXTENSIONS,
9349
9518
  parse: parseImage,
@@ -9402,845 +9571,226 @@
9402
9571
  }
9403
9572
  });
9404
9573
 
9405
- // ../textures/src/lib/utils/version.ts
9406
- var VERSION8;
9407
- var init_version6 = __esm({
9408
- "../textures/src/lib/utils/version.ts"() {
9409
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
9410
- }
9411
- });
9412
-
9413
- // ../textures/src/lib/parsers/basis-module-loader.ts
9414
- async function loadBasisTranscoderModule(options) {
9415
- const modules = options.modules || {};
9416
- if (modules.basis) {
9417
- return modules.basis;
9574
+ // ../gltf/src/lib/utils/assert.ts
9575
+ function assert7(condition, message) {
9576
+ if (!condition) {
9577
+ throw new Error(message || "assert failed: gltf");
9418
9578
  }
9419
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
9420
- return await loadBasisTranscoderPromise;
9421
- }
9422
- async function loadBasisTranscoder(options) {
9423
- let BASIS = null;
9424
- let wasmBinary = null;
9425
- [BASIS, wasmBinary] = await Promise.all([
9426
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
9427
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
9428
- ]);
9429
- BASIS = BASIS || globalThis.BASIS;
9430
- return await initializeBasisTranscoderModule(BASIS, wasmBinary);
9431
9579
  }
9432
- function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
9433
- const options = {};
9434
- if (wasmBinary) {
9435
- options.wasmBinary = wasmBinary;
9580
+ var init_assert6 = __esm({
9581
+ "../gltf/src/lib/utils/assert.ts"() {
9436
9582
  }
9437
- return new Promise((resolve2) => {
9438
- BasisModule(options).then((module) => {
9439
- const { BasisFile, initializeBasis } = module;
9440
- initializeBasis();
9441
- resolve2({ BasisFile });
9442
- });
9443
- });
9583
+ });
9584
+
9585
+ // ../gltf/src/lib/gltf-utils/gltf-utils.ts
9586
+ function getAccessorTypeFromSize(size) {
9587
+ const type = TYPES[size - 1];
9588
+ return type || TYPES[0];
9444
9589
  }
9445
- async function loadBasisEncoderModule(options) {
9446
- const modules = options.modules || {};
9447
- if (modules.basisEncoder) {
9448
- return modules.basisEncoder;
9590
+ function getComponentTypeFromArray(typedArray) {
9591
+ const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);
9592
+ if (!componentType) {
9593
+ throw new Error("Illegal typed array");
9449
9594
  }
9450
- loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
9451
- return await loadBasisEncoderPromise;
9595
+ return componentType;
9452
9596
  }
9453
- async function loadBasisEncoder(options) {
9454
- let BASIS_ENCODER = null;
9455
- let wasmBinary = null;
9456
- [BASIS_ENCODER, wasmBinary] = await Promise.all([
9457
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
9458
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
9459
- ]);
9460
- BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
9461
- return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
9597
+ function getAccessorArrayTypeAndLength(accessor, bufferView) {
9598
+ const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];
9599
+ const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];
9600
+ const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
9601
+ const length4 = accessor.count * components;
9602
+ const byteLength = accessor.count * components * bytesPerComponent;
9603
+ assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
9604
+ return { ArrayType, length: length4, byteLength };
9462
9605
  }
9463
- function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
9464
- const options = {};
9465
- if (wasmBinary) {
9466
- options.wasmBinary = wasmBinary;
9467
- }
9468
- return new Promise((resolve2) => {
9469
- BasisEncoderModule(options).then((module) => {
9470
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
9471
- initializeBasis();
9472
- resolve2({ BasisFile, KTX2File, BasisEncoder });
9473
- });
9474
- });
9606
+ function getMemoryUsageGLTF(gltf) {
9607
+ let { images, bufferViews } = gltf;
9608
+ images = images || [];
9609
+ bufferViews = bufferViews || [];
9610
+ const imageBufferViews = images.map((i2) => i2.bufferView);
9611
+ bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
9612
+ const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
9613
+ const pixelCount = images.reduce((acc, image) => {
9614
+ const { width, height } = image.image;
9615
+ return acc + width * height;
9616
+ }, 0);
9617
+ return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
9475
9618
  }
9476
- var BASIS_EXTERNAL_LIBRARIES, loadBasisTranscoderPromise, loadBasisEncoderPromise;
9477
- var init_basis_module_loader = __esm({
9478
- "../textures/src/lib/parsers/basis-module-loader.ts"() {
9479
- init_src();
9480
- BASIS_EXTERNAL_LIBRARIES = {
9481
- TRANSCODER: "basis_transcoder.js",
9482
- TRANSCODER_WASM: "basis_transcoder.wasm",
9483
- ENCODER: "basis_encoder.js",
9484
- ENCODER_WASM: "basis_encoder.wasm"
9619
+ var MIPMAP_FACTOR, 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;
9620
+ var init_gltf_utils = __esm({
9621
+ "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
9622
+ init_assert6();
9623
+ MIPMAP_FACTOR = 1.33;
9624
+ TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
9625
+ ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
9626
+ [Int8Array, 5120],
9627
+ [Uint8Array, 5121],
9628
+ [Int16Array, 5122],
9629
+ [Uint16Array, 5123],
9630
+ [Uint32Array, 5125],
9631
+ [Float32Array, 5126],
9632
+ [Float64Array, 5130]
9633
+ ];
9634
+ ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);
9635
+ ATTRIBUTE_TYPE_TO_COMPONENTS = {
9636
+ SCALAR: 1,
9637
+ VEC2: 2,
9638
+ VEC3: 3,
9639
+ VEC4: 4,
9640
+ MAT2: 4,
9641
+ MAT3: 9,
9642
+ MAT4: 16
9643
+ };
9644
+ ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
9645
+ 5120: 1,
9646
+ 5121: 1,
9647
+ 5122: 2,
9648
+ 5123: 2,
9649
+ 5125: 4,
9650
+ 5126: 4
9651
+ };
9652
+ ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
9653
+ 5120: Int8Array,
9654
+ 5121: Uint8Array,
9655
+ 5122: Int16Array,
9656
+ 5123: Uint16Array,
9657
+ 5125: Uint32Array,
9658
+ 5126: Float32Array
9485
9659
  };
9486
9660
  }
9487
9661
  });
9488
9662
 
9489
- // ../textures/src/lib/gl-extensions.ts
9490
- var GL_EXTENSIONS_CONSTANTS;
9491
- var init_gl_extensions = __esm({
9492
- "../textures/src/lib/gl-extensions.ts"() {
9493
- GL_EXTENSIONS_CONSTANTS = {
9494
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
9495
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
9496
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
9497
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
9498
- COMPRESSED_R11_EAC: 37488,
9499
- COMPRESSED_SIGNED_R11_EAC: 37489,
9500
- COMPRESSED_RG11_EAC: 37490,
9501
- COMPRESSED_SIGNED_RG11_EAC: 37491,
9502
- COMPRESSED_RGB8_ETC2: 37492,
9503
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
9504
- COMPRESSED_SRGB8_ETC2: 37494,
9505
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
9506
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
9507
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
9508
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
9509
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
9510
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
9511
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
9512
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
9513
- COMPRESSED_RGB_ATC_WEBGL: 35986,
9514
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
9515
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
9516
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
9517
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
9518
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
9519
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
9520
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
9521
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
9522
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
9523
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
9524
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
9525
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
9526
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
9527
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
9528
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
9529
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
9530
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
9531
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
9532
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
9533
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
9534
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
9535
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
9536
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
9537
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
9538
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
9539
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
9540
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
9541
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
9542
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
9543
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
9544
- COMPRESSED_RED_RGTC1_EXT: 36283,
9545
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
9546
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
9547
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
9548
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
9549
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
9550
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
9551
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
9552
- };
9553
- }
9554
- });
9555
-
9556
- // ../textures/src/lib/utils/texture-formats.ts
9557
- function getSupportedGPUTextureFormats(gl) {
9558
- if (!formats) {
9559
- gl = gl || getWebGLContext() || void 0;
9560
- formats = new Set();
9561
- for (const prefix of BROWSER_PREFIXES) {
9562
- for (const extension in WEBGL_EXTENSIONS) {
9563
- if (gl && gl.getExtension(`${prefix}${extension}`)) {
9564
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
9565
- formats.add(gpuTextureFormat);
9663
+ // ../gltf/src/lib/api/gltf-scenegraph.ts
9664
+ function makeDefaultGLTFJson() {
9665
+ return {
9666
+ asset: {
9667
+ version: "2.0",
9668
+ generator: "loaders.gl"
9669
+ },
9670
+ buffers: [],
9671
+ extensions: {},
9672
+ extensionsRequired: [],
9673
+ extensionsUsed: []
9674
+ };
9675
+ }
9676
+ var GLTFScenegraph;
9677
+ var init_gltf_scenegraph = __esm({
9678
+ "../gltf/src/lib/api/gltf-scenegraph.ts"() {
9679
+ init_src8();
9680
+ init_src2();
9681
+ init_assert6();
9682
+ init_gltf_utils();
9683
+ GLTFScenegraph = class {
9684
+ constructor(gltf) {
9685
+ this.gltf = {
9686
+ json: gltf?.json || makeDefaultGLTFJson(),
9687
+ buffers: gltf?.buffers || [],
9688
+ images: gltf?.images || []
9689
+ };
9690
+ this.sourceBuffers = [];
9691
+ this.byteLength = 0;
9692
+ if (this.gltf.buffers && this.gltf.buffers[0]) {
9693
+ this.byteLength = this.gltf.buffers[0].byteLength;
9694
+ this.sourceBuffers = [this.gltf.buffers[0]];
9566
9695
  }
9567
9696
  }
9568
- }
9569
- }
9570
- return formats;
9571
- }
9572
- function getWebGLContext() {
9573
- try {
9574
- const canvas = document.createElement("canvas");
9575
- return canvas.getContext("webgl");
9576
- } catch (error) {
9577
- return null;
9578
- }
9579
- }
9580
- var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
9581
- var init_texture_formats = __esm({
9582
- "../textures/src/lib/utils/texture-formats.ts"() {
9583
- BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
9584
- WEBGL_EXTENSIONS = {
9585
- WEBGL_compressed_texture_s3tc: "dxt",
9586
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
9587
- WEBGL_compressed_texture_etc1: "etc1",
9588
- WEBGL_compressed_texture_etc: "etc2",
9589
- WEBGL_compressed_texture_pvrtc: "pvrtc",
9590
- WEBGL_compressed_texture_atc: "atc",
9591
- WEBGL_compressed_texture_astc: "astc",
9592
- EXT_texture_compression_rgtc: "rgtc"
9593
- };
9594
- formats = null;
9595
- }
9596
- });
9597
-
9598
- // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
9599
- var t, n, i, s, a, r, o, l, f;
9600
- var init_ktx_parse_modern = __esm({
9601
- "../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
9602
- t = new Uint8Array([0]);
9603
- !function(t2) {
9604
- t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
9605
- }(n || (n = {})), function(t2) {
9606
- t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
9607
- }(i || (i = {})), function(t2) {
9608
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
9609
- }(s || (s = {})), function(t2) {
9610
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
9611
- }(a || (a = {})), function(t2) {
9612
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.LINEAR = 1] = "LINEAR", t2[t2.SRGB = 2] = "SRGB", t2[t2.ITU = 3] = "ITU", t2[t2.NTSC = 4] = "NTSC", t2[t2.SLOG = 5] = "SLOG", t2[t2.SLOG2 = 6] = "SLOG2";
9613
- }(r || (r = {})), function(t2) {
9614
- t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
9615
- }(o || (o = {})), function(t2) {
9616
- t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
9617
- }(l || (l = {})), function(t2) {
9618
- t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
9619
- }(f || (f = {}));
9620
- }
9621
- });
9622
-
9623
- // ../textures/src/lib/parsers/parse-ktx.ts
9624
- function isKTX(data) {
9625
- const id = new Uint8Array(data);
9626
- const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
9627
- return !notKTX;
9628
- }
9629
- var KTX2_ID;
9630
- var init_parse_ktx = __esm({
9631
- "../textures/src/lib/parsers/parse-ktx.ts"() {
9632
- init_ktx_parse_modern();
9633
- KTX2_ID = [
9634
- 171,
9635
- 75,
9636
- 84,
9637
- 88,
9638
- 32,
9639
- 50,
9640
- 48,
9641
- 187,
9642
- 13,
9643
- 10,
9644
- 26,
9645
- 10
9646
- ];
9647
- }
9648
- });
9649
-
9650
- // ../textures/src/lib/parsers/parse-basis.ts
9651
- async function parseBasis(data, options) {
9652
- if (options.basis.containerFormat === "auto") {
9653
- if (isKTX(data)) {
9654
- const fileConstructors = await loadBasisEncoderModule(options);
9655
- return parseKTX2File(fileConstructors.KTX2File, data, options);
9656
- }
9657
- const { BasisFile } = await loadBasisTranscoderModule(options);
9658
- return parseBasisFile(BasisFile, data, options);
9659
- }
9660
- switch (options.basis.module) {
9661
- case "encoder":
9662
- const fileConstructors = await loadBasisEncoderModule(options);
9663
- switch (options.basis.containerFormat) {
9664
- case "ktx2":
9665
- return parseKTX2File(fileConstructors.KTX2File, data, options);
9666
- case "basis":
9667
- default:
9668
- return parseBasisFile(fileConstructors.BasisFile, data, options);
9697
+ get json() {
9698
+ return this.gltf.json;
9669
9699
  }
9670
- case "transcoder":
9671
- default:
9672
- const { BasisFile } = await loadBasisTranscoderModule(options);
9673
- return parseBasisFile(BasisFile, data, options);
9674
- }
9675
- }
9676
- function parseBasisFile(BasisFile, data, options) {
9677
- const basisFile = new BasisFile(new Uint8Array(data));
9678
- try {
9679
- if (!basisFile.startTranscoding()) {
9680
- throw new Error("Failed to start basis transcoding");
9681
- }
9682
- const imageCount = basisFile.getNumImages();
9683
- const images = [];
9684
- for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
9685
- const levelsCount = basisFile.getNumLevels(imageIndex);
9686
- const levels = [];
9687
- for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
9688
- levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
9700
+ getApplicationData(key) {
9701
+ const data = this.json[key];
9702
+ return data;
9689
9703
  }
9690
- images.push(levels);
9691
- }
9692
- return images;
9693
- } finally {
9694
- basisFile.close();
9695
- basisFile.delete();
9696
- }
9697
- }
9698
- function transcodeImage(basisFile, imageIndex, levelIndex, options) {
9699
- const width = basisFile.getImageWidth(imageIndex, levelIndex);
9700
- const height = basisFile.getImageHeight(imageIndex, levelIndex);
9701
- const hasAlpha = basisFile.getHasAlpha();
9702
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
9703
- const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
9704
- const decodedData = new Uint8Array(decodedSize);
9705
- if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
9706
- throw new Error("failed to start Basis transcoding");
9707
- }
9708
- return {
9709
- width,
9710
- height,
9711
- data: decodedData,
9712
- compressed,
9713
- format,
9714
- hasAlpha
9715
- };
9716
- }
9717
- function parseKTX2File(KTX2File, data, options) {
9718
- const ktx2File = new KTX2File(new Uint8Array(data));
9719
- try {
9720
- if (!ktx2File.startTranscoding()) {
9721
- throw new Error("failed to start KTX2 transcoding");
9722
- }
9723
- const levelsCount = ktx2File.getLevels();
9724
- const levels = [];
9725
- for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
9726
- levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
9727
- break;
9728
- }
9729
- return [levels];
9730
- } finally {
9731
- ktx2File.close();
9732
- ktx2File.delete();
9733
- }
9734
- }
9735
- function transcodeKTX2Image(ktx2File, levelIndex, options) {
9736
- const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
9737
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
9738
- const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
9739
- const decodedData = new Uint8Array(decodedSize);
9740
- if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
9741
- throw new Error("Failed to transcode KTX2 image");
9742
- }
9743
- return {
9744
- width,
9745
- height,
9746
- data: decodedData,
9747
- compressed,
9748
- levelSize: decodedSize,
9749
- hasAlpha: alphaFlag,
9750
- format
9751
- };
9752
- }
9753
- function getBasisOptions(options, hasAlpha) {
9754
- let format = options && options.basis && options.basis.format;
9755
- if (format === "auto") {
9756
- format = selectSupportedBasisFormat();
9757
- }
9758
- if (typeof format === "object") {
9759
- format = hasAlpha ? format.alpha : format.noAlpha;
9760
- }
9761
- format = format.toLowerCase();
9762
- return OutputFormat[format];
9763
- }
9764
- function selectSupportedBasisFormat() {
9765
- const supportedFormats = getSupportedGPUTextureFormats();
9766
- if (supportedFormats.has("astc")) {
9767
- return "astc-4x4";
9768
- } else if (supportedFormats.has("dxt")) {
9769
- return {
9770
- alpha: "bc3",
9771
- noAlpha: "bc1"
9772
- };
9773
- } else if (supportedFormats.has("pvrtc")) {
9774
- return {
9775
- alpha: "pvrtc1-4-rgba",
9776
- noAlpha: "pvrtc1-4-rgb"
9777
- };
9778
- } else if (supportedFormats.has("etc1")) {
9779
- return "etc1";
9780
- } else if (supportedFormats.has("etc2")) {
9781
- return "etc2";
9782
- }
9783
- return "rgb565";
9784
- }
9785
- var OutputFormat;
9786
- var init_parse_basis = __esm({
9787
- "../textures/src/lib/parsers/parse-basis.ts"() {
9788
- init_basis_module_loader();
9789
- init_gl_extensions();
9790
- init_texture_formats();
9791
- init_parse_ktx();
9792
- OutputFormat = {
9793
- etc1: {
9794
- basisFormat: 0,
9795
- compressed: true,
9796
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
9797
- },
9798
- etc2: { basisFormat: 1, compressed: true },
9799
- bc1: {
9800
- basisFormat: 2,
9801
- compressed: true,
9802
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
9803
- },
9804
- bc3: {
9805
- basisFormat: 3,
9806
- compressed: true,
9807
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
9808
- },
9809
- bc4: { basisFormat: 4, compressed: true },
9810
- bc5: { basisFormat: 5, compressed: true },
9811
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
9812
- "bc7-m5": { basisFormat: 7, compressed: true },
9813
- "pvrtc1-4-rgb": {
9814
- basisFormat: 8,
9815
- compressed: true,
9816
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
9817
- },
9818
- "pvrtc1-4-rgba": {
9819
- basisFormat: 9,
9820
- compressed: true,
9821
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
9822
- },
9823
- "astc-4x4": {
9824
- basisFormat: 10,
9825
- compressed: true,
9826
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
9827
- },
9828
- "atc-rgb": { basisFormat: 11, compressed: true },
9829
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
9830
- rgba32: { basisFormat: 13, compressed: false },
9831
- rgb565: { basisFormat: 14, compressed: false },
9832
- bgr565: { basisFormat: 15, compressed: false },
9833
- rgba4444: { basisFormat: 16, compressed: false }
9834
- };
9835
- }
9836
- });
9837
-
9838
- // ../textures/src/basis-loader.ts
9839
- var BasisWorkerLoader, BasisLoader;
9840
- var init_basis_loader = __esm({
9841
- "../textures/src/basis-loader.ts"() {
9842
- init_version6();
9843
- init_parse_basis();
9844
- BasisWorkerLoader = {
9845
- name: "Basis",
9846
- id: "basis",
9847
- module: "textures",
9848
- version: VERSION8,
9849
- worker: true,
9850
- extensions: ["basis", "ktx2"],
9851
- mimeTypes: ["application/octet-stream", "image/ktx2"],
9852
- tests: ["sB"],
9853
- binary: true,
9854
- options: {
9855
- basis: {
9856
- format: "auto",
9857
- libraryPath: "libs/",
9858
- containerFormat: "auto",
9859
- module: "transcoder"
9704
+ getExtraData(key) {
9705
+ const extras = this.json.extras || {};
9706
+ return extras[key];
9707
+ }
9708
+ hasExtension(extensionName) {
9709
+ const isUsedExtension = this.getUsedExtensions().find((name12) => name12 === extensionName);
9710
+ const isRequiredExtension = this.getRequiredExtensions().find((name12) => name12 === extensionName);
9711
+ return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
9712
+ }
9713
+ getExtension(extensionName) {
9714
+ const isExtension = this.getUsedExtensions().find((name12) => name12 === extensionName);
9715
+ const extensions = this.json.extensions || {};
9716
+ return isExtension ? extensions[extensionName] : null;
9717
+ }
9718
+ getRequiredExtension(extensionName) {
9719
+ const isRequired = this.getRequiredExtensions().find((name12) => name12 === extensionName);
9720
+ return isRequired ? this.getExtension(extensionName) : null;
9721
+ }
9722
+ getRequiredExtensions() {
9723
+ return this.json.extensionsRequired || [];
9724
+ }
9725
+ getUsedExtensions() {
9726
+ return this.json.extensionsUsed || [];
9727
+ }
9728
+ getRemovedExtensions() {
9729
+ return this.json.extensionsRemoved || [];
9730
+ }
9731
+ getObjectExtension(object, extensionName) {
9732
+ const extensions = object.extensions || {};
9733
+ return extensions[extensionName];
9734
+ }
9735
+ getScene(index) {
9736
+ return this.getObject("scenes", index);
9737
+ }
9738
+ getNode(index) {
9739
+ return this.getObject("nodes", index);
9740
+ }
9741
+ getSkin(index) {
9742
+ return this.getObject("skins", index);
9743
+ }
9744
+ getMesh(index) {
9745
+ return this.getObject("meshes", index);
9746
+ }
9747
+ getMaterial(index) {
9748
+ return this.getObject("materials", index);
9749
+ }
9750
+ getAccessor(index) {
9751
+ return this.getObject("accessors", index);
9752
+ }
9753
+ getTexture(index) {
9754
+ return this.getObject("textures", index);
9755
+ }
9756
+ getSampler(index) {
9757
+ return this.getObject("samplers", index);
9758
+ }
9759
+ getImage(index) {
9760
+ return this.getObject("images", index);
9761
+ }
9762
+ getBufferView(index) {
9763
+ return this.getObject("bufferViews", index);
9764
+ }
9765
+ getBuffer(index) {
9766
+ return this.getObject("buffers", index);
9767
+ }
9768
+ getObject(array, index) {
9769
+ if (typeof index === "object") {
9770
+ return index;
9771
+ }
9772
+ const object = this.json[array] && this.json[array][index];
9773
+ if (!object) {
9774
+ throw new Error(`glTF file error: Could not find ${array}[${index}]`);
9860
9775
  }
9776
+ return object;
9861
9777
  }
9862
- };
9863
- BasisLoader = {
9864
- ...BasisWorkerLoader,
9865
- parse: parseBasis
9866
- };
9867
- }
9868
- });
9869
-
9870
- // ../textures/src/index.ts
9871
- var init_src9 = __esm({
9872
- "../textures/src/index.ts"() {
9873
- init_basis_loader();
9874
- init_parse_basis();
9875
- }
9876
- });
9877
-
9878
- // ../gltf/src/lib/utils/assert.ts
9879
- function assert7(condition, message) {
9880
- if (!condition) {
9881
- throw new Error(message || "assert failed: gltf");
9882
- }
9883
- }
9884
- var init_assert6 = __esm({
9885
- "../gltf/src/lib/utils/assert.ts"() {
9886
- }
9887
- });
9888
-
9889
- // ../gltf/src/lib/parsers/parse-glb.ts
9890
- function getMagicString4(dataView, byteOffset = 0) {
9891
- 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))}`;
9892
- }
9893
- function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
9894
- const dataView = new DataView(arrayBuffer);
9895
- const { magic = MAGIC_glTF } = options;
9896
- const magic1 = dataView.getUint32(byteOffset, false);
9897
- return magic1 === magic || magic1 === MAGIC_glTF;
9898
- }
9899
- function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
9900
- const dataView = new DataView(arrayBuffer);
9901
- const type = getMagicString4(dataView, byteOffset + 0);
9902
- const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9903
- const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
9904
- Object.assign(glb, {
9905
- header: {
9906
- byteOffset,
9907
- byteLength,
9908
- hasBinChunk: false
9909
- },
9910
- type,
9911
- version,
9912
- json: {},
9913
- binChunks: []
9914
- });
9915
- byteOffset += GLB_FILE_HEADER_SIZE;
9916
- switch (glb.version) {
9917
- case 1:
9918
- return parseGLBV1(glb, dataView, byteOffset);
9919
- case 2:
9920
- return parseGLBV2(glb, dataView, byteOffset, options = {});
9921
- default:
9922
- throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
9923
- }
9924
- }
9925
- function parseGLBV1(glb, dataView, byteOffset) {
9926
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
9927
- const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
9928
- const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9929
- byteOffset += GLB_CHUNK_HEADER_SIZE;
9930
- assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
9931
- parseJSONChunk(glb, dataView, byteOffset, contentLength);
9932
- byteOffset += contentLength;
9933
- byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
9934
- return byteOffset;
9935
- }
9936
- function parseGLBV2(glb, dataView, byteOffset, options) {
9937
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
9938
- parseGLBChunksSync(glb, dataView, byteOffset, options);
9939
- return byteOffset + glb.header.byteLength;
9940
- }
9941
- function parseGLBChunksSync(glb, dataView, byteOffset, options) {
9942
- while (byteOffset + 8 <= glb.header.byteLength) {
9943
- const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
9944
- const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9945
- byteOffset += GLB_CHUNK_HEADER_SIZE;
9946
- switch (chunkFormat) {
9947
- case GLB_CHUNK_TYPE_JSON:
9948
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
9949
- break;
9950
- case GLB_CHUNK_TYPE_BIN:
9951
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
9952
- break;
9953
- case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
9954
- if (!options.strict) {
9955
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
9956
- }
9957
- break;
9958
- case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
9959
- if (!options.strict) {
9960
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
9961
- }
9962
- break;
9963
- default:
9964
- break;
9965
- }
9966
- byteOffset += padToNBytes(chunkLength, 4);
9967
- }
9968
- return byteOffset;
9969
- }
9970
- function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
9971
- const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
9972
- const textDecoder = new TextDecoder("utf8");
9973
- const jsonText = textDecoder.decode(jsonChunk);
9974
- glb.json = JSON.parse(jsonText);
9975
- return padToNBytes(chunkLength, 4);
9976
- }
9977
- function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
9978
- glb.header.hasBinChunk = true;
9979
- glb.binChunks.push({
9980
- byteOffset,
9981
- byteLength: chunkLength,
9982
- arrayBuffer: dataView.buffer
9983
- });
9984
- return padToNBytes(chunkLength, 4);
9985
- }
9986
- var LITTLE_ENDIAN2, MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_V1_CONTENT_FORMAT_JSON, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED;
9987
- var init_parse_glb = __esm({
9988
- "../gltf/src/lib/parsers/parse-glb.ts"() {
9989
- init_src2();
9990
- LITTLE_ENDIAN2 = true;
9991
- MAGIC_glTF = 1735152710;
9992
- GLB_FILE_HEADER_SIZE = 12;
9993
- GLB_CHUNK_HEADER_SIZE = 8;
9994
- GLB_CHUNK_TYPE_JSON = 1313821514;
9995
- GLB_CHUNK_TYPE_BIN = 5130562;
9996
- GLB_V1_CONTENT_FORMAT_JSON = 0;
9997
- GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
9998
- GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
9999
- }
10000
- });
10001
-
10002
- // ../gltf/src/lib/gltf-utils/resolve-url.ts
10003
- function resolveUrl(url, options) {
10004
- const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
10005
- if (absolute) {
10006
- return url;
10007
- }
10008
- const baseUrl = options.baseUri || options.uri;
10009
- if (!baseUrl) {
10010
- throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
10011
- }
10012
- return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
10013
- }
10014
- var init_resolve_url = __esm({
10015
- "../gltf/src/lib/gltf-utils/resolve-url.ts"() {
10016
- }
10017
- });
10018
-
10019
- // ../gltf/src/lib/gltf-utils/get-typed-array.ts
10020
- function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
10021
- const bufferView = json.bufferViews[bufferViewIndex];
10022
- assert7(bufferView);
10023
- const bufferIndex = bufferView.buffer;
10024
- const binChunk = buffers[bufferIndex];
10025
- assert7(binChunk);
10026
- const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
10027
- return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
10028
- }
10029
- var init_get_typed_array = __esm({
10030
- "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
10031
- init_assert6();
10032
- }
10033
- });
10034
-
10035
- // ../gltf/src/lib/gltf-utils/gltf-utils.ts
10036
- function getAccessorTypeFromSize(size) {
10037
- const type = TYPES[size - 1];
10038
- return type || TYPES[0];
10039
- }
10040
- function getComponentTypeFromArray(typedArray) {
10041
- const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);
10042
- if (!componentType) {
10043
- throw new Error("Illegal typed array");
10044
- }
10045
- return componentType;
10046
- }
10047
- function getAccessorArrayTypeAndLength(accessor, bufferView) {
10048
- const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];
10049
- const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];
10050
- const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
10051
- const length4 = accessor.count * components;
10052
- const byteLength = accessor.count * components * bytesPerComponent;
10053
- assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
10054
- return { ArrayType, length: length4, byteLength };
10055
- }
10056
- function getMemoryUsageGLTF(gltf) {
10057
- let { images, bufferViews } = gltf;
10058
- images = images || [];
10059
- bufferViews = bufferViews || [];
10060
- const imageBufferViews = images.map((i2) => i2.bufferView);
10061
- bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
10062
- const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
10063
- const pixelCount = images.reduce((acc, image) => {
10064
- const { width, height } = image.image;
10065
- return acc + width * height;
10066
- }, 0);
10067
- return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
10068
- }
10069
- var MIPMAP_FACTOR, 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;
10070
- var init_gltf_utils = __esm({
10071
- "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
10072
- init_assert6();
10073
- MIPMAP_FACTOR = 1.33;
10074
- TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
10075
- ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
10076
- [Int8Array, 5120],
10077
- [Uint8Array, 5121],
10078
- [Int16Array, 5122],
10079
- [Uint16Array, 5123],
10080
- [Uint32Array, 5125],
10081
- [Float32Array, 5126],
10082
- [Float64Array, 5130]
10083
- ];
10084
- ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);
10085
- ATTRIBUTE_TYPE_TO_COMPONENTS = {
10086
- SCALAR: 1,
10087
- VEC2: 2,
10088
- VEC3: 3,
10089
- VEC4: 4,
10090
- MAT2: 4,
10091
- MAT3: 9,
10092
- MAT4: 16
10093
- };
10094
- ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
10095
- 5120: 1,
10096
- 5121: 1,
10097
- 5122: 2,
10098
- 5123: 2,
10099
- 5125: 4,
10100
- 5126: 4
10101
- };
10102
- ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
10103
- 5120: Int8Array,
10104
- 5121: Uint8Array,
10105
- 5122: Int16Array,
10106
- 5123: Uint16Array,
10107
- 5125: Uint32Array,
10108
- 5126: Float32Array
10109
- };
10110
- }
10111
- });
10112
-
10113
- // ../gltf/src/lib/api/gltf-scenegraph.ts
10114
- function makeDefaultGLTFJson() {
10115
- return {
10116
- asset: {
10117
- version: "2.0",
10118
- generator: "loaders.gl"
10119
- },
10120
- buffers: [],
10121
- extensions: {},
10122
- extensionsRequired: [],
10123
- extensionsUsed: []
10124
- };
10125
- }
10126
- var GLTFScenegraph;
10127
- var init_gltf_scenegraph = __esm({
10128
- "../gltf/src/lib/api/gltf-scenegraph.ts"() {
10129
- init_src8();
10130
- init_src2();
10131
- init_assert6();
10132
- init_gltf_utils();
10133
- GLTFScenegraph = class {
10134
- constructor(gltf) {
10135
- this.gltf = {
10136
- json: gltf?.json || makeDefaultGLTFJson(),
10137
- buffers: gltf?.buffers || [],
10138
- images: gltf?.images || []
10139
- };
10140
- this.sourceBuffers = [];
10141
- this.byteLength = 0;
10142
- if (this.gltf.buffers && this.gltf.buffers[0]) {
10143
- this.byteLength = this.gltf.buffers[0].byteLength;
10144
- this.sourceBuffers = [this.gltf.buffers[0]];
10145
- }
9778
+ getTypedArrayForBufferView(bufferView) {
9779
+ bufferView = this.getBufferView(bufferView);
9780
+ const bufferIndex = bufferView.buffer;
9781
+ const binChunk = this.gltf.buffers[bufferIndex];
9782
+ assert7(binChunk);
9783
+ const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
9784
+ return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
10146
9785
  }
10147
- get json() {
10148
- return this.gltf.json;
10149
- }
10150
- getApplicationData(key) {
10151
- const data = this.json[key];
10152
- return data;
10153
- }
10154
- getExtraData(key) {
10155
- const extras = this.json.extras || {};
10156
- return extras[key];
10157
- }
10158
- hasExtension(extensionName) {
10159
- const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
10160
- const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
10161
- return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
10162
- }
10163
- getExtension(extensionName) {
10164
- const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
10165
- const extensions = this.json.extensions || {};
10166
- return isExtension ? extensions[extensionName] : null;
10167
- }
10168
- getRequiredExtension(extensionName) {
10169
- const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
10170
- return isRequired ? this.getExtension(extensionName) : null;
10171
- }
10172
- getRequiredExtensions() {
10173
- return this.json.extensionsRequired || [];
10174
- }
10175
- getUsedExtensions() {
10176
- return this.json.extensionsUsed || [];
10177
- }
10178
- getRemovedExtensions() {
10179
- return this.json.extensionsRemoved || [];
10180
- }
10181
- getObjectExtension(object, extensionName) {
10182
- const extensions = object.extensions || {};
10183
- return extensions[extensionName];
10184
- }
10185
- getScene(index) {
10186
- return this.getObject("scenes", index);
10187
- }
10188
- getNode(index) {
10189
- return this.getObject("nodes", index);
10190
- }
10191
- getSkin(index) {
10192
- return this.getObject("skins", index);
10193
- }
10194
- getMesh(index) {
10195
- return this.getObject("meshes", index);
10196
- }
10197
- getMaterial(index) {
10198
- return this.getObject("materials", index);
10199
- }
10200
- getAccessor(index) {
10201
- return this.getObject("accessors", index);
10202
- }
10203
- getTexture(index) {
10204
- return this.getObject("textures", index);
10205
- }
10206
- getSampler(index) {
10207
- return this.getObject("samplers", index);
10208
- }
10209
- getImage(index) {
10210
- return this.getObject("images", index);
10211
- }
10212
- getBufferView(index) {
10213
- return this.getObject("bufferViews", index);
10214
- }
10215
- getBuffer(index) {
10216
- return this.getObject("buffers", index);
10217
- }
10218
- getObject(array, index) {
10219
- if (typeof index === "object") {
10220
- return index;
10221
- }
10222
- const object = this.json[array] && this.json[array][index];
10223
- if (!object) {
10224
- throw new Error(`glTF file error: Could not find ${array}[${index}]`);
10225
- }
10226
- return object;
10227
- }
10228
- getTypedArrayForBufferView(bufferView) {
10229
- bufferView = this.getBufferView(bufferView);
10230
- const bufferIndex = bufferView.buffer;
10231
- const binChunk = this.gltf.buffers[bufferIndex];
10232
- assert7(binChunk);
10233
- const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
10234
- return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
10235
- }
10236
- getTypedArrayForAccessor(accessor) {
10237
- accessor = this.getAccessor(accessor);
10238
- const bufferView = this.getBufferView(accessor.bufferView);
10239
- const buffer = this.getBuffer(bufferView.buffer);
10240
- const arrayBuffer = buffer.data;
10241
- const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
10242
- const byteOffset = bufferView.byteOffset + accessor.byteOffset;
10243
- return new ArrayType(arrayBuffer, byteOffset, length4);
9786
+ getTypedArrayForAccessor(accessor) {
9787
+ accessor = this.getAccessor(accessor);
9788
+ const bufferView = this.getBufferView(accessor.bufferView);
9789
+ const buffer = this.getBuffer(bufferView.buffer);
9790
+ const arrayBuffer = buffer.data;
9791
+ const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
9792
+ const byteOffset = bufferView.byteOffset + accessor.byteOffset;
9793
+ return new ArrayType(arrayBuffer, byteOffset, length4);
10244
9794
  }
10245
9795
  getTypedArrayForImageData(image) {
10246
9796
  image = this.getAccessor(image);
@@ -10476,66 +10026,1432 @@
10476
10026
  }
10477
10027
  }
10478
10028
  }
10479
- _addAttributes(attributes = {}) {
10480
- const result = {};
10481
- for (const attributeKey in attributes) {
10482
- const attributeData = attributes[attributeKey];
10483
- const attrName = this._getGltfAttributeName(attributeKey);
10484
- const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
10485
- result[attrName] = accessor;
10486
- }
10487
- return result;
10029
+ _addAttributes(attributes = {}) {
10030
+ const result = {};
10031
+ for (const attributeKey in attributes) {
10032
+ const attributeData = attributes[attributeKey];
10033
+ const attrName = this._getGltfAttributeName(attributeKey);
10034
+ const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
10035
+ result[attrName] = accessor;
10036
+ }
10037
+ return result;
10038
+ }
10039
+ _addIndices(indices) {
10040
+ return this.addBinaryBuffer(indices, { size: 1 });
10041
+ }
10042
+ _getGltfAttributeName(attributeName) {
10043
+ switch (attributeName.toLowerCase()) {
10044
+ case "position":
10045
+ case "positions":
10046
+ case "vertices":
10047
+ return "POSITION";
10048
+ case "normal":
10049
+ case "normals":
10050
+ return "NORMAL";
10051
+ case "color":
10052
+ case "colors":
10053
+ return "COLOR_0";
10054
+ case "texcoord":
10055
+ case "texcoords":
10056
+ return "TEXCOORD_0";
10057
+ default:
10058
+ return attributeName;
10059
+ }
10060
+ }
10061
+ _getAccessorMinMax(buffer, size) {
10062
+ const result = { min: null, max: null };
10063
+ if (buffer.length < size) {
10064
+ return result;
10065
+ }
10066
+ result.min = [];
10067
+ result.max = [];
10068
+ const initValues = buffer.subarray(0, size);
10069
+ for (const value of initValues) {
10070
+ result.min.push(value);
10071
+ result.max.push(value);
10072
+ }
10073
+ for (let index = size; index < buffer.length; index += size) {
10074
+ for (let componentIndex = 0; componentIndex < size; componentIndex++) {
10075
+ result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
10076
+ result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
10077
+ }
10078
+ }
10079
+ return result;
10080
+ }
10081
+ };
10082
+ }
10083
+ });
10084
+
10085
+ // ../gltf/src/lib/extensions/data-processing.ts
10086
+ function getArrayElementByteSize(attributeType, componentType) {
10087
+ return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10088
+ }
10089
+ function convertRawBufferToMetadataArray(typedArray, attributeType, componentType, elementCount = 1) {
10090
+ const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10091
+ const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[componentType];
10092
+ const length4 = elementCount * numberOfComponents;
10093
+ const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType];
10094
+ const offset = typedArray.byteOffset % size ? Math.ceil(typedArray.byteOffset / size) * size : typedArray.byteOffset;
10095
+ return new ArrayType(typedArray.buffer, offset, length4);
10096
+ }
10097
+ function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
10098
+ const json = scenegraph.gltf.json;
10099
+ const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
10100
+ const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10101
+ const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10102
+ const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10103
+ const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10104
+ const textureIndex = textureInfo.index;
10105
+ const imageIndex = json.textures?.[textureIndex]?.source;
10106
+ if (typeof imageIndex !== "undefined") {
10107
+ const mimeType = json.images?.[imageIndex]?.mimeType;
10108
+ const parsedImage = scenegraph.gltf.images?.[imageIndex];
10109
+ if (parsedImage && typeof parsedImage.width !== "undefined") {
10110
+ const textureData = [];
10111
+ for (let index = 0; index < textureCoordinates.length; index += 2) {
10112
+ const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, textureInfo.channels);
10113
+ textureData.push(value);
10114
+ }
10115
+ return textureData;
10116
+ }
10117
+ }
10118
+ return null;
10119
+ }
10120
+ function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
10121
+ if (propertyData === null)
10122
+ return;
10123
+ const featureIndices = [];
10124
+ for (const texelData of propertyData) {
10125
+ let index = featureTable.findIndex((item) => item === texelData);
10126
+ if (index === -1) {
10127
+ index = featureTable.push(texelData) - 1;
10128
+ }
10129
+ featureIndices.push(index);
10130
+ }
10131
+ const typedArray = new Uint32Array(featureIndices);
10132
+ const bufferIndex = scenegraph.gltf.buffers.push({
10133
+ arrayBuffer: typedArray.buffer,
10134
+ byteOffset: typedArray.byteOffset,
10135
+ byteLength: typedArray.byteLength
10136
+ }) - 1;
10137
+ const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
10138
+ const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
10139
+ size: 1,
10140
+ componentType: getComponentTypeFromArray(typedArray),
10141
+ count: typedArray.length
10142
+ });
10143
+ primitive.attributes[attributeName] = accessorIndex;
10144
+ }
10145
+ function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
10146
+ const CHANNELS_MAP = [
10147
+ { offset: 0, shift: 0 },
10148
+ { offset: 1, shift: 8 },
10149
+ { offset: 2, shift: 16 },
10150
+ { offset: 3, shift: 24 }
10151
+ ];
10152
+ const u = textureCoordinates[index];
10153
+ const v = textureCoordinates[index + 1];
10154
+ let components = 1;
10155
+ if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
10156
+ components = 4;
10157
+ const offset = coordinatesToOffset(u, v, parsedImage, components);
10158
+ let value = 0;
10159
+ for (const c of channels) {
10160
+ const map2 = CHANNELS_MAP[c];
10161
+ const imageOffset = offset + map2.offset;
10162
+ const imageData = getImageData(parsedImage);
10163
+ if (imageData.data.length <= imageOffset) {
10164
+ throw new Error(`${imageData.data.length} <= ${imageOffset}`);
10165
+ }
10166
+ const imageValue = imageData.data[imageOffset];
10167
+ value |= imageValue << map2.shift;
10168
+ }
10169
+ return value;
10170
+ }
10171
+ function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
10172
+ const w = parsedImage.width;
10173
+ const iX = emod(u) * (w - 1);
10174
+ const indX = Math.round(iX);
10175
+ const h = parsedImage.height;
10176
+ const iY = emod(v) * (h - 1);
10177
+ const indY = Math.round(iY);
10178
+ const components = parsedImage.components ? parsedImage.components : componentsCount;
10179
+ const offset = (indY * w + indX) * components;
10180
+ return offset;
10181
+ }
10182
+ var ATTRIBUTE_TYPE_TO_COMPONENTS2, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2;
10183
+ var init_data_processing = __esm({
10184
+ "../gltf/src/lib/extensions/data-processing.ts"() {
10185
+ init_gltf_utils();
10186
+ init_src8();
10187
+ init_src7();
10188
+ ATTRIBUTE_TYPE_TO_COMPONENTS2 = {
10189
+ SCALAR: 1,
10190
+ VEC2: 2,
10191
+ VEC3: 3,
10192
+ VEC4: 4,
10193
+ MAT2: 4,
10194
+ MAT3: 9,
10195
+ MAT4: 16,
10196
+ BOOLEAN: 1,
10197
+ STRING: 1,
10198
+ ENUM: 1
10199
+ };
10200
+ ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2 = {
10201
+ INT8: Int8Array,
10202
+ UINT8: Uint8Array,
10203
+ INT16: Int16Array,
10204
+ UINT16: Uint16Array,
10205
+ INT32: Int32Array,
10206
+ UINT32: Uint32Array,
10207
+ INT64: BigInt64Array,
10208
+ UINT64: BigUint64Array,
10209
+ FLOAT32: Float32Array,
10210
+ FLOAT64: Float64Array
10211
+ };
10212
+ ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2 = {
10213
+ INT8: 1,
10214
+ UINT8: 1,
10215
+ INT16: 2,
10216
+ UINT16: 2,
10217
+ INT32: 4,
10218
+ UINT32: 4,
10219
+ INT64: 8,
10220
+ UINT64: 8,
10221
+ FLOAT32: 4,
10222
+ FLOAT64: 8
10223
+ };
10224
+ }
10225
+ });
10226
+
10227
+ // ../gltf/src/lib/extensions/EXT_structural_metadata.ts
10228
+ var EXT_structural_metadata_exports = {};
10229
+ __export(EXT_structural_metadata_exports, {
10230
+ decode: () => decode,
10231
+ getPropertyTablePopulated: () => getPropertyTablePopulated,
10232
+ name: () => name
10233
+ });
10234
+ async function decode(gltfData, options) {
10235
+ const scenegraph = new GLTFScenegraph(gltfData);
10236
+ decodeExtStructuralMetadata(scenegraph, options);
10237
+ }
10238
+ function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
10239
+ const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10240
+ const propertyTable = extension?.propertyTables?.[propertyTableIndex];
10241
+ if (extension?.schema && propertyTable) {
10242
+ processPropertyTable(scenegraph, extension.schema, propertyTable);
10243
+ return propertyTable;
10244
+ }
10245
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`);
10246
+ }
10247
+ function decodeExtStructuralMetadata(scenegraph, options) {
10248
+ const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10249
+ if (!extension?.schema) {
10250
+ return;
10251
+ }
10252
+ const propertyTextures = extension.propertyTextures;
10253
+ const json = scenegraph.gltf.json;
10254
+ if (propertyTextures && json.meshes && options?.gltf?.loadImages) {
10255
+ for (const mesh of json.meshes) {
10256
+ for (const primitive of mesh.primitives) {
10257
+ processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
10258
+ }
10259
+ }
10260
+ }
10261
+ const schemaClasses = extension.schema.classes;
10262
+ const propertyTables = extension.propertyTables;
10263
+ if (schemaClasses && propertyTables) {
10264
+ for (const schemaName in schemaClasses) {
10265
+ const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
10266
+ if (propertyTable) {
10267
+ processPropertyTable(scenegraph, extension.schema, propertyTable);
10268
+ }
10269
+ }
10270
+ }
10271
+ }
10272
+ function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
10273
+ if (!propertyTextures) {
10274
+ return;
10275
+ }
10276
+ const primitiveExtension = primitive.extensions?.[EXT_STRUCTURAL_METADATA_NAME];
10277
+ const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;
10278
+ if (!primitivePropertyTextureIndices) {
10279
+ return;
10280
+ }
10281
+ for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {
10282
+ const propertyTexture = propertyTextures[primitivePropertyTextureIndex];
10283
+ processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);
10284
+ }
10285
+ }
10286
+ function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension) {
10287
+ if (!propertyTexture.properties) {
10288
+ return;
10289
+ }
10290
+ if (!extension.dataAttributeNames) {
10291
+ extension.dataAttributeNames = [];
10292
+ }
10293
+ const className = propertyTexture.class;
10294
+ for (const propName in propertyTexture.properties) {
10295
+ const attributeName = `${className}_${propName}`;
10296
+ const textureInfoTopLevel = propertyTexture.properties?.[propName];
10297
+ if (!textureInfoTopLevel) {
10298
+ continue;
10299
+ }
10300
+ if (!textureInfoTopLevel.data) {
10301
+ textureInfoTopLevel.data = [];
10302
+ }
10303
+ const featureTextureTable = textureInfoTopLevel.data;
10304
+ const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive);
10305
+ if (propertyData === null) {
10306
+ continue;
10307
+ }
10308
+ primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
10309
+ textureInfoTopLevel.data = featureTextureTable;
10310
+ extension.dataAttributeNames.push(attributeName);
10311
+ }
10312
+ }
10313
+ function processPropertyTable(scenegraph, schema, propertyTable) {
10314
+ const schemaClass = schema.classes?.[propertyTable.class];
10315
+ if (!schemaClass) {
10316
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
10317
+ }
10318
+ const numberOfElements = propertyTable.count;
10319
+ for (const propertyName in schemaClass.properties) {
10320
+ const classProperty = schemaClass.properties[propertyName];
10321
+ const propertyTableProperty = propertyTable.properties?.[propertyName];
10322
+ if (propertyTableProperty) {
10323
+ const data = getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty);
10324
+ propertyTableProperty.data = data;
10325
+ }
10326
+ }
10327
+ }
10328
+ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty) {
10329
+ let data = [];
10330
+ const valuesBufferView = propertyTableProperty.values;
10331
+ const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
10332
+ let arrayOffsets = null;
10333
+ if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined" && typeof propertyTableProperty.arrayOffsetType !== "undefined") {
10334
+ arrayOffsets = getOffsetArray(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
10335
+ }
10336
+ let stringOffsets = null;
10337
+ if (typeof propertyTableProperty.stringOffsets !== "undefined" && typeof propertyTableProperty.stringOffsetType !== "undefined") {
10338
+ stringOffsets = getOffsetArray(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
10339
+ }
10340
+ switch (classProperty.type) {
10341
+ case "SCALAR":
10342
+ case "VEC2":
10343
+ case "VEC3":
10344
+ case "VEC4":
10345
+ case "MAT2":
10346
+ case "MAT3":
10347
+ case "MAT4": {
10348
+ data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
10349
+ break;
10350
+ }
10351
+ case "BOOLEAN": {
10352
+ throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
10353
+ }
10354
+ case "STRING": {
10355
+ data = getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);
10356
+ break;
10357
+ }
10358
+ case "ENUM": {
10359
+ data = getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
10360
+ break;
10361
+ }
10362
+ default:
10363
+ throw new Error(`Unknown classProperty type ${classProperty.type}`);
10364
+ }
10365
+ return data;
10366
+ }
10367
+ function getOffsetArray(scenegraph, offsets, offsetType, numberOfElements) {
10368
+ const arrayOffsetsBufferView = offsets;
10369
+ const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(arrayOffsetsBufferView);
10370
+ const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
10371
+ return arrayOffsets;
10372
+ }
10373
+ function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10374
+ const isArray2 = classProperty.array;
10375
+ const arrayCount = classProperty.count;
10376
+ const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);
10377
+ const elementCount = valuesDataBytes.byteLength / elementSize;
10378
+ let valuesData;
10379
+ if (classProperty.componentType) {
10380
+ valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
10381
+ } else {
10382
+ valuesData = valuesDataBytes;
10383
+ }
10384
+ if (isArray2) {
10385
+ if (arrayOffsets) {
10386
+ return handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
10387
+ }
10388
+ if (arrayCount) {
10389
+ return handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
10390
+ }
10391
+ return [];
10392
+ }
10393
+ const attributeValueArray = [];
10394
+ for (let index = 0; index < numberOfElements; index++) {
10395
+ const value = valuesData[index];
10396
+ attributeValueArray.push(value);
10397
+ }
10398
+ return attributeValueArray;
10399
+ }
10400
+ function handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize) {
10401
+ const attributeValueArray = [];
10402
+ for (let index = 0; index < numberOfElements; index++) {
10403
+ const array = [];
10404
+ const arrayOffset = arrayOffsets[index];
10405
+ const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10406
+ if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
10407
+ const typedArrayOffset = arrayOffset / elementSize;
10408
+ const elementCount = arrayByteSize / elementSize;
10409
+ for (let i2 = 0; i2 < elementCount; i2++) {
10410
+ const value = valuesData[typedArrayOffset + i2];
10411
+ array.push(value);
10412
+ }
10413
+ }
10414
+ attributeValueArray.push(array);
10415
+ }
10416
+ return attributeValueArray;
10417
+ }
10418
+ function handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
10419
+ const attributeValueArray = [];
10420
+ for (let index = 0; index < numberOfElements; index++) {
10421
+ const array = [];
10422
+ for (let i2 = 0; i2 < arrayCount; i2++) {
10423
+ const value = valuesData[i2];
10424
+ array.push(value);
10425
+ }
10426
+ attributeValueArray.push(array);
10427
+ }
10428
+ return attributeValueArray;
10429
+ }
10430
+ function getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets) {
10431
+ if (arrayOffsets) {
10432
+ throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
10433
+ }
10434
+ if (stringOffsets) {
10435
+ const stringsArray = [];
10436
+ const textDecoder = new TextDecoder("utf8");
10437
+ let stringOffset = 0;
10438
+ for (let index = 0; index < numberOfElements; index++) {
10439
+ const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];
10440
+ if (stringByteSize + stringOffset <= valuesDataBytes.length) {
10441
+ const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);
10442
+ const stringAttribute = textDecoder.decode(stringData);
10443
+ stringsArray.push(stringAttribute);
10444
+ stringOffset += stringByteSize;
10445
+ }
10446
+ }
10447
+ return stringsArray;
10448
+ }
10449
+ return [];
10450
+ }
10451
+ function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10452
+ const data = [];
10453
+ const isArray2 = classProperty.array;
10454
+ const arrayCount = classProperty.count;
10455
+ const enumType = classProperty.enumType;
10456
+ if (!enumType) {
10457
+ throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");
10458
+ }
10459
+ const enumEntry = schema.enums?.[enumType];
10460
+ if (!enumEntry) {
10461
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`);
10462
+ }
10463
+ const enumValueType = enumEntry.valueType || "UINT16";
10464
+ const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
10465
+ const elementCount = valuesDataBytes.byteLength / elementSize;
10466
+ const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
10467
+ if (isArray2) {
10468
+ if (arrayOffsets) {
10469
+ return handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize, enumEntry);
10470
+ }
10471
+ if (arrayCount) {
10472
+ return handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
10473
+ }
10474
+ return [];
10475
+ }
10476
+ for (let index = 0; index < numberOfElements; index++) {
10477
+ const enumValue = valuesData[index];
10478
+ const enumObject = getEnumByValue(enumEntry, enumValue);
10479
+ if (enumObject) {
10480
+ data.push(enumObject.name);
10481
+ }
10482
+ }
10483
+ return data;
10484
+ }
10485
+ function handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize, enumEntry) {
10486
+ const attributeValueArray = [];
10487
+ for (let index = 0; index < numberOfElements; index++) {
10488
+ const array = [];
10489
+ const arrayOffset = arrayOffsets[index];
10490
+ const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10491
+ if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
10492
+ const typedArrayOffset = arrayOffset / elementSize;
10493
+ const elementCount = arrayByteSize / elementSize;
10494
+ for (let i2 = 0; i2 < elementCount; i2++) {
10495
+ const value = valuesData[typedArrayOffset + i2];
10496
+ const enumObject = getEnumByValue(enumEntry, value);
10497
+ if (enumObject) {
10498
+ array.push(enumObject.name);
10499
+ }
10500
+ }
10501
+ }
10502
+ attributeValueArray.push(array);
10503
+ }
10504
+ return attributeValueArray;
10505
+ }
10506
+ function handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
10507
+ const attributeValueArray = [];
10508
+ for (let index = 0; index < numberOfElements; index++) {
10509
+ const array = [];
10510
+ for (let i2 = 0; i2 < arrayCount; i2++) {
10511
+ const value = valuesData[i2];
10512
+ const enumObject = getEnumByValue(enumEntry, value);
10513
+ if (enumObject) {
10514
+ array.push(enumObject.name);
10515
+ }
10516
+ }
10517
+ attributeValueArray.push(array);
10518
+ }
10519
+ return attributeValueArray;
10520
+ }
10521
+ function findPropertyTableByClass(propertyTables, schemaClassName) {
10522
+ for (let i2 = 0, len2 = propertyTables.length; i2 < len2; i2++) {
10523
+ const propertyTable = propertyTables[i2];
10524
+ if (propertyTable.class === schemaClassName) {
10525
+ return propertyTable;
10526
+ }
10527
+ }
10528
+ return null;
10529
+ }
10530
+ function getEnumByValue(enumEntry, value) {
10531
+ for (const enumValue of enumEntry.values) {
10532
+ if (enumValue.value === value) {
10533
+ return enumValue;
10534
+ }
10535
+ }
10536
+ return null;
10537
+ }
10538
+ var EXT_STRUCTURAL_METADATA_NAME, name;
10539
+ var init_EXT_structural_metadata = __esm({
10540
+ "../gltf/src/lib/extensions/EXT_structural_metadata.ts"() {
10541
+ init_gltf_scenegraph();
10542
+ init_data_processing();
10543
+ EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
10544
+ name = EXT_STRUCTURAL_METADATA_NAME;
10545
+ }
10546
+ });
10547
+
10548
+ // ../gltf/src/lib/extensions/EXT_mesh_features.ts
10549
+ var EXT_mesh_features_exports = {};
10550
+ __export(EXT_mesh_features_exports, {
10551
+ decode: () => decode2,
10552
+ name: () => name2
10553
+ });
10554
+ async function decode2(gltfData, options) {
10555
+ const scenegraph = new GLTFScenegraph(gltfData);
10556
+ decodeExtMeshFeatures(scenegraph, options);
10557
+ }
10558
+ function decodeExtMeshFeatures(scenegraph, options) {
10559
+ const json = scenegraph.gltf.json;
10560
+ if (!json.meshes) {
10561
+ return;
10562
+ }
10563
+ for (const mesh of json.meshes) {
10564
+ for (const primitive of mesh.primitives) {
10565
+ processMeshPrimitiveFeatures(scenegraph, primitive, options);
10566
+ }
10567
+ }
10568
+ }
10569
+ function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
10570
+ const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
10571
+ const featureIds = extension?.featureIds;
10572
+ if (!featureIds)
10573
+ return;
10574
+ if (!extension.dataAttributeNames) {
10575
+ extension.dataAttributeNames = [];
10576
+ }
10577
+ let featureIdCount = 0;
10578
+ for (const featureId of featureIds) {
10579
+ let propertyTable = null;
10580
+ if (typeof featureId.propertyTable === "number") {
10581
+ propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);
10582
+ }
10583
+ let propertyData = null;
10584
+ if (typeof featureId.attribute !== "undefined") {
10585
+ const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
10586
+ const accessorIndex = primitive.attributes[accessorKey];
10587
+ const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);
10588
+ propertyData = Array.prototype.slice.call(propertyDataTypedArray);
10589
+ } else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
10590
+ propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
10591
+ } else {
10592
+ }
10593
+ const attributeName = featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;
10594
+ const featureTable = [];
10595
+ if (propertyData) {
10596
+ primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive);
10597
+ }
10598
+ extension.dataAttributeNames.push(attributeName);
10599
+ featureId.data = featureTable;
10600
+ featureIdCount++;
10601
+ }
10602
+ }
10603
+ var EXT_MESH_FEATURES_NAME, name2;
10604
+ var init_EXT_mesh_features = __esm({
10605
+ "../gltf/src/lib/extensions/EXT_mesh_features.ts"() {
10606
+ init_gltf_scenegraph();
10607
+ init_data_processing();
10608
+ init_EXT_structural_metadata();
10609
+ EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
10610
+ name2 = EXT_MESH_FEATURES_NAME;
10611
+ }
10612
+ });
10613
+
10614
+ // ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
10615
+ var EXT_feature_metadata_exports = {};
10616
+ __export(EXT_feature_metadata_exports, {
10617
+ decode: () => decode3,
10618
+ name: () => name3
10619
+ });
10620
+ async function decode3(gltfData, options) {
10621
+ const scenegraph = new GLTFScenegraph(gltfData);
10622
+ decodeExtFeatureMetadata(scenegraph, options);
10623
+ }
10624
+ function decodeExtFeatureMetadata(scenegraph, options) {
10625
+ const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
10626
+ if (!extension)
10627
+ return;
10628
+ const schemaClasses = extension.schema?.classes;
10629
+ const { featureTables } = extension;
10630
+ if (schemaClasses && featureTables) {
10631
+ for (const schemaName in schemaClasses) {
10632
+ const schemaClass = schemaClasses[schemaName];
10633
+ const featureTable = findFeatureTableByName(featureTables, schemaName);
10634
+ if (featureTable) {
10635
+ handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
10636
+ }
10637
+ }
10638
+ }
10639
+ const { featureTextures } = extension;
10640
+ if (schemaClasses && featureTextures && options.gltf?.loadImages) {
10641
+ for (const schemaName in schemaClasses) {
10642
+ const schemaClass = schemaClasses[schemaName];
10643
+ const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
10644
+ if (featureTexture) {
10645
+ handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
10646
+ }
10647
+ }
10648
+ }
10649
+ }
10650
+ function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
10651
+ for (const propertyName in schemaClass.properties) {
10652
+ const schemaProperty = schemaClass.properties[propertyName];
10653
+ const featureTableProperty = featureTable?.properties?.[propertyName];
10654
+ const numberOfFeatures = featureTable.count;
10655
+ if (featureTableProperty) {
10656
+ const data = getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
10657
+ featureTableProperty.data = data;
10658
+ }
10659
+ }
10660
+ }
10661
+ function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
10662
+ const attributeName = featureTexture.class;
10663
+ for (const propertyName in schemaClass.properties) {
10664
+ const featureTextureProperty = featureTexture?.properties?.[propertyName];
10665
+ if (featureTextureProperty) {
10666
+ const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
10667
+ featureTextureProperty.data = data;
10668
+ }
10669
+ }
10670
+ }
10671
+ function getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
10672
+ const bufferView = featureTableProperty.bufferView;
10673
+ const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
10674
+ switch (schemaProperty.type) {
10675
+ case "STRING": {
10676
+ const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
10677
+ const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
10678
+ return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
10679
+ }
10680
+ default:
10681
+ }
10682
+ return dataArray;
10683
+ }
10684
+ function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
10685
+ const json = scenegraph.gltf.json;
10686
+ if (!json.meshes) {
10687
+ return [];
10688
+ }
10689
+ const featureTextureTable = [];
10690
+ for (const mesh of json.meshes) {
10691
+ for (const primitive of mesh.primitives) {
10692
+ processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
10693
+ }
10694
+ }
10695
+ return featureTextureTable;
10696
+ }
10697
+ function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
10698
+ const json = scenegraph.gltf.json;
10699
+ const textureData = [];
10700
+ const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
10701
+ const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10702
+ const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10703
+ const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10704
+ const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10705
+ const textureIndex = featureTextureProperty.texture.index;
10706
+ const texture = json.textures?.[textureIndex];
10707
+ const imageIndex = texture?.source;
10708
+ if (typeof imageIndex !== "undefined") {
10709
+ const image = json.images?.[imageIndex];
10710
+ const mimeType = image?.mimeType;
10711
+ const parsedImage = scenegraph.gltf.images?.[imageIndex];
10712
+ if (parsedImage) {
10713
+ for (let index = 0; index < textureCoordinates.length; index += 2) {
10714
+ const value = getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
10715
+ textureData.push(value);
10716
+ }
10717
+ }
10718
+ }
10719
+ const featureIndices = [];
10720
+ for (const texelData of textureData) {
10721
+ let index = featureTextureTable.findIndex((item) => item === texelData);
10722
+ if (index === -1) {
10723
+ index = featureTextureTable.push(texelData) - 1;
10724
+ }
10725
+ featureIndices.push(index);
10726
+ }
10727
+ const typedArray = new Uint32Array(featureIndices);
10728
+ const bufferIndex = scenegraph.gltf.buffers.push({
10729
+ arrayBuffer: typedArray.buffer,
10730
+ byteOffset: 0,
10731
+ byteLength: typedArray.byteLength
10732
+ }) - 1;
10733
+ const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
10734
+ const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
10735
+ size: 1,
10736
+ componentType: getComponentTypeFromArray(typedArray),
10737
+ count: typedArray.length
10738
+ });
10739
+ primitive.attributes[attributeName] = accessorIndex;
10740
+ }
10741
+ function getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, channels) {
10742
+ const CHANNELS_MAP = {
10743
+ r: { offset: 0, shift: 0 },
10744
+ g: { offset: 1, shift: 8 },
10745
+ b: { offset: 2, shift: 16 },
10746
+ a: { offset: 3, shift: 24 }
10747
+ };
10748
+ const u = textureCoordinates[index];
10749
+ const v = textureCoordinates[index + 1];
10750
+ let components = 1;
10751
+ if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
10752
+ components = 4;
10753
+ const offset = coordinatesToOffset2(u, v, parsedImage, components);
10754
+ let value = 0;
10755
+ for (const c of channels) {
10756
+ const map2 = CHANNELS_MAP[c];
10757
+ const val = getVal(parsedImage, offset + map2.offset);
10758
+ value |= val << map2.shift;
10759
+ }
10760
+ return value;
10761
+ }
10762
+ function getVal(parsedImage, offset) {
10763
+ const imageData = getImageData(parsedImage);
10764
+ if (imageData.data.length <= offset) {
10765
+ throw new Error(`${imageData.data.length} <= ${offset}`);
10766
+ }
10767
+ return imageData.data[offset];
10768
+ }
10769
+ function coordinatesToOffset2(u, v, parsedImage, componentsCount = 1) {
10770
+ const w = parsedImage.width;
10771
+ const iX = emod(u) * (w - 1);
10772
+ const indX = Math.round(iX);
10773
+ const h = parsedImage.height;
10774
+ const iY = emod(v) * (h - 1);
10775
+ const indY = Math.round(iY);
10776
+ const components = parsedImage.components ? parsedImage.components : componentsCount;
10777
+ const offset = (indY * w + indX) * components;
10778
+ return offset;
10779
+ }
10780
+ function findFeatureTableByName(featureTables, schemaClassName) {
10781
+ for (const featureTableName in featureTables) {
10782
+ const featureTable = featureTables[featureTableName];
10783
+ if (featureTable.class === schemaClassName) {
10784
+ return featureTable;
10785
+ }
10786
+ }
10787
+ return null;
10788
+ }
10789
+ function findFeatureTextureByName(featureTextures, schemaClassName) {
10790
+ for (const featureTexturesName in featureTextures) {
10791
+ const featureTable = featureTextures[featureTexturesName];
10792
+ if (featureTable.class === schemaClassName) {
10793
+ return featureTable;
10794
+ }
10795
+ }
10796
+ return null;
10797
+ }
10798
+ function getStringAttributes(data, offsetsData, stringsCount) {
10799
+ const stringsArray = [];
10800
+ const textDecoder = new TextDecoder("utf8");
10801
+ let stringOffset = 0;
10802
+ const bytesPerStringSize = 4;
10803
+ for (let index = 0; index < stringsCount; index++) {
10804
+ const stringByteSize = offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];
10805
+ const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
10806
+ const stringAttribute = textDecoder.decode(stringData);
10807
+ stringsArray.push(stringAttribute);
10808
+ stringOffset += stringByteSize;
10809
+ }
10810
+ return stringsArray;
10811
+ }
10812
+ var EXT_FEATURE_METADATA_NAME, name3;
10813
+ var init_EXT_feature_metadata = __esm({
10814
+ "../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
10815
+ init_gltf_scenegraph();
10816
+ init_src8();
10817
+ init_gltf_utils();
10818
+ init_src7();
10819
+ EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
10820
+ name3 = EXT_FEATURE_METADATA_NAME;
10821
+ }
10822
+ });
10823
+
10824
+ // ../gltf/src/lib/utils/version.ts
10825
+ var VERSION7;
10826
+ var init_version5 = __esm({
10827
+ "../gltf/src/lib/utils/version.ts"() {
10828
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
10829
+ }
10830
+ });
10831
+
10832
+ // ../textures/src/lib/utils/version.ts
10833
+ var VERSION8;
10834
+ var init_version6 = __esm({
10835
+ "../textures/src/lib/utils/version.ts"() {
10836
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
10837
+ }
10838
+ });
10839
+
10840
+ // ../textures/src/lib/parsers/basis-module-loader.ts
10841
+ async function loadBasisTranscoderModule(options) {
10842
+ const modules = options.modules || {};
10843
+ if (modules.basis) {
10844
+ return modules.basis;
10845
+ }
10846
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
10847
+ return await loadBasisTranscoderPromise;
10848
+ }
10849
+ async function loadBasisTranscoder(options) {
10850
+ let BASIS = null;
10851
+ let wasmBinary = null;
10852
+ [BASIS, wasmBinary] = await Promise.all([
10853
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
10854
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
10855
+ ]);
10856
+ BASIS = BASIS || globalThis.BASIS;
10857
+ return await initializeBasisTranscoderModule(BASIS, wasmBinary);
10858
+ }
10859
+ function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
10860
+ const options = {};
10861
+ if (wasmBinary) {
10862
+ options.wasmBinary = wasmBinary;
10863
+ }
10864
+ return new Promise((resolve2) => {
10865
+ BasisModule(options).then((module) => {
10866
+ const { BasisFile, initializeBasis } = module;
10867
+ initializeBasis();
10868
+ resolve2({ BasisFile });
10869
+ });
10870
+ });
10871
+ }
10872
+ async function loadBasisEncoderModule(options) {
10873
+ const modules = options.modules || {};
10874
+ if (modules.basisEncoder) {
10875
+ return modules.basisEncoder;
10876
+ }
10877
+ loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
10878
+ return await loadBasisEncoderPromise;
10879
+ }
10880
+ async function loadBasisEncoder(options) {
10881
+ let BASIS_ENCODER = null;
10882
+ let wasmBinary = null;
10883
+ [BASIS_ENCODER, wasmBinary] = await Promise.all([
10884
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
10885
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
10886
+ ]);
10887
+ BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
10888
+ return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
10889
+ }
10890
+ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
10891
+ const options = {};
10892
+ if (wasmBinary) {
10893
+ options.wasmBinary = wasmBinary;
10894
+ }
10895
+ return new Promise((resolve2) => {
10896
+ BasisEncoderModule(options).then((module) => {
10897
+ const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
10898
+ initializeBasis();
10899
+ resolve2({ BasisFile, KTX2File, BasisEncoder });
10900
+ });
10901
+ });
10902
+ }
10903
+ var BASIS_EXTERNAL_LIBRARIES, loadBasisTranscoderPromise, loadBasisEncoderPromise;
10904
+ var init_basis_module_loader = __esm({
10905
+ "../textures/src/lib/parsers/basis-module-loader.ts"() {
10906
+ init_src();
10907
+ BASIS_EXTERNAL_LIBRARIES = {
10908
+ TRANSCODER: "basis_transcoder.js",
10909
+ TRANSCODER_WASM: "basis_transcoder.wasm",
10910
+ ENCODER: "basis_encoder.js",
10911
+ ENCODER_WASM: "basis_encoder.wasm"
10912
+ };
10913
+ }
10914
+ });
10915
+
10916
+ // ../textures/src/lib/gl-extensions.ts
10917
+ var GL_EXTENSIONS_CONSTANTS;
10918
+ var init_gl_extensions = __esm({
10919
+ "../textures/src/lib/gl-extensions.ts"() {
10920
+ GL_EXTENSIONS_CONSTANTS = {
10921
+ COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
10922
+ COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
10923
+ COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
10924
+ COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
10925
+ COMPRESSED_R11_EAC: 37488,
10926
+ COMPRESSED_SIGNED_R11_EAC: 37489,
10927
+ COMPRESSED_RG11_EAC: 37490,
10928
+ COMPRESSED_SIGNED_RG11_EAC: 37491,
10929
+ COMPRESSED_RGB8_ETC2: 37492,
10930
+ COMPRESSED_RGBA8_ETC2_EAC: 37493,
10931
+ COMPRESSED_SRGB8_ETC2: 37494,
10932
+ COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
10933
+ COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
10934
+ COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
10935
+ COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
10936
+ COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
10937
+ COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
10938
+ COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
10939
+ COMPRESSED_RGB_ETC1_WEBGL: 36196,
10940
+ COMPRESSED_RGB_ATC_WEBGL: 35986,
10941
+ COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
10942
+ COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
10943
+ COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
10944
+ COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
10945
+ COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
10946
+ COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
10947
+ COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
10948
+ COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
10949
+ COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
10950
+ COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
10951
+ COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
10952
+ COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
10953
+ COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
10954
+ COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
10955
+ COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
10956
+ COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
10957
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
10958
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
10959
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
10960
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
10961
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
10962
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
10963
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
10964
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
10965
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
10966
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
10967
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
10968
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
10969
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
10970
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
10971
+ COMPRESSED_RED_RGTC1_EXT: 36283,
10972
+ COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
10973
+ COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
10974
+ COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
10975
+ COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
10976
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
10977
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
10978
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
10979
+ };
10980
+ }
10981
+ });
10982
+
10983
+ // ../textures/src/lib/utils/texture-formats.ts
10984
+ function getSupportedGPUTextureFormats(gl) {
10985
+ if (!formats) {
10986
+ gl = gl || getWebGLContext() || void 0;
10987
+ formats = new Set();
10988
+ for (const prefix of BROWSER_PREFIXES) {
10989
+ for (const extension in WEBGL_EXTENSIONS) {
10990
+ if (gl && gl.getExtension(`${prefix}${extension}`)) {
10991
+ const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
10992
+ formats.add(gpuTextureFormat);
10993
+ }
10994
+ }
10995
+ }
10996
+ }
10997
+ return formats;
10998
+ }
10999
+ function getWebGLContext() {
11000
+ try {
11001
+ const canvas = document.createElement("canvas");
11002
+ return canvas.getContext("webgl");
11003
+ } catch (error) {
11004
+ return null;
11005
+ }
11006
+ }
11007
+ var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
11008
+ var init_texture_formats = __esm({
11009
+ "../textures/src/lib/utils/texture-formats.ts"() {
11010
+ BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
11011
+ WEBGL_EXTENSIONS = {
11012
+ WEBGL_compressed_texture_s3tc: "dxt",
11013
+ WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
11014
+ WEBGL_compressed_texture_etc1: "etc1",
11015
+ WEBGL_compressed_texture_etc: "etc2",
11016
+ WEBGL_compressed_texture_pvrtc: "pvrtc",
11017
+ WEBGL_compressed_texture_atc: "atc",
11018
+ WEBGL_compressed_texture_astc: "astc",
11019
+ EXT_texture_compression_rgtc: "rgtc"
11020
+ };
11021
+ formats = null;
11022
+ }
11023
+ });
11024
+
11025
+ // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
11026
+ var t, n, i, s, a, r, o, l, f;
11027
+ var init_ktx_parse_modern = __esm({
11028
+ "../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
11029
+ t = new Uint8Array([0]);
11030
+ !function(t2) {
11031
+ t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
11032
+ }(n || (n = {})), function(t2) {
11033
+ t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
11034
+ }(i || (i = {})), function(t2) {
11035
+ t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
11036
+ }(s || (s = {})), function(t2) {
11037
+ t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
11038
+ }(a || (a = {})), function(t2) {
11039
+ t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.LINEAR = 1] = "LINEAR", t2[t2.SRGB = 2] = "SRGB", t2[t2.ITU = 3] = "ITU", t2[t2.NTSC = 4] = "NTSC", t2[t2.SLOG = 5] = "SLOG", t2[t2.SLOG2 = 6] = "SLOG2";
11040
+ }(r || (r = {})), function(t2) {
11041
+ t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
11042
+ }(o || (o = {})), function(t2) {
11043
+ t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
11044
+ }(l || (l = {})), function(t2) {
11045
+ t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
11046
+ }(f || (f = {}));
11047
+ }
11048
+ });
11049
+
11050
+ // ../textures/src/lib/parsers/parse-ktx.ts
11051
+ function isKTX(data) {
11052
+ const id = new Uint8Array(data);
11053
+ const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
11054
+ return !notKTX;
11055
+ }
11056
+ var KTX2_ID;
11057
+ var init_parse_ktx = __esm({
11058
+ "../textures/src/lib/parsers/parse-ktx.ts"() {
11059
+ init_ktx_parse_modern();
11060
+ KTX2_ID = [
11061
+ 171,
11062
+ 75,
11063
+ 84,
11064
+ 88,
11065
+ 32,
11066
+ 50,
11067
+ 48,
11068
+ 187,
11069
+ 13,
11070
+ 10,
11071
+ 26,
11072
+ 10
11073
+ ];
11074
+ }
11075
+ });
11076
+
11077
+ // ../textures/src/lib/parsers/parse-basis.ts
11078
+ async function parseBasis(data, options) {
11079
+ if (options.basis.containerFormat === "auto") {
11080
+ if (isKTX(data)) {
11081
+ const fileConstructors = await loadBasisEncoderModule(options);
11082
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
11083
+ }
11084
+ const { BasisFile } = await loadBasisTranscoderModule(options);
11085
+ return parseBasisFile(BasisFile, data, options);
11086
+ }
11087
+ switch (options.basis.module) {
11088
+ case "encoder":
11089
+ const fileConstructors = await loadBasisEncoderModule(options);
11090
+ switch (options.basis.containerFormat) {
11091
+ case "ktx2":
11092
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
11093
+ case "basis":
11094
+ default:
11095
+ return parseBasisFile(fileConstructors.BasisFile, data, options);
10488
11096
  }
10489
- _addIndices(indices) {
10490
- return this.addBinaryBuffer(indices, { size: 1 });
11097
+ case "transcoder":
11098
+ default:
11099
+ const { BasisFile } = await loadBasisTranscoderModule(options);
11100
+ return parseBasisFile(BasisFile, data, options);
11101
+ }
11102
+ }
11103
+ function parseBasisFile(BasisFile, data, options) {
11104
+ const basisFile = new BasisFile(new Uint8Array(data));
11105
+ try {
11106
+ if (!basisFile.startTranscoding()) {
11107
+ throw new Error("Failed to start basis transcoding");
11108
+ }
11109
+ const imageCount = basisFile.getNumImages();
11110
+ const images = [];
11111
+ for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
11112
+ const levelsCount = basisFile.getNumLevels(imageIndex);
11113
+ const levels = [];
11114
+ for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
11115
+ levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
10491
11116
  }
10492
- _getGltfAttributeName(attributeName) {
10493
- switch (attributeName.toLowerCase()) {
10494
- case "position":
10495
- case "positions":
10496
- case "vertices":
10497
- return "POSITION";
10498
- case "normal":
10499
- case "normals":
10500
- return "NORMAL";
10501
- case "color":
10502
- case "colors":
10503
- return "COLOR_0";
10504
- case "texcoord":
10505
- case "texcoords":
10506
- return "TEXCOORD_0";
10507
- default:
10508
- return attributeName;
11117
+ images.push(levels);
11118
+ }
11119
+ return images;
11120
+ } finally {
11121
+ basisFile.close();
11122
+ basisFile.delete();
11123
+ }
11124
+ }
11125
+ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
11126
+ const width = basisFile.getImageWidth(imageIndex, levelIndex);
11127
+ const height = basisFile.getImageHeight(imageIndex, levelIndex);
11128
+ const hasAlpha = basisFile.getHasAlpha();
11129
+ const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
11130
+ const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
11131
+ const decodedData = new Uint8Array(decodedSize);
11132
+ if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
11133
+ throw new Error("failed to start Basis transcoding");
11134
+ }
11135
+ return {
11136
+ width,
11137
+ height,
11138
+ data: decodedData,
11139
+ compressed,
11140
+ format,
11141
+ hasAlpha
11142
+ };
11143
+ }
11144
+ function parseKTX2File(KTX2File, data, options) {
11145
+ const ktx2File = new KTX2File(new Uint8Array(data));
11146
+ try {
11147
+ if (!ktx2File.startTranscoding()) {
11148
+ throw new Error("failed to start KTX2 transcoding");
11149
+ }
11150
+ const levelsCount = ktx2File.getLevels();
11151
+ const levels = [];
11152
+ for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
11153
+ levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
11154
+ break;
11155
+ }
11156
+ return [levels];
11157
+ } finally {
11158
+ ktx2File.close();
11159
+ ktx2File.delete();
11160
+ }
11161
+ }
11162
+ function transcodeKTX2Image(ktx2File, levelIndex, options) {
11163
+ const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
11164
+ const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
11165
+ const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
11166
+ const decodedData = new Uint8Array(decodedSize);
11167
+ if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
11168
+ throw new Error("Failed to transcode KTX2 image");
11169
+ }
11170
+ return {
11171
+ width,
11172
+ height,
11173
+ data: decodedData,
11174
+ compressed,
11175
+ levelSize: decodedSize,
11176
+ hasAlpha: alphaFlag,
11177
+ format
11178
+ };
11179
+ }
11180
+ function getBasisOptions(options, hasAlpha) {
11181
+ let format = options && options.basis && options.basis.format;
11182
+ if (format === "auto") {
11183
+ format = selectSupportedBasisFormat();
11184
+ }
11185
+ if (typeof format === "object") {
11186
+ format = hasAlpha ? format.alpha : format.noAlpha;
11187
+ }
11188
+ format = format.toLowerCase();
11189
+ return OutputFormat[format];
11190
+ }
11191
+ function selectSupportedBasisFormat() {
11192
+ const supportedFormats = getSupportedGPUTextureFormats();
11193
+ if (supportedFormats.has("astc")) {
11194
+ return "astc-4x4";
11195
+ } else if (supportedFormats.has("dxt")) {
11196
+ return {
11197
+ alpha: "bc3",
11198
+ noAlpha: "bc1"
11199
+ };
11200
+ } else if (supportedFormats.has("pvrtc")) {
11201
+ return {
11202
+ alpha: "pvrtc1-4-rgba",
11203
+ noAlpha: "pvrtc1-4-rgb"
11204
+ };
11205
+ } else if (supportedFormats.has("etc1")) {
11206
+ return "etc1";
11207
+ } else if (supportedFormats.has("etc2")) {
11208
+ return "etc2";
11209
+ }
11210
+ return "rgb565";
11211
+ }
11212
+ var OutputFormat;
11213
+ var init_parse_basis = __esm({
11214
+ "../textures/src/lib/parsers/parse-basis.ts"() {
11215
+ init_basis_module_loader();
11216
+ init_gl_extensions();
11217
+ init_texture_formats();
11218
+ init_parse_ktx();
11219
+ OutputFormat = {
11220
+ etc1: {
11221
+ basisFormat: 0,
11222
+ compressed: true,
11223
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
11224
+ },
11225
+ etc2: { basisFormat: 1, compressed: true },
11226
+ bc1: {
11227
+ basisFormat: 2,
11228
+ compressed: true,
11229
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
11230
+ },
11231
+ bc3: {
11232
+ basisFormat: 3,
11233
+ compressed: true,
11234
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
11235
+ },
11236
+ bc4: { basisFormat: 4, compressed: true },
11237
+ bc5: { basisFormat: 5, compressed: true },
11238
+ "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
11239
+ "bc7-m5": { basisFormat: 7, compressed: true },
11240
+ "pvrtc1-4-rgb": {
11241
+ basisFormat: 8,
11242
+ compressed: true,
11243
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
11244
+ },
11245
+ "pvrtc1-4-rgba": {
11246
+ basisFormat: 9,
11247
+ compressed: true,
11248
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
11249
+ },
11250
+ "astc-4x4": {
11251
+ basisFormat: 10,
11252
+ compressed: true,
11253
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
11254
+ },
11255
+ "atc-rgb": { basisFormat: 11, compressed: true },
11256
+ "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
11257
+ rgba32: { basisFormat: 13, compressed: false },
11258
+ rgb565: { basisFormat: 14, compressed: false },
11259
+ bgr565: { basisFormat: 15, compressed: false },
11260
+ rgba4444: { basisFormat: 16, compressed: false }
11261
+ };
11262
+ }
11263
+ });
11264
+
11265
+ // ../textures/src/basis-loader.ts
11266
+ var BasisWorkerLoader, BasisLoader;
11267
+ var init_basis_loader = __esm({
11268
+ "../textures/src/basis-loader.ts"() {
11269
+ init_version6();
11270
+ init_parse_basis();
11271
+ BasisWorkerLoader = {
11272
+ name: "Basis",
11273
+ id: "basis",
11274
+ module: "textures",
11275
+ version: VERSION8,
11276
+ worker: true,
11277
+ extensions: ["basis", "ktx2"],
11278
+ mimeTypes: ["application/octet-stream", "image/ktx2"],
11279
+ tests: ["sB"],
11280
+ binary: true,
11281
+ options: {
11282
+ basis: {
11283
+ format: "auto",
11284
+ libraryPath: "libs/",
11285
+ containerFormat: "auto",
11286
+ module: "transcoder"
10509
11287
  }
10510
11288
  }
10511
- _getAccessorMinMax(buffer, size) {
10512
- const result = { min: null, max: null };
10513
- if (buffer.length < size) {
10514
- return result;
10515
- }
10516
- result.min = [];
10517
- result.max = [];
10518
- const initValues = buffer.subarray(0, size);
10519
- for (const value of initValues) {
10520
- result.min.push(value);
10521
- result.max.push(value);
11289
+ };
11290
+ BasisLoader = {
11291
+ ...BasisWorkerLoader,
11292
+ parse: parseBasis
11293
+ };
11294
+ }
11295
+ });
11296
+
11297
+ // ../textures/src/index.ts
11298
+ var init_src9 = __esm({
11299
+ "../textures/src/index.ts"() {
11300
+ init_basis_loader();
11301
+ init_parse_basis();
11302
+ }
11303
+ });
11304
+
11305
+ // ../gltf/src/lib/parsers/parse-glb.ts
11306
+ function getMagicString4(dataView, byteOffset = 0) {
11307
+ 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))}`;
11308
+ }
11309
+ function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
11310
+ const dataView = new DataView(arrayBuffer);
11311
+ const { magic = MAGIC_glTF } = options;
11312
+ const magic1 = dataView.getUint32(byteOffset, false);
11313
+ return magic1 === magic || magic1 === MAGIC_glTF;
11314
+ }
11315
+ function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
11316
+ const dataView = new DataView(arrayBuffer);
11317
+ const type = getMagicString4(dataView, byteOffset + 0);
11318
+ const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11319
+ const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
11320
+ Object.assign(glb, {
11321
+ header: {
11322
+ byteOffset,
11323
+ byteLength,
11324
+ hasBinChunk: false
11325
+ },
11326
+ type,
11327
+ version,
11328
+ json: {},
11329
+ binChunks: []
11330
+ });
11331
+ byteOffset += GLB_FILE_HEADER_SIZE;
11332
+ switch (glb.version) {
11333
+ case 1:
11334
+ return parseGLBV1(glb, dataView, byteOffset);
11335
+ case 2:
11336
+ return parseGLBV2(glb, dataView, byteOffset, options = {});
11337
+ default:
11338
+ throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
11339
+ }
11340
+ }
11341
+ function parseGLBV1(glb, dataView, byteOffset) {
11342
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
11343
+ const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
11344
+ const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11345
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
11346
+ assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
11347
+ parseJSONChunk(glb, dataView, byteOffset, contentLength);
11348
+ byteOffset += contentLength;
11349
+ byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
11350
+ return byteOffset;
11351
+ }
11352
+ function parseGLBV2(glb, dataView, byteOffset, options) {
11353
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
11354
+ parseGLBChunksSync(glb, dataView, byteOffset, options);
11355
+ return byteOffset + glb.header.byteLength;
11356
+ }
11357
+ function parseGLBChunksSync(glb, dataView, byteOffset, options) {
11358
+ while (byteOffset + 8 <= glb.header.byteLength) {
11359
+ const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
11360
+ const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11361
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
11362
+ switch (chunkFormat) {
11363
+ case GLB_CHUNK_TYPE_JSON:
11364
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
11365
+ break;
11366
+ case GLB_CHUNK_TYPE_BIN:
11367
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
11368
+ break;
11369
+ case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
11370
+ if (!options.strict) {
11371
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
10522
11372
  }
10523
- for (let index = size; index < buffer.length; index += size) {
10524
- for (let componentIndex = 0; componentIndex < size; componentIndex++) {
10525
- result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
10526
- result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
10527
- }
11373
+ break;
11374
+ case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
11375
+ if (!options.strict) {
11376
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
10528
11377
  }
10529
- return result;
10530
- }
10531
- };
11378
+ break;
11379
+ default:
11380
+ break;
11381
+ }
11382
+ byteOffset += padToNBytes(chunkLength, 4);
11383
+ }
11384
+ return byteOffset;
11385
+ }
11386
+ function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
11387
+ const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
11388
+ const textDecoder = new TextDecoder("utf8");
11389
+ const jsonText = textDecoder.decode(jsonChunk);
11390
+ glb.json = JSON.parse(jsonText);
11391
+ return padToNBytes(chunkLength, 4);
11392
+ }
11393
+ function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
11394
+ glb.header.hasBinChunk = true;
11395
+ glb.binChunks.push({
11396
+ byteOffset,
11397
+ byteLength: chunkLength,
11398
+ arrayBuffer: dataView.buffer
11399
+ });
11400
+ return padToNBytes(chunkLength, 4);
11401
+ }
11402
+ var LITTLE_ENDIAN2, MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_V1_CONTENT_FORMAT_JSON, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED;
11403
+ var init_parse_glb = __esm({
11404
+ "../gltf/src/lib/parsers/parse-glb.ts"() {
11405
+ init_src2();
11406
+ LITTLE_ENDIAN2 = true;
11407
+ MAGIC_glTF = 1735152710;
11408
+ GLB_FILE_HEADER_SIZE = 12;
11409
+ GLB_CHUNK_HEADER_SIZE = 8;
11410
+ GLB_CHUNK_TYPE_JSON = 1313821514;
11411
+ GLB_CHUNK_TYPE_BIN = 5130562;
11412
+ GLB_V1_CONTENT_FORMAT_JSON = 0;
11413
+ GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
11414
+ GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
11415
+ }
11416
+ });
11417
+
11418
+ // ../gltf/src/lib/gltf-utils/resolve-url.ts
11419
+ function resolveUrl(url, options) {
11420
+ const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
11421
+ if (absolute) {
11422
+ return url;
11423
+ }
11424
+ const baseUrl = options.baseUri || options.uri;
11425
+ if (!baseUrl) {
11426
+ throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
11427
+ }
11428
+ return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
11429
+ }
11430
+ var init_resolve_url = __esm({
11431
+ "../gltf/src/lib/gltf-utils/resolve-url.ts"() {
11432
+ }
11433
+ });
11434
+
11435
+ // ../gltf/src/lib/gltf-utils/get-typed-array.ts
11436
+ function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
11437
+ const bufferView = json.bufferViews[bufferViewIndex];
11438
+ assert7(bufferView);
11439
+ const bufferIndex = bufferView.buffer;
11440
+ const binChunk = buffers[bufferIndex];
11441
+ assert7(binChunk);
11442
+ const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
11443
+ return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
11444
+ }
11445
+ var init_get_typed_array = __esm({
11446
+ "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
11447
+ init_assert6();
10532
11448
  }
10533
11449
  });
10534
11450
 
10535
11451
  // ../gltf/src/meshopt/meshopt-decoder.ts
10536
11452
  async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") {
10537
11453
  const instance = await loadWasmInstance();
10538
- decode(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]);
11454
+ decode4(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]);
10539
11455
  }
10540
11456
  async function loadWasmInstance() {
10541
11457
  if (!wasmPromise) {
@@ -10565,7 +11481,7 @@
10565
11481
  }
10566
11482
  return result.buffer.slice(0, write);
10567
11483
  }
10568
- function decode(instance, fun, target, count, size, source, filter) {
11484
+ function decode4(instance, fun, target, count, size, source, filter) {
10569
11485
  const sbrk = instance.exports.sbrk;
10570
11486
  const count4 = count + 3 & ~3;
10571
11487
  const tp = sbrk(count4 * size);
@@ -10726,10 +11642,10 @@
10726
11642
  // ../gltf/src/lib/extensions/EXT_meshopt_compression.ts
10727
11643
  var EXT_meshopt_compression_exports = {};
10728
11644
  __export(EXT_meshopt_compression_exports, {
10729
- decode: () => decode2,
10730
- name: () => name
11645
+ decode: () => decode5,
11646
+ name: () => name4
10731
11647
  });
10732
- async function decode2(gltfData, options) {
11648
+ async function decode5(gltfData, options) {
10733
11649
  const scenegraph = new GLTFScenegraph(gltfData);
10734
11650
  if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {
10735
11651
  return;
@@ -10760,20 +11676,20 @@
10760
11676
  scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
10761
11677
  }
10762
11678
  }
10763
- var EXT_MESHOPT_COMPRESSION, name;
11679
+ var EXT_MESHOPT_COMPRESSION, name4;
10764
11680
  var init_EXT_meshopt_compression = __esm({
10765
11681
  "../gltf/src/lib/extensions/EXT_meshopt_compression.ts"() {
10766
11682
  init_gltf_scenegraph();
10767
11683
  init_meshopt_decoder();
10768
11684
  EXT_MESHOPT_COMPRESSION = "EXT_meshopt_compression";
10769
- name = EXT_MESHOPT_COMPRESSION;
11685
+ name4 = EXT_MESHOPT_COMPRESSION;
10770
11686
  }
10771
11687
  });
10772
11688
 
10773
11689
  // ../gltf/src/lib/extensions/EXT_texture_webp.ts
10774
11690
  var EXT_texture_webp_exports = {};
10775
11691
  __export(EXT_texture_webp_exports, {
10776
- name: () => name2,
11692
+ name: () => name5,
10777
11693
  preprocess: () => preprocess
10778
11694
  });
10779
11695
  function preprocess(gltfData, options) {
@@ -10794,20 +11710,20 @@
10794
11710
  }
10795
11711
  scenegraph.removeExtension(EXT_TEXTURE_WEBP);
10796
11712
  }
10797
- var EXT_TEXTURE_WEBP, name2;
11713
+ var EXT_TEXTURE_WEBP, name5;
10798
11714
  var init_EXT_texture_webp = __esm({
10799
11715
  "../gltf/src/lib/extensions/EXT_texture_webp.ts"() {
10800
11716
  init_src8();
10801
11717
  init_gltf_scenegraph();
10802
11718
  EXT_TEXTURE_WEBP = "EXT_texture_webp";
10803
- name2 = EXT_TEXTURE_WEBP;
11719
+ name5 = EXT_TEXTURE_WEBP;
10804
11720
  }
10805
11721
  });
10806
11722
 
10807
11723
  // ../gltf/src/lib/extensions/KHR_texture_basisu.ts
10808
11724
  var KHR_texture_basisu_exports = {};
10809
11725
  __export(KHR_texture_basisu_exports, {
10810
- name: () => name3,
11726
+ name: () => name6,
10811
11727
  preprocess: () => preprocess2
10812
11728
  });
10813
11729
  function preprocess2(gltfData, options) {
@@ -10822,23 +11738,23 @@
10822
11738
  }
10823
11739
  scene.removeExtension(KHR_TEXTURE_BASISU);
10824
11740
  }
10825
- var KHR_TEXTURE_BASISU, name3;
11741
+ var KHR_TEXTURE_BASISU, name6;
10826
11742
  var init_KHR_texture_basisu = __esm({
10827
11743
  "../gltf/src/lib/extensions/KHR_texture_basisu.ts"() {
10828
11744
  init_gltf_scenegraph();
10829
11745
  KHR_TEXTURE_BASISU = "KHR_texture_basisu";
10830
- name3 = KHR_TEXTURE_BASISU;
11746
+ name6 = KHR_TEXTURE_BASISU;
10831
11747
  }
10832
11748
  });
10833
11749
 
10834
11750
  // ../gltf/src/lib/gltf-utils/gltf-attribute-utils.ts
10835
11751
  function getGLTFAccessors(attributes) {
10836
11752
  const accessors = {};
10837
- for (const name10 in attributes) {
10838
- const attribute = attributes[name10];
10839
- if (name10 !== "indices") {
11753
+ for (const name12 in attributes) {
11754
+ const attribute = attributes[name12];
11755
+ if (name12 !== "indices") {
10840
11756
  const glTFAccessor = getGLTFAccessor(attribute);
10841
- accessors[name10] = glTFAccessor;
11757
+ accessors[name12] = glTFAccessor;
10842
11758
  }
10843
11759
  }
10844
11760
  return accessors;
@@ -10892,9 +11808,9 @@
10892
11808
  // ../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts
10893
11809
  var KHR_draco_mesh_compression_exports = {};
10894
11810
  __export(KHR_draco_mesh_compression_exports, {
10895
- decode: () => decode3,
11811
+ decode: () => decode6,
10896
11812
  encode: () => encode,
10897
- name: () => name4,
11813
+ name: () => name7,
10898
11814
  preprocess: () => preprocess3
10899
11815
  });
10900
11816
  function preprocess3(gltfData, options, context) {
@@ -10904,7 +11820,7 @@
10904
11820
  }
10905
11821
  }
10906
11822
  }
10907
- async function decode3(gltfData, options, context) {
11823
+ async function decode6(gltfData, options, context) {
10908
11824
  if (!options?.gltf?.decompressMeshes) {
10909
11825
  return;
10910
11826
  }
@@ -10932,10 +11848,9 @@
10932
11848
  }
10933
11849
  const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
10934
11850
  const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
10935
- const { parse: parse5 } = context;
10936
11851
  const dracoOptions = { ...options };
10937
11852
  delete dracoOptions["3d-tiles"];
10938
- const decodedData = await parse5(bufferCopy, DracoLoader2, dracoOptions, context);
11853
+ const decodedData = await parseFromContext(bufferCopy, DracoLoader2, dracoOptions, context);
10939
11854
  const decodedAttributes = getGLTFAccessors(decodedData.attributes);
10940
11855
  for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
10941
11856
  if (attributeName in primitive.attributes) {
@@ -10990,15 +11905,15 @@
10990
11905
  }
10991
11906
  }
10992
11907
  }
10993
- var KHR_DRACO_MESH_COMPRESSION, name4;
11908
+ var KHR_DRACO_MESH_COMPRESSION, name7;
10994
11909
  var init_KHR_draco_mesh_compression = __esm({
10995
11910
  "../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts"() {
10996
- init_src6();
10997
11911
  init_src2();
11912
+ init_src6();
10998
11913
  init_gltf_scenegraph();
10999
11914
  init_gltf_attribute_utils();
11000
11915
  KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
11001
- name4 = KHR_DRACO_MESH_COMPRESSION;
11916
+ name7 = KHR_DRACO_MESH_COMPRESSION;
11002
11917
  }
11003
11918
  });
11004
11919
 
@@ -11029,10 +11944,10 @@
11029
11944
  // ../gltf/src/lib/extensions/KHR_texture_transform.ts
11030
11945
  var KHR_texture_transform_exports = {};
11031
11946
  __export(KHR_texture_transform_exports, {
11032
- decode: () => decode4,
11033
- name: () => name5
11947
+ decode: () => decode7,
11948
+ name: () => name8
11034
11949
  });
11035
- async function decode4(gltfData, options) {
11950
+ async function decode7(gltfData, options) {
11036
11951
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11037
11952
  const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
11038
11953
  if (!hasExtension || !options.gltf?.loadBuffers) {
@@ -11174,7 +12089,7 @@
11174
12089
  const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1);
11175
12090
  return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
11176
12091
  }
11177
- var EXT_MESHOPT_TRANSFORM, name5, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
12092
+ var EXT_MESHOPT_TRANSFORM, name8, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
11178
12093
  var init_KHR_texture_transform = __esm({
11179
12094
  "../gltf/src/lib/extensions/KHR_texture_transform.ts"() {
11180
12095
  init_esm();
@@ -11182,7 +12097,7 @@
11182
12097
  init_gltf_constants();
11183
12098
  init_gltf_scenegraph();
11184
12099
  EXT_MESHOPT_TRANSFORM = "KHR_texture_transform";
11185
- name5 = EXT_MESHOPT_TRANSFORM;
12100
+ name8 = EXT_MESHOPT_TRANSFORM;
11186
12101
  scratchVector7 = new Vector3();
11187
12102
  scratchRotationMatrix = new Matrix3();
11188
12103
  scratchScaleMatrix = new Matrix3();
@@ -11192,11 +12107,11 @@
11192
12107
  // ../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts
11193
12108
  var KHR_lights_punctual_exports = {};
11194
12109
  __export(KHR_lights_punctual_exports, {
11195
- decode: () => decode5,
12110
+ decode: () => decode8,
11196
12111
  encode: () => encode2,
11197
- name: () => name6
12112
+ name: () => name9
11198
12113
  });
11199
- async function decode5(gltfData) {
12114
+ async function decode8(gltfData) {
11200
12115
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11201
12116
  const { json } = gltfScenegraph;
11202
12117
  const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);
@@ -11229,24 +12144,24 @@
11229
12144
  delete gltfScenegraph.json.lights;
11230
12145
  }
11231
12146
  }
11232
- var KHR_LIGHTS_PUNCTUAL, name6;
12147
+ var KHR_LIGHTS_PUNCTUAL, name9;
11233
12148
  var init_KHR_lights_punctual = __esm({
11234
12149
  "../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
11235
12150
  init_assert6();
11236
12151
  init_gltf_scenegraph();
11237
12152
  KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
11238
- name6 = KHR_LIGHTS_PUNCTUAL;
12153
+ name9 = KHR_LIGHTS_PUNCTUAL;
11239
12154
  }
11240
12155
  });
11241
12156
 
11242
12157
  // ../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts
11243
12158
  var KHR_materials_unlit_exports = {};
11244
12159
  __export(KHR_materials_unlit_exports, {
11245
- decode: () => decode6,
12160
+ decode: () => decode9,
11246
12161
  encode: () => encode3,
11247
- name: () => name7
12162
+ name: () => name10
11248
12163
  });
11249
- async function decode6(gltfData) {
12164
+ async function decode9(gltfData) {
11250
12165
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11251
12166
  const { json } = gltfScenegraph;
11252
12167
  for (const material of json.materials || []) {
@@ -11264,300 +12179,87 @@
11264
12179
  if (gltfScenegraph.materials) {
11265
12180
  for (const material of json.materials || []) {
11266
12181
  if (material.unlit) {
11267
- delete material.unlit;
11268
- gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
11269
- gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
11270
- }
11271
- }
11272
- }
11273
- }
11274
- var KHR_MATERIALS_UNLIT, name7;
11275
- var init_KHR_materials_unlit = __esm({
11276
- "../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
11277
- init_gltf_scenegraph();
11278
- KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
11279
- name7 = KHR_MATERIALS_UNLIT;
11280
- }
11281
- });
11282
-
11283
- // ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
11284
- var KHR_techniques_webgl_exports = {};
11285
- __export(KHR_techniques_webgl_exports, {
11286
- decode: () => decode7,
11287
- encode: () => encode4,
11288
- name: () => name8
11289
- });
11290
- async function decode7(gltfData) {
11291
- const gltfScenegraph = new GLTFScenegraph(gltfData);
11292
- const { json } = gltfScenegraph;
11293
- const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
11294
- if (extension) {
11295
- const techniques = resolveTechniques(extension, gltfScenegraph);
11296
- for (const material of json.materials || []) {
11297
- const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11298
- if (materialExtension) {
11299
- material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
11300
- material.technique.values = resolveValues(material.technique, gltfScenegraph);
11301
- }
11302
- gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11303
- }
11304
- gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
11305
- }
11306
- }
11307
- async function encode4(gltfData, options) {
11308
- }
11309
- function resolveTechniques(techniquesExtension, gltfScenegraph) {
11310
- const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
11311
- const textDecoder = new TextDecoder();
11312
- shaders.forEach((shader) => {
11313
- if (Number.isFinite(shader.bufferView)) {
11314
- shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
11315
- } else {
11316
- throw new Error("KHR_techniques_webgl: no shader code");
11317
- }
11318
- });
11319
- programs.forEach((program) => {
11320
- program.fragmentShader = shaders[program.fragmentShader];
11321
- program.vertexShader = shaders[program.vertexShader];
11322
- });
11323
- techniques.forEach((technique) => {
11324
- technique.program = programs[technique.program];
11325
- });
11326
- return techniques;
11327
- }
11328
- function resolveValues(technique, gltfScenegraph) {
11329
- const values = Object.assign({}, technique.values);
11330
- Object.keys(technique.uniforms || {}).forEach((uniform) => {
11331
- if (technique.uniforms[uniform].value && !(uniform in values)) {
11332
- values[uniform] = technique.uniforms[uniform].value;
11333
- }
11334
- });
11335
- Object.keys(values).forEach((uniform) => {
11336
- if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
11337
- values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
11338
- }
11339
- });
11340
- return values;
11341
- }
11342
- var KHR_TECHNIQUES_WEBGL, name8;
11343
- var init_KHR_techniques_webgl = __esm({
11344
- "../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
11345
- init_gltf_scenegraph();
11346
- KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
11347
- name8 = KHR_TECHNIQUES_WEBGL;
11348
- }
11349
- });
11350
-
11351
- // ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
11352
- var EXT_feature_metadata_exports = {};
11353
- __export(EXT_feature_metadata_exports, {
11354
- decode: () => decode8,
11355
- name: () => name9
11356
- });
11357
- async function decode8(gltfData, options) {
11358
- const scenegraph = new GLTFScenegraph(gltfData);
11359
- decodeExtFeatureMetadata(scenegraph, options);
11360
- }
11361
- function decodeExtFeatureMetadata(scenegraph, options) {
11362
- const extension = scenegraph.getExtension(EXT_FEATURE_METADATA);
11363
- if (!extension)
11364
- return;
11365
- const schemaClasses = extension.schema?.classes;
11366
- const { featureTables } = extension;
11367
- if (schemaClasses && featureTables) {
11368
- for (const schemaName in schemaClasses) {
11369
- const schemaClass = schemaClasses[schemaName];
11370
- const featureTable = findFeatureTableByName(featureTables, schemaName);
11371
- if (featureTable) {
11372
- handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
11373
- }
11374
- }
11375
- }
11376
- const { featureTextures } = extension;
11377
- if (schemaClasses && featureTextures && options.gltf?.loadImages) {
11378
- for (const schemaName in schemaClasses) {
11379
- const schemaClass = schemaClasses[schemaName];
11380
- const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
11381
- if (featureTexture) {
11382
- handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
11383
- }
11384
- }
11385
- }
11386
- }
11387
- function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
11388
- for (const propertyName in schemaClass.properties) {
11389
- const schemaProperty = schemaClass.properties[propertyName];
11390
- const featureTableProperty = featureTable?.properties?.[propertyName];
11391
- const numberOfFeatures = featureTable.count;
11392
- if (featureTableProperty) {
11393
- const data = getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
11394
- featureTableProperty.data = data;
11395
- }
11396
- }
11397
- }
11398
- function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
11399
- const attributeName = featureTexture.class;
11400
- for (const propertyName in schemaClass.properties) {
11401
- const featureTextureProperty = featureTexture?.properties?.[propertyName];
11402
- if (featureTextureProperty) {
11403
- const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
11404
- featureTextureProperty.data = data;
11405
- }
11406
- }
11407
- }
11408
- function getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
11409
- const bufferView = featureTableProperty.bufferView;
11410
- const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
11411
- switch (schemaProperty.type) {
11412
- case "STRING": {
11413
- const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
11414
- const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
11415
- return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
11416
- }
11417
- default:
11418
- }
11419
- return dataArray;
11420
- }
11421
- function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
11422
- const json = scenegraph.gltf.json;
11423
- if (!json.meshes) {
11424
- return [];
11425
- }
11426
- const featureTextureTable = [];
11427
- for (const mesh of json.meshes) {
11428
- for (const primitive of mesh.primitives) {
11429
- processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
11430
- }
11431
- }
11432
- return featureTextureTable;
11433
- }
11434
- function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
11435
- const json = scenegraph.gltf.json;
11436
- const textureData = [];
11437
- const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
11438
- const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
11439
- const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
11440
- const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
11441
- const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
11442
- const textureIndex = featureTextureProperty.texture.index;
11443
- const texture = json.textures?.[textureIndex];
11444
- const imageIndex = texture?.source;
11445
- if (typeof imageIndex !== "undefined") {
11446
- const image = json.images?.[imageIndex];
11447
- const mimeType = image?.mimeType;
11448
- const parsedImage = scenegraph.gltf.images?.[imageIndex];
11449
- if (parsedImage) {
11450
- for (let index = 0; index < textureCoordinates.length; index += 2) {
11451
- const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
11452
- textureData.push(value);
11453
- }
11454
- }
11455
- }
11456
- const featureIndices = [];
11457
- for (const texelData of textureData) {
11458
- let index = featureTextureTable.findIndex((item) => item === texelData);
11459
- if (index === -1) {
11460
- index = featureTextureTable.push(texelData) - 1;
11461
- }
11462
- featureIndices.push(index);
11463
- }
11464
- const typedArray = new Uint32Array(featureIndices);
11465
- const bufferIndex = scenegraph.gltf.buffers.push({
11466
- arrayBuffer: typedArray.buffer,
11467
- byteOffset: 0,
11468
- byteLength: typedArray.byteLength
11469
- }) - 1;
11470
- const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
11471
- const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
11472
- size: 1,
11473
- componentType: getComponentTypeFromArray(typedArray),
11474
- count: typedArray.length
11475
- });
11476
- primitive.attributes[attributeName] = accessorIndex;
11477
- }
11478
- function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels) {
11479
- const CHANNELS_MAP = {
11480
- r: { offset: 0, shift: 0 },
11481
- g: { offset: 1, shift: 8 },
11482
- b: { offset: 2, shift: 16 },
11483
- a: { offset: 3, shift: 24 }
11484
- };
11485
- const u = textureCoordinates[index];
11486
- const v = textureCoordinates[index + 1];
11487
- let components = 1;
11488
- if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
11489
- components = 4;
11490
- const offset = coordinatesToOffset(u, v, parsedImage, components);
11491
- let value = 0;
11492
- for (const c of channels) {
11493
- const map2 = CHANNELS_MAP[c];
11494
- const val = getVal(parsedImage, offset + map2.offset);
11495
- value |= val << map2.shift;
12182
+ delete material.unlit;
12183
+ gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
12184
+ gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
12185
+ }
12186
+ }
11496
12187
  }
11497
- return value;
11498
12188
  }
11499
- function getVal(parsedImage, offset) {
11500
- const imageData = getImageData(parsedImage);
11501
- if (imageData.data.length <= offset) {
11502
- throw new Error(`${imageData.data.length} <= ${offset}`);
12189
+ var KHR_MATERIALS_UNLIT, name10;
12190
+ var init_KHR_materials_unlit = __esm({
12191
+ "../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
12192
+ init_gltf_scenegraph();
12193
+ KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
12194
+ name10 = KHR_MATERIALS_UNLIT;
11503
12195
  }
11504
- return imageData.data[offset];
11505
- }
11506
- function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
11507
- const w = parsedImage.width;
11508
- const iX = emod(u) * (w - 1);
11509
- const indX = Math.round(iX);
11510
- const h = parsedImage.height;
11511
- const iY = emod(v) * (h - 1);
11512
- const indY = Math.round(iY);
11513
- const components = parsedImage.components ? parsedImage.components : componentsCount;
11514
- const offset = (indY * w + indX) * components;
11515
- return offset;
11516
- }
11517
- function emod(n2) {
11518
- const a2 = (n2 % 1 + 1) % 1;
11519
- return a2;
11520
- }
11521
- function findFeatureTableByName(featureTables, schemaClassName) {
11522
- for (const featureTableName in featureTables) {
11523
- const featureTable = featureTables[featureTableName];
11524
- if (featureTable.class === schemaClassName) {
11525
- return featureTable;
12196
+ });
12197
+
12198
+ // ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
12199
+ var KHR_techniques_webgl_exports = {};
12200
+ __export(KHR_techniques_webgl_exports, {
12201
+ decode: () => decode10,
12202
+ encode: () => encode4,
12203
+ name: () => name11
12204
+ });
12205
+ async function decode10(gltfData) {
12206
+ const gltfScenegraph = new GLTFScenegraph(gltfData);
12207
+ const { json } = gltfScenegraph;
12208
+ const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
12209
+ if (extension) {
12210
+ const techniques = resolveTechniques(extension, gltfScenegraph);
12211
+ for (const material of json.materials || []) {
12212
+ const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
12213
+ if (materialExtension) {
12214
+ material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
12215
+ material.technique.values = resolveValues(material.technique, gltfScenegraph);
12216
+ }
12217
+ gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11526
12218
  }
12219
+ gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
11527
12220
  }
11528
- return null;
11529
12221
  }
11530
- function findFeatureTextureByName(featureTextures, schemaClassName) {
11531
- for (const featureTexturesName in featureTextures) {
11532
- const featureTable = featureTextures[featureTexturesName];
11533
- if (featureTable.class === schemaClassName) {
11534
- return featureTable;
12222
+ async function encode4(gltfData, options) {
12223
+ }
12224
+ function resolveTechniques(techniquesExtension, gltfScenegraph) {
12225
+ const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
12226
+ const textDecoder = new TextDecoder();
12227
+ shaders.forEach((shader) => {
12228
+ if (Number.isFinite(shader.bufferView)) {
12229
+ shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
12230
+ } else {
12231
+ throw new Error("KHR_techniques_webgl: no shader code");
11535
12232
  }
11536
- }
11537
- return null;
12233
+ });
12234
+ programs.forEach((program) => {
12235
+ program.fragmentShader = shaders[program.fragmentShader];
12236
+ program.vertexShader = shaders[program.vertexShader];
12237
+ });
12238
+ techniques.forEach((technique) => {
12239
+ technique.program = programs[technique.program];
12240
+ });
12241
+ return techniques;
11538
12242
  }
11539
- function getStringAttributes(data, offsetsData, stringsCount) {
11540
- const stringsArray = [];
11541
- const textDecoder = new TextDecoder("utf8");
11542
- let stringOffset = 0;
11543
- const bytesPerStringSize = 4;
11544
- for (let index = 0; index < stringsCount; index++) {
11545
- const stringByteSize = offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];
11546
- const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
11547
- const stringAttribute = textDecoder.decode(stringData);
11548
- stringsArray.push(stringAttribute);
11549
- stringOffset += stringByteSize;
11550
- }
11551
- return stringsArray;
12243
+ function resolveValues(technique, gltfScenegraph) {
12244
+ const values = Object.assign({}, technique.values);
12245
+ Object.keys(technique.uniforms || {}).forEach((uniform) => {
12246
+ if (technique.uniforms[uniform].value && !(uniform in values)) {
12247
+ values[uniform] = technique.uniforms[uniform].value;
12248
+ }
12249
+ });
12250
+ Object.keys(values).forEach((uniform) => {
12251
+ if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
12252
+ values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
12253
+ }
12254
+ });
12255
+ return values;
11552
12256
  }
11553
- var EXT_FEATURE_METADATA, name9;
11554
- var init_EXT_feature_metadata = __esm({
11555
- "../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
12257
+ var KHR_TECHNIQUES_WEBGL, name11;
12258
+ var init_KHR_techniques_webgl = __esm({
12259
+ "../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
11556
12260
  init_gltf_scenegraph();
11557
- init_src8();
11558
- init_gltf_utils();
11559
- EXT_FEATURE_METADATA = "EXT_feature_metadata";
11560
- name9 = EXT_FEATURE_METADATA;
12261
+ KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
12262
+ name11 = KHR_TECHNIQUES_WEBGL;
11561
12263
  }
11562
12264
  });
11563
12265
 
@@ -11582,6 +12284,8 @@
11582
12284
  var EXTENSIONS2;
11583
12285
  var init_gltf_extensions = __esm({
11584
12286
  "../gltf/src/lib/api/gltf-extensions.ts"() {
12287
+ init_EXT_mesh_features();
12288
+ init_EXT_structural_metadata();
11585
12289
  init_EXT_meshopt_compression();
11586
12290
  init_EXT_texture_webp();
11587
12291
  init_KHR_texture_basisu();
@@ -11592,6 +12296,8 @@
11592
12296
  init_KHR_techniques_webgl();
11593
12297
  init_EXT_feature_metadata();
11594
12298
  EXTENSIONS2 = [
12299
+ EXT_mesh_features_exports,
12300
+ EXT_structural_metadata_exports,
11595
12301
  EXT_meshopt_compression_exports,
11596
12302
  EXT_texture_webp_exports,
11597
12303
  KHR_texture_basisu_exports,
@@ -11920,10 +12626,10 @@
11920
12626
  return Array.from(imageIndices).sort();
11921
12627
  }
11922
12628
  async function loadImage(gltf, image, index, options, context) {
11923
- const { fetch: fetch2, parse: parse5 } = context;
11924
12629
  let arrayBuffer;
11925
12630
  if (image.uri && !image.hasOwnProperty("bufferView")) {
11926
12631
  const uri = resolveUrl(image.uri, options);
12632
+ const { fetch: fetch2 } = context;
11927
12633
  const response = await fetch2(uri);
11928
12634
  arrayBuffer = await response.arrayBuffer();
11929
12635
  image.bufferView = {
@@ -11935,7 +12641,7 @@
11935
12641
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
11936
12642
  }
11937
12643
  assert7(arrayBuffer, "glTF image has no data");
11938
- let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], {
12644
+ let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], {
11939
12645
  ...options,
11940
12646
  mimeType: image.mimeType,
11941
12647
  basis: options.basis || { format: selectSupportedBasisFormat() }
@@ -11977,13 +12683,13 @@
11977
12683
  var GLTFLoader;
11978
12684
  var init_gltf_loader = __esm({
11979
12685
  "../gltf/src/gltf-loader.ts"() {
11980
- init_version4();
12686
+ init_version5();
11981
12687
  init_parse_gltf();
11982
12688
  GLTFLoader = {
11983
12689
  name: "glTF",
11984
12690
  id: "gltf",
11985
12691
  module: "gltf",
11986
- version: VERSION6,
12692
+ version: VERSION7,
11987
12693
  extensions: ["gltf", "glb"],
11988
12694
  mimeTypes: ["model/gltf+json", "model/gltf-binary"],
11989
12695
  text: true,
@@ -12420,14 +13126,14 @@
12420
13126
  if (!context) {
12421
13127
  return;
12422
13128
  }
12423
- const { parse: parse5, fetch: fetch2 } = context;
12424
13129
  if (tile.gltfUrl) {
13130
+ const { fetch: fetch2 } = context;
12425
13131
  const response = await fetch2(tile.gltfUrl, options);
12426
13132
  tile.gltfArrayBuffer = await response.arrayBuffer();
12427
13133
  tile.gltfByteOffset = 0;
12428
13134
  }
12429
13135
  if (tile.gltfArrayBuffer) {
12430
- const gltfWithBuffers = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
13136
+ const gltfWithBuffers = await parseFromContext(tile.gltfArrayBuffer, GLTFLoader, options, context);
12431
13137
  tile.gltf = postProcessGLTF(gltfWithBuffers);
12432
13138
  tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
12433
13139
  delete tile.gltfArrayBuffer;
@@ -12646,7 +13352,7 @@
12646
13352
  byteOffset += 4;
12647
13353
  tile.tiles = [];
12648
13354
  while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
12649
- const subtile = {};
13355
+ const subtile = { shape: "tile3d" };
12650
13356
  tile.tiles.push(subtile);
12651
13357
  byteOffset = await parse3DTile2(arrayBuffer, byteOffset, options, context, subtile);
12652
13358
  }
@@ -12661,27 +13367,28 @@
12661
13367
  // src/lib/parsers/parse-3d-tile-gltf.ts
12662
13368
  async function parseGltf3DTile(tile, arrayBuffer, options, context) {
12663
13369
  tile.rotateYtoZ = true;
12664
- tile.gltfUpAxis = options?.["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
13370
+ tile.gltfUpAxis = options?.["3d-tiles"]?.assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
12665
13371
  if (options?.["3d-tiles"]?.loadGLTF) {
12666
13372
  if (!context) {
12667
- return;
13373
+ return arrayBuffer.byteLength;
12668
13374
  }
12669
- const { parse: parse5 } = context;
12670
- const gltfWithBuffers = await parse5(arrayBuffer, GLTFLoader, options, context);
13375
+ const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
12671
13376
  tile.gltf = postProcessGLTF(gltfWithBuffers);
12672
13377
  tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
12673
13378
  } else {
12674
13379
  tile.gltfArrayBuffer = arrayBuffer;
12675
13380
  }
13381
+ return arrayBuffer.byteLength;
12676
13382
  }
12677
13383
  var init_parse_3d_tile_gltf = __esm({
12678
13384
  "src/lib/parsers/parse-3d-tile-gltf.ts"() {
13385
+ init_src2();
12679
13386
  init_src10();
12680
13387
  }
12681
13388
  });
12682
13389
 
12683
13390
  // src/lib/parsers/parse-3d-tile.ts
12684
- async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
13391
+ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = { shape: "tile3d" }) {
12685
13392
  tile.byteOffset = byteOffset;
12686
13393
  tile.type = getMagicString3(arrayBuffer, byteOffset);
12687
13394
  switch (tile.type) {
@@ -13001,7 +13708,7 @@
13001
13708
  for (const key of propNames) {
13002
13709
  const value = object[key];
13003
13710
  if (typeof value === "function") {
13004
- if (!predefined.find((name10) => key === name10)) {
13711
+ if (!predefined.find((name12) => key === name12)) {
13005
13712
  object[key] = value.bind(obj);
13006
13713
  }
13007
13714
  }
@@ -13834,7 +14541,7 @@
13834
14541
  LongPrototype.toInt = function toInt() {
13835
14542
  return this.unsigned ? this.low >>> 0 : this.low;
13836
14543
  };
13837
- LongPrototype.toNumber = function toNumber() {
14544
+ LongPrototype.toNumber = function toNumber2() {
13838
14545
  if (this.unsigned)
13839
14546
  return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
13840
14547
  return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
@@ -14903,7 +15610,7 @@
14903
15610
  } else if (uri.startsWith("/")) {
14904
15611
  return uri;
14905
15612
  }
14906
- return `${basePath}/${uri}`;
15613
+ return path_exports.resolve(basePath, uri);
14907
15614
  }
14908
15615
  function normalizeTileData(tile, basePath) {
14909
15616
  if (!tile) {
@@ -15028,6 +15735,7 @@
15028
15735
  }
15029
15736
  var init_parse_3d_tile_header2 = __esm({
15030
15737
  "src/lib/parsers/parse-3d-tile-header.ts"() {
15738
+ init_src2();
15031
15739
  init_tile_3d_subtree_loader();
15032
15740
  init_src3();
15033
15741
  init_src4();
@@ -15054,6 +15762,7 @@
15054
15762
  const normalizedRoot = await normalizeTileHeaders(tilesetJson, basePath, options || {});
15055
15763
  const tilesetJsonPostprocessed = {
15056
15764
  ...tilesetJson,
15765
+ shape: "tileset3d",
15057
15766
  loader: Tiles3DLoader,
15058
15767
  url: tilesetUrl,
15059
15768
  queryString: context?.queryString || "",
@@ -15068,6 +15777,7 @@
15068
15777
  async function parseTile(arrayBuffer, options, context) {
15069
15778
  const tile = {
15070
15779
  content: {
15780
+ shape: "tile3d",
15071
15781
  featureIds: null
15072
15782
  }
15073
15783
  };
@@ -15201,44 +15911,6 @@
15201
15911
  }
15202
15912
  });
15203
15913
 
15204
- // ../zip/src/file-provider/data-view-file.ts
15205
- var toNumber2, DataViewFile;
15206
- var init_data_view_file = __esm({
15207
- "../zip/src/file-provider/data-view-file.ts"() {
15208
- toNumber2 = (bigint) => {
15209
- if (bigint > Number.MAX_SAFE_INTEGER) {
15210
- throw new Error("Offset is out of bounds");
15211
- }
15212
- return Number(bigint);
15213
- };
15214
- DataViewFile = class {
15215
- constructor(file) {
15216
- this.file = file;
15217
- }
15218
- async destroy() {
15219
- }
15220
- async getUint8(offset) {
15221
- return this.file.getUint8(toNumber2(offset));
15222
- }
15223
- async getUint16(offset) {
15224
- return this.file.getUint16(toNumber2(offset), true);
15225
- }
15226
- async getUint32(offset) {
15227
- return this.file.getUint32(toNumber2(offset), true);
15228
- }
15229
- async getBigUint64(offset) {
15230
- return this.file.getBigUint64(toNumber2(offset), true);
15231
- }
15232
- async slice(startOffset, endOffset) {
15233
- return this.file.buffer.slice(toNumber2(startOffset), toNumber2(endOffset));
15234
- }
15235
- get length() {
15236
- return BigInt(this.file.byteLength);
15237
- }
15238
- };
15239
- }
15240
- });
15241
-
15242
15914
  // ../zip/src/parse-zip/search-from-the-end.ts
15243
15915
  var searchFromTheEnd;
15244
15916
  var init_search_from_the_end = __esm({
@@ -15707,17 +16379,6 @@
15707
16379
  }
15708
16380
  });
15709
16381
 
15710
- // ../zip/src/index.ts
15711
- var init_src11 = __esm({
15712
- "../zip/src/index.ts"() {
15713
- init_data_view_file();
15714
- init_cd_file_header();
15715
- init_local_file_header();
15716
- init_search_from_the_end();
15717
- init_hash_file_utility();
15718
- }
15719
- });
15720
-
15721
16382
  // ../compression/src/lib/compression.ts
15722
16383
  var Compression;
15723
16384
  var init_compression = __esm({
@@ -15766,6 +16427,36 @@
15766
16427
  }
15767
16428
  });
15768
16429
 
16430
+ // ../compression/src/lib/no-compression.ts
16431
+ var NoCompression;
16432
+ var init_no_compression = __esm({
16433
+ "../compression/src/lib/no-compression.ts"() {
16434
+ init_compression();
16435
+ NoCompression = class extends Compression {
16436
+ constructor(options) {
16437
+ super(options);
16438
+ this.name = "uncompressed";
16439
+ this.extensions = [];
16440
+ this.contentEncodings = [];
16441
+ this.isSupported = true;
16442
+ this.options = options || {};
16443
+ }
16444
+ compressSync(input) {
16445
+ return input;
16446
+ }
16447
+ decompressSync(input) {
16448
+ return input;
16449
+ }
16450
+ async *compressBatches(asyncIterator) {
16451
+ return yield* asyncIterator;
16452
+ }
16453
+ async *decompressBatches(asyncIterator) {
16454
+ return yield* asyncIterator;
16455
+ }
16456
+ };
16457
+ }
16458
+ });
16459
+
15769
16460
  // ../../node_modules/pako/lib/utils/common.js
15770
16461
  var require_common = __commonJS({
15771
16462
  "../../node_modules/pako/lib/utils/common.js"(exports) {
@@ -19984,19 +20675,23 @@
19984
20675
  });
19985
20676
 
19986
20677
  // ../compression/src/index.ts
19987
- var init_src12 = __esm({
20678
+ var init_src11 = __esm({
19988
20679
  "../compression/src/index.ts"() {
20680
+ init_no_compression();
19989
20681
  init_deflate_compression();
19990
20682
  }
19991
20683
  });
19992
20684
 
19993
- // src/tz3/tz3-archive.ts
19994
- var import_md52, COMPRESSION_METHODS, TZ3Archive;
19995
- var init_tz3_archive = __esm({
19996
- "src/tz3/tz3-archive.ts"() {
19997
- import_md52 = __toModule(require_md5());
20685
+ // ../zip/src/filesystems/zip-filesystem.ts
20686
+ var COMPRESSION_METHODS, ZipFileSystem;
20687
+ var init_zip_filesystem = __esm({
20688
+ "../zip/src/filesystems/zip-filesystem.ts"() {
20689
+ init_src2();
20690
+ init_src2();
20691
+ init_src2();
20692
+ init_cd_file_header();
20693
+ init_local_file_header();
19998
20694
  init_src11();
19999
- init_src12();
20000
20695
  COMPRESSION_METHODS = {
20001
20696
  0: async (compressedFile) => compressedFile,
20002
20697
  8: async (compressedFile) => {
@@ -20005,9 +20700,109 @@
20005
20700
  return decompressedData;
20006
20701
  }
20007
20702
  };
20008
- TZ3Archive = class {
20009
- constructor(tz3Archive, hashFile) {
20010
- this.tz3Archive = tz3Archive;
20703
+ ZipFileSystem = class {
20704
+ constructor(file) {
20705
+ this.fileProvider = Promise.resolve(null);
20706
+ if (typeof file === "string") {
20707
+ this.fileName = file;
20708
+ if (!isBrowser) {
20709
+ this.fileProvider = FileHandleFile.from(file);
20710
+ } else {
20711
+ throw new Error("Cannot open file for random access in a WEB browser");
20712
+ }
20713
+ } else if (isFileProvider(file)) {
20714
+ this.fileProvider = Promise.resolve(file);
20715
+ }
20716
+ }
20717
+ async destroy() {
20718
+ const fileProvider = await this.fileProvider;
20719
+ if (fileProvider) {
20720
+ await fileProvider.destroy();
20721
+ }
20722
+ }
20723
+ async readdir() {
20724
+ const fileProvider = await this.fileProvider;
20725
+ if (!fileProvider) {
20726
+ throw new Error("No data detected in the zip archive");
20727
+ }
20728
+ const fileNames = [];
20729
+ const zipCDIterator = zipCDFileHeaderGenerator(fileProvider);
20730
+ for await (const cdHeader of zipCDIterator) {
20731
+ fileNames.push(cdHeader.fileName);
20732
+ }
20733
+ return fileNames;
20734
+ }
20735
+ async stat(filename2) {
20736
+ const cdFileHeader = await this.getCDFileHeader(filename2);
20737
+ return { ...cdFileHeader, size: Number(cdFileHeader.uncompressedSize) };
20738
+ }
20739
+ async fetch(filename2) {
20740
+ const fileProvider = await this.fileProvider;
20741
+ if (!fileProvider) {
20742
+ throw new Error("No data detected in the zip archive");
20743
+ }
20744
+ const cdFileHeader = await this.getCDFileHeader(filename2);
20745
+ const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
20746
+ if (!localFileHeader) {
20747
+ throw new Error("Local file header has not been found in the zip archive`");
20748
+ }
20749
+ const compressionHandler = COMPRESSION_METHODS[localFileHeader.compressionMethod.toString()];
20750
+ if (!compressionHandler) {
20751
+ throw Error("Only Deflation compression is supported");
20752
+ }
20753
+ const compressedFile = await fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20754
+ const uncompressedFile = await compressionHandler(compressedFile);
20755
+ const response = new Response(uncompressedFile);
20756
+ Object.defineProperty(response, "url", { value: `${this.fileName || ""}/${filename2}` });
20757
+ return response;
20758
+ }
20759
+ async getCDFileHeader(filename2) {
20760
+ const fileProvider = await this.fileProvider;
20761
+ if (!fileProvider) {
20762
+ throw new Error("No data detected in the zip archive");
20763
+ }
20764
+ const zipCDIterator = zipCDFileHeaderGenerator(fileProvider);
20765
+ let result = null;
20766
+ for await (const cdHeader of zipCDIterator) {
20767
+ if (cdHeader.fileName === filename2) {
20768
+ result = cdHeader;
20769
+ break;
20770
+ }
20771
+ }
20772
+ if (!result) {
20773
+ throw new Error("File has not been found in the zip archive");
20774
+ }
20775
+ return result;
20776
+ }
20777
+ };
20778
+ }
20779
+ });
20780
+
20781
+ // ../zip/src/index.ts
20782
+ var init_src12 = __esm({
20783
+ "../zip/src/index.ts"() {
20784
+ init_cd_file_header();
20785
+ init_local_file_header();
20786
+ init_search_from_the_end();
20787
+ init_hash_file_utility();
20788
+ init_zip_filesystem();
20789
+ }
20790
+ });
20791
+
20792
+ // src/3d-tiles-archive/3d-tiles-archive-archive.ts
20793
+ var import_md52, COMPRESSION_METHODS2, Tiles3DArchive;
20794
+ var init_d_tiles_archive_archive = __esm({
20795
+ "src/3d-tiles-archive/3d-tiles-archive-archive.ts"() {
20796
+ import_md52 = __toModule(require_md5());
20797
+ init_src12();
20798
+ init_src11();
20799
+ COMPRESSION_METHODS2 = {
20800
+ 0: (data) => new NoCompression().decompress(data),
20801
+ 8: (data) => new DeflateCompression({ raw: true }).decompress(data)
20802
+ };
20803
+ Tiles3DArchive = class {
20804
+ constructor(fileProvider, hashFile) {
20805
+ this.fileProvider = fileProvider;
20011
20806
  this.hashArray = hashFile;
20012
20807
  }
20013
20808
  async getFile(path) {
@@ -20016,10 +20811,9 @@
20016
20811
  data = await this.getFileBytes(path);
20017
20812
  }
20018
20813
  if (!data) {
20019
- throw new Error("No such file in the archieve");
20814
+ throw new Error("No such file in the archive");
20020
20815
  }
20021
- const decompressedFile = Buffer.from(data);
20022
- return decompressedFile;
20816
+ return data;
20023
20817
  }
20024
20818
  async getFileBytes(path) {
20025
20819
  const nameHash = Buffer.from((0, import_md52.default)(path), "hex");
@@ -20027,12 +20821,12 @@
20027
20821
  if (!fileInfo) {
20028
20822
  return null;
20029
20823
  }
20030
- const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.tz3Archive);
20824
+ const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.fileProvider);
20031
20825
  if (!localFileHeader) {
20032
20826
  return null;
20033
20827
  }
20034
- const compressedFile = await this.tz3Archive.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20035
- const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
20828
+ const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20829
+ const compressionMethod = COMPRESSION_METHODS2[localFileHeader.compressionMethod];
20036
20830
  if (!compressionMethod) {
20037
20831
  throw Error("Only Deflation compression is supported");
20038
20832
  }
@@ -20042,13 +20836,13 @@
20042
20836
  }
20043
20837
  });
20044
20838
 
20045
- // src/tz3/tz3-parser.ts
20046
- var parse3tz;
20047
- var init_tz3_parser = __esm({
20048
- "src/tz3/tz3-parser.ts"() {
20049
- init_src11();
20050
- init_tz3_archive();
20051
- parse3tz = async (fileProvider, cb) => {
20839
+ // src/3d-tiles-archive/3d-tiles-archive-parser.ts
20840
+ var parse3DTilesArchive;
20841
+ var init_d_tiles_archive_parser = __esm({
20842
+ "src/3d-tiles-archive/3d-tiles-archive-parser.ts"() {
20843
+ init_src12();
20844
+ init_d_tiles_archive_archive();
20845
+ parse3DTilesArchive = async (fileProvider, cb) => {
20052
20846
  const hashCDOffset = await searchFromTheEnd(fileProvider, signature);
20053
20847
  const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
20054
20848
  let hashData;
@@ -20066,34 +20860,86 @@
20066
20860
  const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
20067
20861
  hashData = parseHashFile(hashFile);
20068
20862
  }
20069
- return new TZ3Archive(fileProvider, hashData);
20863
+ return new Tiles3DArchive(fileProvider, hashData);
20070
20864
  };
20071
20865
  }
20072
20866
  });
20073
20867
 
20074
- // src/tz3-loader.ts
20075
- async function parse3tz2(data, options = {}) {
20076
- return (await parse3tz(new DataViewFile(new DataView(data)))).getFile(options.tz3?.path ?? "");
20868
+ // src/3d-tiles-archive-loader.ts
20869
+ async function parse3DTilesArchive2(data, options = {}) {
20870
+ const archive = await parse3DTilesArchive(new DataViewFile(new DataView(data)));
20871
+ return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
20077
20872
  }
20078
- var VERSION10, TZ3Loader;
20079
- var init_tz3_loader = __esm({
20080
- "src/tz3-loader.ts"() {
20081
- init_src11();
20082
- init_tz3_parser();
20873
+ var VERSION10, Tiles3DArchiveFileLoader;
20874
+ var init_d_tiles_archive_loader = __esm({
20875
+ "src/3d-tiles-archive-loader.ts"() {
20876
+ init_src2();
20877
+ init_d_tiles_archive_parser();
20083
20878
  VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
20084
- TZ3Loader = {
20879
+ Tiles3DArchiveFileLoader = {
20085
20880
  name: "3tz",
20086
20881
  id: "3tz",
20087
- module: "i3s",
20882
+ module: "3d-tiles",
20088
20883
  version: VERSION10,
20089
- mimeTypes: ["application/octet-stream"],
20090
- parse: parse3tz2,
20884
+ mimeTypes: ["application/octet-stream", "application/vnd.maxar.archive.3tz+zip"],
20885
+ parse: parse3DTilesArchive2,
20091
20886
  extensions: ["3tz"],
20092
20887
  options: {}
20093
20888
  };
20094
20889
  }
20095
20890
  });
20096
20891
 
20892
+ // src/lib/filesystems/tiles-3d-archive-file-system.ts
20893
+ var Tiles3DArchiveFileSystem;
20894
+ var init_tiles_3d_archive_file_system = __esm({
20895
+ "src/lib/filesystems/tiles-3d-archive-file-system.ts"() {
20896
+ init_src12();
20897
+ init_d_tiles_archive_archive();
20898
+ Tiles3DArchiveFileSystem = class extends ZipFileSystem {
20899
+ constructor(file) {
20900
+ super(file);
20901
+ }
20902
+ async fetch(filename2) {
20903
+ const fileProvider = await this.fileProvider;
20904
+ if (!fileProvider) {
20905
+ throw new Error("No data detected in the zip archive");
20906
+ }
20907
+ await this.parseHashFile();
20908
+ if (this.hashData) {
20909
+ const archive = new Tiles3DArchive(fileProvider, this.hashData);
20910
+ const fileData = await archive.getFile(filename2);
20911
+ const response = new Response(fileData);
20912
+ Object.defineProperty(response, "url", { value: `${this.fileName || ""}/${filename2}` });
20913
+ return response;
20914
+ }
20915
+ return super.fetch(filename2);
20916
+ }
20917
+ async parseHashFile() {
20918
+ if (this.hashData !== void 0) {
20919
+ return;
20920
+ }
20921
+ const fileProvider = await this.fileProvider;
20922
+ if (!fileProvider) {
20923
+ throw new Error("No data detected in the zip archive");
20924
+ }
20925
+ const hashCDOffset = await searchFromTheEnd(fileProvider, signature);
20926
+ const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
20927
+ if (cdFileHeader?.fileName === "@3dtilesIndex1@") {
20928
+ const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
20929
+ if (!localFileHeader) {
20930
+ throw new Error("corrupted 3tz");
20931
+ }
20932
+ const fileDataOffset = localFileHeader.fileDataOffset;
20933
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
20934
+ this.hashData = parseHashFile(hashFile);
20935
+ } else {
20936
+ this.hashData = null;
20937
+ }
20938
+ }
20939
+ };
20940
+ }
20941
+ });
20942
+
20097
20943
  // src/lib/encoders/helpers/encode-3d-tile-header.ts
20098
20944
  function encode3DTileHeader(tile, dataView, byteOffset) {
20099
20945
  const HEADER_SIZE = 12;
@@ -20320,11 +21166,12 @@
20320
21166
  __export(src_exports, {
20321
21167
  CesiumIonLoader: () => CesiumIonLoader,
20322
21168
  TILE3D_TYPE: () => TILE3D_TYPE,
20323
- TZ3Loader: () => TZ3Loader,
20324
21169
  Tile3DBatchTable: () => Tile3DBatchTableParser,
20325
21170
  Tile3DFeatureTable: () => Tile3DFeatureTable,
20326
21171
  Tile3DSubtreeLoader: () => Tile3DSubtreeLoader,
20327
21172
  Tile3DWriter: () => Tile3DWriter,
21173
+ Tiles3DArchiveFileLoader: () => Tiles3DArchiveFileLoader,
21174
+ Tiles3DArchiveFileSystem: () => Tiles3DArchiveFileSystem,
20328
21175
  Tiles3DLoader: () => Tiles3DLoader,
20329
21176
  _getIonTilesetMetadata: () => getIonTilesetMetadata
20330
21177
  });
@@ -20333,7 +21180,8 @@
20333
21180
  init_tiles_3d_loader();
20334
21181
  init_cesium_ion_loader();
20335
21182
  init_tile_3d_subtree_loader();
20336
- init_tz3_loader();
21183
+ init_d_tiles_archive_loader();
21184
+ init_tiles_3d_archive_file_system();
20337
21185
  init_tile_3d_writer();
20338
21186
  init_tile_3d_feature_table();
20339
21187
  init_tile_3d_batch_table();