@loaders.gl/gltf 3.4.0-alpha.1 → 3.4.0-alpha.2

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.
package/dist/dist.min.js CHANGED
@@ -282,7 +282,7 @@
282
282
  }
283
283
  });
284
284
 
285
- // ../loader-utils/src/lib/binary-utils/binary-copy-utils.ts
285
+ // ../loader-utils/src/lib/binary-utils/dataview-copy-utils.ts
286
286
  function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
287
287
  const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);
288
288
  const padLength = paddedLength - sourceBuffer.byteLength;
@@ -303,8 +303,8 @@
303
303
  byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
304
304
  return byteOffset;
305
305
  }
306
- var init_binary_copy_utils = __esm({
307
- "../loader-utils/src/lib/binary-utils/binary-copy-utils.ts"() {
306
+ var init_dataview_copy_utils = __esm({
307
+ "../loader-utils/src/lib/binary-utils/dataview-copy-utils.ts"() {
308
308
  init_memory_copy_utils();
309
309
  }
310
310
  });
@@ -317,7 +317,7 @@
317
317
  init_parse_json();
318
318
  init_array_buffer_utils();
319
319
  init_memory_copy_utils();
320
- init_binary_copy_utils();
320
+ init_dataview_copy_utils();
321
321
  }
322
322
  });
323
323
 
@@ -986,10 +986,62 @@
986
986
  }
987
987
  });
988
988
 
989
+ // ../images/src/lib/category-api/parse-isobmff-binary.ts
990
+ function getISOBMFFMediaType(buffer) {
991
+ if (!checkString(buffer, "ftyp", 4)) {
992
+ return null;
993
+ }
994
+ if ((buffer[8] & 96) === 0) {
995
+ return null;
996
+ }
997
+ return decodeMajorBrand(buffer);
998
+ }
999
+ function decodeMajorBrand(buffer) {
1000
+ const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
1001
+ switch (brandMajor) {
1002
+ case "avif":
1003
+ case "avis":
1004
+ return { extension: "avif", mimeType: "image/avif" };
1005
+ default:
1006
+ return null;
1007
+ }
1008
+ }
1009
+ function getUTF8String(array, start, end) {
1010
+ return String.fromCharCode(...array.slice(start, end));
1011
+ }
1012
+ function stringToBytes(string) {
1013
+ return [...string].map((character) => character.charCodeAt(0));
1014
+ }
1015
+ function checkString(buffer, header, offset = 0) {
1016
+ const headerBytes = stringToBytes(header);
1017
+ for (let i2 = 0; i2 < headerBytes.length; ++i2) {
1018
+ if (headerBytes[i2] !== buffer[i2 + offset]) {
1019
+ return false;
1020
+ }
1021
+ }
1022
+ return true;
1023
+ }
1024
+ var init_parse_isobmff_binary = __esm({
1025
+ "../images/src/lib/category-api/parse-isobmff-binary.ts"() {
1026
+ }
1027
+ });
1028
+
989
1029
  // ../images/src/lib/category-api/binary-image-api.ts
990
1030
  function getBinaryImageMetadata(binaryData) {
991
1031
  const dataView = toDataView(binaryData);
992
- return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView);
1032
+ return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
1033
+ }
1034
+ function getISOBMFFMetadata(binaryData) {
1035
+ const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
1036
+ const mediaType = getISOBMFFMediaType(buffer);
1037
+ if (!mediaType) {
1038
+ return null;
1039
+ }
1040
+ return {
1041
+ mimeType: mediaType.mimeType,
1042
+ width: 0,
1043
+ height: 0
1044
+ };
993
1045
  }
