@loaders.gl/3d-tiles 4.0.0-alpha.22 → 4.0.0-alpha.24

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 (121) hide show
  1. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +2 -1
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
  3. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +1 -1
  4. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
  5. package/dist/3d-tiles-archive-loader.d.ts +1 -1
  6. package/dist/3d-tiles-archive-loader.d.ts.map +1 -1
  7. package/dist/cesium-ion-loader.d.ts +2 -2
  8. package/dist/cesium-ion-loader.d.ts.map +1 -1
  9. package/dist/dist.min.js +2074 -1483
  10. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
  11. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
  12. package/dist/es5/3d-tiles-archive-loader.js +3 -3
  13. package/dist/es5/3d-tiles-archive-loader.js.map +1 -1
  14. package/dist/es5/cesium-ion-loader.js.map +1 -1
  15. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -1
  16. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +3 -1
  17. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  18. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +3 -1
  19. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-3d-tile.js +3 -1
  21. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  22. package/dist/es5/lib/utils/version.js +1 -1
  23. package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
  24. package/dist/es5/tile-3d-writer.js.map +1 -1
  25. package/dist/es5/tiles-3d-loader.js +2 -0
  26. package/dist/es5/tiles-3d-loader.js.map +1 -1
  27. package/dist/es5/types.js.map +1 -1
  28. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
  29. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
  30. package/dist/esm/3d-tiles-archive-loader.js +2 -2
  31. package/dist/esm/3d-tiles-archive-loader.js.map +1 -1
  32. package/dist/esm/cesium-ion-loader.js.map +1 -1
  33. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -1
  34. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +3 -1
  35. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  36. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +2 -1
  37. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  38. package/dist/esm/lib/parsers/parse-3d-tile.js +3 -1
  39. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  40. package/dist/esm/lib/utils/version.js +1 -1
  41. package/dist/esm/tile-3d-subtree-loader.js.map +1 -1
  42. package/dist/esm/tile-3d-writer.js.map +1 -1
  43. package/dist/esm/tiles-3d-loader.js +2 -0
  44. package/dist/esm/tiles-3d-loader.js.map +1 -1
  45. package/dist/esm/types.js.map +1 -1
  46. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +2 -1
  47. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -1
  48. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
  49. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  50. package/dist/lib/parsers/parse-3d-tile.d.ts +1 -1
  51. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  52. package/dist/tile-3d-subtree-loader.d.ts +3 -3
  53. package/dist/tile-3d-subtree-loader.d.ts.map +1 -1
  54. package/dist/tile-3d-writer.d.ts +2 -2
  55. package/dist/tile-3d-writer.d.ts.map +1 -1
  56. package/dist/tiles-3d-loader.d.ts +2 -1
  57. package/dist/tiles-3d-loader.d.ts.map +1 -1
  58. package/dist/types.d.ts +2 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/package.json +8 -8
  61. package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +2 -1
  62. package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +1 -1
  63. package/src/3d-tiles-archive-loader.ts +2 -2
  64. package/src/cesium-ion-loader.ts +2 -3
  65. package/src/lib/filesystems/tiles-3d-archive-file-system.ts +1 -1
  66. package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
  67. package/src/lib/parsers/parse-3d-tile-gltf.ts +3 -2
  68. package/src/lib/parsers/parse-3d-tile.ts +2 -2
  69. package/src/tile-3d-subtree-loader.ts +3 -3
  70. package/src/tile-3d-writer.ts +2 -2
  71. package/src/tiles-3d-loader.ts +16 -4
  72. package/src/types.ts +3 -0
  73. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +0 -72
  74. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +0 -33
  75. package/dist/3d-tiles-archive-loader.js +0 -31
  76. package/dist/bundle.js +0 -5
  77. package/dist/cesium-ion-loader.js +0 -41
  78. package/dist/index.js +0 -30
  79. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +0 -113
  80. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +0 -197
  81. package/dist/lib/classes/tile-3d-batch-table.js +0 -245
  82. package/dist/lib/classes/tile-3d-feature-table.js +0 -72
  83. package/dist/lib/constants.js +0 -26
  84. package/dist/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  85. package/dist/lib/encoders/encode-3d-tile-composite.js +0 -24
  86. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  87. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +0 -39
  88. package/dist/lib/encoders/encode-3d-tile.js +0 -33
  89. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +0 -30
  90. package/dist/lib/filesystems/tiles-3d-archive-file-system.js +0 -75
  91. package/dist/lib/ion/ion.js +0 -68
  92. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -65
  93. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  94. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -42
  95. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -303
  96. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -96
  97. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +0 -28
  98. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -87
  99. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +0 -93
  100. package/dist/lib/parsers/helpers/parse-utils.js +0 -32
  101. package/dist/lib/parsers/parse-3d-tile-batched-model.js +0 -33
  102. package/dist/lib/parsers/parse-3d-tile-composite.js +0 -24
  103. package/dist/lib/parsers/parse-3d-tile-gltf.js +0 -28
  104. package/dist/lib/parsers/parse-3d-tile-header.js +0 -194
  105. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -172
  106. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -441
  107. package/dist/lib/parsers/parse-3d-tile.js +0 -33
  108. package/dist/lib/utils/obb/s2-corners-to-obb.js +0 -37
  109. package/dist/lib/utils/s2/converters/s2-to-boundary.js +0 -61
  110. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +0 -36
  111. package/dist/lib/utils/s2/converters/s2-to-region.js +0 -59
  112. package/dist/lib/utils/s2/index.js +0 -23
  113. package/dist/lib/utils/s2/s2-geometry-functions.js +0 -29
  114. package/dist/lib/utils/s2/s2-token-functions.js +0 -68
  115. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +0 -32
  116. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +0 -260
  117. package/dist/lib/utils/version.js +0 -7
  118. package/dist/tile-3d-subtree-loader.js +0 -23
  119. package/dist/tile-3d-writer.js +0 -27
  120. package/dist/tiles-3d-loader.js +0 -76
  121. package/dist/types.js +0 -2
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") {
@@ -263,9 +263,9 @@
263
263
  constructor(props) {
264
264
  this.terminated = false;
265
265
  this._loadableURL = "";
266
- const { name: name10, source, url } = props;
266
+ const { name: name12, source, url } = props;
267
267
  assert3(source || url);
268
- this.name = name10;
268
+ this.name = name12;
269
269
  this.source = source;
270
270
  this.url = url;
271
271
  this.onMessage = NOOP;
@@ -390,9 +390,9 @@
390
390
  this.onDebug = props.onDebug;
391
391
  }
392
392
  }
393
- 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)) {
394
394
  const startPromise = new Promise((onStart) => {
395
- this.jobQueue.push({ name: name10, onMessage: onMessage2, onError, onStart });
395
+ this.jobQueue.push({ name: name12, onMessage: onMessage2, onError, onStart });
396
396
  return this;
397
397
  });
398
398
  this._startQueuedJob();
@@ -443,8 +443,8 @@
443
443
  }
444
444
  if (this.count < this._getMaxConcurrency()) {
445
445
  this.count++;
446
- const name10 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
447
- 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 });
448
448
  }
449
449
  return null;
450
450
  }
@@ -496,16 +496,16 @@
496
496
  }
497
497
  }
498
498
  getWorkerPool(options) {
499
- const { name: name10, source, url } = options;
500
- let workerPool = this.workerPools.get(name10);
499
+ const { name: name12, source, url } = options;
500
+ let workerPool = this.workerPools.get(name12);
501
501
  if (!workerPool) {
502
502
  workerPool = new WorkerPool({
503
- name: name10,
503
+ name: name12,
504
504
  source,
505
505
  url
506
506
  });
507
507
  workerPool.setProps(this._getWorkerPoolProps());
508
- this.workerPools.set(name10, workerPool);
508
+ this.workerPools.set(name12, workerPool);
509
509
  }
510
510
  return workerPool;
511
511
  }
@@ -688,10 +688,10 @@
688
688
  return loader.worker && options?.worker;
689
689
  }
690
690
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
691
- const name10 = loader.id;
691
+ const name12 = loader.id;
692
692
  const url = getWorkerURL(loader, options);
693
693
  const workerFarm = WorkerFarm.getWorkerFarm(options);
694
- const workerPool = workerFarm.getWorkerPool({ name: name10, url });
694
+ const workerPool = workerFarm.getWorkerPool({ name: name12, url });
695
695
  options = JSON.parse(JSON.stringify(options));
696
696
  context = JSON.parse(JSON.stringify(context || {}));
697
697
  const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
@@ -1190,12 +1190,160 @@
1190
1190
  }
1191
1191
  });
1192
1192
 
1193
+ // ../loader-utils/src/lib/file-provider/file-provider.ts
1194
+ var isFileProvider;
1195
+ var init_file_provider = __esm({
1196
+ "../loader-utils/src/lib/file-provider/file-provider.ts"() {
1197
+ isFileProvider = (fileProvider) => {
1198
+ return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
1199
+ };
1200
+ }
1201
+ });
1202
+
1193
1203
  // (disabled):fs
