@loaders.gl/gltf 4.4.0-alpha.9 → 4.4.0
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 +318 -155
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +20 -11
- package/dist/index.cjs.map +2 -2
- package/dist/lib/gltf-utils/get-typed-array.d.ts +2 -2
- package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -1
- package/dist/lib/gltf-utils/resolve-url.d.ts +2 -1
- package/dist/lib/gltf-utils/resolve-url.d.ts.map +1 -1
- package/dist/lib/gltf-utils/resolve-url.js +14 -4
- package/dist/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/lib/parsers/parse-gltf.js +6 -7
- package/dist/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/lib/utils/version.js +1 -1
- package/dist/lib/utils/version.js.map +1 -1
- package/package.json +7 -7
- package/src/lib/gltf-utils/resolve-url.ts +19 -4
- package/src/lib/parsers/parse-gltf.ts +6 -7
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
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
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
|
|
2704
|
+
var WEBGL_TEXTURE_FORMATS = {
|
|
2748
2705
|
/* eslint-disable camelcase */
|
|
2749
|
-
WEBGL_compressed_texture_s3tc:
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
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-rgb-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-rgb2unorm-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
|
|
2760
|
-
function
|
|
2761
|
-
if (!
|
|
2781
|
+
var textureFormats = null;
|
|
2782
|
+
function detectSupportedTextureFormats(gl) {
|
|
2783
|
+
if (!textureFormats) {
|
|
2762
2784
|
gl = gl || getWebGLContext() || void 0;
|
|
2763
|
-
|
|
2785
|
+
textureFormats = /* @__PURE__ */ new Set();
|
|
2764
2786
|
for (const prefix of BROWSER_PREFIXES) {
|
|
2765
|
-
for (const extension in
|
|
2787
|
+
for (const extension in WEBGL_TEXTURE_FORMATS) {
|
|
2766
2788
|
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
2767
|
-
const
|
|
2768
|
-
|
|
2789
|
+
for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
|
|
2790
|
+
textureFormats.add(textureFormat);
|
|
2791
|
+
}
|
|
2769
2792
|
}
|
|
2770
2793
|
}
|
|
2771
2794
|
}
|
|
2772
2795
|
}
|
|
2773
|
-
return
|
|
2796
|
+
return textureFormats;
|
|
2774
2797
|
}
|
|
2775
2798
|
function getWebGLContext() {
|
|
2776
2799
|
try {
|
|
@@ -2815,73 +2838,154 @@ var __exports__ = (() => {
|
|
|
2815
2838
|
}
|
|
2816
2839
|
|
|
2817
2840
|
// ../textures/src/lib/parsers/parse-basis.ts
|
|
2818
|
-
var
|
|
2841
|
+
var basisTranscodingLock = Promise.resolve();
|
|
2842
|
+
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
2819
2843
|
etc1: {
|
|
2820
2844
|
basisFormat: 0,
|
|
2821
2845
|
compressed: true,
|
|
2822
|
-
format:
|
|
2846
|
+
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
2847
|
+
textureFormat: "etc1-rgb-unorm-webgl"
|
|
2848
|
+
},
|
|
2849
|
+
etc2: {
|
|
2850
|
+
basisFormat: 1,
|
|
2851
|
+
compressed: true,
|
|
2852
|
+
format: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
2853
|
+
textureFormat: "etc2-rgba8unorm"
|
|
2823
2854
|
},
|
|
2824
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
2825
2855
|
bc1: {
|
|
2826
2856
|
basisFormat: 2,
|
|
2827
2857
|
compressed: true,
|
|
2828
|
-
format:
|
|
2858
|
+
format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
2859
|
+
textureFormat: "bc1-rgb-unorm-webgl"
|
|
2829
2860
|
},
|
|
2830
2861
|
bc3: {
|
|
2831
2862
|
basisFormat: 3,
|
|
2832
2863
|
compressed: true,
|
|
2833
|
-
format:
|
|
2864
|
+
format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
2865
|
+
textureFormat: "bc3-rgba-unorm"
|
|
2866
|
+
},
|
|
2867
|
+
bc4: {
|
|
2868
|
+
basisFormat: 4,
|
|
2869
|
+
compressed: true,
|
|
2870
|
+
format: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
2871
|
+
textureFormat: "bc4-r-unorm"
|
|
2872
|
+
},
|
|
2873
|
+
bc5: {
|
|
2874
|
+
basisFormat: 5,
|
|
2875
|
+
compressed: true,
|
|
2876
|
+
format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
2877
|
+
textureFormat: "bc5-rg-unorm"
|
|
2878
|
+
},
|
|
2879
|
+
"bc7-m6-opaque-only": {
|
|
2880
|
+
basisFormat: 6,
|
|
2881
|
+
compressed: true,
|
|
2882
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
2883
|
+
textureFormat: "bc7-rgba-unorm"
|
|
2884
|
+
},
|
|
2885
|
+
"bc7-m5": {
|
|
2886
|
+
basisFormat: 7,
|
|
2887
|
+
compressed: true,
|
|
2888
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
2889
|
+
textureFormat: "bc7-rgba-unorm"
|
|
2834
2890
|
},
|
|
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
2891
|
"pvrtc1-4-rgb": {
|
|
2840
2892
|
basisFormat: 8,
|
|
2841
2893
|
compressed: true,
|
|
2842
|
-
format:
|
|
2894
|
+
format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
2895
|
+
textureFormat: "pvrtc-rgb4unorm-webgl"
|
|
2843
2896
|
},
|
|
2844
2897
|
"pvrtc1-4-rgba": {
|
|
2845
2898
|
basisFormat: 9,
|
|
2846
2899
|
compressed: true,
|
|
2847
|
-
format:
|
|
2900
|
+
format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
2901
|
+
textureFormat: "pvrtc-rgba4unorm-webgl"
|
|
2848
2902
|
},
|
|
2849
2903
|
"astc-4x4": {
|
|
2850
2904
|
basisFormat: 10,
|
|
2851
2905
|
compressed: true,
|
|
2852
|
-
format:
|
|
2906
|
+
format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
2907
|
+
textureFormat: "astc-4x4-unorm"
|
|
2908
|
+
},
|
|
2909
|
+
"atc-rgb": {
|
|
2910
|
+
basisFormat: 11,
|
|
2911
|
+
compressed: true,
|
|
2912
|
+
format: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
2913
|
+
textureFormat: "atc-rgb-unorm-webgl"
|
|
2914
|
+
},
|
|
2915
|
+
"atc-rgba-interpolated-alpha": {
|
|
2916
|
+
basisFormat: 12,
|
|
2917
|
+
compressed: true,
|
|
2918
|
+
format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
2919
|
+
textureFormat: "atc-rgbai-unorm-webgl"
|
|
2853
2920
|
},
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2921
|
+
rgba32: {
|
|
2922
|
+
basisFormat: 13,
|
|
2923
|
+
compressed: false,
|
|
2924
|
+
format: GL_RGBA8,
|
|
2925
|
+
textureFormat: "rgba8unorm"
|
|
2926
|
+
},
|
|
2927
|
+
rgb565: {
|
|
2928
|
+
basisFormat: 14,
|
|
2929
|
+
compressed: false,
|
|
2930
|
+
format: GL_RGB565,
|
|
2931
|
+
textureFormat: "rgb565unorm-webgl"
|
|
2932
|
+
},
|
|
2933
|
+
bgr565: {
|
|
2934
|
+
basisFormat: 15,
|
|
2935
|
+
compressed: false,
|
|
2936
|
+
format: GL_RGB565,
|
|
2937
|
+
textureFormat: "rgb565unorm-webgl"
|
|
2938
|
+
},
|
|
2939
|
+
rgba4444: {
|
|
2940
|
+
basisFormat: 16,
|
|
2941
|
+
compressed: false,
|
|
2942
|
+
format: GL_RGBA4,
|
|
2943
|
+
textureFormat: "rgba4unorm-webgl"
|
|
2944
|
+
}
|
|
2860
2945
|
};
|
|
2946
|
+
var BASIS_FORMATS = Object.freeze(
|
|
2947
|
+
Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
|
|
2948
|
+
);
|
|
2949
|
+
async function withBasisTranscodingLock(transcode) {
|
|
2950
|
+
const previousLock = basisTranscodingLock;
|
|
2951
|
+
let releaseLock;
|
|
2952
|
+
basisTranscodingLock = new Promise((resolve) => {
|
|
2953
|
+
releaseLock = resolve;
|
|
2954
|
+
});
|
|
2955
|
+
await previousLock;
|
|
2956
|
+
try {
|
|
2957
|
+
return await transcode();
|
|
2958
|
+
} finally {
|
|
2959
|
+
releaseLock();
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2861
2962
|
async function parseBasis(data, options = {}) {
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
return parseBasisFile(BasisFile, data, options);
|
|
2869
|
-
}
|
|
2870
|
-
switch (options.basis.module) {
|
|
2871
|
-
case "encoder":
|
|
2872
|
-
const fileConstructors = await loadBasisEncoderModule(options?.core || {});
|
|
2873
|
-
switch (options.basis.containerFormat) {
|
|
2874
|
-
case "ktx2":
|
|
2875
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2876
|
-
case "basis":
|
|
2877
|
-
default:
|
|
2878
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
2963
|
+
const loadLibraryOptions = extractLoadLibraryOptions(options);
|
|
2964
|
+
return await withBasisTranscodingLock(async () => {
|
|
2965
|
+
if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
|
|
2966
|
+
if (isKTX(data)) {
|
|
2967
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
2968
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2879
2969
|
}
|
|
2880
|
-
|
|
2881
|
-
default:
|
|
2882
|
-
const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
|
|
2970
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
2883
2971
|
return parseBasisFile(BasisFile, data, options);
|
|
2884
|
-
|
|
2972
|
+
}
|
|
2973
|
+
switch (options.basis.module) {
|
|
2974
|
+
case "encoder":
|
|
2975
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
2976
|
+
switch (options.basis.containerFormat) {
|
|
2977
|
+
case "ktx2":
|
|
2978
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2979
|
+
case "basis":
|
|
2980
|
+
default:
|
|
2981
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
2982
|
+
}
|
|
2983
|
+
case "transcoder":
|
|
2984
|
+
default:
|
|
2985
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
2986
|
+
return parseBasisFile(BasisFile, data, options);
|
|
2987
|
+
}
|
|
2988
|
+
});
|
|
2885
2989
|
}
|
|
2886
2990
|
function parseBasisFile(BasisFile, data, options) {
|
|
2887
2991
|
const basisFile = new BasisFile(new Uint8Array(data));
|
|
@@ -2911,7 +3015,7 @@ var __exports__ = (() => {
|
|
|
2911
3015
|
const hasAlpha = basisFile.getHasAlpha(
|
|
2912
3016
|
/* imageIndex, levelIndex */
|
|
2913
3017
|
);
|
|
2914
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
3018
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
|
|
2915
3019
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
2916
3020
|
const decodedData = new Uint8Array(decodedSize);
|
|
2917
3021
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
@@ -2919,11 +3023,13 @@ var __exports__ = (() => {
|
|
|
2919
3023
|
}
|
|
2920
3024
|
return {
|
|
2921
3025
|
// standard loaders.gl image category payload
|
|
3026
|
+
shape: "texture-level",
|
|
2922
3027
|
width,
|
|
2923
3028
|
height,
|
|
2924
3029
|
data: decodedData,
|
|
2925
3030
|
compressed,
|
|
2926
|
-
format,
|
|
3031
|
+
...format !== void 0 ? { format } : {},
|
|
3032
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
2927
3033
|
// Additional fields
|
|
2928
3034
|
// Add levelSize field.
|
|
2929
3035
|
hasAlpha
|
|
@@ -2948,7 +3054,7 @@ var __exports__ = (() => {
|
|
|
2948
3054
|
}
|
|
2949
3055
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
2950
3056
|
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
2951
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
3057
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
|
|
2952
3058
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
|
|
2953
3059
|
levelIndex,
|
|
2954
3060
|
0,
|
|
@@ -2971,48 +3077,98 @@ var __exports__ = (() => {
|
|
|
2971
3077
|
}
|
|
2972
3078
|
return {
|
|
2973
3079
|
// standard loaders.gl image category payload
|
|
3080
|
+
shape: "texture-level",
|
|
2974
3081
|
width,
|
|
2975
3082
|
height,
|
|
2976
3083
|
data: decodedData,
|
|
2977
3084
|
compressed,
|
|
3085
|
+
...format !== void 0 ? { format } : {},
|
|
3086
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
2978
3087
|
// Additional fields
|
|
2979
3088
|
levelSize: decodedSize,
|
|
2980
|
-
hasAlpha: alphaFlag
|
|
2981
|
-
format
|
|
3089
|
+
hasAlpha: alphaFlag
|
|
2982
3090
|
};
|
|
2983
3091
|
}
|
|
2984
3092
|
function getBasisOptions(options, hasAlpha) {
|
|
2985
|
-
let format = options.basis?.format;
|
|
3093
|
+
let format = options.basis?.format || "auto";
|
|
2986
3094
|
if (format === "auto") {
|
|
2987
|
-
format = selectSupportedBasisFormat();
|
|
3095
|
+
format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
|
|
2988
3096
|
}
|
|
2989
3097
|
if (typeof format === "object") {
|
|
2990
3098
|
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
2991
3099
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
3100
|
+
const normalizedFormat = format.toLowerCase();
|
|
3101
|
+
const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
|
|
3102
|
+
if (!basisOutputOptions) {
|
|
3103
|
+
throw new Error(`Unknown Basis format ${format}`);
|
|
3104
|
+
}
|
|
3105
|
+
return basisOutputOptions;
|
|
2994
3106
|
}
|
|
2995
|
-
function selectSupportedBasisFormat() {
|
|
2996
|
-
const
|
|
2997
|
-
if (
|
|
3107
|
+
function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
|
|
3108
|
+
const textureFormats2 = new Set(supportedTextureFormats);
|
|
3109
|
+
if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
|
|
2998
3110
|
return "astc-4x4";
|
|
2999
|
-
} else if (
|
|
3111
|
+
} else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
|
|
3112
|
+
return {
|
|
3113
|
+
alpha: "bc7-m5",
|
|
3114
|
+
noAlpha: "bc7-m6-opaque-only"
|
|
3115
|
+
};
|
|
3116
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
3117
|
+
"bc1-rgb-unorm-webgl",
|
|
3118
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
3119
|
+
"bc1-rgba-unorm",
|
|
3120
|
+
"bc1-rgba-unorm-srgb",
|
|
3121
|
+
"bc2-rgba-unorm",
|
|
3122
|
+
"bc2-rgba-unorm-srgb",
|
|
3123
|
+
"bc3-rgba-unorm",
|
|
3124
|
+
"bc3-rgba-unorm-srgb"
|
|
3125
|
+
])) {
|
|
3000
3126
|
return {
|
|
3001
3127
|
alpha: "bc3",
|
|
3002
3128
|
noAlpha: "bc1"
|
|
3003
3129
|
};
|
|
3004
|
-
} else if (
|
|
3130
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
3131
|
+
"pvrtc-rgb4unorm-webgl",
|
|
3132
|
+
"pvrtc-rgba4unorm-webgl",
|
|
3133
|
+
"pvrtc-rgb2unorm-webgl",
|
|
3134
|
+
"pvrtc-rgba2unorm-webgl"
|
|
3135
|
+
])) {
|
|
3005
3136
|
return {
|
|
3006
3137
|
alpha: "pvrtc1-4-rgba",
|
|
3007
3138
|
noAlpha: "pvrtc1-4-rgb"
|
|
3008
3139
|
};
|
|
3009
|
-
} else if (
|
|
3010
|
-
|
|
3011
|
-
|
|
3140
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
3141
|
+
"etc2-rgb8unorm",
|
|
3142
|
+
"etc2-rgb8unorm-srgb",
|
|
3143
|
+
"etc2-rgb8a1unorm",
|
|
3144
|
+
"etc2-rgb8a1unorm-srgb",
|
|
3145
|
+
"etc2-rgba8unorm",
|
|
3146
|
+
"etc2-rgba8unorm-srgb",
|
|
3147
|
+
"eac-r11unorm",
|
|
3148
|
+
"eac-r11snorm",
|
|
3149
|
+
"eac-rg11unorm",
|
|
3150
|
+
"eac-rg11snorm"
|
|
3151
|
+
])) {
|
|
3012
3152
|
return "etc2";
|
|
3153
|
+
} else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
|
|
3154
|
+
return "etc1";
|
|
3155
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
3156
|
+
"atc-rgb-unorm-webgl",
|
|
3157
|
+
"atc-rgba-unorm-webgl",
|
|
3158
|
+
"atc-rgbai-unorm-webgl"
|
|
3159
|
+
])) {
|
|
3160
|
+
return {
|
|
3161
|
+
alpha: "atc-rgba-interpolated-alpha",
|
|
3162
|
+
noAlpha: "atc-rgb"
|
|
3163
|
+
};
|
|
3013
3164
|
}
|
|
3014
3165
|
return "rgb565";
|
|
3015
3166
|
}
|
|
3167
|
+
function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
|
|
3168
|
+
return candidateTextureFormats.some(
|
|
3169
|
+
(textureFormat) => supportedTextureFormats.has(textureFormat)
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3016
3172
|
|
|
3017
3173
|
// ../textures/src/basis-loader.ts
|
|
3018
3174
|
var BasisWorkerLoader = {
|
|
@@ -3030,7 +3186,6 @@ var __exports__ = (() => {
|
|
|
3030
3186
|
options: {
|
|
3031
3187
|
basis: {
|
|
3032
3188
|
format: "auto",
|
|
3033
|
-
libraryPath: "libs/",
|
|
3034
3189
|
containerFormat: "auto",
|
|
3035
3190
|
module: "transcoder"
|
|
3036
3191
|
}
|
|
@@ -3152,16 +3307,26 @@ var __exports__ = (() => {
|
|
|
3152
3307
|
}
|
|
3153
3308
|
|
|
3154
3309
|
// src/lib/gltf-utils/resolve-url.ts
|
|
3155
|
-
function resolveUrl(url, options) {
|
|
3310
|
+
function resolveUrl(url, options, context) {
|
|
3156
3311
|
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
3157
3312
|
if (absolute) {
|
|
3158
3313
|
return url;
|
|
3159
3314
|
}
|
|
3160
|
-
const baseUrl =
|
|
3315
|
+
const baseUrl = context?.baseUrl || getResolveBaseUrl(options?.core?.baseUrl);
|
|
3316
|
+
if (!baseUrl) {
|
|
3317
|
+
throw new Error(`'baseUrl' must be provided to resolve relative url ${url}`);
|
|
3318
|
+
}
|
|
3319
|
+
return baseUrl.endsWith("/") ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
3320
|
+
}
|
|
3321
|
+
function getResolveBaseUrl(baseUrl) {
|
|
3161
3322
|
if (!baseUrl) {
|
|
3162
|
-
|
|
3323
|
+
return void 0;
|
|
3324
|
+
}
|
|
3325
|
+
if (baseUrl.endsWith("/")) {
|
|
3326
|
+
return baseUrl;
|
|
3163
3327
|
}
|
|
3164
|
-
|
|
3328
|
+
const slashIndex = baseUrl.lastIndexOf("/");
|
|
3329
|
+
return slashIndex >= 0 ? baseUrl.slice(0, slashIndex + 1) : "";
|
|
3165
3330
|
}
|
|
3166
3331
|
|
|
3167
3332
|
// src/lib/extensions/EXT_meshopt_compression.ts
|
|
@@ -4186,7 +4351,6 @@ var __exports__ = (() => {
|
|
|
4186
4351
|
draco: {
|
|
4187
4352
|
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
4188
4353
|
// 'js' for IE11
|
|
4189
|
-
libraryPath: "libs/",
|
|
4190
4354
|
extraAttributes: {},
|
|
4191
4355
|
attributeNameEntry: void 0
|
|
4192
4356
|
}
|
|
@@ -4198,7 +4362,7 @@ var __exports__ = (() => {
|
|
|
4198
4362
|
};
|
|
4199
4363
|
async function parse(arrayBuffer, options) {
|
|
4200
4364
|
const { draco } = await loadDracoDecoderModule(
|
|
4201
|
-
options
|
|
4365
|
+
extractLoadLibraryOptions(options),
|
|
4202
4366
|
options?.draco?.decoderType || "wasm"
|
|
4203
4367
|
);
|
|
4204
4368
|
const dracoParser = new DracoParser(draco);
|
|
@@ -6207,8 +6371,8 @@ var __exports__ = (() => {
|
|
|
6207
6371
|
return gltf;
|
|
6208
6372
|
}
|
|
6209
6373
|
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
6210
|
-
if (options.core?.
|
|
6211
|
-
gltf.baseUri = options.core?.
|
|
6374
|
+
if (options.core?.baseUrl) {
|
|
6375
|
+
gltf.baseUri = options.core?.baseUrl;
|
|
6212
6376
|
}
|
|
6213
6377
|
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
6214
6378
|
const textDecoder = new TextDecoder();
|
|
@@ -6245,7 +6409,7 @@ var __exports__ = (() => {
|
|
|
6245
6409
|
if (buffer.uri) {
|
|
6246
6410
|
const { fetch: fetch2 } = context;
|
|
6247
6411
|
assert3(fetch2);
|
|
6248
|
-
const uri = resolveUrl(buffer.uri, options);
|
|
6412
|
+
const uri = resolveUrl(buffer.uri, options, context);
|
|
6249
6413
|
const response = await context?.fetch?.(uri);
|
|
6250
6414
|
const arrayBuffer = await response?.arrayBuffer?.();
|
|
6251
6415
|
gltf.buffers[i] = {
|
|
@@ -6285,7 +6449,7 @@ var __exports__ = (() => {
|
|
|
6285
6449
|
async function loadImage(gltf, image, index, options, context) {
|
|
6286
6450
|
let arrayBuffer;
|
|
6287
6451
|
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
6288
|
-
const uri = resolveUrl(image.uri, options);
|
|
6452
|
+
const uri = resolveUrl(image.uri, options, context);
|
|
6289
6453
|
const { fetch: fetch2 } = context;
|
|
6290
6454
|
const response = await fetch2(uri);
|
|
6291
6455
|
arrayBuffer = await response.arrayBuffer();
|
|
@@ -6301,8 +6465,7 @@ var __exports__ = (() => {
|
|
|
6301
6465
|
const strictOptions = options;
|
|
6302
6466
|
const gltfOptions = {
|
|
6303
6467
|
...strictOptions,
|
|
6304
|
-
core: { ...strictOptions?.core, mimeType: image.mimeType }
|
|
6305
|
-
basis: strictOptions.basis || { format: selectSupportedBasisFormat() }
|
|
6468
|
+
core: { ...strictOptions?.core, mimeType: image.mimeType }
|
|
6306
6469
|
};
|
|
6307
6470
|
let parsedImage = await parseFromContext(
|
|
6308
6471
|
arrayBuffer,
|