@loaders.gl/gltf 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.
package/dist/dist.dev.js CHANGED
@@ -170,6 +170,16 @@ var __exports__ = (() => {
170
170
 
171
171
  // ../worker-utils/src/lib/library-utils/library-utils.ts
172
172
  var loadLibraryPromises = {};
173
+ function extractLoadLibraryOptions(options = {}) {
174
+ const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries;
175
+ const CDN = options.CDN ?? options.core?.CDN;
176
+ const modules = options.modules;
177
+ return {
178
+ ...useLocalLibraries !== void 0 ? { useLocalLibraries } : {},
179
+ ...CDN !== void 0 ? { CDN } : {},
180
+ ...modules !== void 0 ? { modules } : {}
181
+ };
182
+ }
173
183
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
174
184
  if (moduleName) {
175
185
  libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
@@ -2673,104 +2683,117 @@ var __exports__ = (() => {
2673
2683
  }
2674
2684
 
2675
2685
  // ../textures/src/lib/gl-extensions.ts
2676
- var GL_EXTENSIONS_CONSTANTS = {
2677
- // WEBGL_compressed_texture_s3tc
2678
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
2679
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
2680
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
2681
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
2682
- // WEBGL_compressed_texture_es3
2683
- COMPRESSED_R11_EAC: 37488,
2684
- COMPRESSED_SIGNED_R11_EAC: 37489,
2685
- COMPRESSED_RG11_EAC: 37490,
2686
- COMPRESSED_SIGNED_RG11_EAC: 37491,
2687
- COMPRESSED_RGB8_ETC2: 37492,
2688
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
2689
- COMPRESSED_SRGB8_ETC2: 37494,
2690
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
2691
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
2692
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
2693
- // WEBGL_compressed_texture_pvrtc
2694
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
2695
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
2696
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
2697
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
2698
- // WEBGL_compressed_texture_etc1
2699
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
2700
- // WEBGL_compressed_texture_atc
2701
- COMPRESSED_RGB_ATC_WEBGL: 35986,
2702
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
2703
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
2704
- // WEBGL_compressed_texture_astc
2705
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
2706
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
2707
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
2708
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
2709
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
2710
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
2711
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
2712
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
2713
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
2714
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
2715
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
2716
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
2717
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
2718
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
2719
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
2720
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
2721
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
2722
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
2723
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
2724
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
2725
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
2726
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
2727
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
2728
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
2729
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
2730
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
2731
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
2732
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
2733
- // EXT_texture_compression_rgtc
2734
- COMPRESSED_RED_RGTC1_EXT: 36283,
2735
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
2736
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
2737
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
2738
- // WEBGL_compressed_texture_s3tc_srgb
2739
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
2740
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
2741
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
2742
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
2743
- };
2686
+ var GL_RGBA4 = 32854;
2687
+ var GL_RGBA8 = 32856;
2688
+ var GL_RGB565 = 36194;
2689
+ var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
2690
+ var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
2691
+ var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
2692
+ var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
2693
+ var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
2694
+ var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
2695
+ var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
2696
+ var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
2697
+ var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
2698
+ var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
2699
+ var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
2700
+ var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
2744
2701
 
2745
- // ../textures/src/lib/utils/texture-formats.ts
2702
+ // ../textures/src/lib/utils/detect-supported-texture-formats.ts
2746
2703
  var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
2747
- var WEBGL_EXTENSIONS = {
2704
+ var WEBGL_TEXTURE_FORMATS = {
2748
2705
  /* eslint-disable camelcase */
2749
- WEBGL_compressed_texture_s3tc: "dxt",
2750
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
2751
- WEBGL_compressed_texture_etc1: "etc1",
2752
- WEBGL_compressed_texture_etc: "etc2",
2753
- WEBGL_compressed_texture_pvrtc: "pvrtc",
2754
- WEBGL_compressed_texture_atc: "atc",
2755
- WEBGL_compressed_texture_astc: "astc",
2756
- EXT_texture_compression_rgtc: "rgtc"
2706
+ WEBGL_compressed_texture_s3tc: [
2707
+ "bc1-rgb-unorm-webgl",
2708
+ "bc1-rgba-unorm",
2709
+ "bc2-rgba-unorm",
2710
+ "bc3-rgba-unorm"
2711
+ ],
2712
+ WEBGL_compressed_texture_s3tc_srgb: [
2713
+ "bc1-rgb-unorm-srgb-webgl",
2714
+ "bc1-rgba-unorm-srgb",
2715
+ "bc2-rgba-unorm-srgb",
2716
+ "bc3-rgba-unorm-srgb"
2717
+ ],
2718
+ EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
2719
+ EXT_texture_compression_bptc: [
2720
+ "bc6h-rgb-ufloat",
2721
+ "bc6h-rgb-float",
2722
+ "bc7-rgba-unorm",
2723
+ "bc7-rgba-unorm-srgb"
2724
+ ],
2725
+ WEBGL_compressed_texture_etc1: ["etc1-rbg-unorm-webgl"],
2726
+ WEBGL_compressed_texture_etc: [
2727
+ "etc2-rgb8unorm",
2728
+ "etc2-rgb8unorm-srgb",
2729
+ "etc2-rgb8a1unorm",
2730
+ "etc2-rgb8a1unorm-srgb",
2731
+ "etc2-rgba8unorm",
2732
+ "etc2-rgba8unorm-srgb",
2733
+ "eac-r11unorm",
2734
+ "eac-r11snorm",
2735
+ "eac-rg11unorm",
2736
+ "eac-rg11snorm"
2737
+ ],
2738
+ WEBGL_compressed_texture_pvrtc: [
2739
+ "pvrtc-rgb4unorm-webgl",
2740
+ "pvrtc-rgba4unorm-webgl",
2741
+ "pvrtc-rbg2unorm-webgl",
2742
+ "pvrtc-rgba2unorm-webgl"
2743
+ ],
2744
+ WEBGL_compressed_texture_atc: [
2745
+ "atc-rgb-unorm-webgl",
2746
+ "atc-rgba-unorm-webgl",
2747
+ "atc-rgbai-unorm-webgl"
2748
+ ],
2749
+ WEBGL_compressed_texture_astc: [
2750
+ "astc-4x4-unorm",
2751
+ "astc-4x4-unorm-srgb",
2752
+ "astc-5x4-unorm",
2753
+ "astc-5x4-unorm-srgb",
2754
+ "astc-5x5-unorm",
2755
+ "astc-5x5-unorm-srgb",
2756
+ "astc-6x5-unorm",
2757
+ "astc-6x5-unorm-srgb",
2758
+ "astc-6x6-unorm",
2759
+ "astc-6x6-unorm-srgb",
2760
+ "astc-8x5-unorm",
2761
+ "astc-8x5-unorm-srgb",
2762
+ "astc-8x6-unorm",
2763
+ "astc-8x6-unorm-srgb",
2764
+ "astc-8x8-unorm",
2765
+ "astc-8x8-unorm-srgb",
2766
+ "astc-10x5-unorm",
2767
+ "astc-10x5-unorm-srgb",
2768
+ "astc-10x6-unorm",
2769
+ "astc-10x6-unorm-srgb",
2770
+ "astc-10x8-unorm",
2771
+ "astc-10x8-unorm-srgb",
2772
+ "astc-10x10-unorm",
2773
+ "astc-10x10-unorm-srgb",
2774
+ "astc-12x10-unorm",
2775
+ "astc-12x10-unorm-srgb",
2776
+ "astc-12x12-unorm",
2777
+ "astc-12x12-unorm-srgb"
2778
+ ]
2757
2779
  /* eslint-enable camelcase */
2758
2780
  };
2759
- var formats = null;
2760
- function getSupportedGPUTextureFormats(gl) {
2761
- if (!formats) {
2781
+ var textureFormats = null;
2782
+ function detectSupportedTextureFormats(gl) {
2783
+ if (!textureFormats) {
2762
2784
  gl = gl || getWebGLContext() || void 0;
2763
- formats = /* @__PURE__ */ new Set();
2785
+ textureFormats = /* @__PURE__ */ new Set();
2764
2786
  for (const prefix of BROWSER_PREFIXES) {
2765
- for (const extension in WEBGL_EXTENSIONS) {
2787
+ for (const extension in WEBGL_TEXTURE_FORMATS) {
2766
2788
  if (gl && gl.getExtension(`${prefix}${extension}`)) {
2767
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
2768
- formats.add(gpuTextureFormat);
2789
+ for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
2790
+ textureFormats.add(textureFormat);
2791
+ }
2769
2792
  }
2770
2793
  }
2771
2794
  }
2772
2795
  }
2773
- return formats;
2796
+ return textureFormats;
2774
2797
  }
2775
2798
  function getWebGLContext() {
2776
2799
  try {
@@ -2815,61 +2838,126 @@ var __exports__ = (() => {
2815
2838
  }
2816
2839
 
2817
2840
  // ../textures/src/lib/parsers/parse-basis.ts
2818
- var OutputFormat = {
2841
+ var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
2819
2842
  etc1: {
2820
2843
  basisFormat: 0,
2821
2844
  compressed: true,
2822
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
2845
+ format: GL_COMPRESSED_RGB_ETC1_WEBGL,
2846
+ textureFormat: "etc1-rbg-unorm-webgl"
2847
+ },
2848
+ etc2: {
2849
+ basisFormat: 1,
2850
+ compressed: true,
2851
+ format: GL_COMPRESSED_RGBA8_ETC2_EAC,
2852
+ textureFormat: "etc2-rgba8unorm"
2823
2853
  },
2824
- etc2: { basisFormat: 1, compressed: true },
2825
2854
  bc1: {
2826
2855
  basisFormat: 2,
2827
2856
  compressed: true,
2828
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
2857
+ format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
2858
+ textureFormat: "bc1-rgb-unorm-webgl"
2829
2859
  },
2830
2860
  bc3: {
2831
2861
  basisFormat: 3,
2832
2862
  compressed: true,
2833
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
2863
+ format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
2864
+ textureFormat: "bc3-rgba-unorm"
2865
+ },
2866
+ bc4: {
2867
+ basisFormat: 4,
2868
+ compressed: true,
2869
+ format: GL_COMPRESSED_RED_RGTC1_EXT,
2870
+ textureFormat: "bc4-r-unorm"
2871
+ },
2872
+ bc5: {
2873
+ basisFormat: 5,
2874
+ compressed: true,
2875
+ format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
2876
+ textureFormat: "bc5-rg-unorm"
2877
+ },
2878
+ "bc7-m6-opaque-only": {
2879
+ basisFormat: 6,
2880
+ compressed: true,
2881
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
2882
+ textureFormat: "bc7-rgba-unorm"
2883
+ },
2884
+ "bc7-m5": {
2885
+ basisFormat: 7,
2886
+ compressed: true,
2887
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
2888
+ textureFormat: "bc7-rgba-unorm"
2834
2889
  },
2835
- bc4: { basisFormat: 4, compressed: true },
2836
- bc5: { basisFormat: 5, compressed: true },
2837
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
2838
- "bc7-m5": { basisFormat: 7, compressed: true },
2839
2890
  "pvrtc1-4-rgb": {
2840
2891
  basisFormat: 8,
2841
2892
  compressed: true,
2842
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
2893
+ format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
2894
+ textureFormat: "pvrtc-rgb4unorm-webgl"
2843
2895
  },
2844
2896
  "pvrtc1-4-rgba": {
2845
2897
  basisFormat: 9,
2846
2898
  compressed: true,
2847
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
2899
+ format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
2900
+ textureFormat: "pvrtc-rgba4unorm-webgl"
2848
2901
  },
2849
2902
  "astc-4x4": {
2850
2903
  basisFormat: 10,
2851
2904
  compressed: true,
2852
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
2905
+ format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
2906
+ textureFormat: "astc-4x4-unorm"
2907
+ },
2908
+ "atc-rgb": {
2909
+ basisFormat: 11,
2910
+ compressed: true,
2911
+ format: GL_COMPRESSED_RGB_ATC_WEBGL,
2912
+ textureFormat: "atc-rgb-unorm-webgl"
2853
2913
  },
2854
- "atc-rgb": { basisFormat: 11, compressed: true },
2855
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
2856
- rgba32: { basisFormat: 13, compressed: false },
2857
- rgb565: { basisFormat: 14, compressed: false },
2858
- bgr565: { basisFormat: 15, compressed: false },
2859
- rgba4444: { basisFormat: 16, compressed: false }
2914
+ "atc-rgba-interpolated-alpha": {
2915
+ basisFormat: 12,
2916
+ compressed: true,
2917
+ format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
2918
+ textureFormat: "atc-rgbai-unorm-webgl"
2919
+ },
2920
+ rgba32: {
2921
+ basisFormat: 13,
2922
+ compressed: false,
2923
+ format: GL_RGBA8,
2924
+ textureFormat: "rgba8unorm"
2925
+ },
2926
+ rgb565: {
2927
+ basisFormat: 14,
2928
+ compressed: false,
2929
+ format: GL_RGB565,
2930
+ textureFormat: "rgb565unorm-webgl"
2931
+ },
2932
+ bgr565: {
2933
+ basisFormat: 15,
2934
+ compressed: false,
2935
+ format: GL_RGB565,
2936
+ textureFormat: "rgb565unorm-webgl"
2937
+ },
2938
+ rgba4444: {
2939
+ basisFormat: 16,
2940
+ compressed: false,
2941
+ format: GL_RGBA4,
2942
+ textureFormat: "rgba4unorm-webgl"
2943
+ }
2860
2944
  };
2945
+ var BASIS_FORMATS = Object.freeze(
2946
+ Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
2947
+ );
2861
2948
  async function parseBasis(data, options = {}) {
2949
+ const loadLibraryOptions = extractLoadLibraryOptions(options);
2862
2950
  if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
2863
2951
  if (isKTX(data)) {
2864
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
2952
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2865
2953
  return parseKTX2File(fileConstructors.KTX2File, data, options);
2866
2954
  }
2867
- const { BasisFile } = await loadBasisTranscoderModule(options?.core || {});
2955
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
2868
2956
  return parseBasisFile(BasisFile, data, options);
2869
2957
  }
2870
2958
  switch (options.basis.module) {
2871
2959
  case "encoder":
2872
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
2960
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2873
2961
  switch (options.basis.containerFormat) {
2874
2962
  case "ktx2":
2875
2963
  return parseKTX2File(fileConstructors.KTX2File, data, options);
@@ -2879,7 +2967,7 @@ var __exports__ = (() => {
2879
2967
  }
2880
2968
  case "transcoder":
2881
2969
  default:
2882
- const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
2970
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
2883
2971
  return parseBasisFile(BasisFile, data, options);
2884
2972
  }
2885
2973
  }
@@ -2911,7 +2999,7 @@ var __exports__ = (() => {
2911
2999
  const hasAlpha = basisFile.getHasAlpha(
2912
3000
  /* imageIndex, levelIndex */
2913
3001
  );
2914
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
3002
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
2915
3003
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
2916
3004
  const decodedData = new Uint8Array(decodedSize);
2917
3005
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
@@ -2919,11 +3007,13 @@ var __exports__ = (() => {
2919
3007
  }
2920
3008
  return {
2921
3009
  // standard loaders.gl image category payload
3010
+ shape: "texture-level",
2922
3011
  width,
2923
3012
  height,
2924
3013
  data: decodedData,
2925
3014
  compressed,
2926
- format,
3015
+ ...format !== void 0 ? { format } : {},
3016
+ ...textureFormat !== void 0 ? { textureFormat } : {},
2927
3017
  // Additional fields
2928
3018
  // Add levelSize field.
2929
3019
  hasAlpha
@@ -2948,7 +3038,7 @@ var __exports__ = (() => {
2948
3038
  }
2949
3039
  function transcodeKTX2Image(ktx2File, levelIndex, options) {
2950
3040
  const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
2951
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
3041
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
2952
3042
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
2953
3043
  levelIndex,
2954
3044
  0,
@@ -2971,48 +3061,98 @@ var __exports__ = (() => {
2971
3061
  }
2972
3062
  return {
2973
3063
  // standard loaders.gl image category payload
3064
+ shape: "texture-level",
2974
3065
  width,
2975
3066
  height,
2976
3067
  data: decodedData,
2977
3068
  compressed,
3069
+ ...format !== void 0 ? { format } : {},
3070
+ ...textureFormat !== void 0 ? { textureFormat } : {},
2978
3071
  // Additional fields
2979
3072
  levelSize: decodedSize,
2980
- hasAlpha: alphaFlag,
2981
- format
3073
+ hasAlpha: alphaFlag
2982
3074
  };
2983
3075
  }
2984
3076
  function getBasisOptions(options, hasAlpha) {
2985
- let format = options.basis?.format;
3077
+ let format = options.basis?.format || "auto";
2986
3078
  if (format === "auto") {
2987
- format = selectSupportedBasisFormat();
3079
+ format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
2988
3080
  }
2989
3081
  if (typeof format === "object") {
2990
3082
  format = hasAlpha ? format.alpha : format.noAlpha;
2991
3083
  }
2992
- format = format.toLowerCase();
2993
- return OutputFormat[format];
3084
+ const normalizedFormat = format.toLowerCase();
3085
+ const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
3086
+ if (!basisOutputOptions) {
3087
+ throw new Error(`Unknown Basis format ${format}`);
3088
+ }
3089
+ return basisOutputOptions;
2994
3090
  }
2995
- function selectSupportedBasisFormat() {
2996
- const supportedFormats = getSupportedGPUTextureFormats();
2997
- if (supportedFormats.has("astc")) {
3091
+ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
3092
+ const textureFormats2 = new Set(supportedTextureFormats);
3093
+ if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
2998
3094
  return "astc-4x4";
2999
- } else if (supportedFormats.has("dxt")) {
3095
+ } else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
3096
+ return {
3097
+ alpha: "bc7-m5",
3098
+ noAlpha: "bc7-m6-opaque-only"
3099
+ };
3100
+ } else if (hasSupportedTextureFormat(textureFormats2, [
3101
+ "bc1-rgb-unorm-webgl",
3102
+ "bc1-rgb-unorm-srgb-webgl",
3103
+ "bc1-rgba-unorm",
3104
+ "bc1-rgba-unorm-srgb",
3105
+ "bc2-rgba-unorm",
3106
+ "bc2-rgba-unorm-srgb",
3107
+ "bc3-rgba-unorm",
3108
+ "bc3-rgba-unorm-srgb"
3109
+ ])) {
3000
3110
  return {
3001
3111
  alpha: "bc3",
3002
3112
  noAlpha: "bc1"
3003
3113
  };
3004
- } else if (supportedFormats.has("pvrtc")) {
3114
+ } else if (hasSupportedTextureFormat(textureFormats2, [
3115
+ "pvrtc-rgb4unorm-webgl",
3116
+ "pvrtc-rgba4unorm-webgl",
3117
+ "pvrtc-rbg2unorm-webgl",
3118
+ "pvrtc-rgba2unorm-webgl"
3119
+ ])) {
3005
3120
  return {
3006
3121
  alpha: "pvrtc1-4-rgba",
3007
3122
  noAlpha: "pvrtc1-4-rgb"
3008
3123
  };
3009
- } else if (supportedFormats.has("etc1")) {
3010
- return "etc1";
3011
- } else if (supportedFormats.has("etc2")) {
3124
+ } else if (hasSupportedTextureFormat(textureFormats2, [
3125
+ "etc2-rgb8unorm",
3126
+ "etc2-rgb8unorm-srgb",
3127
+ "etc2-rgb8a1unorm",
3128
+ "etc2-rgb8a1unorm-srgb",
3129
+ "etc2-rgba8unorm",
3130
+ "etc2-rgba8unorm-srgb",
3131
+ "eac-r11unorm",
3132
+ "eac-r11snorm",
3133
+ "eac-rg11unorm",
3134
+ "eac-rg11snorm"
3135
+ ])) {
3012
3136
  return "etc2";
3137
+ } else if (textureFormats2.has("etc1-rbg-unorm-webgl")) {
3138
+ return "etc1";
3139
+ } else if (hasSupportedTextureFormat(textureFormats2, [
3140
+ "atc-rgb-unorm-webgl",
3141
+ "atc-rgba-unorm-webgl",
3142
+ "atc-rgbai-unorm-webgl"
3143
+ ])) {
3144
+ return {
3145
+ alpha: "atc-rgba-interpolated-alpha",
3146
+ noAlpha: "atc-rgb"
3147
+ };
3013
3148
  }
3014
3149
  return "rgb565";
3015
3150
  }
3151
+ function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
3152
+ return candidateTextureFormats.some(
3153
+ (textureFormat) => supportedTextureFormats.has(textureFormat)
3154
+ );
3155
+ }
3016
3156
 
3017
3157
  // ../textures/src/basis-loader.ts
3018
3158
  var BasisWorkerLoader = {
@@ -3030,7 +3170,6 @@ var __exports__ = (() => {
3030
3170
  options: {
3031
3171
  basis: {
3032
3172
  format: "auto",
3033
- libraryPath: "libs/",
3034
3173
  containerFormat: "auto",
3035
3174
  module: "transcoder"
3036
3175
  }
@@ -4186,7 +4325,6 @@ var __exports__ = (() => {
4186
4325
  draco: {
4187
4326
  decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
4188
4327
  // 'js' for IE11
4189
- libraryPath: "libs/",
4190
4328
  extraAttributes: {},
4191
4329
  attributeNameEntry: void 0
4192
4330
  }
@@ -4198,7 +4336,7 @@ var __exports__ = (() => {
4198
4336
  };
4199
4337
  async function parse(arrayBuffer, options) {
4200
4338
  const { draco } = await loadDracoDecoderModule(
4201
- options?.core,
4339
+ extractLoadLibraryOptions(options),
4202
4340
  options?.draco?.decoderType || "wasm"
4203
4341
  );
4204
4342
  const dracoParser = new DracoParser(draco);
@@ -6301,8 +6439,7 @@ var __exports__ = (() => {
6301
6439
  const strictOptions = options;
6302
6440
  const gltfOptions = {
6303
6441
  ...strictOptions,
6304
- core: { ...strictOptions?.core, mimeType: image.mimeType },
6305
- basis: strictOptions.basis || { format: selectSupportedBasisFormat() }
6442
+ core: { ...strictOptions?.core, mimeType: image.mimeType }
6306
6443
  };
6307
6444
  let parsedImage = await parseFromContext(
6308
6445
  arrayBuffer,