1194
- var require_fs = __commonJS({
1204
+ var init_fs = __esm({
1195
1205
  "(disabled):fs"() {
1196
1206
  }
1197
1207
  });
1198
1208
 
1209
+ // ../loader-utils/src/lib/file-provider/file-handle.ts
1210
+ var FileHandle;
1211
+ var init_file_handle = __esm({
1212
+ "../loader-utils/src/lib/file-provider/file-handle.ts"() {
1213
+ init_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
+
1199
1347
  // ../loader-utils/src/index.ts
1200
1348
  var init_src2 = __esm({
1201
1349
  "../loader-utils/src/index.ts"() {
@@ -1212,6 +1360,9 @@
1212
1360
  init_memory_conversion_utils();
1213
1361
  init_promisify();
1214
1362
  init_path();
1363
+ init_file_provider();
1364
+ init_file_handle_file();
1365
+ init_data_view_file();
1215
1366
  }
1216
1367
  });
1217
1368
 
@@ -5775,7 +5926,7 @@
5775
5926
  for (const key of propNames) {
5776
5927
  const value = object[key];
5777
5928
  if (typeof value === "function") {
5778
- if (!predefined.find((name10) => key === name10)) {
5929
+ if (!predefined.find((name12) => key === name12)) {
5779
5930
  object[key] = value.bind(obj);
5780
5931
  }
5781
5932
  }
@@ -6971,7 +7122,6 @@
6971
7122
  "../core/src/index.ts"() {
6972
7123
  init_fetch_file();
6973
7124
  init_load();
6974
- init_src2();
6975
7125
  }
6976
7126
  });
6977
7127
 
@@ -7153,11 +7303,11 @@
7153
7303
  });
7154
7304
 
7155
7305
  // ../schema/src/lib/mesh/deduce-mesh-schema.ts
7156
- function deduceMeshField(name10, attribute, optionalMetadata) {
7306
+ function deduceMeshField(name12, attribute, optionalMetadata) {
7157
7307
  const type = getDataTypeFromTypedArray(attribute.value);
7158
7308
  const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
7159
7309
  return {
7160
- name: name10,
7310
+ name: name12,
7161
7311
  type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
7162
7312
  nullable: false,
7163
7313
  metadata
@@ -7625,7 +7775,7 @@
7625
7775
  var init_draco_module_loader = __esm({
7626
7776
  "../draco/src/lib/draco-module-loader.ts"() {
7627
7777
  init_src();
7628
- DRACO_DECODER_VERSION = "1.5.5";
7778
+ DRACO_DECODER_VERSION = "1.5.6";
7629
7779
  DRACO_ENCODER_VERSION = "1.4.1";
7630
7780
  STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
7631
7781
  DRACO_EXTERNAL_LIBRARIES = {
@@ -7733,8 +7883,8 @@
7733
7883
  }
7734
7884
  throw new Error(ERR_TYPE_CONVERSION);
7735
7885
  }
7736
- static fromName(name10) {
7737
- const glType = NAME_TO_GL_TYPE[name10];
7886
+ static fromName(name12) {
7887
+ const glType = NAME_TO_GL_TYPE[name12];
7738
7888
  if (!glType) {
7739
7889
  throw new Error(ERR_TYPE_CONVERSION);
7740
7890
  }
@@ -7837,6 +7987,15 @@
7837
7987
  }
7838
7988
  });
7839
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
+
7840
7999
  // ../math/src/index.ts
7841
8000
  var init_src7 = __esm({
7842
8001
  "../math/src/index.ts"() {
@@ -7844,6 +8003,7 @@
7844
8003
  init_gl_type();
7845
8004
  init_rgb565();
7846
8005
  init_attribute_compression();
8006
+ init_coordinates();
7847
8007
  }
7848
8008
  });
7849
8009
 
@@ -8293,10 +8453,10 @@
8293
8453
  }
8294
8454
  return void 0;
8295
8455
  }
8296
- hasProperty(batchId, name10) {
8456
+ hasProperty(batchId, name12) {
8297
8457
  this._checkBatchId(batchId);
8298
- assert2(typeof name10 === "string", name10);
8299
- 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);
8300
8460
  }
8301
8461
  getPropertyNames(batchId, results) {
8302
8462
  this._checkBatchId(batchId);
@@ -8309,47 +8469,47 @@
8309
8469
  }
8310
8470
  return results;
8311
8471
  }
8312
- getProperty(batchId, name10) {
8472
+ getProperty(batchId, name12) {
8313
8473
  this._checkBatchId(batchId);
8314
- assert2(typeof name10 === "string", name10);
8474
+ assert2(typeof name12 === "string", name12);
8315
8475
  if (this._binaryProperties) {
8316
- const binaryProperty = this._binaryProperties[name10];
8476
+ const binaryProperty = this._binaryProperties[name12];
8317
8477
  if (defined2(binaryProperty)) {
8318
8478
  return this._getBinaryProperty(binaryProperty, batchId);
8319
8479
  }
8320
8480
  }
8321
- const propertyValues = this._properties[name10];
8481
+ const propertyValues = this._properties[name12];
8322
8482
  if (defined2(propertyValues)) {
8323
8483
  return clone3(propertyValues[batchId], true);
8324
8484
  }
8325
8485
  if (this._hierarchy) {
8326
- const hierarchyProperty = this._getHierarchyProperty(batchId, name10);
8486
+ const hierarchyProperty = this._getHierarchyProperty(batchId, name12);
8327
8487
  if (defined2(hierarchyProperty)) {
8328
8488
  return hierarchyProperty;
8329
8489
  }
8330
8490
  }
8331
8491
  return void 0;
8332
8492
  }
8333
- setProperty(batchId, name10, value) {
8493
+ setProperty(batchId, name12, value) {
8334
8494
  const featureCount = this.featureCount;
8335
8495
  this._checkBatchId(batchId);
8336
- assert2(typeof name10 === "string", name10);
8496
+ assert2(typeof name12 === "string", name12);
8337
8497
  if (this._binaryProperties) {
8338
- const binaryProperty = this._binaryProperties[name10];
8498
+ const binaryProperty = this._binaryProperties[name12];
8339
8499
  if (binaryProperty) {
8340
8500
  this._setBinaryProperty(binaryProperty, batchId, value);
8341
8501
  return;
8342
8502
  }
8343
8503
  }
8344
8504
  if (this._hierarchy) {
8345
- if (this._setHierarchyProperty(this, batchId, name10, value)) {
8505
+ if (this._setHierarchyProperty(this, batchId, name12, value)) {
8346
8506
  return;
8347
8507
  }
8348
8508
  }
8349
- let propertyValues = this._properties[name10];
8509
+ let propertyValues = this._properties[name12];
8350
8510
  if (!defined2(propertyValues)) {
8351
- this._properties[name10] = new Array(featureCount);
8352
- propertyValues = this._properties[name10];
8511
+ this._properties[name12] = new Array(featureCount);
8512
+ propertyValues = this._properties[name12];
8353
8513
  }
8354
8514
  propertyValues[batchId] = clone3(value, true);
8355
8515
  }
@@ -8367,21 +8527,21 @@
8367
8527
  }
8368
8528
  _initializeBinaryProperties() {
8369
8529
  let binaryProperties = null;
8370
- for (const name10 in this._properties) {
8371
- const property = this._properties[name10];
8372
- 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);
8373
8533
  if (binaryProperty) {
8374
8534
  binaryProperties = binaryProperties || {};
8375
- binaryProperties[name10] = binaryProperty;
8535
+ binaryProperties[name12] = binaryProperty;
8376
8536
  }
8377
8537
  }
8378
8538
  return binaryProperties;
8379
8539
  }
8380
- _initializeBinaryProperty(name10, property) {
8540
+ _initializeBinaryProperty(name12, property) {
8381
8541
  if ("byteOffset" in property) {
8382
8542
  const tile3DAccessor = property;
8383
- assert2(this.binary, `Property ${name10} requires a batch table binary.`);
8384
- 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.`);
8385
8545
  const accessor = createTypedArrayFromAccessor(tile3DAccessor, this.binary.buffer, this.binary.byteOffset | 0, this.featureCount);
8386
8546
  return {
8387
8547
  typedArray: accessor.values,
@@ -8392,14 +8552,14 @@
8392
8552
  }
8393
8553
  return null;
8394
8554
  }
8395
- _hasPropertyInHierarchy(batchId, name10) {
8555
+ _hasPropertyInHierarchy(batchId, name12) {
8396
8556
  if (!this._hierarchy) {
8397
8557
  return false;
8398
8558
  }
8399
8559
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8400
8560
  const classId = hierarchy.classIds[instanceIndex];
8401
8561
  const instances = hierarchy.classes[classId].instances;
8402
- return defined2(instances[name10]);
8562
+ return defined2(instances[name12]);
8403
8563
  });
8404
8564
  return defined2(result);
8405
8565
  }
@@ -8407,21 +8567,21 @@
8407
8567
  traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8408
8568
  const classId = hierarchy.classIds[instanceIndex];
8409
8569
  const instances = hierarchy.classes[classId].instances;
8410
- for (const name10 in instances) {
8411
- if (instances.hasOwnProperty(name10)) {
8412
- if (results.indexOf(name10) === -1) {
8413
- results.push(name10);
8570
+ for (const name12 in instances) {
8571
+ if (instances.hasOwnProperty(name12)) {
8572
+ if (results.indexOf(name12) === -1) {
8573
+ results.push(name12);
8414
8574
  }
8415
8575
  }
8416
8576
  }
8417
8577
  });
8418
8578
  }
8419
- _getHierarchyProperty(batchId, name10) {
8579
+ _getHierarchyProperty(batchId, name12) {
8420
8580
  return traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8421
8581
  const classId = hierarchy.classIds[instanceIndex];
8422
8582
  const instanceClass = hierarchy.classes[classId];
8423
8583
  const indexInClass = hierarchy.classIndexes[instanceIndex];
8424
- const propertyValues = instanceClass.instances[name10];
8584
+ const propertyValues = instanceClass.instances[name12];
8425
8585
  if (defined2(propertyValues)) {
8426
8586
  if (defined2(propertyValues.typedArray)) {
8427
8587
  return this._getBinaryProperty(propertyValues, indexInClass);
@@ -8431,14 +8591,14 @@
8431
8591
  return null;
8432
8592
  });
8433
8593
  }
8434
- _setHierarchyProperty(batchTable, batchId, name10, value) {
8594
+ _setHierarchyProperty(batchTable, batchId, name12, value) {
8435
8595
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
8436
8596
  const classId = hierarchy.classIds[instanceIndex];
8437
8597
  const instanceClass = hierarchy.classes[classId];
8438
8598
  const indexInClass = hierarchy.classIndexes[instanceIndex];
8439
- const propertyValues = instanceClass.instances[name10];
8599
+ const propertyValues = instanceClass.instances[name12];
8440
8600
  if (defined2(propertyValues)) {
8441
- assert2(instanceIndex === batchId, `Inherited property "${name10}" is read-only.`);
8601
+ assert2(instanceIndex === batchId, `Inherited property "${name12}" is read-only.`);
8442
8602
  if (defined2(propertyValues.typedArray)) {
8443
8603
  this._setBinaryProperty(propertyValues, indexInClass, value);
8444
8604
  } else {
@@ -8899,19 +9059,11 @@
8899
9059
  }
8900
9060
  });
8901
9061
 
8902
- // ../gltf/src/lib/utils/version.ts
9062
+ // ../images/src/lib/utils/version.ts
8903
9063
  var VERSION6;
8904
9064
  var init_version4 = __esm({
8905
- "../gltf/src/lib/utils/version.ts"() {
8906
- VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8907
- }
8908
- });
8909
-
8910
- // ../images/src/lib/utils/version.ts
8911
- var VERSION7;
8912
- var init_version5 = __esm({
8913
9065
  "../images/src/lib/utils/version.ts"() {
8914
- VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
9066
+ VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8915
9067
  }
8916
9068
  });
8917
9069
 
@@ -9336,7 +9488,7 @@
9336
9488
  var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
9337
9489
  var init_image_loader = __esm({
9338
9490
  "../images/src/image-loader.ts"() {
9339
- init_version5();
9491
+ init_version4();
9340
9492
  init_parse_image();
9341
9493
  init_binary_image_api();
9342
9494
  EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
@@ -9360,7 +9512,7 @@
9360
9512
  id: "image",
9361
9513
  module: "images",
9362
9514
  name: "Images",
9363
- version: VERSION7,
9515
+ version: VERSION6,
9364
9516
  mimeTypes: MIME_TYPES,
9365
9517
  extensions: EXTENSIONS,
9366
9518
  parse: parseImage,
@@ -9419,901 +9571,282 @@
9419
9571
  }
9420
9572
  });
9421
9573
 
9422
- // ../textures/src/lib/utils/version.ts
9423
- var VERSION8;
9424
- var init_version6 = __esm({
9425
- "../textures/src/lib/utils/version.ts"() {
9426
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
9427
- }
9428
- });
9429
-
9430
- // ../textures/src/lib/parsers/basis-module-loader.ts
9431
- async function loadBasisTranscoderModule(options) {
9432
- const modules = options.modules || {};
9433
- if (modules.basis) {
9434
- 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");
9435
9578
  }
9436
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
9437
- return await loadBasisTranscoderPromise;
9438
- }
9439
- async function loadBasisTranscoder(options) {
9440
- let BASIS = null;
9441
- let wasmBinary = null;
9442
- [BASIS, wasmBinary] = await Promise.all([
9443
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
9444
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
9445
- ]);
9446
- BASIS = BASIS || globalThis.BASIS;
9447
- return await initializeBasisTranscoderModule(BASIS, wasmBinary);
9448
9579
  }
9449
- function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
9450
- const options = {};
9451
- if (wasmBinary) {
9452
- options.wasmBinary = wasmBinary;
9580
+ var init_assert6 = __esm({
9581
+ "../gltf/src/lib/utils/assert.ts"() {
9453
9582
  }
9454
- return new Promise((resolve2) => {
9455
- BasisModule(options).then((module) => {
9456
- const { BasisFile, initializeBasis } = module;
9457
- initializeBasis();
9458
- resolve2({ BasisFile });
9459
- });
9460
- });
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];
9461
9589
  }
9462
- async function loadBasisEncoderModule(options) {
9463
- const modules = options.modules || {};
9464
- if (modules.basisEncoder) {
9465
- 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");
9466
9594
  }
9467
- loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
9468
- return await loadBasisEncoderPromise;
9595
+ return componentType;
9469
9596
  }
9470
- async function loadBasisEncoder(options) {
9471
- let BASIS_ENCODER = null;
9472
- let wasmBinary = null;
9473
- [BASIS_ENCODER, wasmBinary] = await Promise.all([
9474
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
9475
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
9476
- ]);
9477
- BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
9478
- 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 };
9479
9605
  }
9480
- function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
9481
- const options = {};
9482
- if (wasmBinary) {
9483
- options.wasmBinary = wasmBinary;
9484
- }
9485
- return new Promise((resolve2) => {
9486
- BasisEncoderModule(options).then((module) => {
9487
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
9488
- initializeBasis();
9489
- resolve2({ BasisFile, KTX2File, BasisEncoder });
9490
- });
9491
- });
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);
9492
9618
  }
9493
- var BASIS_EXTERNAL_LIBRARIES, loadBasisTranscoderPromise, loadBasisEncoderPromise;
9494
- var init_basis_module_loader = __esm({
9495
- "../textures/src/lib/parsers/basis-module-loader.ts"() {
9496
- init_src();
9497
- BASIS_EXTERNAL_LIBRARIES = {
9498
- TRANSCODER: "basis_transcoder.js",
9499
- TRANSCODER_WASM: "basis_transcoder.wasm",
9500
- ENCODER: "basis_encoder.js",
9501
- ENCODER_WASM: "basis_encoder.wasm"
9502
- };
9503
- }
9504
- });
9505
-
9506
- // ../textures/src/lib/gl-extensions.ts
9507
- var GL_EXTENSIONS_CONSTANTS;
9508
- var init_gl_extensions = __esm({
9509
- "../textures/src/lib/gl-extensions.ts"() {
9510
- GL_EXTENSIONS_CONSTANTS = {
9511
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
9512
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
9513
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
9514
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
9515
- COMPRESSED_R11_EAC: 37488,
9516
- COMPRESSED_SIGNED_R11_EAC: 37489,
9517
- COMPRESSED_RG11_EAC: 37490,
9518
- COMPRESSED_SIGNED_RG11_EAC: 37491,
9519
- COMPRESSED_RGB8_ETC2: 37492,
9520
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
9521
- COMPRESSED_SRGB8_ETC2: 37494,
9522
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
9523
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
9524
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
9525
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
9526
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
9527
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
9528
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
9529
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
9530
- COMPRESSED_RGB_ATC_WEBGL: 35986,
9531
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
9532
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
9533
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
9534
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
9535
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
9536
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
9537
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
9538
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
9539
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
9540
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
9541
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
9542
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
9543
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
9544
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
9545
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
9546
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
9547
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
9548
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
9549
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
9550
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
9551
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
9552
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
9553
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
9554
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
9555
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
9556
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
9557
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
9558
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
9559
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
9560
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
9561
- COMPRESSED_RED_RGTC1_EXT: 36283,
9562
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
9563
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
9564
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
9565
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
9566
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
9567
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
9568
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
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
9569
9643
  };
9570
- }
9571
- });
9572
-
9573
- // ../textures/src/lib/utils/texture-formats.ts
9574
- function getSupportedGPUTextureFormats(gl) {
9575
- if (!formats) {
9576
- gl = gl || getWebGLContext() || void 0;
9577
- formats = new Set();
9578
- for (const prefix of BROWSER_PREFIXES) {
9579
- for (const extension in WEBGL_EXTENSIONS) {
9580
- if (gl && gl.getExtension(`${prefix}${extension}`)) {
9581
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
9582
- formats.add(gpuTextureFormat);
9583
- }
9584
- }
9585
- }
9586
- }
9587
- return formats;
9588
- }
9589
- function getWebGLContext() {
9590
- try {
9591
- const canvas = document.createElement("canvas");
9592
- return canvas.getContext("webgl");
9593
- } catch (error) {
9594
- return null;
9595
- }
9596
- }
9597
- var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
9598
- var init_texture_formats = __esm({
9599
- "../textures/src/lib/utils/texture-formats.ts"() {
9600
- BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
9601
- WEBGL_EXTENSIONS = {
9602
- WEBGL_compressed_texture_s3tc: "dxt",
9603
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
9604
- WEBGL_compressed_texture_etc1: "etc1",
9605
- WEBGL_compressed_texture_etc: "etc2",
9606
- WEBGL_compressed_texture_pvrtc: "pvrtc",
9607
- WEBGL_compressed_texture_atc: "atc",
9608
- WEBGL_compressed_texture_astc: "astc",
9609
- EXT_texture_compression_rgtc: "rgtc"
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
9610
9659
  };
9611
- formats = null;
9612
- }
9613
- });
9614
-
9615
- // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
9616
- var t, n, i, s, a, r, o, l, f;
9617
- var init_ktx_parse_modern = __esm({
9618
- "../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
9619
- t = new Uint8Array([0]);
9620
- !function(t2) {
9621
- t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
9622
- }(n || (n = {})), function(t2) {
9623
- t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
9624
- }(i || (i = {})), function(t2) {
9625
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
9626
- }(s || (s = {})), function(t2) {
9627
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
9628
- }(a || (a = {})), function(t2) {
9629
- 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";
9630
- }(r || (r = {})), function(t2) {
9631
- t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
9632
- }(o || (o = {})), function(t2) {
9633
- t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
9634
- }(l || (l = {})), function(t2) {
9635
- t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
9636
- }(f || (f = {}));
9637
9660
  }
9638
9661
  });
9639
9662
 
9640
- // ../textures/src/lib/parsers/parse-ktx.ts
9641
- function isKTX(data) {
9642
- const id = new Uint8Array(data);
9643
- 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];
9644
- return !notKTX;
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
+ };
9645
9675
  }
9646
- var KTX2_ID;
9647
- var init_parse_ktx = __esm({
9648
- "../textures/src/lib/parsers/parse-ktx.ts"() {
9649
- init_ktx_parse_modern();
9650
- KTX2_ID = [
9651
- 171,
9652
- 75,
9653
- 84,
9654
- 88,
9655
- 32,
9656
- 50,
9657
- 48,
9658
- 187,
9659
- 13,
9660
- 10,
9661
- 26,
9662
- 10
9663
- ];
9664
- }
9665
- });
9666
-
9667
- // ../textures/src/lib/parsers/parse-basis.ts
9668
- async function parseBasis(data, options) {
9669
- if (options.basis.containerFormat === "auto") {
9670
- if (isKTX(data)) {
9671
- const fileConstructors = await loadBasisEncoderModule(options);
9672
- return parseKTX2File(fileConstructors.KTX2File, data, options);
9673
- }
9674
- const { BasisFile } = await loadBasisTranscoderModule(options);
9675
- return parseBasisFile(BasisFile, data, options);
9676
- }
9677
- switch (options.basis.module) {
9678
- case "encoder":
9679
- const fileConstructors = await loadBasisEncoderModule(options);
9680
- switch (options.basis.containerFormat) {
9681
- case "ktx2":
9682
- return parseKTX2File(fileConstructors.KTX2File, data, options);
9683
- case "basis":
9684
- default:
9685
- return parseBasisFile(fileConstructors.BasisFile, data, options);
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]];
9695
+ }
9686
9696
  }
9687
- case "transcoder":
9688
- default:
9689
- const { BasisFile } = await loadBasisTranscoderModule(options);
9690
- return parseBasisFile(BasisFile, data, options);
9691
- }
9692
- }
9693
- function parseBasisFile(BasisFile, data, options) {
9694
- const basisFile = new BasisFile(new Uint8Array(data));
9695
- try {
9696
- if (!basisFile.startTranscoding()) {
9697
- throw new Error("Failed to start basis transcoding");
9698
- }
9699
- const imageCount = basisFile.getNumImages();
9700
- const images = [];
9701
- for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
9702
- const levelsCount = basisFile.getNumLevels(imageIndex);
9703
- const levels = [];
9704
- for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
9705
- levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
9697
+ get json() {
9698
+ return this.gltf.json;
9706
9699
  }
9707
- images.push(levels);
9708
- }
9709
- return images;
9710
- } finally {
9711
- basisFile.close();
9712
- basisFile.delete();
9713
- }
9714
- }
9715
- function transcodeImage(basisFile, imageIndex, levelIndex, options) {
9716
- const width = basisFile.getImageWidth(imageIndex, levelIndex);
9717
- const height = basisFile.getImageHeight(imageIndex, levelIndex);
9718
- const hasAlpha = basisFile.getHasAlpha();
9719
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
9720
- const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
9721
- const decodedData = new Uint8Array(decodedSize);
9722
- if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
9723
- throw new Error("failed to start Basis transcoding");
9724
- }
9725
- return {
9726
- width,
9727
- height,
9728
- data: decodedData,
9729
- compressed,
9730
- format,
9731
- hasAlpha
9732
- };
9733
- }
9734
- function parseKTX2File(KTX2File, data, options) {
9735
- const ktx2File = new KTX2File(new Uint8Array(data));
9736
- try {
9737
- if (!ktx2File.startTranscoding()) {
9738
- throw new Error("failed to start KTX2 transcoding");
9739
- }
9740
- const levelsCount = ktx2File.getLevels();
9741
- const levels = [];
9742
- for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
9743
- levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
9744
- break;
9745
- }
9746
- return [levels];
9747
- } finally {
9748
- ktx2File.close();
9749
- ktx2File.delete();
9750
- }
9751
- }
9752
- function transcodeKTX2Image(ktx2File, levelIndex, options) {
9753
- const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
9754
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
9755
- const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
9756
- const decodedData = new Uint8Array(decodedSize);
9757
- if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
9758
- throw new Error("Failed to transcode KTX2 image");
9759
- }
9760
- return {
9761
- width,
9762
- height,
9763
- data: decodedData,
9764
- compressed,
9765
- levelSize: decodedSize,
9766
- hasAlpha: alphaFlag,
9767
- format
9768
- };
9769
- }
9770
- function getBasisOptions(options, hasAlpha) {
9771
- let format = options && options.basis && options.basis.format;
9772
- if (format === "auto") {
9773
- format = selectSupportedBasisFormat();
9774
- }
9775
- if (typeof format === "object") {
9776
- format = hasAlpha ? format.alpha : format.noAlpha;
9777
- }
9778
- format = format.toLowerCase();
9779
- return OutputFormat[format];
9780
- }
9781
- function selectSupportedBasisFormat() {
9782
- const supportedFormats = getSupportedGPUTextureFormats();
9783
- if (supportedFormats.has("astc")) {
9784
- return "astc-4x4";
9785
- } else if (supportedFormats.has("dxt")) {
9786
- return {
9787
- alpha: "bc3",
9788
- noAlpha: "bc1"
9789
- };
9790
- } else if (supportedFormats.has("pvrtc")) {
9791
- return {
9792
- alpha: "pvrtc1-4-rgba",
9793
- noAlpha: "pvrtc1-4-rgb"
9794
- };
9795
- } else if (supportedFormats.has("etc1")) {
9796
- return "etc1";
9797
- } else if (supportedFormats.has("etc2")) {
9798
- return "etc2";
9799
- }
9800
- return "rgb565";
9801
- }
9802
- var OutputFormat;
9803
- var init_parse_basis = __esm({
9804
- "../textures/src/lib/parsers/parse-basis.ts"() {
9805
- init_basis_module_loader();
9806
- init_gl_extensions();
9807
- init_texture_formats();
9808
- init_parse_ktx();
9809
- OutputFormat = {
9810
- etc1: {
9811
- basisFormat: 0,
9812
- compressed: true,
9813
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
9814
- },
9815
- etc2: { basisFormat: 1, compressed: true },
9816
- bc1: {
9817
- basisFormat: 2,
9818
- compressed: true,
9819
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
9820
- },
9821
- bc3: {
9822
- basisFormat: 3,
9823
- compressed: true,
9824
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
9825
- },
9826
- bc4: { basisFormat: 4, compressed: true },
9827
- bc5: { basisFormat: 5, compressed: true },
9828
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
9829
- "bc7-m5": { basisFormat: 7, compressed: true },
9830
- "pvrtc1-4-rgb": {
9831
- basisFormat: 8,
9832
- compressed: true,
9833
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
9834
- },
9835
- "pvrtc1-4-rgba": {
9836
- basisFormat: 9,
9837
- compressed: true,
9838
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
9839
- },
9840
- "astc-4x4": {
9841
- basisFormat: 10,
9842
- compressed: true,
9843
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
9844
- },
9845
- "atc-rgb": { basisFormat: 11, compressed: true },
9846
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
9847
- rgba32: { basisFormat: 13, compressed: false },
9848
- rgb565: { basisFormat: 14, compressed: false },
9849
- bgr565: { basisFormat: 15, compressed: false },
9850
- rgba4444: { basisFormat: 16, compressed: false }
9851
- };
9852
- }
9853
- });
9854
-
9855
- // ../textures/src/basis-loader.ts
9856
- var BasisWorkerLoader, BasisLoader;
9857
- var init_basis_loader = __esm({
9858
- "../textures/src/basis-loader.ts"() {
9859
- init_version6();
9860
- init_parse_basis();
9861
- BasisWorkerLoader = {
9862
- name: "Basis",
9863
- id: "basis",
9864
- module: "textures",
9865
- version: VERSION8,
9866
- worker: true,
9867
- extensions: ["basis", "ktx2"],
9868
- mimeTypes: ["application/octet-stream", "image/ktx2"],
9869
- tests: ["sB"],
9870
- binary: true,
9871
- options: {
9872
- basis: {
9873
- format: "auto",
9874
- libraryPath: "libs/",
9875
- containerFormat: "auto",
9876
- module: "transcoder"
9700
+ getApplicationData(key) {
9701
+ const data = this.json[key];
9702
+ return data;
9703
+ }
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;
9877
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}]`);
9775
+ }
9776
+ return object;
9878
9777
  }
9879
- };
9880
- BasisLoader = {
9881
- ...BasisWorkerLoader,
9882
- parse: parseBasis
9883
- };
9884
- }
9885
- });
9886
-
9887
- // ../textures/src/index.ts
9888
- var init_src9 = __esm({
9889
- "../textures/src/index.ts"() {
9890
- init_basis_loader();
9891
- init_parse_basis();
9892
- }
9893
- });
9894
-
9895
- // ../gltf/src/lib/utils/assert.ts
9896
- function assert7(condition, message) {
9897
- if (!condition) {
9898
- throw new Error(message || "assert failed: gltf");
9899
- }
9900
- }
9901
- var init_assert6 = __esm({
9902
- "../gltf/src/lib/utils/assert.ts"() {
9903
- }
9904
- });
9905
-
9906
- // ../gltf/src/lib/parsers/parse-glb.ts
9907
- function getMagicString4(dataView, byteOffset = 0) {
9908
- 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))}`;
9909
- }
9910
- function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
9911
- const dataView = new DataView(arrayBuffer);
9912
- const { magic = MAGIC_glTF } = options;
9913
- const magic1 = dataView.getUint32(byteOffset, false);
9914
- return magic1 === magic || magic1 === MAGIC_glTF;
9915
- }
9916
- function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
9917
- const dataView = new DataView(arrayBuffer);
9918
- const type = getMagicString4(dataView, byteOffset + 0);
9919
- const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9920
- const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
9921
- Object.assign(glb, {
9922
- header: {
9923
- byteOffset,
9924
- byteLength,
9925
- hasBinChunk: false
9926
- },
9927
- type,
9928
- version,
9929
- json: {},
9930
- binChunks: []
9931
- });
9932
- byteOffset += GLB_FILE_HEADER_SIZE;
9933
- switch (glb.version) {
9934
- case 1:
9935
- return parseGLBV1(glb, dataView, byteOffset);
9936
- case 2:
9937
- return parseGLBV2(glb, dataView, byteOffset, options = {});
9938
- default:
9939
- throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
9940
- }
9941
- }
9942
- function parseGLBV1(glb, dataView, byteOffset) {
9943
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
9944
- const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
9945
- const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9946
- byteOffset += GLB_CHUNK_HEADER_SIZE;
9947
- assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
9948
- parseJSONChunk(glb, dataView, byteOffset, contentLength);
9949
- byteOffset += contentLength;
9950
- byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
9951
- return byteOffset;
9952
- }
9953
- function parseGLBV2(glb, dataView, byteOffset, options) {
9954
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
9955
- parseGLBChunksSync(glb, dataView, byteOffset, options);
9956
- return byteOffset + glb.header.byteLength;
9957
- }
9958
- function parseGLBChunksSync(glb, dataView, byteOffset, options) {
9959
- while (byteOffset + 8 <= glb.header.byteLength) {
9960
- const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
9961
- const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
9962
- byteOffset += GLB_CHUNK_HEADER_SIZE;
9963
- switch (chunkFormat) {
9964
- case GLB_CHUNK_TYPE_JSON:
9965
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
9966
- break;
9967
- case GLB_CHUNK_TYPE_BIN:
9968
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
9969
- break;
9970
- case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
9971
- if (!options.strict) {
9972
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
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);
9785
+ }
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);
9794
+ }
9795
+ getTypedArrayForImageData(image) {
9796
+ image = this.getAccessor(image);
9797
+ const bufferView = this.getBufferView(image.bufferView);
9798
+ const buffer = this.getBuffer(bufferView.buffer);
9799
+ const arrayBuffer = buffer.data;
9800
+ const byteOffset = bufferView.byteOffset || 0;
9801
+ return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
9802
+ }
9803
+ addApplicationData(key, data) {
9804
+ this.json[key] = data;
9805
+ return this;
9806
+ }
9807
+ addExtraData(key, data) {
9808
+ this.json.extras = this.json.extras || {};
9809
+ this.json.extras[key] = data;
9810
+ return this;
9811
+ }
9812
+ addObjectExtension(object, extensionName, data) {
9813
+ object.extensions = object.extensions || {};
9814
+ object.extensions[extensionName] = data;
9815
+ this.registerUsedExtension(extensionName);
9816
+ return this;
9817
+ }
9818
+ setObjectExtension(object, extensionName, data) {
9819
+ const extensions = object.extensions || {};
9820
+ extensions[extensionName] = data;
9821
+ }
9822
+ removeObjectExtension(object, extensionName) {
9823
+ const extensions = object?.extensions || {};
9824
+ if (extensions[extensionName]) {
9825
+ this.json.extensionsRemoved = this.json.extensionsRemoved || [];
9826
+ const extensionsRemoved = this.json.extensionsRemoved;
9827
+ if (!extensionsRemoved.includes(extensionName)) {
9828
+ extensionsRemoved.push(extensionName);
9829
+ }
9973
9830
  }
9974
- break;
9975
- case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
9976
- if (!options.strict) {
9977
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
9978
- }
9979
- break;
9980
- default:
9981
- break;
9982
- }
9983
- byteOffset += padToNBytes(chunkLength, 4);
9984
- }
9985
- return byteOffset;
9986
- }
9987
- function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
9988
- const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
9989
- const textDecoder = new TextDecoder("utf8");
9990
- const jsonText = textDecoder.decode(jsonChunk);
9991
- glb.json = JSON.parse(jsonText);
9992
- return padToNBytes(chunkLength, 4);
9993
- }
9994
- function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
9995
- glb.header.hasBinChunk = true;
9996
- glb.binChunks.push({
9997
- byteOffset,
9998
- byteLength: chunkLength,
9999
- arrayBuffer: dataView.buffer
10000
- });
10001
- return padToNBytes(chunkLength, 4);
10002
- }
10003
- 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;
10004
- var init_parse_glb = __esm({
10005
- "../gltf/src/lib/parsers/parse-glb.ts"() {
10006
- init_src2();
10007
- LITTLE_ENDIAN2 = true;
10008
- MAGIC_glTF = 1735152710;
10009
- GLB_FILE_HEADER_SIZE = 12;
10010
- GLB_CHUNK_HEADER_SIZE = 8;
10011
- GLB_CHUNK_TYPE_JSON = 1313821514;
10012
- GLB_CHUNK_TYPE_BIN = 5130562;
10013
- GLB_V1_CONTENT_FORMAT_JSON = 0;
10014
- GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
10015
- GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
10016
- }
10017
- });
10018
-
10019
- // ../gltf/src/lib/gltf-utils/resolve-url.ts
10020
- function resolveUrl(url, options) {
10021
- const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
10022
- if (absolute) {
10023
- return url;
10024
- }
10025
- const baseUrl = options.baseUri || options.uri;
10026
- if (!baseUrl) {
10027
- throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
10028
- }
10029
- return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
10030
- }
10031
- var init_resolve_url = __esm({
10032
- "../gltf/src/lib/gltf-utils/resolve-url.ts"() {
10033
- }
10034
- });
10035
-
10036
- // ../gltf/src/lib/gltf-utils/get-typed-array.ts
10037
- function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
10038
- const bufferView = json.bufferViews[bufferViewIndex];
10039
- assert7(bufferView);
10040
- const bufferIndex = bufferView.buffer;
10041
- const binChunk = buffers[bufferIndex];
10042
- assert7(binChunk);
10043
- const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
10044
- return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
10045
- }
10046
- var init_get_typed_array = __esm({
10047
- "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
10048
- init_assert6();
10049
- }
10050
- });
10051
-
10052
- // ../gltf/src/lib/gltf-utils/gltf-utils.ts
10053
- function getAccessorTypeFromSize(size) {
10054
- const type = TYPES[size - 1];
10055
- return type || TYPES[0];
10056
- }
10057
- function getComponentTypeFromArray(typedArray) {
10058
- const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);
10059
- if (!componentType) {
10060
- throw new Error("Illegal typed array");
10061
- }
10062
- return componentType;
10063
- }
10064
- function getAccessorArrayTypeAndLength(accessor, bufferView) {
10065
- const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];
10066
- const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];
10067
- const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
10068
- const length4 = accessor.count * components;
10069
- const byteLength = accessor.count * components * bytesPerComponent;
10070
- assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
10071
- return { ArrayType, length: length4, byteLength };
10072
- }
10073
- function getMemoryUsageGLTF(gltf) {
10074
- let { images, bufferViews } = gltf;
10075
- images = images || [];
10076
- bufferViews = bufferViews || [];
10077
- const imageBufferViews = images.map((i2) => i2.bufferView);
10078
- bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
10079
- const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
10080
- const pixelCount = images.reduce((acc, image) => {
10081
- const { width, height } = image.image;
10082
- return acc + width * height;
10083
- }, 0);
10084
- return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
10085
- }
10086
- 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;
10087
- var init_gltf_utils = __esm({
10088
- "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
10089
- init_assert6();
10090
- MIPMAP_FACTOR = 1.33;
10091
- TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
10092
- ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
10093
- [Int8Array, 5120],
10094
- [Uint8Array, 5121],
10095
- [Int16Array, 5122],
10096
- [Uint16Array, 5123],
10097
- [Uint32Array, 5125],
10098
- [Float32Array, 5126],
10099
- [Float64Array, 5130]
10100
- ];
10101
- ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);
10102
- ATTRIBUTE_TYPE_TO_COMPONENTS = {
10103
- SCALAR: 1,
10104
- VEC2: 2,
10105
- VEC3: 3,
10106
- VEC4: 4,
10107
- MAT2: 4,
10108
- MAT3: 9,
10109
- MAT4: 16
10110
- };
10111
- ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
10112
- 5120: 1,
10113
- 5121: 1,
10114
- 5122: 2,
10115
- 5123: 2,
10116
- 5125: 4,
10117
- 5126: 4
10118
- };
10119
- ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
10120
- 5120: Int8Array,
10121
- 5121: Uint8Array,
10122
- 5122: Int16Array,
10123
- 5123: Uint16Array,
10124
- 5125: Uint32Array,
10125
- 5126: Float32Array
10126
- };
10127
- }
10128
- });
10129
-
10130
- // ../gltf/src/lib/api/gltf-scenegraph.ts
10131
- function makeDefaultGLTFJson() {
10132
- return {
10133
- asset: {
10134
- version: "2.0",
10135
- generator: "loaders.gl"
10136
- },
10137
- buffers: [],
10138
- extensions: {},
10139
- extensionsRequired: [],
10140
- extensionsUsed: []
10141
- };
10142
- }
10143
- var GLTFScenegraph;
10144
- var init_gltf_scenegraph = __esm({
10145
- "../gltf/src/lib/api/gltf-scenegraph.ts"() {
10146
- init_src8();
10147
- init_src2();
10148
- init_assert6();
10149
- init_gltf_utils();
10150
- GLTFScenegraph = class {
10151
- constructor(gltf) {
10152
- this.gltf = {
10153
- json: gltf?.json || makeDefaultGLTFJson(),
10154
- buffers: gltf?.buffers || [],
10155
- images: gltf?.images || []
10156
- };
10157
- this.sourceBuffers = [];
10158
- this.byteLength = 0;
10159
- if (this.gltf.buffers && this.gltf.buffers[0]) {
10160
- this.byteLength = this.gltf.buffers[0].byteLength;
10161
- this.sourceBuffers = [this.gltf.buffers[0]];
10162
- }
10163
- }
10164
- get json() {
10165
- return this.gltf.json;
10166
- }
10167
- getApplicationData(key) {
10168
- const data = this.json[key];
10169
- return data;
10170
- }
10171
- getExtraData(key) {
10172
- const extras = this.json.extras || {};
10173
- return extras[key];
10174
- }
10175
- hasExtension(extensionName) {
10176
- const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
10177
- const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
10178
- return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
10179
- }
10180
- getExtension(extensionName) {
10181
- const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
10182
- const extensions = this.json.extensions || {};
10183
- return isExtension ? extensions[extensionName] : null;
10184
- }
10185
- getRequiredExtension(extensionName) {
10186
- const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
10187
- return isRequired ? this.getExtension(extensionName) : null;
10188
- }
10189
- getRequiredExtensions() {
10190
- return this.json.extensionsRequired || [];
10191
- }
10192
- getUsedExtensions() {
10193
- return this.json.extensionsUsed || [];
10194
- }
10195
- getRemovedExtensions() {
10196
- return this.json.extensionsRemoved || [];
10197
- }
10198
- getObjectExtension(object, extensionName) {
10199
- const extensions = object.extensions || {};
10200
- return extensions[extensionName];
10201
- }
10202
- getScene(index) {
10203
- return this.getObject("scenes", index);
10204
- }
10205
- getNode(index) {
10206
- return this.getObject("nodes", index);
10207
- }
10208
- getSkin(index) {
10209
- return this.getObject("skins", index);
10210
- }
10211
- getMesh(index) {
10212
- return this.getObject("meshes", index);
10213
- }
10214
- getMaterial(index) {
10215
- return this.getObject("materials", index);
10216
- }
10217
- getAccessor(index) {
10218
- return this.getObject("accessors", index);
10219
- }
10220
- getTexture(index) {
10221
- return this.getObject("textures", index);
10222
- }
10223
- getSampler(index) {
10224
- return this.getObject("samplers", index);
10225
- }
10226
- getImage(index) {
10227
- return this.getObject("images", index);
10228
- }
10229
- getBufferView(index) {
10230
- return this.getObject("bufferViews", index);
10231
- }
10232
- getBuffer(index) {
10233
- return this.getObject("buffers", index);
10234
- }
10235
- getObject(array, index) {
10236
- if (typeof index === "object") {
10237
- return index;
10238
- }
10239
- const object = this.json[array] && this.json[array][index];
10240
- if (!object) {
10241
- throw new Error(`glTF file error: Could not find ${array}[${index}]`);
10242
- }
10243
- return object;
10244
- }
10245
- getTypedArrayForBufferView(bufferView) {
10246
- bufferView = this.getBufferView(bufferView);
10247
- const bufferIndex = bufferView.buffer;
10248
- const binChunk = this.gltf.buffers[bufferIndex];
10249
- assert7(binChunk);
10250
- const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
10251
- return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
10252
- }
10253
- getTypedArrayForAccessor(accessor) {
10254
- accessor = this.getAccessor(accessor);
10255
- const bufferView = this.getBufferView(accessor.bufferView);
10256
- const buffer = this.getBuffer(bufferView.buffer);
10257
- const arrayBuffer = buffer.data;
10258
- const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
10259
- const byteOffset = bufferView.byteOffset + accessor.byteOffset;
10260
- return new ArrayType(arrayBuffer, byteOffset, length4);
10261
- }
10262
- getTypedArrayForImageData(image) {
10263
- image = this.getAccessor(image);
10264
- const bufferView = this.getBufferView(image.bufferView);
10265
- const buffer = this.getBuffer(bufferView.buffer);
10266
- const arrayBuffer = buffer.data;
10267
- const byteOffset = bufferView.byteOffset || 0;
10268
- return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
10269
- }
10270
- addApplicationData(key, data) {
10271
- this.json[key] = data;
10272
- return this;
10273
- }
10274
- addExtraData(key, data) {
10275
- this.json.extras = this.json.extras || {};
10276
- this.json.extras[key] = data;
10277
- return this;
10278
- }
10279
- addObjectExtension(object, extensionName, data) {
10280
- object.extensions = object.extensions || {};
10281
- object.extensions[extensionName] = data;
10282
- this.registerUsedExtension(extensionName);
10283
- return this;
10284
- }
10285
- setObjectExtension(object, extensionName, data) {
10286
- const extensions = object.extensions || {};
10287
- extensions[extensionName] = data;
10288
- }
10289
- removeObjectExtension(object, extensionName) {
10290
- const extensions = object?.extensions || {};
10291
- if (extensions[extensionName]) {
10292
- this.json.extensionsRemoved = this.json.extensionsRemoved || [];
10293
- const extensionsRemoved = this.json.extensionsRemoved;
10294
- if (!extensionsRemoved.includes(extensionName)) {
10295
- extensionsRemoved.push(extensionName);
10296
- }
10297
- }
10298
- delete extensions[extensionName];
10299
- }
10300
- addExtension(extensionName, extensionData = {}) {
10301
- assert7(extensionData);
10302
- this.json.extensions = this.json.extensions || {};
10303
- this.json.extensions[extensionName] = extensionData;
10304
- this.registerUsedExtension(extensionName);
10305
- return extensionData;
10306
- }
10307
- addRequiredExtension(extensionName, extensionData = {}) {
10308
- assert7(extensionData);
10309
- this.addExtension(extensionName, extensionData);
10310
- this.registerRequiredExtension(extensionName);
10311
- return extensionData;
10312
- }
10313
- registerUsedExtension(extensionName) {
10314
- this.json.extensionsUsed = this.json.extensionsUsed || [];
10315
- if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
10316
- this.json.extensionsUsed.push(extensionName);
9831
+ delete extensions[extensionName];
9832
+ }
9833
+ addExtension(extensionName, extensionData = {}) {
9834
+ assert7(extensionData);
9835
+ this.json.extensions = this.json.extensions || {};
9836
+ this.json.extensions[extensionName] = extensionData;
9837
+ this.registerUsedExtension(extensionName);
9838
+ return extensionData;
9839
+ }
9840
+ addRequiredExtension(extensionName, extensionData = {}) {
9841
+ assert7(extensionData);
9842
+ this.addExtension(extensionName, extensionData);
9843
+ this.registerRequiredExtension(extensionName);
9844
+ return extensionData;
9845
+ }
9846
+ registerUsedExtension(extensionName) {
9847
+ this.json.extensionsUsed = this.json.extensionsUsed || [];
9848
+ if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
9849
+ this.json.extensionsUsed.push(extensionName);
10317
9850
  }
10318
9851
  }
10319
9852
  registerRequiredExtension(extensionName) {
@@ -10493,66 +10026,1478 @@
10493
10026
  }
10494
10027
  }
10495
10028
  }
10496
- _addAttributes(attributes = {}) {
10497
- const result = {};
10498
- for (const attributeKey in attributes) {
10499
- const attributeData = attributes[attributeKey];
10500
- const attrName = this._getGltfAttributeName(attributeKey);
10501
- const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
10502
- result[attrName] = accessor;
10503
- }
10504
- 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/utils/3d-tiles-utils.ts
10086
+ function getArrayElementByteSize(attributeType, componentType) {
10087
+ return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10088
+ }
10089
+ function getOffsetsForProperty(scenegraph, bufferViewIndex, offsetType, numberOfElements) {
10090
+ if (offsetType !== "UINT8" && offsetType !== "UINT16" && offsetType !== "UINT32" && offsetType !== "UINT64") {
10091
+ return null;
10092
+ }
10093
+ const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
10094
+ const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
10095
+ if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
10096
+ return null;
10097
+ }
10098
+ return arrayOffsets;
10099
+ }
10100
+ function convertRawBufferToMetadataArray(data, attributeType, componentType, elementCount = 1) {
10101
+ const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10102
+ const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[componentType];
10103
+ const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType];
10104
+ const length4 = elementCount * numberOfComponents;
10105
+ const byteLength = length4 * size;
10106
+ let buffer = data.buffer;
10107
+ let offset = data.byteOffset;
10108
+ if (offset % size !== 0) {
10109
+ const bufferArray = new Uint8Array(buffer);
10110
+ buffer = bufferArray.slice(offset, offset + byteLength).buffer;
10111
+ offset = 0;
10112
+ }
10113
+ return new ArrayType(buffer, offset, length4);
10114
+ }
10115
+ function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
10116
+ const json = scenegraph.gltf.json;
10117
+ const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
10118
+ const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10119
+ const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10120
+ const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10121
+ const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10122
+ const textureIndex = textureInfo.index;
10123
+ const imageIndex = json.textures?.[textureIndex]?.source;
10124
+ if (typeof imageIndex !== "undefined") {
10125
+ const mimeType = json.images?.[imageIndex]?.mimeType;
10126
+ const parsedImage = scenegraph.gltf.images?.[imageIndex];
10127
+ if (parsedImage && typeof parsedImage.width !== "undefined") {
10128
+ const textureData = [];
10129
+ for (let index = 0; index < textureCoordinates.length; index += 2) {
10130
+ const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, textureInfo.channels);
10131
+ textureData.push(value);
10132
+ }
10133
+ return textureData;
10134
+ }
10135
+ }
10136
+ return null;
10137
+ }
10138
+ function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
10139
+ if (propertyData === null)
10140
+ return;
10141
+ const featureIndices = [];
10142
+ for (const texelData of propertyData) {
10143
+ let index = featureTable.findIndex((item) => item === texelData);
10144
+ if (index === -1) {
10145
+ index = featureTable.push(texelData) - 1;
10146
+ }
10147
+ featureIndices.push(index);
10148
+ }
10149
+ const typedArray = new Uint32Array(featureIndices);
10150
+ const bufferIndex = scenegraph.gltf.buffers.push({
10151
+ arrayBuffer: typedArray.buffer,
10152
+ byteOffset: typedArray.byteOffset,
10153
+ byteLength: typedArray.byteLength
10154
+ }) - 1;
10155
+ const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
10156
+ const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
10157
+ size: 1,
10158
+ componentType: getComponentTypeFromArray(typedArray),
10159
+ count: typedArray.length
10160
+ });
10161
+ primitive.attributes[attributeName] = accessorIndex;
10162
+ }
10163
+ function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
10164
+ const CHANNELS_MAP = [
10165
+ { offset: 0, shift: 0 },
10166
+ { offset: 1, shift: 8 },
10167
+ { offset: 2, shift: 16 },
10168
+ { offset: 3, shift: 24 }
10169
+ ];
10170
+ const u = textureCoordinates[index];
10171
+ const v = textureCoordinates[index + 1];
10172
+ let components = 1;
10173
+ if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
10174
+ components = 4;
10175
+ const offset = coordinatesToOffset(u, v, parsedImage, components);
10176
+ let value = 0;
10177
+ for (const c of channels) {
10178
+ const map2 = CHANNELS_MAP[c];
10179
+ const imageOffset = offset + map2.offset;
10180
+ const imageData = getImageData(parsedImage);
10181
+ if (imageData.data.length <= imageOffset) {
10182
+ throw new Error(`${imageData.data.length} <= ${imageOffset}`);
10183
+ }
10184
+ const imageValue = imageData.data[imageOffset];
10185
+ value |= imageValue << map2.shift;
10186
+ }
10187
+ return value;
10188
+ }
10189
+ function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
10190
+ const w = parsedImage.width;
10191
+ const iX = emod(u) * (w - 1);
10192
+ const indX = Math.round(iX);
10193
+ const h = parsedImage.height;
10194
+ const iY = emod(v) * (h - 1);
10195
+ const indY = Math.round(iY);
10196
+ const components = parsedImage.components ? parsedImage.components : componentsCount;
10197
+ const offset = (indY * w + indX) * components;
10198
+ return offset;
10199
+ }
10200
+ var ATTRIBUTE_TYPE_TO_COMPONENTS2, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2;
10201
+ var init_d_tiles_utils = __esm({
10202
+ "../gltf/src/lib/extensions/utils/3d-tiles-utils.ts"() {
10203
+ init_gltf_utils();
10204
+ init_src8();
10205
+ init_src7();
10206
+ ATTRIBUTE_TYPE_TO_COMPONENTS2 = {
10207
+ SCALAR: 1,
10208
+ VEC2: 2,
10209
+ VEC3: 3,
10210
+ VEC4: 4,
10211
+ MAT2: 4,
10212
+ MAT3: 9,
10213
+ MAT4: 16,
10214
+ BOOLEAN: 1,
10215
+ STRING: 1,
10216
+ ENUM: 1
10217
+ };
10218
+ ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2 = {
10219
+ INT8: Int8Array,
10220
+ UINT8: Uint8Array,
10221
+ INT16: Int16Array,
10222
+ UINT16: Uint16Array,
10223
+ INT32: Int32Array,
10224
+ UINT32: Uint32Array,
10225
+ INT64: BigInt64Array,
10226
+ UINT64: BigUint64Array,
10227
+ FLOAT32: Float32Array,
10228
+ FLOAT64: Float64Array
10229
+ };
10230
+ ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2 = {
10231
+ INT8: 1,
10232
+ UINT8: 1,
10233
+ INT16: 2,
10234
+ UINT16: 2,
10235
+ INT32: 4,
10236
+ UINT32: 4,
10237
+ INT64: 8,
10238
+ UINT64: 8,
10239
+ FLOAT32: 4,
10240
+ FLOAT64: 8
10241
+ };
10242
+ }
10243
+ });
10244
+
10245
+ // ../gltf/src/lib/extensions/EXT_structural_metadata.ts
10246
+ var EXT_structural_metadata_exports = {};
10247
+ __export(EXT_structural_metadata_exports, {
10248
+ decode: () => decode,
10249
+ getPropertyTablePopulated: () => getPropertyTablePopulated,
10250
+ name: () => name
10251
+ });
10252
+ async function decode(gltfData, options) {
10253
+ const scenegraph = new GLTFScenegraph(gltfData);
10254
+ decodeExtStructuralMetadata(scenegraph, options);
10255
+ }
10256
+ function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
10257
+ const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10258
+ const propertyTable = extension?.propertyTables?.[propertyTableIndex];
10259
+ if (extension?.schema && propertyTable) {
10260
+ processPropertyTable(scenegraph, extension.schema, propertyTable);
10261
+ return propertyTable;
10262
+ }
10263
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`);
10264
+ }
10265
+ function decodeExtStructuralMetadata(scenegraph, options) {
10266
+ const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10267
+ if (!extension?.schema) {
10268
+ return;
10269
+ }
10270
+ const propertyTextures = extension.propertyTextures;
10271
+ const json = scenegraph.gltf.json;
10272
+ if (propertyTextures && json.meshes && options?.gltf?.loadImages) {
10273
+ for (const mesh of json.meshes) {
10274
+ for (const primitive of mesh.primitives) {
10275
+ processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
10276
+ }
10277
+ }
10278
+ }
10279
+ const schemaClasses = extension.schema.classes;
10280
+ const propertyTables = extension.propertyTables;
10281
+ if (schemaClasses && propertyTables) {
10282
+ for (const schemaName in schemaClasses) {
10283
+ const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
10284
+ if (propertyTable) {
10285
+ processPropertyTable(scenegraph, extension.schema, propertyTable);
10286
+ }
10287
+ }
10288
+ }
10289
+ }
10290
+ function findPropertyTableByClass(propertyTables, schemaClassName) {
10291
+ for (let i2 = 0, len2 = propertyTables.length; i2 < len2; i2++) {
10292
+ const propertyTable = propertyTables[i2];
10293
+ if (propertyTable.class === schemaClassName) {
10294
+ return propertyTable;
10295
+ }
10296
+ }
10297
+ return null;
10298
+ }
10299
+ function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
10300
+ if (!propertyTextures) {
10301
+ return;
10302
+ }
10303
+ const primitiveExtension = primitive.extensions?.[EXT_STRUCTURAL_METADATA_NAME];
10304
+ const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;
10305
+ if (!primitivePropertyTextureIndices) {
10306
+ return;
10307
+ }
10308
+ for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {
10309
+ const propertyTexture = propertyTextures[primitivePropertyTextureIndex];
10310
+ processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);
10311
+ }
10312
+ }
10313
+ function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension) {
10314
+ if (!propertyTexture.properties) {
10315
+ return;
10316
+ }
10317
+ if (!extension.dataAttributeNames) {
10318
+ extension.dataAttributeNames = [];
10319
+ }
10320
+ const className = propertyTexture.class;
10321
+ for (const propName in propertyTexture.properties) {
10322
+ const attributeName = `${className}_${propName}`;
10323
+ const textureInfoTopLevel = propertyTexture.properties?.[propName];
10324
+ if (!textureInfoTopLevel) {
10325
+ continue;
10326
+ }
10327
+ if (!textureInfoTopLevel.data) {
10328
+ textureInfoTopLevel.data = [];
10329
+ }
10330
+ const featureTextureTable = textureInfoTopLevel.data;
10331
+ const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive);
10332
+ if (propertyData === null) {
10333
+ continue;
10334
+ }
10335
+ primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
10336
+ textureInfoTopLevel.data = featureTextureTable;
10337
+ extension.dataAttributeNames.push(attributeName);
10338
+ }
10339
+ }
10340
+ function processPropertyTable(scenegraph, schema, propertyTable) {
10341
+ const schemaClass = schema.classes?.[propertyTable.class];
10342
+ if (!schemaClass) {
10343
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
10344
+ }
10345
+ const numberOfElements = propertyTable.count;
10346
+ for (const propertyName in schemaClass.properties) {
10347
+ const classProperty = schemaClass.properties[propertyName];
10348
+ const propertyTableProperty = propertyTable.properties?.[propertyName];
10349
+ if (propertyTableProperty) {
10350
+ const data = getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty);
10351
+ propertyTableProperty.data = data;
10352
+ }
10353
+ }
10354
+ }
10355
+ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty) {
10356
+ let data = [];
10357
+ const valuesBufferView = propertyTableProperty.values;
10358
+ const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
10359
+ const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements);
10360
+ const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements);
10361
+ switch (classProperty.type) {
10362
+ case "SCALAR":
10363
+ case "VEC2":
10364
+ case "VEC3":
10365
+ case "VEC4":
10366
+ case "MAT2":
10367
+ case "MAT3":
10368
+ case "MAT4": {
10369
+ data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
10370
+ break;
10371
+ }
10372
+ case "BOOLEAN": {
10373
+ throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
10374
+ }
10375
+ case "STRING": {
10376
+ data = getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);
10377
+ break;
10378
+ }
10379
+ case "ENUM": {
10380
+ data = getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
10381
+ break;
10382
+ }
10383
+ default:
10384
+ throw new Error(`Unknown classProperty type ${classProperty.type}`);
10385
+ }
10386
+ return data;
10387
+ }
10388
+ function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
10389
+ if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined" && typeof propertyTableProperty.arrayOffsetType !== "undefined") {
10390
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
10391
+ }
10392
+ return null;
10393
+ }
10394
+ function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
10395
+ if (typeof propertyTableProperty.stringOffsets !== "undefined" && typeof propertyTableProperty.stringOffsetType !== "undefined") {
10396
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
10397
+ }
10398
+ return null;
10399
+ }
10400
+ function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10401
+ const isArray2 = classProperty.array;
10402
+ const arrayCount = classProperty.count;
10403
+ const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);
10404
+ const elementCount = valuesDataBytes.byteLength / elementSize;
10405
+ let valuesData;
10406
+ if (classProperty.componentType) {
10407
+ valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
10408
+ if (!valuesData) {
10409
+ valuesData = valuesDataBytes;
10410
+ }
10411
+ } else {
10412
+ valuesData = valuesDataBytes;
10413
+ }
10414
+ if (isArray2) {
10415
+ if (arrayOffsets) {
10416
+ return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
10417
+ }
10418
+ if (arrayCount) {
10419
+ return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
10420
+ }
10421
+ return [];
10422
+ }
10423
+ return valuesData;
10424
+ }
10425
+ function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) {
10426
+ const attributeValueArray = [];
10427
+ for (let index = 0; index < numberOfElements; index++) {
10428
+ const arrayOffset = arrayOffsets[index];
10429
+ const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10430
+ if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
10431
+ break;
10432
+ }
10433
+ const typedArrayOffset = arrayOffset / valueSize;
10434
+ const elementCount = arrayByteSize / valueSize;
10435
+ attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));
10436
+ }
10437
+ return attributeValueArray;
10438
+ }
10439
+ function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
10440
+ const attributeValueArray = [];
10441
+ for (let index = 0; index < numberOfElements; index++) {
10442
+ const elementOffset = index * arrayCount;
10443
+ attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));
10444
+ }
10445
+ return attributeValueArray;
10446
+ }
10447
+ function getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets) {
10448
+ if (arrayOffsets) {
10449
+ throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
10450
+ }
10451
+ if (stringOffsets) {
10452
+ const stringsArray = [];
10453
+ const textDecoder = new TextDecoder("utf8");
10454
+ let stringOffset = 0;
10455
+ for (let index = 0; index < numberOfElements; index++) {
10456
+ const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];
10457
+ if (stringByteSize + stringOffset <= valuesDataBytes.length) {
10458
+ const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);
10459
+ const stringAttribute = textDecoder.decode(stringData);
10460
+ stringsArray.push(stringAttribute);
10461
+ stringOffset += stringByteSize;
10462
+ }
10463
+ }
10464
+ return stringsArray;
10465
+ }
10466
+ return [];
10467
+ }
10468
+ function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10469
+ const enumType = classProperty.enumType;
10470
+ if (!enumType) {
10471
+ throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");
10472
+ }
10473
+ const enumEntry = schema.enums?.[enumType];
10474
+ if (!enumEntry) {
10475
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`);
10476
+ }
10477
+ const enumValueType = enumEntry.valueType || "UINT16";
10478
+ const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
10479
+ const elementCount = valuesDataBytes.byteLength / elementSize;
10480
+ let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
10481
+ if (!valuesData) {
10482
+ valuesData = valuesDataBytes;
10483
+ }
10484
+ if (classProperty.array) {
10485
+ if (arrayOffsets) {
10486
+ return parseVariableLengthArrayENUM({
10487
+ valuesData,
10488
+ numberOfElements,
10489
+ arrayOffsets,
10490
+ valuesDataBytesLength: valuesDataBytes.length,
10491
+ elementSize,
10492
+ enumEntry
10493
+ });
10494
+ }
10495
+ const arrayCount = classProperty.count;
10496
+ if (arrayCount) {
10497
+ return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
10498
+ }
10499
+ return [];
10500
+ }
10501
+ return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);
10502
+ }
10503
+ function parseVariableLengthArrayENUM(params) {
10504
+ const {
10505
+ valuesData,
10506
+ numberOfElements,
10507
+ arrayOffsets,
10508
+ valuesDataBytesLength,
10509
+ elementSize,
10510
+ enumEntry
10511
+ } = params;
10512
+ const attributeValueArray = [];
10513
+ for (let index = 0; index < numberOfElements; index++) {
10514
+ const arrayOffset = arrayOffsets[index];
10515
+ const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10516
+ if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
10517
+ break;
10518
+ }
10519
+ const typedArrayOffset = arrayOffset / elementSize;
10520
+ const elementCount = arrayByteSize / elementSize;
10521
+ const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);
10522
+ attributeValueArray.push(array);
10523
+ }
10524
+ return attributeValueArray;
10525
+ }
10526
+ function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
10527
+ const attributeValueArray = [];
10528
+ for (let index = 0; index < numberOfElements; index++) {
10529
+ const elementOffset = arrayCount * index;
10530
+ const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);
10531
+ attributeValueArray.push(array);
10532
+ }
10533
+ return attributeValueArray;
10534
+ }
10535
+ function getEnumsArray(valuesData, offset, count, enumEntry) {
10536
+ const array = [];
10537
+ for (let i2 = 0; i2 < count; i2++) {
10538
+ if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {
10539
+ array.push("");
10540
+ } else {
10541
+ const value = valuesData[offset + i2];
10542
+ const enumObject = getEnumByValue(enumEntry, value);
10543
+ if (enumObject) {
10544
+ array.push(enumObject.name);
10545
+ } else {
10546
+ array.push("");
10547
+ }
10548
+ }
10549
+ }
10550
+ return array;
10551
+ }
10552
+ function getEnumByValue(enumEntry, value) {
10553
+ for (const enumValue of enumEntry.values) {
10554
+ if (enumValue.value === value) {
10555
+ return enumValue;
10556
+ }
10557
+ }
10558
+ return null;
10559
+ }
10560
+ var EXT_STRUCTURAL_METADATA_NAME, name;
10561
+ var init_EXT_structural_metadata = __esm({
10562
+ "../gltf/src/lib/extensions/EXT_structural_metadata.ts"() {
10563
+ init_gltf_scenegraph();
10564
+ init_d_tiles_utils();
10565
+ EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
10566
+ name = EXT_STRUCTURAL_METADATA_NAME;
10567
+ }
10568
+ });
10569
+
10570
+ // ../gltf/src/lib/extensions/EXT_mesh_features.ts
10571
+ var EXT_mesh_features_exports = {};
10572
+ __export(EXT_mesh_features_exports, {
10573
+ decode: () => decode2,
10574
+ name: () => name2
10575
+ });
10576
+ async function decode2(gltfData, options) {
10577
+ const scenegraph = new GLTFScenegraph(gltfData);
10578
+ decodeExtMeshFeatures(scenegraph, options);
10579
+ }
10580
+ function decodeExtMeshFeatures(scenegraph, options) {
10581
+ const json = scenegraph.gltf.json;
10582
+ if (!json.meshes) {
10583
+ return;
10584
+ }
10585
+ for (const mesh of json.meshes) {
10586
+ for (const primitive of mesh.primitives) {
10587
+ processMeshPrimitiveFeatures(scenegraph, primitive, options);
10588
+ }
10589
+ }
10590
+ }
10591
+ function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
10592
+ const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
10593
+ const featureIds = extension?.featureIds;
10594
+ if (!featureIds)
10595
+ return;
10596
+ if (!extension.dataAttributeNames) {
10597
+ extension.dataAttributeNames = [];
10598
+ }
10599
+ let featureIdCount = 0;
10600
+ for (const featureId of featureIds) {
10601
+ let propertyTable = null;
10602
+ if (typeof featureId.propertyTable === "number") {
10603
+ propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);
10604
+ }
10605
+ let propertyData = null;
10606
+ if (typeof featureId.attribute !== "undefined") {
10607
+ const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
10608
+ const accessorIndex = primitive.attributes[accessorKey];
10609
+ const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);
10610
+ propertyData = Array.prototype.slice.call(propertyDataTypedArray);
10611
+ } else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
10612
+ propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
10613
+ } else {
10614
+ }
10615
+ const attributeName = featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;
10616
+ const featureTable = [];
10617
+ if (propertyData) {
10618
+ primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive);
10619
+ }
10620
+ extension.dataAttributeNames.push(attributeName);
10621
+ featureId.data = featureTable;
10622
+ featureIdCount++;
10623
+ }
10624
+ }
10625
+ var EXT_MESH_FEATURES_NAME, name2;
10626
+ var init_EXT_mesh_features = __esm({
10627
+ "../gltf/src/lib/extensions/EXT_mesh_features.ts"() {
10628
+ init_gltf_scenegraph();
10629
+ init_d_tiles_utils();
10630
+ init_EXT_structural_metadata();
10631
+ EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
10632
+ name2 = EXT_MESH_FEATURES_NAME;
10633
+ }
10634
+ });
10635
+
10636
+ // ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
10637
+ var EXT_feature_metadata_exports = {};
10638
+ __export(EXT_feature_metadata_exports, {
10639
+ decode: () => decode3,
10640
+ name: () => name3
10641
+ });
10642
+ async function decode3(gltfData, options) {
10643
+ const scenegraph = new GLTFScenegraph(gltfData);
10644
+ decodeExtFeatureMetadata(scenegraph, options);
10645
+ }
10646
+ function decodeExtFeatureMetadata(scenegraph, options) {
10647
+ const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
10648
+ if (!extension)
10649
+ return;
10650
+ const schemaClasses = extension.schema?.classes;
10651
+ const { featureTables } = extension;
10652
+ if (schemaClasses && featureTables) {
10653
+ for (const schemaName in schemaClasses) {
10654
+ const schemaClass = schemaClasses[schemaName];
10655
+ const featureTable = findFeatureTableByName(featureTables, schemaName);
10656
+ if (featureTable) {
10657
+ handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
10658
+ }
10659
+ }
10660
+ }
10661
+ const { featureTextures } = extension;
10662
+ if (schemaClasses && featureTextures && options.gltf?.loadImages) {
10663
+ for (const schemaName in schemaClasses) {
10664
+ const schemaClass = schemaClasses[schemaName];
10665
+ const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
10666
+ if (featureTexture) {
10667
+ handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
10668
+ }
10669
+ }
10670
+ }
10671
+ }
10672
+ function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
10673
+ for (const propertyName in schemaClass.properties) {
10674
+ const schemaProperty = schemaClass.properties[propertyName];
10675
+ const featureTableProperty = featureTable?.properties?.[propertyName];
10676
+ const numberOfFeatures = featureTable.count;
10677
+ if (featureTableProperty) {
10678
+ const data = getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
10679
+ featureTableProperty.data = data;
10680
+ }
10681
+ }
10682
+ }
10683
+ function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
10684
+ const attributeName = featureTexture.class;
10685
+ for (const propertyName in schemaClass.properties) {
10686
+ const featureTextureProperty = featureTexture?.properties?.[propertyName];
10687
+ if (featureTextureProperty) {
10688
+ const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
10689
+ featureTextureProperty.data = data;
10690
+ }
10691
+ }
10692
+ }
10693
+ function getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
10694
+ const bufferView = featureTableProperty.bufferView;
10695
+ const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
10696
+ if (schemaProperty.type === "STRING") {
10697
+ const offsetsData = getStringOffsets(scenegraph, featureTableProperty, numberOfFeatures);
10698
+ if (!offsetsData) {
10699
+ return [];
10700
+ }
10701
+ return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
10702
+ } else if (isNumericProperty(schemaProperty.type)) {
10703
+ return getNumericAttributes(dataArray, schemaProperty.type, numberOfFeatures);
10704
+ }
10705
+ return dataArray;
10706
+ }
10707
+ function isNumericProperty(schemaPropertyType) {
10708
+ return [
10709
+ "UINT8",
10710
+ "INT16",
10711
+ "UINT16",
10712
+ "INT32",
10713
+ "UINT32",
10714
+ "INT64",
10715
+ "UINT64",
10716
+ "FLOAT32",
10717
+ "FLOAT64"
10718
+ ].includes(schemaPropertyType);
10719
+ }
10720
+ function getStringOffsets(scenegraph, featureTableProperty, numberOfElements) {
10721
+ if (typeof featureTableProperty.stringOffsetBufferView !== "undefined") {
10722
+ return getOffsetsForProperty(scenegraph, featureTableProperty.stringOffsetBufferView, featureTableProperty.offsetType || "UINT32", numberOfElements);
10723
+ }
10724
+ return null;
10725
+ }
10726
+ function getNumericAttributes(valuesDataBytes, propertyType, elementCount) {
10727
+ let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, "SCALAR", propertyType, elementCount);
10728
+ if (!valuesData) {
10729
+ valuesData = valuesDataBytes;
10730
+ }
10731
+ return valuesData;
10732
+ }
10733
+ function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
10734
+ const json = scenegraph.gltf.json;
10735
+ if (!json.meshes) {
10736
+ return [];
10737
+ }
10738
+ const featureTextureTable = [];
10739
+ for (const mesh of json.meshes) {
10740
+ for (const primitive of mesh.primitives) {
10741
+ processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
10742
+ }
10743
+ }
10744
+ return featureTextureTable;
10745
+ }
10746
+ function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
10747
+ const json = scenegraph.gltf.json;
10748
+ const textureData = [];
10749
+ const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
10750
+ const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10751
+ const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10752
+ const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10753
+ const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10754
+ const textureIndex = featureTextureProperty.texture.index;
10755
+ const texture = json.textures?.[textureIndex];
10756
+ const imageIndex = texture?.source;
10757
+ if (typeof imageIndex !== "undefined") {
10758
+ const image = json.images?.[imageIndex];
10759
+ const mimeType = image?.mimeType;
10760
+ const parsedImage = scenegraph.gltf.images?.[imageIndex];
10761
+ if (parsedImage) {
10762
+ for (let index = 0; index < textureCoordinates.length; index += 2) {
10763
+ const value = getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
10764
+ textureData.push(value);
10765
+ }
10766
+ }
10767
+ }
10768
+ const featureIndices = [];
10769
+ for (const texelData of textureData) {
10770
+ let index = featureTextureTable.findIndex((item) => item === texelData);
10771
+ if (index === -1) {
10772
+ index = featureTextureTable.push(texelData) - 1;
10773
+ }
10774
+ featureIndices.push(index);
10775
+ }
10776
+ const typedArray = new Uint32Array(featureIndices);
10777
+ const bufferIndex = scenegraph.gltf.buffers.push({
10778
+ arrayBuffer: typedArray.buffer,
10779
+ byteOffset: 0,
10780
+ byteLength: typedArray.byteLength
10781
+ }) - 1;
10782
+ const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
10783
+ const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
10784
+ size: 1,
10785
+ componentType: getComponentTypeFromArray(typedArray),
10786
+ count: typedArray.length
10787
+ });
10788
+ primitive.attributes[attributeName] = accessorIndex;
10789
+ }
10790
+ function getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, channels) {
10791
+ const CHANNELS_MAP = {
10792
+ r: { offset: 0, shift: 0 },
10793
+ g: { offset: 1, shift: 8 },
10794
+ b: { offset: 2, shift: 16 },
10795
+ a: { offset: 3, shift: 24 }
10796
+ };
10797
+ const u = textureCoordinates[index];
10798
+ const v = textureCoordinates[index + 1];
10799
+ let components = 1;
10800
+ if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
10801
+ components = 4;
10802
+ const offset = coordinatesToOffset2(u, v, parsedImage, components);
10803
+ let value = 0;
10804
+ for (const c of channels) {
10805
+ const map2 = CHANNELS_MAP[c];
10806
+ const val = getVal(parsedImage, offset + map2.offset);
10807
+ value |= val << map2.shift;
10808
+ }
10809
+ return value;
10810
+ }
10811
+ function getVal(parsedImage, offset) {
10812
+ const imageData = getImageData(parsedImage);
10813
+ if (imageData.data.length <= offset) {
10814
+ throw new Error(`${imageData.data.length} <= ${offset}`);
10815
+ }
10816
+ return imageData.data[offset];
10817
+ }
10818
+ function coordinatesToOffset2(u, v, parsedImage, componentsCount = 1) {
10819
+ const w = parsedImage.width;
10820
+ const iX = emod(u) * (w - 1);
10821
+ const indX = Math.round(iX);
10822
+ const h = parsedImage.height;
10823
+ const iY = emod(v) * (h - 1);
10824
+ const indY = Math.round(iY);
10825
+ const components = parsedImage.components ? parsedImage.components : componentsCount;
10826
+ const offset = (indY * w + indX) * components;
10827
+ return offset;
10828
+ }
10829
+ function findFeatureTableByName(featureTables, schemaClassName) {
10830
+ for (const featureTableName in featureTables) {
10831
+ const featureTable = featureTables[featureTableName];
10832
+ if (featureTable.class === schemaClassName) {
10833
+ return featureTable;
10834
+ }
10835
+ }
10836
+ return null;
10837
+ }
10838
+ function findFeatureTextureByName(featureTextures, schemaClassName) {
10839
+ for (const featureTexturesName in featureTextures) {
10840
+ const featureTable = featureTextures[featureTexturesName];
10841
+ if (featureTable.class === schemaClassName) {
10842
+ return featureTable;
10843
+ }
10844
+ }
10845
+ return null;
10846
+ }
10847
+ function getStringAttributes(data, offsetsData, stringsCount) {
10848
+ const stringsArray = [];
10849
+ const textDecoder = new TextDecoder("utf8");
10850
+ for (let index = 0; index < stringsCount; index++) {
10851
+ const stringData = data.slice(offsetsData[index], offsetsData[index + 1]);
10852
+ const stringAttribute = textDecoder.decode(stringData);
10853
+ stringsArray.push(stringAttribute);
10854
+ }
10855
+ return stringsArray;
10856
+ }
10857
+ var EXT_FEATURE_METADATA_NAME, name3;
10858
+ var init_EXT_feature_metadata = __esm({
10859
+ "../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
10860
+ init_gltf_scenegraph();
10861
+ init_src8();
10862
+ init_gltf_utils();
10863
+ init_src7();
10864
+ init_d_tiles_utils();
10865
+ EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
10866
+ name3 = EXT_FEATURE_METADATA_NAME;
10867
+ }
10868
+ });
10869
+
10870
+ // ../gltf/src/lib/utils/version.ts
10871
+ var VERSION7;
10872
+ var init_version5 = __esm({
10873
+ "../gltf/src/lib/utils/version.ts"() {
10874
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
10875
+ }
10876
+ });
10877
+
10878
+ // ../textures/src/lib/utils/version.ts
10879
+ var VERSION8;
10880
+ var init_version6 = __esm({
10881
+ "../textures/src/lib/utils/version.ts"() {
10882
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
10883
+ }
10884
+ });
10885
+
10886
+ // ../textures/src/lib/parsers/basis-module-loader.ts
10887
+ async function loadBasisTranscoderModule(options) {
10888
+ const modules = options.modules || {};
10889
+ if (modules.basis) {
10890
+ return modules.basis;
10891
+ }
10892
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
10893
+ return await loadBasisTranscoderPromise;
10894
+ }
10895
+ async function loadBasisTranscoder(options) {
10896
+ let BASIS = null;
10897
+ let wasmBinary = null;
10898
+ [BASIS, wasmBinary] = await Promise.all([
10899
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
10900
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
10901
+ ]);
10902
+ BASIS = BASIS || globalThis.BASIS;
10903
+ return await initializeBasisTranscoderModule(BASIS, wasmBinary);
10904
+ }
10905
+ function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
10906
+ const options = {};
10907
+ if (wasmBinary) {
10908
+ options.wasmBinary = wasmBinary;
10909
+ }
10910
+ return new Promise((resolve2) => {
10911
+ BasisModule(options).then((module) => {
10912
+ const { BasisFile, initializeBasis } = module;
10913
+ initializeBasis();
10914
+ resolve2({ BasisFile });
10915
+ });
10916
+ });
10917
+ }
10918
+ async function loadBasisEncoderModule(options) {
10919
+ const modules = options.modules || {};
10920
+ if (modules.basisEncoder) {
10921
+ return modules.basisEncoder;
10922
+ }
10923
+ loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
10924
+ return await loadBasisEncoderPromise;
10925
+ }
10926
+ async function loadBasisEncoder(options) {
10927
+ let BASIS_ENCODER = null;
10928
+ let wasmBinary = null;
10929
+ [BASIS_ENCODER, wasmBinary] = await Promise.all([
10930
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
10931
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
10932
+ ]);
10933
+ BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
10934
+ return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
10935
+ }
10936
+ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
10937
+ const options = {};
10938
+ if (wasmBinary) {
10939
+ options.wasmBinary = wasmBinary;
10940
+ }
10941
+ return new Promise((resolve2) => {
10942
+ BasisEncoderModule(options).then((module) => {
10943
+ const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
10944
+ initializeBasis();
10945
+ resolve2({ BasisFile, KTX2File, BasisEncoder });
10946
+ });
10947
+ });
10948
+ }
10949
+ var BASIS_EXTERNAL_LIBRARIES, loadBasisTranscoderPromise, loadBasisEncoderPromise;
10950
+ var init_basis_module_loader = __esm({
10951
+ "../textures/src/lib/parsers/basis-module-loader.ts"() {
10952
+ init_src();
10953
+ BASIS_EXTERNAL_LIBRARIES = {
10954
+ TRANSCODER: "basis_transcoder.js",
10955
+ TRANSCODER_WASM: "basis_transcoder.wasm",
10956
+ ENCODER: "basis_encoder.js",
10957
+ ENCODER_WASM: "basis_encoder.wasm"
10958
+ };
10959
+ }
10960
+ });
10961
+
10962
+ // ../textures/src/lib/gl-extensions.ts
10963
+ var GL_EXTENSIONS_CONSTANTS;
10964
+ var init_gl_extensions = __esm({
10965
+ "../textures/src/lib/gl-extensions.ts"() {
10966
+ GL_EXTENSIONS_CONSTANTS = {
10967
+ COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
10968
+ COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
10969
+ COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
10970
+ COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
10971
+ COMPRESSED_R11_EAC: 37488,
10972
+ COMPRESSED_SIGNED_R11_EAC: 37489,
10973
+ COMPRESSED_RG11_EAC: 37490,
10974
+ COMPRESSED_SIGNED_RG11_EAC: 37491,
10975
+ COMPRESSED_RGB8_ETC2: 37492,
10976
+ COMPRESSED_RGBA8_ETC2_EAC: 37493,
10977
+ COMPRESSED_SRGB8_ETC2: 37494,
10978
+ COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
10979
+ COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
10980
+ COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
10981
+ COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
10982
+ COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
10983
+ COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
10984
+ COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
10985
+ COMPRESSED_RGB_ETC1_WEBGL: 36196,
10986
+ COMPRESSED_RGB_ATC_WEBGL: 35986,
10987
+ COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
10988
+ COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
10989
+ COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
10990
+ COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
10991
+ COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
10992
+ COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
10993
+ COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
10994
+ COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
10995
+ COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
10996
+ COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
10997
+ COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
10998
+ COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
10999
+ COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
11000
+ COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
11001
+ COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
11002
+ COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
11003
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
11004
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
11005
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
11006
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
11007
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
11008
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
11009
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
11010
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
11011
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
11012
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
11013
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
11014
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
11015
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
11016
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
11017
+ COMPRESSED_RED_RGTC1_EXT: 36283,
11018
+ COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
11019
+ COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
11020
+ COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
11021
+ COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
11022
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
11023
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
11024
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
11025
+ };
11026
+ }
11027
+ });
11028
+
11029
+ // ../textures/src/lib/utils/texture-formats.ts
11030
+ function getSupportedGPUTextureFormats(gl) {
11031
+ if (!formats) {
11032
+ gl = gl || getWebGLContext() || void 0;
11033
+ formats = new Set();
11034
+ for (const prefix of BROWSER_PREFIXES) {
11035
+ for (const extension in WEBGL_EXTENSIONS) {
11036
+ if (gl && gl.getExtension(`${prefix}${extension}`)) {
11037
+ const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
11038
+ formats.add(gpuTextureFormat);
11039
+ }
11040
+ }
11041
+ }
11042
+ }
11043
+ return formats;
11044
+ }
11045
+ function getWebGLContext() {
11046
+ try {
11047
+ const canvas = document.createElement("canvas");
11048
+ return canvas.getContext("webgl");
11049
+ } catch (error) {
11050
+ return null;
11051
+ }
11052
+ }
11053
+ var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
11054
+ var init_texture_formats = __esm({
11055
+ "../textures/src/lib/utils/texture-formats.ts"() {
11056
+ BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
11057
+ WEBGL_EXTENSIONS = {
11058
+ WEBGL_compressed_texture_s3tc: "dxt",
11059
+ WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
11060
+ WEBGL_compressed_texture_etc1: "etc1",
11061
+ WEBGL_compressed_texture_etc: "etc2",
11062
+ WEBGL_compressed_texture_pvrtc: "pvrtc",
11063
+ WEBGL_compressed_texture_atc: "atc",
11064
+ WEBGL_compressed_texture_astc: "astc",
11065
+ EXT_texture_compression_rgtc: "rgtc"
11066
+ };
11067
+ formats = null;
11068
+ }
11069
+ });
11070
+
11071
+ // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
11072
+ var t, n, i, s, a, r, o, l, f;
11073
+ var init_ktx_parse_modern = __esm({
11074
+ "../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
11075
+ t = new Uint8Array([0]);
11076
+ !function(t2) {
11077
+ t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
11078
+ }(n || (n = {})), function(t2) {
11079
+ t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
11080
+ }(i || (i = {})), function(t2) {
11081
+ t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
11082
+ }(s || (s = {})), function(t2) {
11083
+ t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
11084
+ }(a || (a = {})), function(t2) {
11085
+ 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";
11086
+ }(r || (r = {})), function(t2) {
11087
+ t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
11088
+ }(o || (o = {})), function(t2) {
11089
+ t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
11090
+ }(l || (l = {})), function(t2) {
11091
+ t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
11092
+ }(f || (f = {}));
11093
+ }
11094
+ });
11095
+
11096
+ // ../textures/src/lib/parsers/parse-ktx.ts
11097
+ function isKTX(data) {
11098
+ const id = new Uint8Array(data);
11099
+ 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];
11100
+ return !notKTX;
11101
+ }
11102
+ var KTX2_ID;
11103
+ var init_parse_ktx = __esm({
11104
+ "../textures/src/lib/parsers/parse-ktx.ts"() {
11105
+ init_ktx_parse_modern();
11106
+ KTX2_ID = [
11107
+ 171,
11108
+ 75,
11109
+ 84,
11110
+ 88,
11111
+ 32,
11112
+ 50,
11113
+ 48,
11114
+ 187,
11115
+ 13,
11116
+ 10,
11117
+ 26,
11118
+ 10
11119
+ ];
11120
+ }
11121
+ });
11122
+
11123
+ // ../textures/src/lib/parsers/parse-basis.ts
11124
+ async function parseBasis(data, options) {
11125
+ if (options.basis.containerFormat === "auto") {
11126
+ if (isKTX(data)) {
11127
+ const fileConstructors = await loadBasisEncoderModule(options);
11128
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
11129
+ }
11130
+ const { BasisFile } = await loadBasisTranscoderModule(options);
11131
+ return parseBasisFile(BasisFile, data, options);
11132
+ }
11133
+ switch (options.basis.module) {
11134
+ case "encoder":
11135
+ const fileConstructors = await loadBasisEncoderModule(options);
11136
+ switch (options.basis.containerFormat) {
11137
+ case "ktx2":
11138
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
11139
+ case "basis":
11140
+ default:
11141
+ return parseBasisFile(fileConstructors.BasisFile, data, options);
10505
11142
  }
10506
- _addIndices(indices) {
10507
- return this.addBinaryBuffer(indices, { size: 1 });
11143
+ case "transcoder":
11144
+ default:
11145
+ const { BasisFile } = await loadBasisTranscoderModule(options);
11146
+ return parseBasisFile(BasisFile, data, options);
11147
+ }
11148
+ }
11149
+ function parseBasisFile(BasisFile, data, options) {
11150
+ const basisFile = new BasisFile(new Uint8Array(data));
11151
+ try {
11152
+ if (!basisFile.startTranscoding()) {
11153
+ throw new Error("Failed to start basis transcoding");
11154
+ }
11155
+ const imageCount = basisFile.getNumImages();
11156
+ const images = [];
11157
+ for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
11158
+ const levelsCount = basisFile.getNumLevels(imageIndex);
11159
+ const levels = [];
11160
+ for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
11161
+ levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
10508
11162
  }
10509
- _getGltfAttributeName(attributeName) {
10510
- switch (attributeName.toLowerCase()) {
10511
- case "position":
10512
- case "positions":
10513
- case "vertices":
10514
- return "POSITION";
10515
- case "normal":
10516
- case "normals":
10517
- return "NORMAL";
10518
- case "color":
10519
- case "colors":
10520
- return "COLOR_0";
10521
- case "texcoord":
10522
- case "texcoords":
10523
- return "TEXCOORD_0";
10524
- default:
10525
- return attributeName;
11163
+ images.push(levels);
11164
+ }
11165
+ return images;
11166
+ } finally {
11167
+ basisFile.close();
11168
+ basisFile.delete();
11169
+ }
11170
+ }
11171
+ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
11172
+ const width = basisFile.getImageWidth(imageIndex, levelIndex);
11173
+ const height = basisFile.getImageHeight(imageIndex, levelIndex);
11174
+ const hasAlpha = basisFile.getHasAlpha();
11175
+ const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
11176
+ const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
11177
+ const decodedData = new Uint8Array(decodedSize);
11178
+ if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
11179
+ throw new Error("failed to start Basis transcoding");
11180
+ }
11181
+ return {
11182
+ width,
11183
+ height,
11184
+ data: decodedData,
11185
+ compressed,
11186
+ format,
11187
+ hasAlpha
11188
+ };
11189
+ }
11190
+ function parseKTX2File(KTX2File, data, options) {
11191
+ const ktx2File = new KTX2File(new Uint8Array(data));
11192
+ try {
11193
+ if (!ktx2File.startTranscoding()) {
11194
+ throw new Error("failed to start KTX2 transcoding");
11195
+ }
11196
+ const levelsCount = ktx2File.getLevels();
11197
+ const levels = [];
11198
+ for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
11199
+ levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
11200
+ break;
11201
+ }
11202
+ return [levels];
11203
+ } finally {
11204
+ ktx2File.close();
11205
+ ktx2File.delete();
11206
+ }
11207
+ }
11208
+ function transcodeKTX2Image(ktx2File, levelIndex, options) {
11209
+ const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
11210
+ const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
11211
+ const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
11212
+ const decodedData = new Uint8Array(decodedSize);
11213
+ if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
11214
+ throw new Error("Failed to transcode KTX2 image");
11215
+ }
11216
+ return {
11217
+ width,
11218
+ height,
11219
+ data: decodedData,
11220
+ compressed,
11221
+ levelSize: decodedSize,
11222
+ hasAlpha: alphaFlag,
11223
+ format
11224
+ };
11225
+ }
11226
+ function getBasisOptions(options, hasAlpha) {
11227
+ let format = options && options.basis && options.basis.format;
11228
+ if (format === "auto") {
11229
+ format = selectSupportedBasisFormat();
11230
+ }
11231
+ if (typeof format === "object") {
11232
+ format = hasAlpha ? format.alpha : format.noAlpha;
11233
+ }
11234
+ format = format.toLowerCase();
11235
+ return OutputFormat[format];
11236
+ }
11237
+ function selectSupportedBasisFormat() {
11238
+ const supportedFormats = getSupportedGPUTextureFormats();
11239
+ if (supportedFormats.has("astc")) {
11240
+ return "astc-4x4";
11241
+ } else if (supportedFormats.has("dxt")) {
11242
+ return {
11243
+ alpha: "bc3",
11244
+ noAlpha: "bc1"
11245
+ };
11246
+ } else if (supportedFormats.has("pvrtc")) {
11247
+ return {
11248
+ alpha: "pvrtc1-4-rgba",
11249
+ noAlpha: "pvrtc1-4-rgb"
11250
+ };
11251
+ } else if (supportedFormats.has("etc1")) {
11252
+ return "etc1";
11253
+ } else if (supportedFormats.has("etc2")) {
11254
+ return "etc2";
11255
+ }
11256
+ return "rgb565";
11257
+ }
11258
+ var OutputFormat;
11259
+ var init_parse_basis = __esm({
11260
+ "../textures/src/lib/parsers/parse-basis.ts"() {
11261
+ init_basis_module_loader();
11262
+ init_gl_extensions();
11263
+ init_texture_formats();
11264
+ init_parse_ktx();
11265
+ OutputFormat = {
11266
+ etc1: {
11267
+ basisFormat: 0,
11268
+ compressed: true,
11269
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
11270
+ },
11271
+ etc2: { basisFormat: 1, compressed: true },
11272
+ bc1: {
11273
+ basisFormat: 2,
11274
+ compressed: true,
11275
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
11276
+ },
11277
+ bc3: {
11278
+ basisFormat: 3,
11279
+ compressed: true,
11280
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
11281
+ },
11282
+ bc4: { basisFormat: 4, compressed: true },
11283
+ bc5: { basisFormat: 5, compressed: true },
11284
+ "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
11285
+ "bc7-m5": { basisFormat: 7, compressed: true },
11286
+ "pvrtc1-4-rgb": {
11287
+ basisFormat: 8,
11288
+ compressed: true,
11289
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
11290
+ },
11291
+ "pvrtc1-4-rgba": {
11292
+ basisFormat: 9,
11293
+ compressed: true,
11294
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
11295
+ },
11296
+ "astc-4x4": {
11297
+ basisFormat: 10,
11298
+ compressed: true,
11299
+ format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
11300
+ },
11301
+ "atc-rgb": { basisFormat: 11, compressed: true },
11302
+ "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
11303
+ rgba32: { basisFormat: 13, compressed: false },
11304
+ rgb565: { basisFormat: 14, compressed: false },
11305
+ bgr565: { basisFormat: 15, compressed: false },
11306
+ rgba4444: { basisFormat: 16, compressed: false }
11307
+ };
11308
+ }
11309
+ });
11310
+
11311
+ // ../textures/src/basis-loader.ts
11312
+ var BasisWorkerLoader, BasisLoader;
11313
+ var init_basis_loader = __esm({
11314
+ "../textures/src/basis-loader.ts"() {
11315
+ init_version6();
11316
+ init_parse_basis();
11317
+ BasisWorkerLoader = {
11318
+ name: "Basis",
11319
+ id: "basis",
11320
+ module: "textures",
11321
+ version: VERSION8,
11322
+ worker: true,
11323
+ extensions: ["basis", "ktx2"],
11324
+ mimeTypes: ["application/octet-stream", "image/ktx2"],
11325
+ tests: ["sB"],
11326
+ binary: true,
11327
+ options: {
11328
+ basis: {
11329
+ format: "auto",
11330
+ libraryPath: "libs/",
11331
+ containerFormat: "auto",
11332
+ module: "transcoder"
10526
11333
  }
10527
11334
  }
10528
- _getAccessorMinMax(buffer, size) {
10529
- const result = { min: null, max: null };
10530
- if (buffer.length < size) {
10531
- return result;
10532
- }
10533
- result.min = [];
10534
- result.max = [];
10535
- const initValues = buffer.subarray(0, size);
10536
- for (const value of initValues) {
10537
- result.min.push(value);
10538
- result.max.push(value);
11335
+ };
11336
+ BasisLoader = {
11337
+ ...BasisWorkerLoader,
11338
+ parse: parseBasis
11339
+ };
11340
+ }
11341
+ });
11342
+
11343
+ // ../textures/src/index.ts
11344
+ var init_src9 = __esm({
11345
+ "../textures/src/index.ts"() {
11346
+ init_basis_loader();
11347
+ init_parse_basis();
11348
+ }
11349
+ });
11350
+
11351
+ // ../gltf/src/lib/parsers/parse-glb.ts
11352
+ function getMagicString4(dataView, byteOffset = 0) {
11353
+ 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))}`;
11354
+ }
11355
+ function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
11356
+ const dataView = new DataView(arrayBuffer);
11357
+ const { magic = MAGIC_glTF } = options;
11358
+ const magic1 = dataView.getUint32(byteOffset, false);
11359
+ return magic1 === magic || magic1 === MAGIC_glTF;
11360
+ }
11361
+ function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
11362
+ const dataView = new DataView(arrayBuffer);
11363
+ const type = getMagicString4(dataView, byteOffset + 0);
11364
+ const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11365
+ const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
11366
+ Object.assign(glb, {
11367
+ header: {
11368
+ byteOffset,
11369
+ byteLength,
11370
+ hasBinChunk: false
11371
+ },
11372
+ type,
11373
+ version,
11374
+ json: {},
11375
+ binChunks: []
11376
+ });
11377
+ byteOffset += GLB_FILE_HEADER_SIZE;
11378
+ switch (glb.version) {
11379
+ case 1:
11380
+ return parseGLBV1(glb, dataView, byteOffset);
11381
+ case 2:
11382
+ return parseGLBV2(glb, dataView, byteOffset, options = {});
11383
+ default:
11384
+ throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
11385
+ }
11386
+ }
11387
+ function parseGLBV1(glb, dataView, byteOffset) {
11388
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
11389
+ const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
11390
+ const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11391
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
11392
+ assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
11393
+ parseJSONChunk(glb, dataView, byteOffset, contentLength);
11394
+ byteOffset += contentLength;
11395
+ byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
11396
+ return byteOffset;
11397
+ }
11398
+ function parseGLBV2(glb, dataView, byteOffset, options) {
11399
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
11400
+ parseGLBChunksSync(glb, dataView, byteOffset, options);
11401
+ return byteOffset + glb.header.byteLength;
11402
+ }
11403
+ function parseGLBChunksSync(glb, dataView, byteOffset, options) {
11404
+ while (byteOffset + 8 <= glb.header.byteLength) {
11405
+ const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
11406
+ const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
11407
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
11408
+ switch (chunkFormat) {
11409
+ case GLB_CHUNK_TYPE_JSON:
11410
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
11411
+ break;
11412
+ case GLB_CHUNK_TYPE_BIN:
11413
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
11414
+ break;
11415
+ case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
11416
+ if (!options.strict) {
11417
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
10539
11418
  }
10540
- for (let index = size; index < buffer.length; index += size) {
10541
- for (let componentIndex = 0; componentIndex < size; componentIndex++) {
10542
- result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
10543
- result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
10544
- }
11419
+ break;
11420
+ case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
11421
+ if (!options.strict) {
11422
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
10545
11423
  }
10546
- return result;
10547
- }
10548
- };
11424
+ break;
11425
+ default:
11426
+ break;
11427
+ }
11428
+ byteOffset += padToNBytes(chunkLength, 4);
11429
+ }
11430
+ return byteOffset;
11431
+ }
11432
+ function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
11433
+ const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
11434
+ const textDecoder = new TextDecoder("utf8");
11435
+ const jsonText = textDecoder.decode(jsonChunk);
11436
+ glb.json = JSON.parse(jsonText);
11437
+ return padToNBytes(chunkLength, 4);
11438
+ }
11439
+ function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
11440
+ glb.header.hasBinChunk = true;
11441
+ glb.binChunks.push({
11442
+ byteOffset,
11443
+ byteLength: chunkLength,
11444
+ arrayBuffer: dataView.buffer
11445
+ });
11446
+ return padToNBytes(chunkLength, 4);
11447
+ }
11448
+ 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;
11449
+ var init_parse_glb = __esm({
11450
+ "../gltf/src/lib/parsers/parse-glb.ts"() {
11451
+ init_src2();
11452
+ LITTLE_ENDIAN2 = true;
11453
+ MAGIC_glTF = 1735152710;
11454
+ GLB_FILE_HEADER_SIZE = 12;
11455
+ GLB_CHUNK_HEADER_SIZE = 8;
11456
+ GLB_CHUNK_TYPE_JSON = 1313821514;
11457
+ GLB_CHUNK_TYPE_BIN = 5130562;
11458
+ GLB_V1_CONTENT_FORMAT_JSON = 0;
11459
+ GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
11460
+ GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
11461
+ }
11462
+ });
11463
+
11464
+ // ../gltf/src/lib/gltf-utils/resolve-url.ts
11465
+ function resolveUrl(url, options) {
11466
+ const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
11467
+ if (absolute) {
11468
+ return url;
11469
+ }
11470
+ const baseUrl = options.baseUri || options.uri;
11471
+ if (!baseUrl) {
11472
+ throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
11473
+ }
11474
+ return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
11475
+ }
11476
+ var init_resolve_url = __esm({
11477
+ "../gltf/src/lib/gltf-utils/resolve-url.ts"() {
11478
+ }
11479
+ });
11480
+
11481
+ // ../gltf/src/lib/gltf-utils/get-typed-array.ts
11482
+ function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
11483
+ const bufferView = json.bufferViews[bufferViewIndex];
11484
+ assert7(bufferView);
11485
+ const bufferIndex = bufferView.buffer;
11486
+ const binChunk = buffers[bufferIndex];
11487
+ assert7(binChunk);
11488
+ const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
11489
+ return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
11490
+ }
11491
+ var init_get_typed_array = __esm({
11492
+ "../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
11493
+ init_assert6();
10549
11494
  }
10550
11495
  });
