@loaders.gl/gltf 4.0.0-beta.3 → 4.0.0-beta.4

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 (2) hide show
  1. package/dist/dist.dev.js +26 -452
  2. package/package.json +6 -6
package/dist/dist.dev.js CHANGED
@@ -94,10 +94,7 @@ var __exports__ = (() => {
94
94
  var window_ = globals.window || globals.self || globals.global || {};
95
95
  var global_ = globals.global || globals.self || globals.window || {};
96
96
  var document_ = globals.document || {};
97
- var isBrowser = (
98
- // @ts-ignore process does not exist on browser
99
- Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
100
- );
97
+ var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
101
98
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
102
99
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
103
100
 
@@ -135,10 +132,7 @@ var __exports__ = (() => {
135
132
  var window_2 = globals2.window || globals2.self || globals2.global || {};
136
133
  var global_2 = globals2.global || globals2.self || globals2.window || {};
137
134
  var document_2 = globals2.document || {};
138
- var isBrowser2 = (
139
- // @ts-ignore process.browser
140
- typeof process !== "object" || String(process) !== "[object process]" || process.browser
141
- );
135
+ var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
142
136
  var isWorker = typeof importScripts === "function";
143
137
  var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
144
138
  var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
@@ -151,8 +145,7 @@ var __exports__ = (() => {
151
145
  if (moduleName) {
152
146
  libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
153
147
  }
154
- loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises
155
- loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
148
+ loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
156
149
  return await loadLibraryPromises[libraryUrl];
157
150
  }
158
151
  function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
@@ -199,7 +192,7 @@ var __exports__ = (() => {
199
192
  return void 0 && (void 0)(scriptSource, id);
200
193
  }
201
194
  if (isWorker) {
202
- eval.call(global_2, scriptSource);
195
+ eval.call(globalThis, scriptSource);
203
196
  return null;
204
197
  }
205
198
  const script = document.createElement("script");
@@ -309,12 +302,10 @@ var __exports__ = (() => {
309
302
  }
310
303
 
311
304
  // ../images/src/lib/category-api/image-type.ts
312
- var {
313
- _parseImageNode
314
- } = globalThis;
305
+ var parseImageNode = globalThis.loaders?.parseImageNode;
315
306
  var IMAGE_SUPPORTED = typeof Image !== "undefined";
316
307
  var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
317
- var NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
308
+ var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
318
309
  var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
319
310
  function isImageTypeSupported(type) {
320
311
  switch (type) {
@@ -531,7 +522,6 @@ var __exports__ = (() => {
531
522
  }
532
523
  return {
533
524
  mimeType: mediaType.mimeType,
534
- // TODO - decode width and height
535
525
  width: 0,
536
526
  height: 0
537
527
  };
@@ -589,9 +579,7 @@ var __exports__ = (() => {
589
579
  return {
590
580
  mimeType: "image/jpeg",
591
581
  height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
592
- // Number of lines
593
582
  width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
594
- // Number of pixels per line
595
583
  };
596
584
  }
597
585
  if (!tableMarkers.has(marker)) {
@@ -631,9 +619,9 @@ var __exports__ = (() => {
631
619
  const {
632
620
  mimeType
633
621
  } = getBinaryImageMetadata(arrayBuffer) || {};
634
- const _parseImageNode2 = globalThis._parseImageNode;
635
- assert(_parseImageNode2);
636
- return await _parseImageNode2(arrayBuffer, mimeType);
622
+ const parseImageNode2 = globalThis.loaders?.parseImageNode;
623
+ assert(parseImageNode2);
624
+ return await parseImageNode2(arrayBuffer, mimeType);
637
625
  }
638
626
 
639
627
  // ../images/src/lib/parsers/parse-image.ts
@@ -682,9 +670,7 @@ var __exports__ = (() => {
682
670
  image: {
683
671
  type: "auto",
684
672
  decode: true
685
- // if format is HTML
686
673
  }
687
- // imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
688
674
  };
689
675
  var ImageLoader = {
690
676
  id: "image",
@@ -694,7 +680,6 @@ var __exports__ = (() => {
694
680
  mimeTypes: MIME_TYPES,
695
681
  extensions: EXTENSIONS,
696
682
  parse: parseImage,
697
- // TODO: byteOffset, byteLength;
698
683
  tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
699
684
  options: DEFAULT_IMAGE_LOADER_OPTIONS
700
685
  };
@@ -710,11 +695,9 @@ var __exports__ = (() => {
710
695
  }
711
696
  function checkNodeImageFormatSupport(mimeType) {
712
697
  const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
713
- const {
714
- _parseImageNode: _parseImageNode2,
715
- _imageFormatsNode = NODE_FORMAT_SUPPORT
716
- } = globalThis;
717
- return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
698
+ const parseImageNode2 = globalThis.loaders?.parseImageNode;
699
+ const imageFormatsNode = globalThis.loaders?.imageFormatsNode || NODE_FORMAT_SUPPORT;
700
+ return Boolean(parseImageNode2) && imageFormatsNode.includes(mimeType);
718
701
  }
719
702
  function checkBrowserImageFormatSupport(mimeType) {
720
703
  switch (mimeType) {
@@ -754,17 +737,11 @@ var __exports__ = (() => {
754
737
  };
755
738
  var BYTES = {
756
739
  5120: 1,
757
- // BYTE
758
740
  5121: 1,
759
- // UNSIGNED_BYTE
760
741
  5122: 2,
761
- // SHORT
762
742
  5123: 2,
763
- // UNSIGNED_SHORT
764
743
  5125: 4,
765
- // UNSIGNED_INT
766
744
  5126: 4
767
- // FLOAT
768
745
  };
769
746
 
770
747
  // src/lib/gltf-utils/gltf-utils.ts
@@ -903,8 +880,6 @@ var __exports__ = (() => {
903
880
  };
904
881
  }
905
882
  var GLTFScenegraph = class {
906
- // internal
907
- // TODO - why is this not GLTFWithBuffers - what happens to images?
908
883
  constructor(gltf) {
909
884
  this.gltf = {
910
885
  json: gltf?.json || makeDefaultGLTFJson(),
@@ -918,7 +893,6 @@ var __exports__ = (() => {
918
893
  this.sourceBuffers = [this.gltf.buffers[0]];
919
894
  }
920
895
  }
921
- // Accessors
922
896
  get json() {
923
897
  return this.gltf.json;
924
898
  }
@@ -975,9 +949,6 @@ var __exports__ = (() => {
975
949
  getAccessor(index) {
976
950
  return this.getObject("accessors", index);
977
951
  }
978
- // getCamera(index: number): object | null {
979
- // return null; // TODO: fix thi: object as null;
980
- // }
981
952
  getTexture(index) {
982
953
  return this.getObject("textures", index);
983
954
  }
@@ -1003,10 +974,6 @@ var __exports__ = (() => {
1003
974
  }
1004
975
  return object;
1005
976
  }
1006
- /**
1007
- * Accepts buffer view index or buffer view object
1008
- * @returns a `Uint8Array`
1009
- */
1010
977
  getTypedArrayForBufferView(bufferView) {
1011
978
  bufferView = this.getBufferView(bufferView);
1012
979
  const bufferIndex = bufferView.buffer;
@@ -1015,16 +982,10 @@ var __exports__ = (() => {
1015
982
  const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
1016
983
  return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
1017
984
  }
1018
- /** Accepts accessor index or accessor object
1019
- * @returns a typed array with type that matches the types
1020
- */
1021
985
  getTypedArrayForAccessor(accessor) {
1022
986
  const gltfAccessor = this.getAccessor(accessor);
1023
987
  return getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);
1024
988
  }
1025
- /** accepts accessor index or accessor object
1026
- * returns a `Uint8Array`
1027
- */
1028
989
  getTypedArrayForImageData(image) {
1029
990
  image = this.getAccessor(image);
1030
991
  const bufferView = this.getBufferView(image.bufferView);
@@ -1033,17 +994,10 @@ var __exports__ = (() => {
1033
994
  const byteOffset = bufferView.byteOffset || 0;
1034
995
  return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
1035
996
  }
1036
- // MODIFERS
1037
- /**
1038
- * Add an extra application-defined key to the top-level data structure
1039
- */
1040
997
  addApplicationData(key, data) {
1041
998
  this.json[key] = data;
1042
999
  return this;
1043
1000
  }
1044
- /**
1045
- * `extras` - Standard GLTF field for storing application specific data
1046
- */
1047
1001
  addExtraData(key, data) {
1048
1002
  this.json.extras = this.json.extras || {};
1049
1003
  this.json.extras[key] = data;
@@ -1070,9 +1024,6 @@ var __exports__ = (() => {
1070
1024
  }
1071
1025
  delete extensions[extensionName];
1072
1026
  }
1073
- /**
1074
- * Add to standard GLTF top level extension object, mark as used
1075
- */
1076
1027
  addExtension(extensionName, extensionData = {}) {
1077
1028
  assert3(extensionData);
1078
1029
  this.json.extensions = this.json.extensions || {};
@@ -1080,27 +1031,18 @@ var __exports__ = (() => {
1080
1031
  this.registerUsedExtension(extensionName);
1081
1032
  return extensionData;
1082
1033
  }
1083
- /**
1084
- * Standard GLTF top level extension object, mark as used and required
1085
- */
1086
1034
  addRequiredExtension(extensionName, extensionData = {}) {
1087
1035
  assert3(extensionData);
1088
1036
  this.addExtension(extensionName, extensionData);
1089
1037
  this.registerRequiredExtension(extensionName);
1090
1038
  return extensionData;
1091
1039
  }
1092
- /**
1093
- * Add extensionName to list of used extensions
1094
- */
1095
1040
  registerUsedExtension(extensionName) {
1096
1041
  this.json.extensionsUsed = this.json.extensionsUsed || [];
1097
1042
  if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
1098
1043
  this.json.extensionsUsed.push(extensionName);
1099
1044
  }
1100
1045
  }
1101
- /**
1102
- * Add extensionName to list of required extensions
1103
- */
1104
1046
  registerRequiredExtension(extensionName) {
1105
1047
  this.registerUsedExtension(extensionName);
1106
1048
  this.json.extensionsRequired = this.json.extensionsRequired || [];
@@ -1108,9 +1050,6 @@ var __exports__ = (() => {
1108
1050
  this.json.extensionsRequired.push(extensionName);
1109
1051
  }
1110
1052
  }
1111
- /**
1112
- * Removes an extension from the top-level list
1113
- */
1114
1053
  removeExtension(extensionName) {
1115
1054
  if (this.json.extensions?.[extensionName]) {
1116
1055
  this.json.extensionsRemoved = this.json.extensionsRemoved || [];
@@ -1129,17 +1068,9 @@ var __exports__ = (() => {
1129
1068
  this._removeStringFromArray(this.json.extensionsUsed, extensionName);
1130
1069
  }
1131
1070
  }
1132
- /**
1133
- * Set default scene which is to be displayed at load time
1134
- */
1135
1071
  setDefaultScene(sceneIndex) {
1136
1072
  this.json.scene = sceneIndex;
1137
1073
  }
1138
- /**
1139
- * @todo: add more properties for scene initialization:
1140
- * name`, `extensions`, `extras`
1141
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene
1142
- */
1143
1074
  addScene(scene) {
1144
1075
  const {
1145
1076
  nodeIndices
@@ -1150,11 +1081,6 @@ var __exports__ = (() => {
1150
1081
  });
1151
1082
  return this.json.scenes.length - 1;
1152
1083
  }
1153
- /**
1154
- * @todo: add more properties for node initialization:
1155
- * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
1156
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
1157
- */
1158
1084
  addNode(node2) {
1159
1085
  const {
1160
1086
  meshIndex,
@@ -1170,7 +1096,6 @@ var __exports__ = (() => {
1170
1096
  this.json.nodes.push(nodeData);
1171
1097
  return this.json.nodes.length - 1;
1172
1098
  }
1173
- /** Adds a mesh to the json part */
1174
1099
  addMesh(mesh) {
1175
1100
  const {
1176
1101
  attributes,
@@ -1202,20 +1127,12 @@ var __exports__ = (() => {
1202
1127
  primitives: [{
1203
1128
  attributes: accessorIndices,
1204
1129
  mode: 0
1205
- // GL.POINTS
1206
1130
  }]
1207
1131
  };
1208
1132
  this.json.meshes = this.json.meshes || [];
1209
1133
  this.json.meshes.push(glTFMesh);
1210
1134
  return this.json.meshes.length - 1;
1211
1135
  }
1212
- /**
1213
- * Adds a binary image. Builds glTF "JSON metadata" and saves buffer reference
1214
- * Buffer will be copied into BIN chunk during "pack"
1215
- * Currently encodes as glTF image
1216
- * @param imageData
1217
- * @param mimeType
1218
- */
1219
1136
  addImage(imageData, mimeTypeOpt) {
1220
1137
  const metadata = getBinaryImageMetadata(imageData);
1221
1138
  const mimeType = mimeTypeOpt || metadata?.mimeType;
@@ -1228,10 +1145,6 @@ var __exports__ = (() => {
1228
1145
  this.json.images.push(glTFImage);
1229
1146
  return this.json.images.length - 1;
1230
1147
  }
1231
- /**
1232
- * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index
1233
- * @param buffer
1234
- */
1235
1148
  addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) {
1236
1149
  const byteLength = buffer.byteLength;
1237
1150
  assert3(Number.isFinite(byteLength));
@@ -1239,7 +1152,6 @@ var __exports__ = (() => {
1239
1152
  this.sourceBuffers.push(buffer);
1240
1153
  const glTFBufferView = {
1241
1154
  buffer: bufferIndex,
1242
- // Write offset from the start of the binary body
1243
1155
  byteOffset,
1244
1156
  byteLength
1245
1157
  };
@@ -1248,36 +1160,19 @@ var __exports__ = (() => {
1248
1160
  this.json.bufferViews.push(glTFBufferView);
1249
1161
  return this.json.bufferViews.length - 1;
1250
1162
  }
1251
- /**
1252
- * Adds an accessor to a bufferView
1253
- * @param bufferViewIndex
1254
- * @param accessor
1255
- */
1256
1163
  addAccessor(bufferViewIndex, accessor) {
1257
1164
  const glTFAccessor = {
1258
1165
  bufferView: bufferViewIndex,
1259
- // @ts-ignore
1260
1166
  type: getAccessorTypeFromSize(accessor.size),
1261
- // @ts-ignore
1262
1167
  componentType: accessor.componentType,
1263
- // @ts-ignore
1264
1168
  count: accessor.count,
1265
- // @ts-ignore
1266
1169
  max: accessor.max,
1267
- // @ts-ignore
1268
1170
  min: accessor.min
1269
1171
  };
1270
1172
  this.json.accessors = this.json.accessors || [];
1271
1173
  this.json.accessors.push(glTFAccessor);
1272
1174
  return this.json.accessors.length - 1;
1273
1175
  }
1274
- /**
1275
- * Add a binary buffer. Builds glTF "JSON metadata" and saves buffer reference
1276
- * Buffer will be copied into BIN chunk during "pack"
1277
- * Currently encodes buffers as glTF accessors, but this could be optimized
1278
- * @param sourceBuffer
1279
- * @param accessor
1280
- */
1281
1176
  addBinaryBuffer(sourceBuffer, accessor = {
1282
1177
  size: 3
1283
1178
  }) {
@@ -1290,22 +1185,14 @@ var __exports__ = (() => {
1290
1185
  minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);
1291
1186
  }
1292
1187
  const accessorDefaults = {
1293
- // @ts-ignore
1294
1188
  size: accessor.size,
1295
1189
  componentType: getComponentTypeFromArray(sourceBuffer),
1296
- // @ts-ignore
1297
1190
  count: Math.round(sourceBuffer.length / accessor.size),
1298
1191
  min: minMax.min,
1299
1192
  max: minMax.max
1300
1193
  };
1301
1194
  return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));
1302
1195
  }
1303
- /**
1304
- * Adds a texture to the json part
1305
- * @todo: add more properties for texture initialization
1306
- * `sampler`, `name`, `extensions`, `extras`
1307
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture
1308
- */
1309
1196
  addTexture(texture) {
1310
1197
  const {
1311
1198
  imageIndex
@@ -1317,13 +1204,11 @@ var __exports__ = (() => {
1317
1204
  this.json.textures.push(glTFTexture);
1318
1205
  return this.json.textures.length - 1;
1319
1206
  }
1320
- /** Adds a material to the json part */
1321
1207
  addMaterial(pbrMaterialInfo) {
1322
1208
  this.json.materials = this.json.materials || [];
1323
1209
  this.json.materials.push(pbrMaterialInfo);
1324
1210
  return this.json.materials.length - 1;
1325
1211
  }
1326
- /** Pack the binary chunk */
1327
1212
  createBinaryChunk() {
1328
1213
  this.gltf.buffers = [];
1329
1214
  const totalByteLength = this.byteLength;
@@ -1343,7 +1228,6 @@ var __exports__ = (() => {
1343
1228
  this.gltf.binary = arrayBuffer;
1344
1229
  this.sourceBuffers = [arrayBuffer];
1345
1230
  }
1346
- // PRIVATE
1347
1231
  _removeStringFromArray(array, string) {
1348
1232
  let found = true;
1349
1233
  while (found) {
@@ -1355,9 +1239,6 @@ var __exports__ = (() => {
1355
1239
  }
1356
1240
  }
1357
1241
  }
1358
- /**
1359
- * Add attributes to buffers and create `attributes` object which is part of `mesh`
1360
- */
1361
1242
  _addAttributes(attributes = {}) {
1362
1243
  const result = {};
1363
1244
  for (const attributeKey in attributes) {
@@ -1368,17 +1249,11 @@ var __exports__ = (() => {
1368
1249
  }
1369
1250
  return result;
1370
1251
  }
1371
- /**
1372
- * Add indices to buffers
1373
- */
1374
1252
  _addIndices(indices) {
1375
1253
  return this.addBinaryBuffer(indices, {
1376
1254
  size: 1
1377
1255
  });
1378
1256
  }
1379
- /**
1380
- * Deduce gltf specific attribue name from input attribute name
1381
- */
1382
1257
  _getGltfAttributeName(attributeName) {
1383
1258
  switch (attributeName.toLowerCase()) {
1384
1259
  case "position":
@@ -1398,10 +1273,6 @@ var __exports__ = (() => {
1398
1273
  return attributeName;
1399
1274
  }
1400
1275
  }
1401
- /**
1402
- * Calculate `min` and `max` arrays of accessor according to spec:
1403
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor
1404
- */
1405
1276
  _getAccessorMinMax(buffer, size) {
1406
1277
  const result = {
1407
1278
  min: null,
@@ -1419,16 +1290,8 @@ var __exports__ = (() => {
1419
1290
  }
1420
1291
  for (let index = size; index < buffer.length; index += size) {
1421
1292
  for (let componentIndex = 0; componentIndex < size; componentIndex++) {
1422
- result.min[0 + componentIndex] = Math.min(
1423
- // @ts-ignore
1424
- result.min[0 + componentIndex],
1425
- buffer[index + componentIndex]
1426
- );
1427
- result.max[0 + componentIndex] = Math.max(
1428
- // @ts-ignore
1429
- result.max[0 + componentIndex],
1430
- buffer[index + componentIndex]
1431
- );
1293
+ result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
1294
+ result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
1432
1295
  }
1433
1296
  }
1434
1297
  return result;
@@ -2639,14 +2502,7 @@ var __exports__ = (() => {
2639
2502
  return null;
2640
2503
  }
2641
2504
  const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
2642
- const arrayOffsets = convertRawBufferToMetadataArray(
2643
- arrayOffsetsBytes,
2644
- "SCALAR",
2645
- // offsets consist of ONE component
2646
- offsetType,
2647
- numberOfElements + 1
2648
- // The number of offsets is equal to the property table `count` plus one.
2649
- );
2505
+ const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
2650
2506
  if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
2651
2507
  return null;
2652
2508
  }
@@ -3020,10 +2876,7 @@ var __exports__ = (() => {
3020
2876
  return data;
3021
2877
  }
3022
2878
  function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
3023
- if (classProperty.array && // `count` is a number of array elements. May only be defined when `array` is true.
3024
- // If `count` is NOT defined, it's a VARIABLE-length array
3025
- typeof classProperty.count === "undefined" && // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.
3026
- typeof propertyTableProperty.arrayOffsets !== "undefined") {
2879
+ if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined") {
3027
2880
  return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || "UINT32", numberOfElements);
3028
2881
  }
3029
2882
  return null;
@@ -3041,13 +2894,7 @@ var __exports__ = (() => {
3041
2894
  const elementCount = valuesDataBytes.byteLength / elementSize;
3042
2895
  let valuesData;
3043
2896
  if (classProperty.componentType) {
3044
- valuesData = convertRawBufferToMetadataArray(
3045
- valuesDataBytes,
3046
- classProperty.type,
3047
- // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.
3048
- classProperty.componentType,
3049
- elementCount
3050
- );
2897
+ valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
3051
2898
  } else {
3052
2899
  valuesData = valuesDataBytes;
3053
2900
  }
@@ -3308,29 +3155,14 @@ var __exports__ = (() => {
3308
3155
  return data;
3309
3156
  }
3310
3157
  function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
3311
- if (classProperty.type === "ARRAY" && // `componentCount` is a number of fixed-length array elements.
3312
- // If `componentCount` is NOT defined, it's a VARIABLE-length array
3313
- typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
3314
- typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
3315
- return getOffsetsForProperty(
3316
- scenegraph,
3317
- propertyTableProperty.arrayOffsetBufferView,
3318
- propertyTableProperty.offsetType || "UINT32",
3319
- // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
3320
- numberOfElements
3321
- );
3158
+ if (classProperty.type === "ARRAY" && typeof classProperty.componentCount === "undefined" && typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
3159
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
3322
3160
  }
3323
3161
  return null;
3324
3162
  }
3325
3163
  function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
3326
3164
  if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
3327
- return getOffsetsForProperty(
3328
- scenegraph,
3329
- propertyTableProperty.stringOffsetBufferView,
3330
- propertyTableProperty.offsetType || "UINT32",
3331
- // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
3332
- numberOfElements
3333
- );
3165
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
3334
3166
  }
3335
3167
  return null;
3336
3168
  }
@@ -3390,13 +3222,9 @@ var __exports__ = (() => {
3390
3222
 
3391
3223
  // ../textures/src/lib/parsers/basis-module-loader.ts
3392
3224
  var BASIS_EXTERNAL_LIBRARIES = {
3393
- /** Basis transcoder, javascript wrapper part */
3394
3225
  TRANSCODER: "basis_transcoder.js",
3395
- /** Basis transcoder, compiled web assembly part */
3396
3226
  TRANSCODER_WASM: "basis_transcoder.wasm",
3397
- /** Basis encoder, javascript wrapper part */
3398
3227
  ENCODER: "basis_encoder.js",
3399
- /** Basis encoder, compiled web assembly part */
3400
3228
  ENCODER_WASM: "basis_encoder.wasm"
3401
3229
  };
3402
3230
  var loadBasisTranscoderPromise;
@@ -3474,12 +3302,10 @@ var __exports__ = (() => {
3474
3302
 
3475
3303
  // ../textures/src/lib/gl-extensions.ts
3476
3304
  var GL_EXTENSIONS_CONSTANTS = {
3477
- // WEBGL_compressed_texture_s3tc
3478
3305
  COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
3479
3306
  COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
3480
3307
  COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
3481
3308
  COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
3482
- // WEBGL_compressed_texture_es3
3483
3309
  COMPRESSED_R11_EAC: 37488,
3484
3310
  COMPRESSED_SIGNED_R11_EAC: 37489,
3485
3311
  COMPRESSED_RG11_EAC: 37490,
@@ -3490,18 +3316,14 @@ var __exports__ = (() => {
3490
3316
  COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
3491
3317
  COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
3492
3318
  COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
3493
- // WEBGL_compressed_texture_pvrtc
3494
3319
  COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
3495
3320
  COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
3496
3321
  COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
3497
3322
  COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
3498
- // WEBGL_compressed_texture_etc1
3499
3323
  COMPRESSED_RGB_ETC1_WEBGL: 36196,
3500
- // WEBGL_compressed_texture_atc
3501
3324
  COMPRESSED_RGB_ATC_WEBGL: 35986,
3502
3325
  COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
3503
3326
  COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
3504
- // WEBGL_compressed_texture_astc
3505
3327
  COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
3506
3328
  COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
3507
3329
  COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
@@ -3530,12 +3352,10 @@ var __exports__ = (() => {
3530
3352
  COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
3531
3353
  COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
3532
3354
  COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
3533
- // EXT_texture_compression_rgtc
3534
3355
  COMPRESSED_RED_RGTC1_EXT: 36283,
3535
3356
  COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
3536
3357
  COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
3537
3358
  COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
3538
- // WEBGL_compressed_texture_s3tc_srgb
3539
3359
  COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
3540
3360
  COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
3541
3361
  COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
@@ -3545,7 +3365,6 @@ var __exports__ = (() => {
3545
3365
  // ../textures/src/lib/utils/texture-formats.ts
3546
3366
  var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
3547
3367
  var WEBGL_EXTENSIONS = {
3548
- /* eslint-disable camelcase */
3549
3368
  WEBGL_compressed_texture_s3tc: "dxt",
3550
3369
  WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
3551
3370
  WEBGL_compressed_texture_etc1: "etc1",
@@ -3554,7 +3373,6 @@ var __exports__ = (() => {
3554
3373
  WEBGL_compressed_texture_atc: "atc",
3555
3374
  WEBGL_compressed_texture_astc: "astc",
3556
3375
  EXT_texture_compression_rgtc: "rgtc"
3557
- /* eslint-enable camelcase */
3558
3376
  };
3559
3377
  var formats = null;
3560
3378
  function getSupportedGPUTextureFormats(gl) {
@@ -3610,35 +3428,10 @@ var __exports__ = (() => {
3610
3428
  }(f || (f = {}));
3611
3429
 
3612
3430
  // ../textures/src/lib/parsers/parse-ktx.ts
3613
- var KTX2_ID = [
3614
- // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
3615
- 171,
3616
- 75,
3617
- 84,
3618
- 88,
3619
- 32,
3620
- 50,
3621
- 48,
3622
- 187,
3623
- 13,
3624
- 10,
3625
- 26,
3626
- 10
3627
- ];
3431
+ var KTX2_ID = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
3628
3432
  function isKTX(data) {
3629
3433
  const id = new Uint8Array(data);
3630
- const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
3631
- id[1] !== KTX2_ID[1] || // 'K'
3632
- id[2] !== KTX2_ID[2] || // 'T'
3633
- id[3] !== KTX2_ID[3] || // 'X'
3634
- id[4] !== KTX2_ID[4] || // ' '
3635
- id[5] !== KTX2_ID[5] || // '2'
3636
- id[6] !== KTX2_ID[6] || // '0'
3637
- id[7] !== KTX2_ID[7] || // 'ª'
3638
- id[8] !== KTX2_ID[8] || // '\r'
3639
- id[9] !== KTX2_ID[9] || // '\n'
3640
- id[10] !== KTX2_ID[10] || // '\x1A'
3641
- id[11] !== KTX2_ID[11];
3434
+ 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];
3642
3435
  return !notKTX;
3643
3436
  }
3644
3437
 
@@ -3773,9 +3566,7 @@ var __exports__ = (() => {
3773
3566
  function transcodeImage(basisFile, imageIndex, levelIndex, options) {
3774
3567
  const width = basisFile.getImageWidth(imageIndex, levelIndex);
3775
3568
  const height = basisFile.getImageHeight(imageIndex, levelIndex);
3776
- const hasAlpha = basisFile.getHasAlpha(
3777
- /* imageIndex, levelIndex */
3778
- );
3569
+ const hasAlpha = basisFile.getHasAlpha();
3779
3570
  const {
3780
3571
  compressed,
3781
3572
  format,
@@ -3787,14 +3578,11 @@ var __exports__ = (() => {
3787
3578
  throw new Error("failed to start Basis transcoding");
3788
3579
  }
3789
3580
  return {
3790
- // standard loaders.gl image category payload
3791
3581
  width,
3792
3582
  height,
3793
3583
  data: decodedData,
3794
3584
  compressed,
3795
3585
  format,
3796
- // Additional fields
3797
- // Add levelSize field.
3798
3586
  hasAlpha
3799
3587
  };
3800
3588
  }
@@ -3829,26 +3617,14 @@ var __exports__ = (() => {
3829
3617
  } = getBasisOptions(options, alphaFlag);
3830
3618
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
3831
3619
  const decodedData = new Uint8Array(decodedSize);
3832
- if (!ktx2File.transcodeImage(
3833
- decodedData,
3834
- levelIndex,
3835
- 0,
3836
- 0,
3837
- basisFormat,
3838
- 0,
3839
- -1,
3840
- -1
3841
- /* channel1 */
3842
- )) {
3620
+ if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
3843
3621
  throw new Error("Failed to transcode KTX2 image");
3844
3622
  }
3845
3623
  return {
3846
- // standard loaders.gl image category payload
3847
3624
  width,
3848
3625
  height,
3849
3626
  data: decodedData,
3850
3627
  compressed,
3851
- // Additional fields
3852
3628
  levelSize: decodedSize,
3853
3629
  hasAlpha: alphaFlag,
3854
3630
  format
@@ -3901,12 +3677,9 @@ var __exports__ = (() => {
3901
3677
  options: {
3902
3678
  basis: {
3903
3679
  format: "auto",
3904
- // gl context doesn't exist on a worker thread
3905
3680
  libraryPath: "libs/",
3906
3681
  containerFormat: "auto",
3907
- // 'basis' || 'ktx2' || 'auto'
3908
3682
  module: "transcoder"
3909
- // 'transcoder' || 'encoder'
3910
3683
  }
3911
3684
  }
3912
3685
  };
@@ -3942,10 +3715,8 @@ var __exports__ = (() => {
3942
3715
  const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
3943
3716
  const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
3944
3717
  Object.assign(glb, {
3945
- // Put less important stuff in a header, to avoid clutter
3946
3718
  header: {
3947
3719
  byteOffset,
3948
- // Byte offset into the initial arrayBuffer
3949
3720
  byteLength,
3950
3721
  hasBinChunk: false
3951
3722
  },
@@ -4022,7 +3793,6 @@ var __exports__ = (() => {
4022
3793
  byteOffset,
4023
3794
  byteLength: chunkLength,
4024
3795
  arrayBuffer: dataView.buffer
4025
- // TODO - copy, or create typed array view?
4026
3796
  });
4027
3797
  return padToNBytes(chunkLength, 4);
4028
3798
  }
@@ -4053,23 +3823,19 @@ var __exports__ = (() => {
4053
3823
  var detector = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 3, 2, 0, 0, 5, 3, 1, 0, 1, 12, 1, 0, 10, 22, 2, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11, 7, 0, 65, 0, 253, 15, 26, 11]);
4054
3824
  var wasmpack = new Uint8Array([32, 0, 65, 253, 3, 1, 2, 34, 4, 106, 6, 5, 11, 8, 7, 20, 13, 33, 12, 16, 128, 9, 116, 64, 19, 113, 127, 15, 10, 21, 22, 14, 255, 66, 24, 54, 136, 107, 18, 23, 192, 26, 114, 118, 132, 17, 77, 101, 130, 144, 27, 87, 131, 44, 45, 74, 156, 154, 70, 167]);
4055
3825
  var FILTERS = {
4056
- // legacy index-based enums for glTF
4057
3826
  0: "",
4058
3827
  1: "meshopt_decodeFilterOct",
4059
3828
  2: "meshopt_decodeFilterQuat",
4060
3829
  3: "meshopt_decodeFilterExp",
4061
- // string-based enums for glTF
4062
3830
  NONE: "",
4063
3831
  OCTAHEDRAL: "meshopt_decodeFilterOct",
4064
3832
  QUATERNION: "meshopt_decodeFilterQuat",
4065
3833
  EXPONENTIAL: "meshopt_decodeFilterExp"
4066
3834
  };
4067
3835
  var DECODERS = {
4068
- // legacy index-based enums for glTF
4069
3836
  0: "meshopt_decodeVertexBuffer",
4070
3837
  1: "meshopt_decodeIndexBuffer",
4071
3838
  2: "meshopt_decodeIndexSequence",
4072
- // string-based enums for glTF
4073
3839
  ATTRIBUTES: "meshopt_decodeVertexBuffer",
4074
3840
  TRIANGLES: "meshopt_decodeIndexBuffer",
4075
3841
  INDICES: "meshopt_decodeIndexSequence"
@@ -4228,7 +3994,6 @@ var __exports__ = (() => {
4228
3994
  var DEFAULT_DRACO_OPTIONS = {
4229
3995
  draco: {
4230
3996
  decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
4231
- // 'js' for IE11
4232
3997
  libraryPath: "libs/",
4233
3998
  extraAttributes: {},
4234
3999
  attributeNameEntry: void 0
@@ -4238,7 +4003,6 @@ var __exports__ = (() => {
4238
4003
  name: "Draco",
4239
4004
  id: "draco",
4240
4005
  module: "draco",
4241
- // shapes: ['mesh'],
4242
4006
  version: VERSION5,
4243
4007
  worker: true,
4244
4008
  extensions: ["drc"],
@@ -4388,24 +4152,15 @@ var __exports__ = (() => {
4388
4152
  };
4389
4153
  var INDEX_ITEM_SIZE = 4;
4390
4154
  var DracoParser = class {
4391
- // draco - the draco decoder, either import `draco3d` or load dynamically
4392
4155
  constructor(draco) {
4393
4156
  this.draco = draco;
4394
4157
  this.decoder = new this.draco.Decoder();
4395
4158
  this.metadataQuerier = new this.draco.MetadataQuerier();
4396
4159
  }
4397
- /**
4398
- * Destroy draco resources
4399
- */
4400
4160
  destroy() {
4401
4161
  this.draco.destroy(this.decoder);
4402
4162
  this.draco.destroy(this.metadataQuerier);
4403
4163
  }
4404
- /**
4405
- * NOTE: caller must call `destroyGeometry` on the return value after using it
4406
- * @param arrayBuffer
4407
- * @param options
4408
- */
4409
4164
  parseSync(arrayBuffer, options = {}) {
4410
4165
  const buffer = new this.draco.DecoderBuffer();
4411
4166
  buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
@@ -4450,14 +4205,6 @@ var __exports__ = (() => {
4450
4205
  }
4451
4206
  }
4452
4207
  }
4453
- // Draco specific "loader data"
4454
- /**
4455
- * Extract
4456
- * @param dracoGeometry
4457
- * @param geometry_type
4458
- * @param options
4459
- * @returns
4460
- */
4461
4208
  _getDracoLoaderData(dracoGeometry, geometry_type, options) {
4462
4209
  const metadata = this._getTopLevelMetadata(dracoGeometry);
4463
4210
  const attributes = this._getDracoAttributes(dracoGeometry, options);
@@ -4470,12 +4217,6 @@ var __exports__ = (() => {
4470
4217
  attributes
4471
4218
  };
4472
4219
  }
4473
- /**
4474
- * Extract all draco provided information and metadata for each attribute
4475
- * @param dracoGeometry
4476
- * @param options
4477
- * @returns
4478
- */
4479
4220
  _getDracoAttributes(dracoGeometry, options) {
4480
4221
  const dracoAttributes = {};
4481
4222
  for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
@@ -4503,12 +4244,6 @@ var __exports__ = (() => {
4503
4244
  }
4504
4245
  return dracoAttributes;
4505
4246
  }
4506
- /**
4507
- * Get standard loaders.gl mesh category data
4508
- * Extracts the geometry from draco
4509
- * @param dracoGeometry
4510
- * @param options
4511
- */
4512
4247
  _getMeshData(dracoGeometry, loaderData, options) {
4513
4248
  const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
4514
4249
  const positionAttribute = attributes.POSITION;
@@ -4521,7 +4256,6 @@ var __exports__ = (() => {
4521
4256
  return {
4522
4257
  topology: "triangle-strip",
4523
4258
  mode: 4,
4524
- // GL.TRIANGLES
4525
4259
  attributes,
4526
4260
  indices: {
4527
4261
  value: this._getTriangleStripIndices(dracoGeometry),
@@ -4533,7 +4267,6 @@ var __exports__ = (() => {
4533
4267
  return {
4534
4268
  topology: "triangle-list",
4535
4269
  mode: 5,
4536
- // GL.TRIANGLE_STRIP
4537
4270
  attributes,
4538
4271
  indices: {
4539
4272
  value: this._getTriangleListIndices(dracoGeometry),
@@ -4545,7 +4278,6 @@ var __exports__ = (() => {
4545
4278
  return {
4546
4279
  topology: "point-list",
4547
4280
  mode: 0,
4548
- // GL.POINTS
4549
4281
  attributes
4550
4282
  };
4551
4283
  }
@@ -4568,11 +4300,6 @@ var __exports__ = (() => {
4568
4300
  }
4569
4301
  return attributes;
4570
4302
  }
4571
- // MESH INDICES EXTRACTION
4572
- /**
4573
- * For meshes, we need indices to define the faces.
4574
- * @param dracoGeometry
4575
- */
4576
4303
  _getTriangleListIndices(dracoGeometry) {
4577
4304
  const numFaces = dracoGeometry.num_faces();
4578
4305
  const numIndices = numFaces * 3;
@@ -4585,10 +4312,6 @@ var __exports__ = (() => {
4585
4312
  this.draco._free(ptr);
4586
4313
  }
4587
4314
  }
4588
- /**
4589
- * For meshes, we need indices to define the faces.
4590
- * @param dracoGeometry
4591
- */
4592
4315
  _getTriangleStripIndices(dracoGeometry) {
4593
4316
  const dracoArray = new this.draco.DracoInt32Array();
4594
4317
  try {
@@ -4598,12 +4321,6 @@ var __exports__ = (() => {
4598
4321
  this.draco.destroy(dracoArray);
4599
4322
  }
4600
4323
  }
4601
- /**
4602
- *
4603
- * @param dracoGeometry
4604
- * @param dracoAttribute
4605
- * @param attributeName
4606
- */
4607
4324
  _getAttributeValues(dracoGeometry, attribute) {
4608
4325
  const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
4609
4326
  const numComponents = attribute.num_components;
@@ -4625,30 +4342,6 @@ var __exports__ = (() => {
4625
4342
  size: numComponents
4626
4343
  };
4627
4344
  }
4628
- // Attribute names
4629
- /**
4630
- * DRACO does not store attribute names - We need to deduce an attribute name
4631
- * for each attribute
4632
- _getAttributeNames(
4633
- dracoGeometry: Mesh | PointCloud,
4634
- options: DracoParseOptions
4635
- ): {[unique_id: number]: string} {
4636
- const attributeNames: {[unique_id: number]: string} = {};
4637
- for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
4638
- const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
4639
- const attributeName = this._deduceAttributeName(dracoAttribute, options);
4640
- attributeNames[attributeName] = attributeName;
4641
- }
4642
- return attributeNames;
4643
- }
4644
- */
4645
- /**
4646
- * Deduce an attribute name.
4647
- * @note DRACO does not save attribute names, just general type (POSITION, COLOR)
4648
- * to help optimize compression. We generate GLTF compatible names for the Draco-recognized
4649
- * types
4650
- * @param attributeData
4651
- */
4652
4345
  _deduceAttributeName(attribute, options) {
4653
4346
  const uniqueId = attribute.unique_id;
4654
4347
  for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
@@ -4669,22 +4362,14 @@ var __exports__ = (() => {
4669
4362
  }
4670
4363
  return `CUSTOM_ATTRIBUTE_${uniqueId}`;
4671
4364
  }
4672
- // METADATA EXTRACTION
4673
- /** Get top level metadata */
4674
4365
  _getTopLevelMetadata(dracoGeometry) {
4675
4366
  const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
4676
4367
  return this._getDracoMetadata(dracoMetadata);
4677
4368
  }
4678
- /** Get per attribute metadata */
4679
4369
  _getAttributeMetadata(dracoGeometry, attributeId) {
4680
4370
  const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
4681
4371
  return this._getDracoMetadata(dracoMetadata);
4682
4372
  }
4683
- /**
4684
- * Extract metadata field values
4685
- * @param dracoMetadata
4686
- * @returns
4687
- */
4688
4373
  _getDracoMetadata(dracoMetadata) {
4689
4374
  if (!dracoMetadata || !dracoMetadata.ptr) {
4690
4375
  return {};
@@ -4697,11 +4382,6 @@ var __exports__ = (() => {
4697
4382
  }
4698
4383
  return result;
4699
4384
  }
4700
- /**
4701
- * Extracts possible values for one metadata entry by name
4702
- * @param dracoMetadata
4703
- * @param entryName
4704
- */
4705
4385
  _getDracoMetadataField(dracoMetadata, entryName) {
4706
4386
  const dracoArray = new this.draco.DracoInt32Array();
4707
4387
  try {
@@ -4717,8 +4397,6 @@ var __exports__ = (() => {
4717
4397
  this.draco.destroy(dracoArray);
4718
4398
  }
4719
4399
  }
4720
- // QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
4721
- /** Skip transforms for specific attribute types */
4722
4400
  _disableAttributeTransforms(options) {
4723
4401
  const {
4724
4402
  quantizedAttributes = [],
@@ -4729,10 +4407,6 @@ var __exports__ = (() => {
4729
4407
  this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
4730
4408
  }
4731
4409
  }
4732
- /**
4733
- * Extract (and apply?) Position Transform
4734
- * @todo not used
4735
- */
4736
4410
  _getQuantizationTransform(dracoAttribute, options) {
4737
4411
  const {
4738
4412
  quantizedAttributes = []
@@ -4775,7 +4449,6 @@ var __exports__ = (() => {
4775
4449
  }
4776
4450
  return null;
4777
4451
  }
4778
- // HELPERS
4779
4452
  };
4780
4453
  function getDracoDataType(draco, attributeType) {
4781
4454
  switch (attributeType) {
@@ -4819,13 +4492,9 @@ var __exports__ = (() => {
4819
4492
  var DRACO_ENCODER_VERSION = "1.4.1";
4820
4493
  var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
4821
4494
  var DRACO_EXTERNAL_LIBRARIES = {
4822
- /** The primary Draco3D encoder, javascript wrapper part */
4823
4495
  DECODER: "draco_wasm_wrapper.js",
4824
- /** The primary draco decoder, compiled web assembly part */
4825
4496
  DECODER_WASM: "draco_decoder.wasm",
4826
- /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
4827
4497
  FALLBACK_DECODER: "draco_decoder.js",
4828
- /** Draco encoder */
4829
4498
  ENCODER: "draco_encoder.js"
4830
4499
  };
4831
4500
  var DRACO_EXTERNAL_LIBRARY_URLS = {
@@ -4873,7 +4542,6 @@ var __exports__ = (() => {
4873
4542
  onModuleLoaded: (draco) => resolve({
4874
4543
  draco
4875
4544
  })
4876
- // Module is Promise-like. Wrap in object to avoid loop.
4877
4545
  });
4878
4546
  });
4879
4547
  }
@@ -4914,14 +4582,8 @@ var __exports__ = (() => {
4914
4582
  count
4915
4583
  } = getAccessorData(attribute);
4916
4584
  const glTFAccessor = {
4917
- // glTF Accessor values
4918
- // TODO: Instead of a bufferView index we could have an actual buffer (typed array)
4919
- // bufferView: null,
4920
- // TODO: Deprecate `value` in favor of bufferView?
4921
- // @ts-ignore
4922
4585
  value: buffer,
4923
4586
  size,
4924
- // Decoded `type` (e.g. SCALAR)
4925
4587
  byteOffset: 0,
4926
4588
  count,
4927
4589
  type: getAccessorTypeFromSize(size),
@@ -5038,14 +4700,11 @@ var __exports__ = (() => {
5038
4700
  const glTFMesh = {
5039
4701
  primitives: [{
5040
4702
  attributes: fauxAccessors,
5041
- // TODO - verify with spec
5042
4703
  mode,
5043
- // GL.POINTS
5044
4704
  extensions: {
5045
4705
  [KHR_DRACO_MESH_COMPRESSION]: {
5046
4706
  bufferView: bufferViewIndex,
5047
4707
  attributes: fauxAccessors
5048
- // TODO - verify with spec
5049
4708
  }
5050
4709
  }
5051
4710
  }]
@@ -5347,12 +5006,7 @@ var __exports__ = (() => {
5347
5006
  for (const material of json.materials || []) {
5348
5007
  const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
5349
5008
  if (materialExtension) {
5350
- material.technique = Object.assign(
5351
- {},
5352
- materialExtension,
5353
- // @ts-ignore
5354
- techniques[materialExtension.technique]
5355
- );
5009
+ material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
5356
5010
  material.technique.values = resolveValues(material.technique, gltfScenegraph);
5357
5011
  }
5358
5012
  gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
@@ -5401,24 +5055,7 @@ var __exports__ = (() => {
5401
5055
  }
5402
5056
 
5403
5057
  // src/lib/api/gltf-extensions.ts
5404
- var EXTENSIONS2 = [
5405
- // 1.0
5406
- // KHR_binary_gltf is handled separately - must be processed before other parsing starts
5407
- // KHR_binary_gltf,
5408
- // 2.0
5409
- EXT_structural_metadata_exports,
5410
- EXT_mesh_features_exports,
5411
- EXT_meshopt_compression_exports,
5412
- EXT_texture_webp_exports,
5413
- // Basisu should come after webp, we want basisu to be preferred if both are provided
5414
- KHR_texture_basisu_exports,
5415
- KHR_draco_mesh_compression_exports,
5416
- KHR_lights_punctual_exports,
5417
- KHR_materials_unlit_exports,
5418
- KHR_techniques_webgl_exports,
5419
- KHR_texture_transform_exports,
5420
- EXT_feature_metadata_exports
5421
- ];
5058
+ var EXTENSIONS2 = [EXT_structural_metadata_exports, EXT_mesh_features_exports, EXT_meshopt_compression_exports, EXT_texture_webp_exports, KHR_texture_basisu_exports, KHR_draco_mesh_compression_exports, KHR_lights_punctual_exports, KHR_materials_unlit_exports, KHR_techniques_webgl_exports, KHR_texture_transform_exports, EXT_feature_metadata_exports];
5422
5059
  function preprocessExtensions(gltf, options = {}, context) {
5423
5060
  const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options));
5424
5061
  for (const extension of extensions) {
@@ -5501,13 +5138,6 @@ var __exports__ = (() => {
5501
5138
  skins: {},
5502
5139
  textures: {}
5503
5140
  };
5504
- // constructor() {}
5505
- /**
5506
- * Convert (normalize) glTF < 2.0 to glTF 2.0
5507
- * @param gltf - object with json and binChunks
5508
- * @param options
5509
- * @param options normalize Whether to actually normalize
5510
- */
5511
5141
  normalize(gltf, options) {
5512
5142
  this.json = gltf.json;
5513
5143
  const json = gltf.json;
@@ -5532,7 +5162,6 @@ var __exports__ = (() => {
5532
5162
  this._updateObjects(json);
5533
5163
  this._updateMaterial(json);
5534
5164
  }
5535
- // asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
5536
5165
  _addAsset(json) {
5537
5166
  json.asset = json.asset || {};
5538
5167
  json.asset.version = "2.0";
@@ -5543,7 +5172,6 @@ var __exports__ = (() => {
5543
5172
  this._convertTopLevelObjectToArray(json, arrayName);
5544
5173
  }
5545
5174
  }
5546
- /** Convert one top level object to array */
5547
5175
  _convertTopLevelObjectToArray(json, mapName) {
5548
5176
  const objectMap = json[mapName];
5549
5177
  if (!objectMap || Array.isArray(objectMap)) {
@@ -5558,7 +5186,6 @@ var __exports__ = (() => {
5558
5186
  this.idToIndexMap[mapName][id] = index;
5559
5187
  }
5560
5188
  }
5561
- /** Go through all objects in all top-level arrays and replace ids with indices */
5562
5189
  _convertObjectIdsToArrayIndices(json) {
5563
5190
  for (const arrayName in GLTF_ARRAYS) {
5564
5191
  this._convertIdsToIndices(json, arrayName);
@@ -5615,7 +5242,6 @@ var __exports__ = (() => {
5615
5242
  scene.nodes = scene.nodes.map((node2) => this._convertIdToIndex(node2, "node"));
5616
5243
  }
5617
5244
  }
5618
- /** Go through all objects in a top-level array and replace ids with indices */
5619
5245
  _convertIdsToIndices(json, topLevelArrayName) {
5620
5246
  if (!json[topLevelArrayName]) {
5621
5247
  console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`);
@@ -5640,19 +5266,11 @@ var __exports__ = (() => {
5640
5266
  }
5641
5267
  return id;
5642
5268
  }
5643
- /**
5644
- *
5645
- * @param {*} json
5646
- */
5647
5269
  _updateObjects(json) {
5648
5270
  for (const buffer of this.json.buffers) {
5649
5271
  delete buffer.type;
5650
5272
  }
5651
5273
  }
5652
- /**
5653
- * Update material (set pbrMetallicRoughness)
5654
- * @param {*} json
5655
- */
5656
5274
  _updateMaterial(json) {
5657
5275
  for (const material of json.materials) {
5658
5276
  material.pbrMetallicRoughness = {
@@ -5798,7 +5416,6 @@ var __exports__ = (() => {
5798
5416
  if (parsedImage && parsedImage[0]) {
5799
5417
  parsedImage = {
5800
5418
  compressed: true,
5801
- // @ts-expect-error
5802
5419
  mipmaps: false,
5803
5420
  width: parsedImage[0].width,
5804
5421
  height: parsedImage[0].height,
@@ -5824,17 +5441,11 @@ var __exports__ = (() => {
5824
5441
  options: {
5825
5442
  gltf: {
5826
5443
  normalize: true,
5827
- // Normalize glTF v1 to glTF v2 format (not yet stable)
5828
5444
  loadBuffers: true,
5829
- // Fetch any linked .BIN buffers, decode base64
5830
5445
  loadImages: true,
5831
- // Create image objects
5832
5446
  decompressMeshes: true
5833
- // Decompress Draco encoded meshes
5834
5447
  },
5835
- // common?
5836
5448
  log: console
5837
- // eslint-disable-line
5838
5449
  },
5839
5450
  deprecatedOptions: {
5840
5451
  fetchImages: "gltf.loadImages",
@@ -5935,9 +5546,7 @@ var __exports__ = (() => {
5935
5546
  module: "gltf",
5936
5547
  version: VERSION3,
5937
5548
  extensions: ["glb"],
5938
- // We only support encoding to binary GLB, not to JSON GLTF
5939
5549
  mimeTypes: ["model/gltf-binary"],
5940
- // 'model/gltf+json',
5941
5550
  binary: true,
5942
5551
  encodeSync,
5943
5552
  options: {
@@ -5969,7 +5578,6 @@ var __exports__ = (() => {
5969
5578
  options: {
5970
5579
  glb: {
5971
5580
  strict: false
5972
- // Enables deprecated XVIZ support (illegal CHUNK formats)
5973
5581
  }
5974
5582
  }
5975
5583
  };
@@ -6022,25 +5630,17 @@ var __exports__ = (() => {
6022
5630
  };
6023
5631
  var BYTES2 = {
6024
5632
  5120: 1,
6025
- // BYTE
6026
5633
  5121: 1,
6027
- // UNSIGNED_BYTE
6028
5634
  5122: 2,
6029
- // SHORT
6030
5635
  5123: 2,
6031
- // UNSIGNED_SHORT
6032
5636
  5125: 4,
6033
- // UNSIGNED_INT
6034
5637
  5126: 4
6035
- // FLOAT
6036
5638
  };
6037
5639
  var GL_SAMPLER = {
6038
- // Sampler parameters
6039
5640
  TEXTURE_MAG_FILTER: 10240,
6040
5641
  TEXTURE_MIN_FILTER: 10241,
6041
5642
  TEXTURE_WRAP_S: 10242,
6042
5643
  TEXTURE_WRAP_T: 10243,
6043
- // Sampler default values
6044
5644
  REPEAT: 10497,
6045
5645
  LINEAR: 9729,
6046
5646
  NEAREST_MIPMAP_LINEAR: 9986
@@ -6071,8 +5671,6 @@ var __exports__ = (() => {
6071
5671
  }
6072
5672
  var GLTFPostProcessor = class {
6073
5673
  baseUri = "";
6074
- // @ts-expect-error
6075
- // @ts-expect-error
6076
5674
  buffers = [];
6077
5675
  images = [];
6078
5676
  postProcess(gltf, options = {}) {
@@ -6092,9 +5690,6 @@ var __exports__ = (() => {
6092
5690
  this.json = this._resolveTree(gltf.json, options);
6093
5691
  return this.json;
6094
5692
  }
6095
- // Convert indexed glTF structure into tree structure
6096
- // cross-link index resolution, enum lookup, convenience calculations
6097
- // eslint-disable-next-line complexity, max-statements
6098
5693
  _resolveTree(gltf, options = {}) {
6099
5694
  const json = {
6100
5695
  ...gltf
@@ -6182,11 +5777,9 @@ var __exports__ = (() => {
6182
5777
  }
6183
5778
  return object;
6184
5779
  }
6185
- // PARSING HELPERS
6186
5780
  _resolveScene(scene, index) {
6187
5781
  return {
6188
5782
  ...scene,
6189
- // @ts-ignore
6190
5783
  id: scene.id || `scene-${index}`,
6191
5784
  nodes: (scene.nodes || []).map((node2) => this.getNode(node2))
6192
5785
  };
@@ -6194,7 +5787,6 @@ var __exports__ = (() => {
6194
5787
  _resolveNode(gltfNode, index) {
6195
5788
  const node2 = {
6196
5789
  ...gltfNode,
6197
- // @ts-expect-error id could already be present, glTF standard does not prevent it
6198
5790
  id: gltfNode?.id || `node-${index}`
6199
5791
  };
6200
5792
  if (gltfNode.mesh !== void 0) {
@@ -6264,7 +5856,6 @@ var __exports__ = (() => {
6264
5856
  _resolveMaterial(gltfMaterial, index) {
6265
5857
  const material = {
6266
5858
  ...gltfMaterial,
6267
- // @ts-expect-error
6268
5859
  id: gltfMaterial.id || `material-${index}`
6269
5860
  };
6270
5861
  if (material.normalTexture) {
@@ -6314,7 +5905,6 @@ var __exports__ = (() => {
6314
5905
  const bytesPerElement = bytesPerComponent * components;
6315
5906
  const accessor = {
6316
5907
  ...gltfAccessor,
6317
- // @ts-expect-error
6318
5908
  id: gltfAccessor.id || `accessor-${index}`,
6319
5909
  bytesPerComponent,
6320
5910
  components,
@@ -6341,16 +5931,6 @@ var __exports__ = (() => {
6341
5931
  }
6342
5932
  return accessor;
6343
5933
  }
6344
- /**
6345
- * Take values of particular accessor from interleaved buffer
6346
- * various parts of the buffer
6347
- * @param buffer
6348
- * @param byteOffset
6349
- * @param byteStride
6350
- * @param bytesPerElement
6351
- * @param count
6352
- * @returns
6353
- */
6354
5934
  _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
6355
5935
  const result = new Uint8Array(count * bytesPerElement);
6356
5936
  for (let i2 = 0; i2 < count; i2++) {
@@ -6362,7 +5942,6 @@ var __exports__ = (() => {
6362
5942
  _resolveTexture(gltfTexture, index) {
6363
5943
  return {
6364
5944
  ...gltfTexture,
6365
- // @ts-expect-error id could already be present, glTF standard does not prevent it
6366
5945
  id: gltfTexture.id || `texture-${index}`,
6367
5946
  sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
6368
5947
  source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
@@ -6370,7 +5949,6 @@ var __exports__ = (() => {
6370
5949
  }
6371
5950
  _resolveSampler(gltfSampler, index) {
6372
5951
  const sampler = {
6373
- // @ts-expect-error id could already be present, glTF standard does not prevent it
6374
5952
  id: gltfSampler.id || `sampler-${index}`,
6375
5953
  ...gltfSampler,
6376
5954
  parameters: {}
@@ -6389,7 +5967,6 @@ var __exports__ = (() => {
6389
5967
  _resolveImage(gltfImage, index) {
6390
5968
  const image = {
6391
5969
  ...gltfImage,
6392
- // @ts-expect-error id could already be present, glTF standard does not prevent it
6393
5970
  id: gltfImage.id || `image-${index}`,
6394
5971
  image: null,
6395
5972
  bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
@@ -6408,10 +5985,8 @@ var __exports__ = (() => {
6408
5985
  byteOffset += gltfBufferView.byteOffset;
6409
5986
  }
6410
5987
  const bufferView = {
6411
- // // @ts-expect-error id could already be present, glTF standard does not prevent it
6412
5988
  id: `bufferView-${index}`,
6413
5989
  ...gltfBufferView,
6414
- // ...this.buffers[bufferIndex],
6415
5990
  buffer: this.buffers[bufferIndex],
6416
5991
  data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
6417
5992
  };
@@ -6420,7 +5995,6 @@ var __exports__ = (() => {
6420
5995
  _resolveCamera(gltfCamera, index) {
6421
5996
  const camera = {
6422
5997
  ...gltfCamera,
6423
- // @ts-expect-error id could already be present, glTF standard does not prevent it
6424
5998
  id: gltfCamera.id || `camera-${index}`
6425
5999
  };
6426
6000
  if (camera.perspective) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/gltf",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.4",
4
4
  "description": "Framework-independent loader for the glTF format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,11 +42,11 @@
42
42
  "build-bundle": "ocular-bundle ./src/index.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@loaders.gl/draco": "4.0.0-beta.3",
46
- "@loaders.gl/images": "4.0.0-beta.3",
47
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
48
- "@loaders.gl/textures": "4.0.0-beta.3",
45
+ "@loaders.gl/draco": "4.0.0-beta.4",
46
+ "@loaders.gl/images": "4.0.0-beta.4",
47
+ "@loaders.gl/loader-utils": "4.0.0-beta.4",
48
+ "@loaders.gl/textures": "4.0.0-beta.4",
49
49
  "@math.gl/core": "^4.0.0"
50
50
  },
51
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
51
+ "gitHead": "848c20b474532d301f2c3f8d4e1fb9bf262b86d4"
52
52
  }