@loaders.gl/3d-tiles 4.4.0-alpha.16 → 4.4.0-alpha.18

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.
@@ -5,7 +5,7 @@ import { DataViewReadableFile } from '@loaders.gl/zip';
5
5
  import { parse3DTilesArchive as parse3DTilesArchiveFromProvider } from "./3d-tiles-archive/3d-tiles-archive-parser.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.4.0-alpha.16" !== 'undefined' ? "4.4.0-alpha.16" : 'latest';
8
+ const VERSION = typeof "4.4.0-alpha.18" !== 'undefined' ? "4.4.0-alpha.18" : 'latest';
9
9
  /**
10
10
  * Loader for 3tz packages
11
11
  */
package/dist/dist.dev.js CHANGED
@@ -4885,6 +4885,16 @@ var __exports__ = (() => {
4885
4885
 
4886
4886
  // ../worker-utils/src/lib/library-utils/library-utils.ts
4887
4887
  var loadLibraryPromises = {};
4888
+ function extractLoadLibraryOptions(options = {}) {
4889
+ const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries;
4890
+ const CDN = options.CDN ?? options.core?.CDN;
4891
+ const modules = options.modules;
4892
+ return {
4893
+ ...useLocalLibraries !== void 0 ? { useLocalLibraries } : {},
4894
+ ...CDN !== void 0 ? { CDN } : {},
4895
+ ...modules !== void 0 ? { modules } : {}
4896
+ };
4897
+ }
4888
4898
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
4889
4899
  if (moduleName) {
4890
4900
  libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
@@ -11657,7 +11667,6 @@ var __exports__ = (() => {
11657
11667
  draco: {
11658
11668
  decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
11659
11669
  // 'js' for IE11
11660
- libraryPath: "libs/",
11661
11670
  extraAttributes: {},
11662
11671
  attributeNameEntry: void 0
11663
11672
  }
@@ -11669,7 +11678,7 @@ var __exports__ = (() => {
11669
11678
  };
11670
11679
  async function parse(arrayBuffer, options) {
11671
11680
  const { draco } = await loadDracoDecoderModule(
11672
- options?.core,
11681
+ extractLoadLibraryOptions(options),
11673
11682
  options?.draco?.decoderType || "wasm"
11674
11683
  );
11675
11684
  const dracoParser = new DracoParser(draco);
@@ -15236,104 +15245,117 @@ var __exports__ = (() => {
15236
15245
  }
15237
15246
 
15238
15247
  // ../textures/src/lib/gl-extensions.ts
15239
- var GL_EXTENSIONS_CONSTANTS = {
15240
- // WEBGL_compressed_texture_s3tc
15241
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
15242
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
15243
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
15244
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
15245
- // WEBGL_compressed_texture_es3
15246
- COMPRESSED_R11_EAC: 37488,
15247
- COMPRESSED_SIGNED_R11_EAC: 37489,
15248
- COMPRESSED_RG11_EAC: 37490,
15249
- COMPRESSED_SIGNED_RG11_EAC: 37491,
15250
- COMPRESSED_RGB8_ETC2: 37492,
15251
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
15252
- COMPRESSED_SRGB8_ETC2: 37494,
15253
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
15254
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
15255
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
15256
- // WEBGL_compressed_texture_pvrtc
15257
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
15258
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
15259
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
15260
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
15261
- // WEBGL_compressed_texture_etc1
15262
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
15263
- // WEBGL_compressed_texture_atc
15264
- COMPRESSED_RGB_ATC_WEBGL: 35986,
15265
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
15266
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
15267
- // WEBGL_compressed_texture_astc
15268
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
15269
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
15270
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
15271
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
15272
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
15273
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
15274
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
15275
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
15276
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
15277
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
15278
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
15279
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
15280
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
15281
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
15282
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
15283
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
15284
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
15285
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
15286
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
15287
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
15288
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
15289
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
15290
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
15291
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
15292
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
15293
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
15294
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
15295
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
15296
- // EXT_texture_compression_rgtc
15297
- COMPRESSED_RED_RGTC1_EXT: 36283,
15298
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
15299
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
15300
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
15301
- // WEBGL_compressed_texture_s3tc_srgb
15302
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
15303
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
15304
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
15305
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
15306
- };
15248
+ var GL_RGBA4 = 32854;
15249
+ var GL_RGBA8 = 32856;
15250
+ var GL_RGB565 = 36194;
15251
+ var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
15252
+ var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
15253
+ var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
15254
+ var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
15255
+ var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
15256
+ var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
15257
+ var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
15258
+ var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
15259
+ var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
15260
+ var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
15261
+ var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
15262
+ var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
15307
15263
 
15308
- // ../textures/src/lib/utils/texture-formats.ts
15264
+ // ../textures/src/lib/utils/detect-supported-texture-formats.ts
15309
15265
  var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
15310
- var WEBGL_EXTENSIONS = {
15266
+ var WEBGL_TEXTURE_FORMATS = {
15311
15267
  /* eslint-disable camelcase */
15312
- WEBGL_compressed_texture_s3tc: "dxt",
15313
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
15314
- WEBGL_compressed_texture_etc1: "etc1",
15315
- WEBGL_compressed_texture_etc: "etc2",
15316
- WEBGL_compressed_texture_pvrtc: "pvrtc",
15317
- WEBGL_compressed_texture_atc: "atc",
15318
- WEBGL_compressed_texture_astc: "astc",
15319
- EXT_texture_compression_rgtc: "rgtc"
15268
+ WEBGL_compressed_texture_s3tc: [
15269
+ "bc1-rgb-unorm-webgl",
15270
+ "bc1-rgba-unorm",
15271
+ "bc2-rgba-unorm",
15272
+ "bc3-rgba-unorm"
15273
+ ],
15274
+ WEBGL_compressed_texture_s3tc_srgb: [
15275
+ "bc1-rgb-unorm-srgb-webgl",
15276
+ "bc1-rgba-unorm-srgb",
15277
+ "bc2-rgba-unorm-srgb",
15278
+ "bc3-rgba-unorm-srgb"
15279
+ ],
15280
+ EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
15281
+ EXT_texture_compression_bptc: [
15282
+ "bc6h-rgb-ufloat",
15283
+ "bc6h-rgb-float",
15284
+ "bc7-rgba-unorm",
15285
+ "bc7-rgba-unorm-srgb"
15286
+ ],
15287
+ WEBGL_compressed_texture_etc1: ["etc1-rbg-unorm-webgl"],
15288
+ WEBGL_compressed_texture_etc: [
15289
+ "etc2-rgb8unorm",
15290
+ "etc2-rgb8unorm-srgb",
15291
+ "etc2-rgb8a1unorm",
15292
+ "etc2-rgb8a1unorm-srgb",
15293
+ "etc2-rgba8unorm",
15294
+ "etc2-rgba8unorm-srgb",
15295
+ "eac-r11unorm",
15296
+ "eac-r11snorm",
15297
+ "eac-rg11unorm",
15298
+ "eac-rg11snorm"
15299
+ ],
15300
+ WEBGL_compressed_texture_pvrtc: [
15301
+ "pvrtc-rgb4unorm-webgl",
15302
+ "pvrtc-rgba4unorm-webgl",
15303
+ "pvrtc-rbg2unorm-webgl",
15304
+ "pvrtc-rgba2unorm-webgl"
15305
+ ],
15306
+ WEBGL_compressed_texture_atc: [
15307
+ "atc-rgb-unorm-webgl",
15308
+ "atc-rgba-unorm-webgl",
15309
+ "atc-rgbai-unorm-webgl"
15310
+ ],
15311
+ WEBGL_compressed_texture_astc: [
15312
+ "astc-4x4-unorm",
15313
+ "astc-4x4-unorm-srgb",
15314
+ "astc-5x4-unorm",
15315
+ "astc-5x4-unorm-srgb",
15316
+ "astc-5x5-unorm",
15317
+ "astc-5x5-unorm-srgb",
15318
+ "astc-6x5-unorm",
15319
+ "astc-6x5-unorm-srgb",
15320
+ "astc-6x6-unorm",
15321
+ "astc-6x6-unorm-srgb",
15322
+ "astc-8x5-unorm",
15323
+ "astc-8x5-unorm-srgb",
15324
+ "astc-8x6-unorm",
15325
+ "astc-8x6-unorm-srgb",
15326
+ "astc-8x8-unorm",
15327
+ "astc-8x8-unorm-srgb",
15328
+ "astc-10x5-unorm",
15329
+ "astc-10x5-unorm-srgb",
15330
+ "astc-10x6-unorm",
15331
+ "astc-10x6-unorm-srgb",
15332
+ "astc-10x8-unorm",
15333
+ "astc-10x8-unorm-srgb",
15334
+ "astc-10x10-unorm",
15335
+ "astc-10x10-unorm-srgb",
15336
+ "astc-12x10-unorm",
15337
+ "astc-12x10-unorm-srgb",
15338
+ "astc-12x12-unorm",
15339
+ "astc-12x12-unorm-srgb"
15340
+ ]
15320
15341
  /* eslint-enable camelcase */
15321
15342
  };
15322
- var formats = null;
15323
- function getSupportedGPUTextureFormats(gl) {
15324
- if (!formats) {
15343
+ var textureFormats = null;
15344
+ function detectSupportedTextureFormats(gl) {
15345
+ if (!textureFormats) {
15325
15346
  gl = gl || getWebGLContext() || void 0;
15326
- formats = /* @__PURE__ */ new Set();
15347
+ textureFormats = /* @__PURE__ */ new Set();
15327
15348
  for (const prefix of BROWSER_PREFIXES) {
15328
- for (const extension in WEBGL_EXTENSIONS) {
15349
+ for (const extension in WEBGL_TEXTURE_FORMATS) {
15329
15350
  if (gl && gl.getExtension(`${prefix}${extension}`)) {
15330
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
15331
- formats.add(gpuTextureFormat);
15351
+ for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
15352
+ textureFormats.add(textureFormat);
15353
+ }
15332
15354
  }
15333
15355
  }
15334
15356
  }
15335
15357
  }
15336
- return formats;
15358
+ return textureFormats;
15337
15359
  }
15338
15360
  function getWebGLContext() {
15339
15361
  try {
@@ -15378,61 +15400,126 @@ var __exports__ = (() => {
15378
15400
  }
15379
15401
 
15380
15402
  // ../textures/src/lib/parsers/parse-basis.ts
15381
- var OutputFormat = {
15403
+ var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
15382
15404
  etc1: {
15383
15405
  basisFormat: 0,
15384
15406
  compressed: true,
15385
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
15407
+ format: GL_COMPRESSED_RGB_ETC1_WEBGL,
15408
+ textureFormat: "etc1-rbg-unorm-webgl"
15409
+ },
15410
+ etc2: {
15411
+ basisFormat: 1,
15412
+ compressed: true,
15413
+ format: GL_COMPRESSED_RGBA8_ETC2_EAC,
15414
+ textureFormat: "etc2-rgba8unorm"
15386
15415
  },
15387
- etc2: { basisFormat: 1, compressed: true },
15388
15416
  bc1: {
15389
15417
  basisFormat: 2,
15390
15418
  compressed: true,
15391
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
15419
+ format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
15420
+ textureFormat: "bc1-rgb-unorm-webgl"
15392
15421
  },
15393
15422
  bc3: {
15394
15423
  basisFormat: 3,
15395
15424
  compressed: true,
15396
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
15425
+ format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
15426
+ textureFormat: "bc3-rgba-unorm"
15427
+ },
15428
+ bc4: {
15429
+ basisFormat: 4,
15430
+ compressed: true,
15431
+ format: GL_COMPRESSED_RED_RGTC1_EXT,
15432
+ textureFormat: "bc4-r-unorm"
15433
+ },
15434
+ bc5: {
15435
+ basisFormat: 5,
15436
+ compressed: true,
15437
+ format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
15438
+ textureFormat: "bc5-rg-unorm"
15439
+ },
15440
+ "bc7-m6-opaque-only": {
15441
+ basisFormat: 6,
15442
+ compressed: true,
15443
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
15444
+ textureFormat: "bc7-rgba-unorm"
15445
+ },
15446
+ "bc7-m5": {
15447
+ basisFormat: 7,
15448
+ compressed: true,
15449
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
15450
+ textureFormat: "bc7-rgba-unorm"
15397
15451
  },
15398
- bc4: { basisFormat: 4, compressed: true },
15399
- bc5: { basisFormat: 5, compressed: true },
15400
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
15401
- "bc7-m5": { basisFormat: 7, compressed: true },
15402
15452
  "pvrtc1-4-rgb": {
15403
15453
  basisFormat: 8,
15404
15454
  compressed: true,
15405
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
15455
+ format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
15456
+ textureFormat: "pvrtc-rgb4unorm-webgl"
15406
15457
  },
15407
15458
  "pvrtc1-4-rgba": {
15408
15459
  basisFormat: 9,
15409
15460
  compressed: true,
15410
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
15461
+ format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
15462
+ textureFormat: "pvrtc-rgba4unorm-webgl"
15411
15463
  },
15412
15464
  "astc-4x4": {
15413
15465
  basisFormat: 10,
15414
15466
  compressed: true,
15415
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
15467
+ format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
15468
+ textureFormat: "astc-4x4-unorm"
15469
+ },
15470
+ "atc-rgb": {
15471
+ basisFormat: 11,
15472
+ compressed: true,
15473
+ format: GL_COMPRESSED_RGB_ATC_WEBGL,
15474
+ textureFormat: "atc-rgb-unorm-webgl"
15475
+ },
15476
+ "atc-rgba-interpolated-alpha": {
15477
+ basisFormat: 12,
15478
+ compressed: true,
15479
+ format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
15480
+ textureFormat: "atc-rgbai-unorm-webgl"
15481
+ },
15482
+ rgba32: {
15483
+ basisFormat: 13,
15484
+ compressed: false,
15485
+ format: GL_RGBA8,
15486
+ textureFormat: "rgba8unorm"
15487
+ },
15488
+ rgb565: {
15489
+ basisFormat: 14,
15490
+ compressed: false,
15491
+ format: GL_RGB565,
15492
+ textureFormat: "rgb565unorm-webgl"
15416
15493
  },
15417
- "atc-rgb": { basisFormat: 11, compressed: true },
15418
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
15419
- rgba32: { basisFormat: 13, compressed: false },
15420
- rgb565: { basisFormat: 14, compressed: false },
15421
- bgr565: { basisFormat: 15, compressed: false },
15422
- rgba4444: { basisFormat: 16, compressed: false }
15494
+ bgr565: {
15495
+ basisFormat: 15,
15496
+ compressed: false,
15497
+ format: GL_RGB565,
15498
+ textureFormat: "rgb565unorm-webgl"
15499
+ },
15500
+ rgba4444: {
15501
+ basisFormat: 16,
15502
+ compressed: false,
15503
+ format: GL_RGBA4,
15504
+ textureFormat: "rgba4unorm-webgl"
15505
+ }
15423
15506
  };
15507
+ var BASIS_FORMATS = Object.freeze(
15508
+ Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
15509
+ );
15424
15510
  async function parseBasis(data, options = {}) {
15511
+ const loadLibraryOptions = extractLoadLibraryOptions(options);
15425
15512
  if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
15426
15513
  if (isKTX(data)) {
15427
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
15514
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
15428
15515
  return parseKTX2File(fileConstructors.KTX2File, data, options);
15429
15516
  }
15430
- const { BasisFile } = await loadBasisTranscoderModule(options?.core || {});
15517
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
15431
15518
  return parseBasisFile(BasisFile, data, options);
15432
15519
  }
15433
15520
  switch (options.basis.module) {
15434
15521
  case "encoder":
15435
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
15522
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
15436
15523
  switch (options.basis.containerFormat) {
15437
15524
  case "ktx2":
15438
15525
  return parseKTX2File(fileConstructors.KTX2File, data, options);
@@ -15442,7 +15529,7 @@ var __exports__ = (() => {
15442
15529
  }
15443
15530
  case "transcoder":
15444
15531
  default:
15445
- const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
15532
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
15446
15533
  return parseBasisFile(BasisFile, data, options);
15447
15534
  }
15448
15535
  }
@@ -15474,7 +15561,7 @@ var __exports__ = (() => {
15474
15561
  const hasAlpha = basisFile.getHasAlpha(
15475
15562
  /* imageIndex, levelIndex */
15476
15563
  );
15477
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
15564
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
15478
15565
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
15479
15566
  const decodedData = new Uint8Array(decodedSize);
15480
15567
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
@@ -15482,11 +15569,13 @@ var __exports__ = (() => {
15482
15569
  }
15483
15570
  return {
15484
15571
  // standard loaders.gl image category payload
15572
+ shape: "texture-level",
15485
15573
  width,
15486
15574
  height,
15487
15575
  data: decodedData,
15488
15576
  compressed,
15489
- format,
15577
+ ...format !== void 0 ? { format } : {},
15578
+ ...textureFormat !== void 0 ? { textureFormat } : {},
15490
15579
  // Additional fields
15491
15580
  // Add levelSize field.
15492
15581
  hasAlpha
@@ -15511,7 +15600,7 @@ var __exports__ = (() => {
15511
15600
  }
15512
15601
  function transcodeKTX2Image(ktx2File, levelIndex, options) {
15513
15602
  const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
15514
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
15603
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
15515
15604
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
15516
15605
  levelIndex,
15517
15606
  0,
@@ -15534,48 +15623,98 @@ var __exports__ = (() => {
15534
15623
  }
15535
15624
  return {
15536
15625
  // standard loaders.gl image category payload
15626
+ shape: "texture-level",
15537
15627
  width,
15538
15628
  height,
15539
15629
  data: decodedData,
15540
15630
  compressed,
15631
+ ...format !== void 0 ? { format } : {},
15632
+ ...textureFormat !== void 0 ? { textureFormat } : {},
15541
15633
  // Additional fields
15542
15634
  levelSize: decodedSize,
15543
- hasAlpha: alphaFlag,
15544
- format
15635
+ hasAlpha: alphaFlag
15545
15636
  };
15546
15637
  }
15547
15638
  function getBasisOptions(options, hasAlpha) {
15548
- let format = options.basis?.format;
15639
+ let format = options.basis?.format || "auto";
15549
15640
  if (format === "auto") {
15550
- format = selectSupportedBasisFormat();
15641
+ format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
15551
15642
  }
15552
15643
  if (typeof format === "object") {
15553
15644
  format = hasAlpha ? format.alpha : format.noAlpha;
15554
15645
  }
15555
- format = format.toLowerCase();
15556
- return OutputFormat[format];
15646
+ const normalizedFormat = format.toLowerCase();
15647
+ const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
15648
+ if (!basisOutputOptions) {
15649
+ throw new Error(`Unknown Basis format ${format}`);
15650
+ }
15651
+ return basisOutputOptions;
15557
15652
  }
15558
- function selectSupportedBasisFormat() {
15559
- const supportedFormats = getSupportedGPUTextureFormats();
15560
- if (supportedFormats.has("astc")) {
15653
+ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
15654
+ const textureFormats2 = new Set(supportedTextureFormats);
15655
+ if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
15561
15656
  return "astc-4x4";
15562
- } else if (supportedFormats.has("dxt")) {
15657
+ } else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
15658
+ return {
15659
+ alpha: "bc7-m5",
15660
+ noAlpha: "bc7-m6-opaque-only"
15661
+ };
15662
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15663
+ "bc1-rgb-unorm-webgl",
15664
+ "bc1-rgb-unorm-srgb-webgl",
15665
+ "bc1-rgba-unorm",
15666
+ "bc1-rgba-unorm-srgb",
15667
+ "bc2-rgba-unorm",
15668
+ "bc2-rgba-unorm-srgb",
15669
+ "bc3-rgba-unorm",
15670
+ "bc3-rgba-unorm-srgb"
15671
+ ])) {
15563
15672
  return {
15564
15673
  alpha: "bc3",
15565
15674
  noAlpha: "bc1"
15566
15675
  };
15567
- } else if (supportedFormats.has("pvrtc")) {
15676
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15677
+ "pvrtc-rgb4unorm-webgl",
15678
+ "pvrtc-rgba4unorm-webgl",
15679
+ "pvrtc-rbg2unorm-webgl",
15680
+ "pvrtc-rgba2unorm-webgl"
15681
+ ])) {
15568
15682
  return {
15569
15683
  alpha: "pvrtc1-4-rgba",
15570
15684
  noAlpha: "pvrtc1-4-rgb"
15571
15685
  };
15572
- } else if (supportedFormats.has("etc1")) {
15573
- return "etc1";
15574
- } else if (supportedFormats.has("etc2")) {
15686
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15687
+ "etc2-rgb8unorm",
15688
+ "etc2-rgb8unorm-srgb",
15689
+ "etc2-rgb8a1unorm",
15690
+ "etc2-rgb8a1unorm-srgb",
15691
+ "etc2-rgba8unorm",
15692
+ "etc2-rgba8unorm-srgb",
15693
+ "eac-r11unorm",
15694
+ "eac-r11snorm",
15695
+ "eac-rg11unorm",
15696
+ "eac-rg11snorm"
15697
+ ])) {
15575
15698
  return "etc2";
15699
+ } else if (textureFormats2.has("etc1-rbg-unorm-webgl")) {
15700
+ return "etc1";
15701
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15702
+ "atc-rgb-unorm-webgl",
15703
+ "atc-rgba-unorm-webgl",
15704
+ "atc-rgbai-unorm-webgl"
15705
+ ])) {
15706
+ return {
15707
+ alpha: "atc-rgba-interpolated-alpha",
15708
+ noAlpha: "atc-rgb"
15709
+ };
15576
15710
  }
15577
15711
  return "rgb565";
15578
15712
  }
15713
+ function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
15714
+ return candidateTextureFormats.some(
15715
+ (textureFormat) => supportedTextureFormats.has(textureFormat)
15716
+ );
15717
+ }
15579
15718
 
15580
15719
  // ../textures/src/basis-loader.ts
15581
15720
  var BasisWorkerLoader = {
@@ -15593,7 +15732,6 @@ var __exports__ = (() => {
15593
15732
  options: {
15594
15733
  basis: {
15595
15734
  format: "auto",
15596
- libraryPath: "libs/",
15597
15735
  containerFormat: "auto",
15598
15736
  module: "transcoder"
15599
15737
  }
@@ -16904,8 +17042,7 @@ var __exports__ = (() => {
16904
17042
  const strictOptions = options;
16905
17043
  const gltfOptions = {
16906
17044
  ...strictOptions,
16907
- core: { ...strictOptions?.core, mimeType: image.mimeType },
16908
- basis: strictOptions.basis || { format: selectSupportedBasisFormat() }
17045
+ core: { ...strictOptions?.core, mimeType: image.mimeType }
16909
17046
  };
16910
17047
  let parsedImage = await parseFromContext(
16911
17048
  arrayBuffer,