10551
11496
 
10552
11497
  // ../gltf/src/meshopt/meshopt-decoder.ts
10553
11498
  async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") {
10554
11499
  const instance = await loadWasmInstance();
10555
- decode(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]);
11500
+ decode4(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]);
10556
11501
  }
10557
11502
  async function loadWasmInstance() {
10558
11503
  if (!wasmPromise) {
@@ -10582,7 +11527,7 @@
10582
11527
  }
10583
11528
  return result.buffer.slice(0, write);
10584
11529
  }
10585
- function decode(instance, fun, target, count, size, source, filter) {
11530
+ function decode4(instance, fun, target, count, size, source, filter) {
10586
11531
  const sbrk = instance.exports.sbrk;
10587
11532
  const count4 = count + 3 & ~3;
10588
11533
  const tp = sbrk(count4 * size);
@@ -10743,10 +11688,10 @@
10743
11688
  // ../gltf/src/lib/extensions/EXT_meshopt_compression.ts
10744
11689
  var EXT_meshopt_compression_exports = {};
10745
11690
  __export(EXT_meshopt_compression_exports, {
10746
- decode: () => decode2,
10747
- name: () => name
11691
+ decode: () => decode5,
11692
+ name: () => name4
10748
11693
  });
10749
- async function decode2(gltfData, options) {
11694
+ async function decode5(gltfData, options) {
10750
11695
  const scenegraph = new GLTFScenegraph(gltfData);
10751
11696
  if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {
10752
11697
  return;
@@ -10777,20 +11722,20 @@
10777
11722
  scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
10778
11723
  }
10779
11724
  }
10780
- var EXT_MESHOPT_COMPRESSION, name;
11725
+ var EXT_MESHOPT_COMPRESSION, name4;
10781
11726
  var init_EXT_meshopt_compression = __esm({
10782
11727
  "../gltf/src/lib/extensions/EXT_meshopt_compression.ts"() {
10783
11728
  init_gltf_scenegraph();
10784
11729
  init_meshopt_decoder();
10785
11730
  EXT_MESHOPT_COMPRESSION = "EXT_meshopt_compression";
10786
- name = EXT_MESHOPT_COMPRESSION;
11731
+ name4 = EXT_MESHOPT_COMPRESSION;
10787
11732
  }
10788
11733
  });
10789
11734
 
10790
11735
  // ../gltf/src/lib/extensions/EXT_texture_webp.ts
10791
11736
  var EXT_texture_webp_exports = {};
10792
11737
  __export(EXT_texture_webp_exports, {
10793
- name: () => name2,
11738
+ name: () => name5,
10794
11739
  preprocess: () => preprocess
10795
11740
  });
10796
11741
  function preprocess(gltfData, options) {
@@ -10811,20 +11756,20 @@
10811
11756
  }
10812
11757
  scenegraph.removeExtension(EXT_TEXTURE_WEBP);
10813
11758
  }
10814
- var EXT_TEXTURE_WEBP, name2;
11759
+ var EXT_TEXTURE_WEBP, name5;
10815
11760
  var init_EXT_texture_webp = __esm({
10816
11761
  "../gltf/src/lib/extensions/EXT_texture_webp.ts"() {
10817
11762
  init_src8();
10818
11763
  init_gltf_scenegraph();
10819
11764
  EXT_TEXTURE_WEBP = "EXT_texture_webp";
10820
- name2 = EXT_TEXTURE_WEBP;
11765
+ name5 = EXT_TEXTURE_WEBP;
10821
11766
  }
10822
11767
  });
10823
11768
 
10824
11769
  // ../gltf/src/lib/extensions/KHR_texture_basisu.ts
10825
11770
  var KHR_texture_basisu_exports = {};
10826
11771
  __export(KHR_texture_basisu_exports, {
10827
- name: () => name3,
11772
+ name: () => name6,
10828
11773
  preprocess: () => preprocess2
10829
11774
  });
10830
11775
  function preprocess2(gltfData, options) {
@@ -10839,23 +11784,23 @@
10839
11784
  }
10840
11785
  scene.removeExtension(KHR_TEXTURE_BASISU);
10841
11786
  }
10842
- var KHR_TEXTURE_BASISU, name3;
11787
+ var KHR_TEXTURE_BASISU, name6;
10843
11788
  var init_KHR_texture_basisu = __esm({
10844
11789
  "../gltf/src/lib/extensions/KHR_texture_basisu.ts"() {
10845
11790
  init_gltf_scenegraph();
10846
11791
  KHR_TEXTURE_BASISU = "KHR_texture_basisu";
10847
- name3 = KHR_TEXTURE_BASISU;
11792
+ name6 = KHR_TEXTURE_BASISU;
10848
11793
  }
10849
11794
  });
10850
11795
 
10851
11796
  // ../gltf/src/lib/gltf-utils/gltf-attribute-utils.ts
10852
11797
  function getGLTFAccessors(attributes) {
10853
11798
  const accessors = {};
10854
- for (const name10 in attributes) {
10855
- const attribute = attributes[name10];
10856
- if (name10 !== "indices") {
11799
+ for (const name12 in attributes) {
11800
+ const attribute = attributes[name12];
11801
+ if (name12 !== "indices") {
10857
11802
  const glTFAccessor = getGLTFAccessor(attribute);
10858
- accessors[name10] = glTFAccessor;
11803
+ accessors[name12] = glTFAccessor;
10859
11804
  }
10860
11805
  }
10861
11806
  return accessors;
@@ -10909,9 +11854,9 @@
10909
11854
  // ../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts
10910
11855
  var KHR_draco_mesh_compression_exports = {};
10911
11856
  __export(KHR_draco_mesh_compression_exports, {
10912
- decode: () => decode3,
11857
+ decode: () => decode6,
10913
11858
  encode: () => encode,
10914
- name: () => name4,
11859
+ name: () => name7,
10915
11860
  preprocess: () => preprocess3
10916
11861
  });
10917
11862
  function preprocess3(gltfData, options, context) {
@@ -10921,7 +11866,7 @@
10921
11866
  }
10922
11867
  }
10923
11868
  }
10924
- async function decode3(gltfData, options, context) {
11869
+ async function decode6(gltfData, options, context) {
10925
11870
  if (!options?.gltf?.decompressMeshes) {
10926
11871
  return;
10927
11872
  }
@@ -11006,7 +11951,7 @@
11006
11951
  }
11007
11952
  }
11008
11953
  }
11009
- var KHR_DRACO_MESH_COMPRESSION, name4;
11954
+ var KHR_DRACO_MESH_COMPRESSION, name7;
11010
11955
  var init_KHR_draco_mesh_compression = __esm({
11011
11956
  "../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts"() {
11012
11957
  init_src2();
@@ -11014,7 +11959,7 @@
11014
11959
  init_gltf_scenegraph();
11015
11960
  init_gltf_attribute_utils();
11016
11961
  KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
11017
- name4 = KHR_DRACO_MESH_COMPRESSION;
11962
+ name7 = KHR_DRACO_MESH_COMPRESSION;
11018
11963
  }
11019
11964
  });
11020
11965
 
@@ -11045,10 +11990,10 @@
11045
11990
  // ../gltf/src/lib/extensions/KHR_texture_transform.ts
11046
11991
  var KHR_texture_transform_exports = {};
11047
11992
  __export(KHR_texture_transform_exports, {
11048
- decode: () => decode4,
11049
- name: () => name5
11993
+ decode: () => decode7,
11994
+ name: () => name8
11050
11995
  });
11051
- async function decode4(gltfData, options) {
11996
+ async function decode7(gltfData, options) {
11052
11997
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11053
11998
  const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
11054
11999
  if (!hasExtension || !options.gltf?.loadBuffers) {
@@ -11190,7 +12135,7 @@
11190
12135
  const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1);
11191
12136
  return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
11192
12137
  }
11193
- var EXT_MESHOPT_TRANSFORM, name5, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
12138
+ var EXT_MESHOPT_TRANSFORM, name8, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
11194
12139
  var init_KHR_texture_transform = __esm({
11195
12140
  "../gltf/src/lib/extensions/KHR_texture_transform.ts"() {
11196
12141
  init_esm();
@@ -11198,7 +12143,7 @@
11198
12143
  init_gltf_constants();
11199
12144
  init_gltf_scenegraph();
11200
12145
  EXT_MESHOPT_TRANSFORM = "KHR_texture_transform";
11201
- name5 = EXT_MESHOPT_TRANSFORM;
12146
+ name8 = EXT_MESHOPT_TRANSFORM;
11202
12147
  scratchVector7 = new Vector3();
11203
12148
  scratchRotationMatrix = new Matrix3();
11204
12149
  scratchScaleMatrix = new Matrix3();
@@ -11208,11 +12153,11 @@
11208
12153
  // ../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts
11209
12154
  var KHR_lights_punctual_exports = {};
11210
12155
  __export(KHR_lights_punctual_exports, {
11211
- decode: () => decode5,
12156
+ decode: () => decode8,
11212
12157
  encode: () => encode2,
11213
- name: () => name6
12158
+ name: () => name9
11214
12159
  });
11215
- async function decode5(gltfData) {
12160
+ async function decode8(gltfData) {
11216
12161
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11217
12162
  const { json } = gltfScenegraph;
11218
12163
  const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);
@@ -11245,335 +12190,122 @@
11245
12190
  delete gltfScenegraph.json.lights;
11246
12191
  }
11247
12192
  }
11248
- var KHR_LIGHTS_PUNCTUAL, name6;
12193
+ var KHR_LIGHTS_PUNCTUAL, name9;
11249
12194
  var init_KHR_lights_punctual = __esm({
11250
12195
  "../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
11251
12196
  init_assert6();
11252
12197
  init_gltf_scenegraph();
11253
12198
  KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
11254
- name6 = KHR_LIGHTS_PUNCTUAL;
12199
+ name9 = KHR_LIGHTS_PUNCTUAL;
11255
12200
  }
11256
12201
  });
11257
12202
 
11258
12203
  // ../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts
11259
12204
  var KHR_materials_unlit_exports = {};
11260
12205
  __export(KHR_materials_unlit_exports, {
11261
- decode: () => decode6,
12206
+ decode: () => decode9,
11262
12207
  encode: () => encode3,
11263
- name: () => name7
11264
- });
11265
- async function decode6(gltfData) {
11266
- const gltfScenegraph = new GLTFScenegraph(gltfData);
11267
- const { json } = gltfScenegraph;
11268
- for (const material of json.materials || []) {
11269
- const extension = material.extensions && material.extensions.KHR_materials_unlit;
11270
- if (extension) {
11271
- material.unlit = true;
11272
- }
11273
- gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT);
11274
- }
11275
- gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);
11276
- }
11277
- function encode3(gltfData) {
11278
- const gltfScenegraph = new GLTFScenegraph(gltfData);
11279
- const { json } = gltfScenegraph;
11280
- if (gltfScenegraph.materials) {
11281
- for (const material of json.materials || []) {
11282
- if (material.unlit) {
11283
- delete material.unlit;
11284
- gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
11285
- gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
11286
- }
11287
- }
11288
- }
11289
- }
11290
- var KHR_MATERIALS_UNLIT, name7;
11291
- var init_KHR_materials_unlit = __esm({
11292
- "../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
11293
- init_gltf_scenegraph();
11294
- KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
11295
- name7 = KHR_MATERIALS_UNLIT;
11296
- }
11297
- });
11298
-
11299
- // ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
11300
- var KHR_techniques_webgl_exports = {};
11301
- __export(KHR_techniques_webgl_exports, {
11302
- decode: () => decode7,
11303
- encode: () => encode4,
11304
- name: () => name8
12208
+ name: () => name10
11305
12209
  });