994
1046
  function getPngMetadata(binaryData) {
995
1047
  const dataView = toDataView(binaryData);
@@ -1090,6 +1142,7 @@
1090
1142
  var BIG_ENDIAN, LITTLE_ENDIAN;
1091
1143
  var init_binary_image_api = __esm({
1092
1144
  "../images/src/lib/category-api/binary-image-api.ts"() {
1145
+ init_parse_isobmff_binary();
1093
1146
  BIG_ENDIAN = false;
1094
1147
  LITTLE_ENDIAN = true;
1095
1148
  }
@@ -1163,12 +1216,13 @@
1163
1216
  init_version4();
1164
1217
  init_parse_image();
1165
1218
  init_binary_image_api();
1166
- EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg"];
1219
+ EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
1167
1220
  MIME_TYPES = [
1168
1221
  "image/png",
1169
1222
  "image/jpeg",
1170
1223
  "image/gif",
1171
1224
  "image/webp",
1225
+ "image/avif",
1172
1226
  "image/bmp",
1173
1227
  "image/vnd.microsoft.icon",
1174
1228
  "image/svg+xml"
@@ -1194,43 +1248,41 @@
1194
1248
  });
1195
1249
 
1196
1250
  // ../images/src/lib/category-api/image-format.ts
1197
- function _isImageFormatSupported(mimeType) {
1198
- if (mimeTypeSupported[mimeType] === void 0) {
1199
- mimeTypeSupported[mimeType] = checkFormatSupport(mimeType);
1251
+ function isImageFormatSupported(mimeType) {
1252
+ if (mimeTypeSupportedSync[mimeType] === void 0) {
1253
+ const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType);
1254
+ mimeTypeSupportedSync[mimeType] = supported;
1200
1255
  }
1201
- return mimeTypeSupported[mimeType];
1256
+ return mimeTypeSupportedSync[mimeType];
1257
+ }
1258
+ function checkNodeImageFormatSupport(mimeType) {
1259
+ const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
1260
+ const { _parseImageNode: _parseImageNode2, _imageFormatsNode = NODE_FORMAT_SUPPORT } = globalThis;
1261
+ return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
1202
1262
  }
1203
- function checkFormatSupport(mimeType) {
1263
+ function checkBrowserImageFormatSupport(mimeType) {
1204
1264
  switch (mimeType) {
1265
+ case "image/avif":
1205
1266
  case "image/webp":
1206
- return checkWebPSupport();
1207
- case "image/svg":
1208
- return isBrowser;
1267
+ return testBrowserImageFormatSupport(mimeType);
1209
1268
  default:
1210
- if (!isBrowser) {
1211
- const { _parseImageNode: _parseImageNode2 } = globalThis;
1212
- return Boolean(_parseImageNode2) && NODE_FORMAT_SUPPORT.includes(mimeType);
1213
- }
1214
1269
  return true;
1215
1270
  }
1216
1271
  }
1217
- function checkWebPSupport() {
1218
- if (!isBrowser) {
1219
- return false;
1220
- }
1272
+ function testBrowserImageFormatSupport(mimeType) {
1221
1273
  try {
1222
1274
  const element = document.createElement("canvas");
1223
- return element.toDataURL("image/webp").indexOf("data:image/webp") === 0;
1275
+ const dataURL = element.toDataURL(mimeType);
1276
+ return dataURL.indexOf(`data:${mimeType}`) === 0;
1224
1277
  } catch {
1225
1278
  return false;
1226
1279
  }
1227
1280
  }
1228
- var NODE_FORMAT_SUPPORT, mimeTypeSupported;
1281
+ var mimeTypeSupportedSync;
1229
1282
  var init_image_format = __esm({
1230
1283
  "../images/src/lib/category-api/image-format.ts"() {
1231
1284
  init_src2();
1232
- NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
1233
- mimeTypeSupported = {};
1285
+ mimeTypeSupportedSync = {};
1234
1286
  }
1235
1287
  });
1236
1288
 
@@ -2015,7 +2067,7 @@
2015
2067
  });
2016
2068
  function preprocess(gltfData, options) {
2017
2069
  const scenegraph = new GLTFScenegraph(gltfData);
2018
- if (!_isImageFormatSupported("image/webp")) {
2070
+ if (!isImageFormatSupported("image/webp")) {
2019
2071
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
2020
2072
  throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);
2021
2073
  }
@@ -18,7 +18,7 @@ var name = EXT_TEXTURE_WEBP;
18
18
  exports.name = name;
19
19
  function preprocess(gltfData, options) {
20
20
  var scenegraph = new _gltfScenegraph.default(gltfData);
21
- if (!(0, _images._isImageFormatSupported)('image/webp')) {
21
+ if (!(0, _images.isImageFormatSupported)('image/webp')) {
22
22
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
23
23
  throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP, " not supported by browser"));
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_texture_webp.js","names":["EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","GLTFScenegraph","_isImageFormatSupported","getRequiredExtensions","includes","Error","json","textures","texture","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-types';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {_isImageFormatSupported} from '@loaders.gl/images';\nimport GLTFScenegraph from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!_isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":";;;;;;;;AAOA;AACA;AAAoD;AAAA;AAAA;AAEpD,IAAMA,gBAAgB,GAAG,kBAAkB;;AAGpC,IAAMC,IAAI,GAAGD,gBAAgB;;AAAC;AAM9B,SAASE,UAAU,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,IAAMC,UAAU,GAAG,IAAIC,uBAAc,CAACH,QAAQ,CAAC;EAE/C,IAAI,CAAC,IAAAI,+BAAuB,EAAC,YAAY,CAAC,EAAE;IAC1C,IAAIF,UAAU,CAACG,qBAAqB,EAAE,CAACC,QAAQ,CAACT,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIU,KAAK,oCAA6BV,gBAAgB,+BAA4B;IAC1F;IACA;EACF;EAEA,IAAOW,IAAI,GAAIN,UAAU,CAAlBM,IAAI;EAAe,2CAEJA,IAAI,CAACC,QAAQ,IAAI,EAAE;IAAA;EAAA;IAAzC,oDAA2C;MAAA,IAAhCC,OAAO;MAChB,IAAMC,SAAS,GAAGT,UAAU,CAACU,kBAAkB,CAC7CF,OAAO,EACPb,gBAAgB,CACjB;MACD,IAAIc,SAAS,EAAE;QAEbD,OAAO,CAACG,MAAM,GAAGF,SAAS,CAACE,MAAM;MACnC;MACAX,UAAU,CAACY,qBAAqB,CAACJ,OAAO,EAAEb,gBAAgB,CAAC;IAC7D;;EAAC;IAAA;EAAA;IAAA;EAAA;EAGDK,UAAU,CAACa,eAAe,CAAClB,gBAAgB,CAAC;AAC9C"}
1
+ {"version":3,"file":"EXT_texture_webp.js","names":["EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","GLTFScenegraph","isImageFormatSupported","getRequiredExtensions","includes","Error","json","textures","texture","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-types';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {isImageFormatSupported} from '@loaders.gl/images';\nimport GLTFScenegraph from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":";;;;;;;;AAOA;AACA;AAAoD;AAAA;AAAA;AAEpD,IAAMA,gBAAgB,GAAG,kBAAkB;;AAGpC,IAAMC,IAAI,GAAGD,gBAAgB;;AAAC;AAM9B,SAASE,UAAU,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,IAAMC,UAAU,GAAG,IAAIC,uBAAc,CAACH,QAAQ,CAAC;EAE/C,IAAI,CAAC,IAAAI,8BAAsB,EAAC,YAAY,CAAC,EAAE;IACzC,IAAIF,UAAU,CAACG,qBAAqB,EAAE,CAACC,QAAQ,CAACT,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIU,KAAK,oCAA6BV,gBAAgB,+BAA4B;IAC1F;IACA;EACF;EAEA,IAAOW,IAAI,GAAIN,UAAU,CAAlBM,IAAI;EAAe,2CAEJA,IAAI,CAACC,QAAQ,IAAI,EAAE;IAAA;EAAA;IAAzC,oDAA2C;MAAA,IAAhCC,OAAO;MAChB,IAAMC,SAAS,GAAGT,UAAU,CAACU,kBAAkB,CAC7CF,OAAO,EACPb,gBAAgB,CACjB;MACD,IAAIc,SAAS,EAAE;QAEbD,OAAO,CAACG,MAAM,GAAGF,SAAS,CAACE,MAAM;MACnC;MACAX,UAAU,CAACY,qBAAqB,CAACJ,OAAO,EAAEb,gBAAgB,CAAC;IAC7D;;EAAC;IAAA;EAAA;IAAA;EAAA;EAGDK,UAAU,CAACa,eAAe,CAAClB,gBAAgB,CAAC;AAC9C"}
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- var VERSION = typeof "3.4.0-alpha.1" !== 'undefined' ? "3.4.0-alpha.1" : 'latest';
7
+ var VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest';
8
8
  exports.VERSION = VERSION;
9
9
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- import { _isImageFormatSupported } from '@loaders.gl/images';
3
+ import { isImageFormatSupported } from '@loaders.gl/images';
4
4
  import GLTFScenegraph from '../api/gltf-scenegraph';
5
5
  const EXT_TEXTURE_WEBP = 'EXT_texture_webp';
6
6
 
@@ -8,7 +8,7 @@ export const name = EXT_TEXTURE_WEBP;
8
8
 
9
9
  export function preprocess(gltfData, options) {
10
10
  const scenegraph = new GLTFScenegraph(gltfData);
11
- if (!_isImageFormatSupported('image/webp')) {
11
+ if (!isImageFormatSupported('image/webp')) {
12
12
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
13
13
  throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP, " not supported by browser"));
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_texture_webp.js","names":["_isImageFormatSupported","GLTFScenegraph","EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","getRequiredExtensions","includes","Error","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-types';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {_isImageFormatSupported} from '@loaders.gl/images';\nimport GLTFScenegraph from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!_isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":";;AAOA,SAAQA,uBAAuB,QAAO,oBAAoB;AAC1D,OAAOC,cAAc,MAAM,wBAAwB;AAEnD,MAAMC,gBAAgB,GAAG,kBAAkB;;AAG3C,OAAO,MAAMC,IAAI,GAAGD,gBAAgB;;AAMpC,OAAO,SAASE,UAAU,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,UAAU,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAE/C,IAAI,CAACL,uBAAuB,CAAC,YAAY,CAAC,EAAE;IAC1C,IAAIO,UAAU,CAACC,qBAAqB,EAAE,CAACC,QAAQ,CAACP,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIQ,KAAK,oCAA6BR,gBAAgB,+BAA4B;IAC1F;IACA;EACF;EAEA,MAAM;IAACS;EAAI,CAAC,GAAGJ,UAAU;EAEzB,KAAK,MAAMK,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGP,UAAU,CAACQ,kBAAkB,CAC7CH,OAAO,EACPV,gBAAgB,CACjB;IACD,IAAIY,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;IACnC;IACAT,UAAU,CAACU,qBAAqB,CAACL,OAAO,EAAEV,gBAAgB,CAAC;EAC7D;;EAGAK,UAAU,CAACW,eAAe,CAAChB,gBAAgB,CAAC;AAC9C"}
1
+ {"version":3,"file":"EXT_texture_webp.js","names":["isImageFormatSupported","GLTFScenegraph","EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","getRequiredExtensions","includes","Error","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-types';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {isImageFormatSupported} from '@loaders.gl/images';\nimport GLTFScenegraph from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":";;AAOA,SAAQA,sBAAsB,QAAO,oBAAoB;AACzD,OAAOC,cAAc,MAAM,wBAAwB;AAEnD,MAAMC,gBAAgB,GAAG,kBAAkB;;AAG3C,OAAO,MAAMC,IAAI,GAAGD,gBAAgB;;AAMpC,OAAO,SAASE,UAAU,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,UAAU,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAE/C,IAAI,CAACL,sBAAsB,CAAC,YAAY,CAAC,EAAE;IACzC,IAAIO,UAAU,CAACC,qBAAqB,EAAE,CAACC,QAAQ,CAACP,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIQ,KAAK,oCAA6BR,gBAAgB,+BAA4B;IAC1F;IACA;EACF;EAEA,MAAM;IAACS;EAAI,CAAC,GAAGJ,UAAU;EAEzB,KAAK,MAAMK,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGP,UAAU,CAACQ,kBAAkB,CAC7CH,OAAO,EACPV,gBAAgB,CACjB;IACD,IAAIY,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;IACnC;IACAT,UAAU,CAACU,qBAAqB,CAACL,OAAO,EAAEV,gBAAgB,CAAC;EAC7D;;EAGAK,UAAU,CAACW,eAAe,CAAChB,gBAAgB,CAAC;AAC9C"}
@@ -1,3 +1,3 @@
1
1
 
2
- export const VERSION = typeof "3.4.0-alpha.1" !== 'undefined' ? "3.4.0-alpha.1" : 'latest';
2
+ export const VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest';
3
3
  //# sourceMappingURL=version.js.map
@@ -18,7 +18,7 @@ exports.name = EXT_TEXTURE_WEBP;
18
18
  */
19
19
  function preprocess(gltfData, options) {
20
20
  const scenegraph = new gltf_scenegraph_1.default(gltfData);
21
- if (!(0, images_1._isImageFormatSupported)('image/webp')) {
21
+ if (!(0, images_1.isImageFormatSupported)('image/webp')) {
22
22
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
23
23
  throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/gltf",
3
- "version": "3.4.0-alpha.1",
3
+ "version": "3.4.0-alpha.2",
4
4
  "description": "Framework-independent loader for the glTF format",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,11 +34,11 @@
34
34
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
35
35
  },
36
36
  "dependencies": {
37
- "@loaders.gl/draco": "3.4.0-alpha.1",
38
- "@loaders.gl/images": "3.4.0-alpha.1",
39
- "@loaders.gl/loader-utils": "3.4.0-alpha.1",
40
- "@loaders.gl/textures": "3.4.0-alpha.1",
37
+ "@loaders.gl/draco": "3.4.0-alpha.2",
38
+ "@loaders.gl/images": "3.4.0-alpha.2",
39
+ "@loaders.gl/loader-utils": "3.4.0-alpha.2",
40
+ "@loaders.gl/textures": "3.4.0-alpha.2",
41
41
  "@math.gl/core": "^3.5.1"
42
42
  },
43
- "gitHead": "4085b0323050e4361614471319a1fb4729547bbf"
43
+ "gitHead": "f1c00c124d8d0c41a138ff40afb0d1a00711bf2e"
44
44
  }
@@ -5,7 +5,7 @@
5
5
  import type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-types';
6
6
  import type {GLTFLoaderOptions} from '../../gltf-loader';
7
7
 
8
- import {_isImageFormatSupported} from '@loaders.gl/images';
8
+ import {isImageFormatSupported} from '@loaders.gl/images';
9
9
  import GLTFScenegraph from '../api/gltf-scenegraph';
10
10
 
11
11
  const EXT_TEXTURE_WEBP = 'EXT_texture_webp';
@@ -20,7 +20,7 @@ export const name = EXT_TEXTURE_WEBP;
20
20
  export function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {
21
21
  const scenegraph = new GLTFScenegraph(gltfData);
22
22
 
23
- if (!_isImageFormatSupported('image/webp')) {
23
+ if (!isImageFormatSupported('image/webp')) {
24
24
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
25
25
  throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);
26
26
  }