11306
- async function decode7(gltfData) {
12210
+ async function decode9(gltfData) {
11307
12211
  const gltfScenegraph = new GLTFScenegraph(gltfData);
11308
- const { json } = gltfScenegraph;
11309
- const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
11310
- if (extension) {
11311
- const techniques = resolveTechniques(extension, gltfScenegraph);
11312
- for (const material of json.materials || []) {
11313
- const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11314
- if (materialExtension) {
11315
- material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
11316
- material.technique.values = resolveValues(material.technique, gltfScenegraph);
11317
- }
11318
- gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11319
- }
11320
- gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
11321
- }
11322
- }
11323
- async function encode4(gltfData, options) {
11324
- }
11325
- function resolveTechniques(techniquesExtension, gltfScenegraph) {
11326
- const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
11327
- const textDecoder = new TextDecoder();
11328
- shaders.forEach((shader) => {
11329
- if (Number.isFinite(shader.bufferView)) {
11330
- shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
11331
- } else {
11332
- throw new Error("KHR_techniques_webgl: no shader code");
11333
- }
11334
- });
11335
- programs.forEach((program) => {
11336
- program.fragmentShader = shaders[program.fragmentShader];
11337
- program.vertexShader = shaders[program.vertexShader];
11338
- });
11339
- techniques.forEach((technique) => {
11340
- technique.program = programs[technique.program];
11341
- });
11342
- return techniques;
11343
- }
11344
- function resolveValues(technique, gltfScenegraph) {
11345
- const values = Object.assign({}, technique.values);
11346
- Object.keys(technique.uniforms || {}).forEach((uniform) => {
11347
- if (technique.uniforms[uniform].value && !(uniform in values)) {
11348
- values[uniform] = technique.uniforms[uniform].value;
11349
- }
11350
- });
11351
- Object.keys(values).forEach((uniform) => {
11352
- if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
11353
- values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
11354
- }
11355
- });
11356
- return values;
11357
- }
11358
- var KHR_TECHNIQUES_WEBGL, name8;
11359
- var init_KHR_techniques_webgl = __esm({
11360
- "../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
11361
- init_gltf_scenegraph();
11362
- KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
11363
- name8 = KHR_TECHNIQUES_WEBGL;
11364
- }
11365
- });
11366
-
11367
- // ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
11368
- var EXT_feature_metadata_exports = {};
11369
- __export(EXT_feature_metadata_exports, {
11370
- decode: () => decode8,
11371
- name: () => name9
11372
- });
11373
- async function decode8(gltfData, options) {
11374
- const scenegraph = new GLTFScenegraph(gltfData);
11375
- decodeExtFeatureMetadata(scenegraph, options);
11376
- }
11377
- function decodeExtFeatureMetadata(scenegraph, options) {
11378
- const extension = scenegraph.getExtension(EXT_FEATURE_METADATA);
11379
- if (!extension)
11380
- return;
11381
- const schemaClasses = extension.schema?.classes;
11382
- const { featureTables } = extension;
11383
- if (schemaClasses && featureTables) {
11384
- for (const schemaName in schemaClasses) {
11385
- const schemaClass = schemaClasses[schemaName];
11386
- const featureTable = findFeatureTableByName(featureTables, schemaName);
11387
- if (featureTable) {
11388
- handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
11389
- }
11390
- }
11391
- }
11392
- const { featureTextures } = extension;
11393
- if (schemaClasses && featureTextures && options.gltf?.loadImages) {
11394
- for (const schemaName in schemaClasses) {
11395
- const schemaClass = schemaClasses[schemaName];
11396
- const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
11397
- if (featureTexture) {
11398
- handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
11399
- }
11400
- }
11401
- }
11402
- }
11403
- function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
11404
- for (const propertyName in schemaClass.properties) {
11405
- const schemaProperty = schemaClass.properties[propertyName];
11406
- const featureTableProperty = featureTable?.properties?.[propertyName];
11407
- const numberOfFeatures = featureTable.count;
11408
- if (featureTableProperty) {
11409
- const data = getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
11410
- featureTableProperty.data = data;
11411
- }
11412
- }
11413
- }
11414
- function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
11415
- const attributeName = featureTexture.class;
11416
- for (const propertyName in schemaClass.properties) {
11417
- const featureTextureProperty = featureTexture?.properties?.[propertyName];
11418
- if (featureTextureProperty) {
11419
- const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
11420
- featureTextureProperty.data = data;
11421
- }
11422
- }
11423
- }
11424
- function getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
11425
- const bufferView = featureTableProperty.bufferView;
11426
- const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
11427
- switch (schemaProperty.type) {
11428
- case "STRING": {
11429
- const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
11430
- const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
11431
- return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
11432
- }
11433
- default:
11434
- }
11435
- return dataArray;
11436
- }
11437
- function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
11438
- const json = scenegraph.gltf.json;
11439
- if (!json.meshes) {
11440
- return [];
11441
- }
11442
- const featureTextureTable = [];
11443
- for (const mesh of json.meshes) {
11444
- for (const primitive of mesh.primitives) {
11445
- processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
11446
- }
11447
- }
11448
- return featureTextureTable;
11449
- }
11450
- function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
11451
- const json = scenegraph.gltf.json;
11452
- const textureData = [];
11453
- const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
11454
- const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
11455
- const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
11456
- const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
11457
- const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
11458
- const textureIndex = featureTextureProperty.texture.index;
11459
- const texture = json.textures?.[textureIndex];
11460
- const imageIndex = texture?.source;
11461
- if (typeof imageIndex !== "undefined") {
11462
- const image = json.images?.[imageIndex];
11463
- const mimeType = image?.mimeType;
11464
- const parsedImage = scenegraph.gltf.images?.[imageIndex];
11465
- if (parsedImage) {
11466
- for (let index = 0; index < textureCoordinates.length; index += 2) {
11467
- const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
11468
- textureData.push(value);
11469
- }
11470
- }
11471
- }
11472
- const featureIndices = [];
11473
- for (const texelData of textureData) {
11474
- let index = featureTextureTable.findIndex((item) => item === texelData);
11475
- if (index === -1) {
11476
- index = featureTextureTable.push(texelData) - 1;
11477
- }
11478
- featureIndices.push(index);
11479
- }
11480
- const typedArray = new Uint32Array(featureIndices);
11481
- const bufferIndex = scenegraph.gltf.buffers.push({
11482
- arrayBuffer: typedArray.buffer,
11483
- byteOffset: 0,
11484
- byteLength: typedArray.byteLength
11485
- }) - 1;
11486
- const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
11487
- const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
11488
- size: 1,
11489
- componentType: getComponentTypeFromArray(typedArray),
11490
- count: typedArray.length
11491
- });
11492
- primitive.attributes[attributeName] = accessorIndex;
11493
- }
11494
- function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels) {
11495
- const CHANNELS_MAP = {
11496
- r: { offset: 0, shift: 0 },
11497
- g: { offset: 1, shift: 8 },
11498
- b: { offset: 2, shift: 16 },
11499
- a: { offset: 3, shift: 24 }
11500
- };
11501
- const u = textureCoordinates[index];
11502
- const v = textureCoordinates[index + 1];
11503
- let components = 1;
11504
- if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
11505
- components = 4;
11506
- const offset = coordinatesToOffset(u, v, parsedImage, components);
11507
- let value = 0;
11508
- for (const c of channels) {
11509
- const map2 = CHANNELS_MAP[c];
11510
- const val = getVal(parsedImage, offset + map2.offset);
11511
- value |= val << map2.shift;
12212
+ const { json } = gltfScenegraph;
12213
+ for (const material of json.materials || []) {
12214
+ const extension = material.extensions && material.extensions.KHR_materials_unlit;
12215
+ if (extension) {
12216
+ material.unlit = true;
12217
+ }
12218
+ gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT);
11512
12219
  }
11513
- return value;
12220
+ gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);
11514
12221
  }
11515
- function getVal(parsedImage, offset) {
11516
- const imageData = getImageData(parsedImage);
11517
- if (imageData.data.length <= offset) {
11518
- throw new Error(`${imageData.data.length} <= ${offset}`);
12222
+ function encode3(gltfData) {
12223
+ const gltfScenegraph = new GLTFScenegraph(gltfData);
12224
+ const { json } = gltfScenegraph;
12225
+ if (gltfScenegraph.materials) {
12226
+ for (const material of json.materials || []) {
12227
+ if (material.unlit) {
12228
+ delete material.unlit;
12229
+ gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
12230
+ gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
12231
+ }
12232
+ }
11519
12233
  }
11520
- return imageData.data[offset];
11521
- }
11522
- function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
11523
- const w = parsedImage.width;
11524
- const iX = emod(u) * (w - 1);
11525
- const indX = Math.round(iX);
11526
- const h = parsedImage.height;
11527
- const iY = emod(v) * (h - 1);
11528
- const indY = Math.round(iY);
11529
- const components = parsedImage.components ? parsedImage.components : componentsCount;
11530
- const offset = (indY * w + indX) * components;
11531
- return offset;
11532
12234
  }
11533
- function emod(n2) {
11534
- const a2 = (n2 % 1 + 1) % 1;
11535
- return a2;
11536
- }
11537
- function findFeatureTableByName(featureTables, schemaClassName) {
11538
- for (const featureTableName in featureTables) {
11539
- const featureTable = featureTables[featureTableName];
11540
- if (featureTable.class === schemaClassName) {
11541
- return featureTable;
12235
+ var KHR_MATERIALS_UNLIT, name10;
12236
+ var init_KHR_materials_unlit = __esm({
12237
+ "../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
12238
+ init_gltf_scenegraph();
12239
+ KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
12240
+ name10 = KHR_MATERIALS_UNLIT;
12241
+ }
12242
+ });
12243
+
12244
+ // ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
12245
+ var KHR_techniques_webgl_exports = {};
12246
+ __export(KHR_techniques_webgl_exports, {
12247
+ decode: () => decode10,
12248
+ encode: () => encode4,
12249
+ name: () => name11
12250
+ });
12251
+ async function decode10(gltfData) {
12252
+ const gltfScenegraph = new GLTFScenegraph(gltfData);
12253
+ const { json } = gltfScenegraph;
12254
+ const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
12255
+ if (extension) {
12256
+ const techniques = resolveTechniques(extension, gltfScenegraph);
12257
+ for (const material of json.materials || []) {
12258
+ const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
12259
+ if (materialExtension) {
12260
+ material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
12261
+ material.technique.values = resolveValues(material.technique, gltfScenegraph);
12262
+ }
12263
+ gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
11542
12264
  }
12265
+ gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
11543
12266
  }
11544
- return null;
11545
12267
  }
11546
- function findFeatureTextureByName(featureTextures, schemaClassName) {
11547
- for (const featureTexturesName in featureTextures) {
11548
- const featureTable = featureTextures[featureTexturesName];
11549
- if (featureTable.class === schemaClassName) {
11550
- return featureTable;
12268
+ async function encode4(gltfData, options) {
12269
+ }
12270
+ function resolveTechniques(techniquesExtension, gltfScenegraph) {
12271
+ const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
12272
+ const textDecoder = new TextDecoder();
12273
+ shaders.forEach((shader) => {
12274
+ if (Number.isFinite(shader.bufferView)) {
12275
+ shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
12276
+ } else {
12277
+ throw new Error("KHR_techniques_webgl: no shader code");
11551
12278
  }
11552
- }
11553
- return null;
12279
+ });
12280
+ programs.forEach((program) => {
12281
+ program.fragmentShader = shaders[program.fragmentShader];
12282
+ program.vertexShader = shaders[program.vertexShader];
12283
+ });
12284
+ techniques.forEach((technique) => {
12285
+ technique.program = programs[technique.program];
12286
+ });
12287
+ return techniques;
11554
12288
  }
11555
- function getStringAttributes(data, offsetsData, stringsCount) {
11556
- const stringsArray = [];
11557
- const textDecoder = new TextDecoder("utf8");
11558
- let stringOffset = 0;
11559
- const bytesPerStringSize = 4;
11560
- for (let index = 0; index < stringsCount; index++) {
11561
- const stringByteSize = offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];
11562
- const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
11563
- const stringAttribute = textDecoder.decode(stringData);
11564
- stringsArray.push(stringAttribute);
11565
- stringOffset += stringByteSize;
11566
- }
11567
- return stringsArray;
12289
+ function resolveValues(technique, gltfScenegraph) {
12290
+ const values = Object.assign({}, technique.values);
12291
+ Object.keys(technique.uniforms || {}).forEach((uniform) => {
12292
+ if (technique.uniforms[uniform].value && !(uniform in values)) {
12293
+ values[uniform] = technique.uniforms[uniform].value;
12294
+ }
12295
+ });
12296
+ Object.keys(values).forEach((uniform) => {
12297
+ if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
12298
+ values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
12299
+ }
12300
+ });
12301
+ return values;
11568
12302
  }
11569
- var EXT_FEATURE_METADATA, name9;
11570
- var init_EXT_feature_metadata = __esm({
11571
- "../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
12303
+ var KHR_TECHNIQUES_WEBGL, name11;
12304
+ var init_KHR_techniques_webgl = __esm({
12305
+ "../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
11572
12306
  init_gltf_scenegraph();
11573
- init_src8();
11574
- init_gltf_utils();
11575
- EXT_FEATURE_METADATA = "EXT_feature_metadata";
11576
- name9 = EXT_FEATURE_METADATA;
12307
+ KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
12308
+ name11 = KHR_TECHNIQUES_WEBGL;
11577
12309
  }
11578
12310
  });
11579
12311
 
@@ -11598,6 +12330,8 @@
11598
12330
  var EXTENSIONS2;
11599
12331
  var init_gltf_extensions = __esm({
11600
12332
  "../gltf/src/lib/api/gltf-extensions.ts"() {
12333
+ init_EXT_mesh_features();
12334
+ init_EXT_structural_metadata();
11601
12335
  init_EXT_meshopt_compression();
11602
12336
  init_EXT_texture_webp();
11603
12337
  init_KHR_texture_basisu();
@@ -11608,6 +12342,8 @@
11608
12342
  init_KHR_techniques_webgl();
11609
12343
  init_EXT_feature_metadata();
11610
12344
  EXTENSIONS2 = [
12345
+ EXT_mesh_features_exports,
12346
+ EXT_structural_metadata_exports,
11611
12347
  EXT_meshopt_compression_exports,
11612
12348
  EXT_texture_webp_exports,
11613
12349
  KHR_texture_basisu_exports,
@@ -11993,13 +12729,13 @@
11993
12729
  var GLTFLoader;
11994
12730
  var init_gltf_loader = __esm({
11995
12731
  "../gltf/src/gltf-loader.ts"() {
11996
- init_version4();
12732
+ init_version5();
11997
12733
  init_parse_gltf();
11998
12734
  GLTFLoader = {
11999
12735
  name: "glTF",
12000
12736
  id: "gltf",
12001
12737
  module: "gltf",
12002
- version: VERSION6,
12738
+ version: VERSION7,
12003
12739
  extensions: ["gltf", "glb"],
12004
12740
  mimeTypes: ["model/gltf+json", "model/gltf-binary"],
12005
12741
  text: true,
@@ -12662,7 +13398,7 @@
12662
13398
  byteOffset += 4;
12663
13399
  tile.tiles = [];
12664
13400
  while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
12665
- const subtile = {};
13401
+ const subtile = { shape: "tile3d" };
12666
13402
  tile.tiles.push(subtile);
12667
13403
  byteOffset = await parse3DTile2(arrayBuffer, byteOffset, options, context, subtile);
12668
13404
  }
@@ -12680,7 +13416,7 @@
12680
13416
  tile.gltfUpAxis = options?.["3d-tiles"]?.assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
12681
13417
  if (options?.["3d-tiles"]?.loadGLTF) {
12682
13418
  if (!context) {
12683
- return;
13419
+ return arrayBuffer.byteLength;
12684
13420
  }
12685
13421
  const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
12686
13422
  tile.gltf = postProcessGLTF(gltfWithBuffers);
@@ -12688,6 +13424,7 @@
12688
13424
  } else {
12689
13425
  tile.gltfArrayBuffer = arrayBuffer;
12690
13426
  }
13427
+ return arrayBuffer.byteLength;
12691
13428
  }
12692
13429
  var init_parse_3d_tile_gltf = __esm({
12693
13430
  "src/lib/parsers/parse-3d-tile-gltf.ts"() {
@@ -12697,7 +13434,7 @@
12697
13434
  });
12698
13435
 
12699
13436
  // src/lib/parsers/parse-3d-tile.ts
12700
- async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
13437
+ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = { shape: "tile3d" }) {
12701
13438
  tile.byteOffset = byteOffset;
12702
13439
  tile.type = getMagicString3(arrayBuffer, byteOffset);
12703
13440
  switch (tile.type) {
@@ -13017,7 +13754,7 @@
13017
13754
  for (const key of propNames) {
13018
13755
  const value = object[key];
13019
13756
  if (typeof value === "function") {
13020
- if (!predefined.find((name10) => key === name10)) {
13757
+ if (!predefined.find((name12) => key === name12)) {
13021
13758
  object[key] = value.bind(obj);
13022
13759
  }
13023
13760
  }
@@ -13850,7 +14587,7 @@
13850
14587
  LongPrototype.toInt = function toInt() {
13851
14588
  return this.unsigned ? this.low >>> 0 : this.low;
13852
14589
  };
13853
- LongPrototype.toNumber = function toNumber() {
14590
+ LongPrototype.toNumber = function toNumber2() {
13854
14591
  if (this.unsigned)
13855
14592
  return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
13856
14593
  return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
@@ -15071,6 +15808,7 @@
15071
15808
  const normalizedRoot = await normalizeTileHeaders(tilesetJson, basePath, options || {});
15072
15809
  const tilesetJsonPostprocessed = {
15073
15810
  ...tilesetJson,
15811
+ shape: "tileset3d",
15074
15812
  loader: Tiles3DLoader,
15075
15813
  url: tilesetUrl,
15076
15814
  queryString: context?.queryString || "",
@@ -15085,6 +15823,7 @@
15085
15823
  async function parseTile(arrayBuffer, options, context) {
15086
15824
  const tile = {
15087
15825
  content: {
15826
+ shape: "tile3d",
15088
15827
  featureIds: null
15089
15828
  }
15090
15829
  };
@@ -15218,143 +15957,6 @@
15218
15957
  }
15219
15958
  });
15220
15959
 
15221
- // ../zip/src/file-provider/file-handle.ts
15222
- var import_fs, _FileHandle, FileHandle;
15223
- var init_file_handle = __esm({
15224
- "../zip/src/file-provider/file-handle.ts"() {
15225
- import_fs = __toModule(require_fs());
15226
- _FileHandle = class {
15227
- constructor(fileDescriptor, stats) {
15228
- this.read = (buffer, offset, length4, position) => {
15229
- return new Promise((s2) => {
15230
- (0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
15231
- });
15232
- };
15233
- this.fileDescriptor = fileDescriptor;
15234
- this.stats = stats;
15235
- }
15236
- async close() {
15237
- return new Promise((resolve2) => {
15238
- (0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
15239
- });
15240
- }
15241
- get stat() {
15242
- return this.stats;
15243
- }
15244
- };
15245
- FileHandle = _FileHandle;
15246
- FileHandle.open = async (path) => {
15247
- const [fd, stats] = await Promise.all([
15248
- new Promise((s2) => {
15249
- (0, import_fs.open)(path, void 0, void 0, (_err, fd2) => s2(fd2));
15250
- }),
15251
- new Promise((s2) => {
15252
- (0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => s2(stats2));
15253
- })
15254
- ]);
15255
- return new _FileHandle(fd, stats);
15256
- };
15257
- }
15258
- });
15259
-
15260
- // ../zip/src/file-provider/file-handle-file.ts
15261
- var FileHandleFile;
15262
- var init_file_handle_file = __esm({
15263
- "../zip/src/file-provider/file-handle-file.ts"() {
15264
- init_file_handle();
15265
- FileHandleFile = class {
15266
- static async from(path) {
15267
- const fileDescriptor = await FileHandle.open(path);
15268
- return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
15269
- }
15270
- constructor(fileDescriptor, size) {
15271
- this.fileDescriptor = fileDescriptor;
15272
- this.size = size;
15273
- }
15274
- async destroy() {
15275
- await this.fileDescriptor.close();
15276
- }
15277
- async getUint8(offset) {
15278
- const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
15279
- if (val === void 0) {
15280
- throw new Error("something went wrong");
15281
- }
15282
- return val;
15283
- }
15284
- async getUint16(offset) {
15285
- const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
15286
- if (val === void 0) {
15287
- throw new Error("something went wrong");
15288
- }
15289
- return val;
15290
- }
15291
- async getUint32(offset) {
15292
- const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
15293
- if (val === void 0) {
15294
- throw new Error("something went wrong");
15295
- }
15296
- return val;
15297
- }
15298
- async getBigUint64(offset) {
15299
- const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
15300
- if (val === void 0) {
15301
- throw new Error("something went wrong");
15302
- }
15303
- return val;
15304
- }
15305
- async slice(startOffsset, endOffset) {
15306
- const bigLength = endOffset - startOffsset;
15307
- if (bigLength > Number.MAX_SAFE_INTEGER) {
15308
- throw new Error("too big slice");
15309
- }
15310
- const length4 = Number(bigLength);
15311
- return (await this.fileDescriptor.read(Buffer.alloc(length4), 0, length4, startOffsset)).buffer.buffer;
15312
- }
15313
- get length() {
15314
- return this.size;
15315
- }
15316
- };
15317
- }
15318
- });
15319
-
15320
- // ../zip/src/file-provider/data-view-file.ts
15321
- var toNumber2, DataViewFile;
15322
- var init_data_view_file = __esm({
15323
- "../zip/src/file-provider/data-view-file.ts"() {
15324
- toNumber2 = (bigint) => {
15325
- if (bigint > Number.MAX_SAFE_INTEGER) {
15326
- throw new Error("Offset is out of bounds");
15327
- }
15328
- return Number(bigint);
15329
- };
15330
- DataViewFile = class {
15331
- constructor(file) {
15332
- this.file = file;
15333
- }
15334
- async destroy() {
15335
- }
15336
- async getUint8(offset) {
15337
- return this.file.getUint8(toNumber2(offset));
15338
- }
15339
- async getUint16(offset) {
15340
- return this.file.getUint16(toNumber2(offset), true);
15341
- }
15342
- async getUint32(offset) {
15343
- return this.file.getUint32(toNumber2(offset), true);
15344
- }
15345
- async getBigUint64(offset) {
15346
- return this.file.getBigUint64(toNumber2(offset), true);
15347
- }
15348
- async slice(startOffset, endOffset) {
15349
- return this.file.buffer.slice(toNumber2(startOffset), toNumber2(endOffset));
15350
- }
15351
- get length() {
15352
- return BigInt(this.file.byteLength);
15353
- }
15354
- };
15355
- }
15356
- });
15357
-
15358
15960
  // ../zip/src/parse-zip/search-from-the-end.ts
15359
15961
  var searchFromTheEnd;
15360
15962
  var init_search_from_the_end = __esm({
@@ -15823,16 +16425,6 @@
15823
16425
  }
15824
16426
  });
15825
16427
 
15826
- // ../zip/src/file-provider/file-provider.ts
15827
- var isFileProvider;
15828
- var init_file_provider = __esm({
15829
- "../zip/src/file-provider/file-provider.ts"() {
15830
- isFileProvider = (fileProvider) => {
15831
- return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
15832
- };
15833
- }
15834
- });
15835
-
15836
16428
  // ../compression/src/lib/compression.ts
15837
16429
  var Compression;
15838
16430
  var init_compression = __esm({
@@ -20140,9 +20732,9 @@
20140
20732
  var COMPRESSION_METHODS, ZipFileSystem;
20141
20733
  var init_zip_filesystem = __esm({
20142
20734
  "../zip/src/filesystems/zip-filesystem.ts"() {
20143
- init_src3();
20144
- init_file_provider();
20145
- init_file_handle_file();
20735
+ init_src2();
20736
+ init_src2();
20737
+ init_src2();
20146
20738
  init_cd_file_header();
20147
20739
  init_local_file_header();
20148
20740
  init_src11();
@@ -20235,7 +20827,6 @@
20235
20827
  // ../zip/src/index.ts
20236
20828
  var init_src12 = __esm({
20237
20829
  "../zip/src/index.ts"() {
20238
- init_data_view_file();
20239
20830
  init_cd_file_header();
20240
20831
  init_local_file_header();
20241
20832
  init_search_from_the_end();
@@ -20328,7 +20919,7 @@
20328
20919
  var VERSION10, Tiles3DArchiveFileLoader;
20329
20920
  var init_d_tiles_archive_loader = __esm({
20330
20921
  "src/3d-tiles-archive-loader.ts"() {
20331
- init_src12();
20922
+ init_src2();
20332
20923
  init_d_tiles_archive_parser();
20333
20924
  VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
20334
20925
  Tiles3DArchiveFileLoader = {