@loaders.gl/textures 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/README.md +197 -1
- package/dist/basis-loader.d.ts +15 -10
- package/dist/basis-loader.d.ts.map +1 -1
- package/dist/basis-loader.js +0 -1
- package/dist/basis-loader.js.map +1 -1
- package/dist/basis-worker-node.js +797 -9971
- package/dist/basis-worker.js +300 -145
- package/dist/compressed-texture-loader.d.ts +0 -4
- package/dist/compressed-texture-loader.d.ts.map +1 -1
- package/dist/compressed-texture-loader.js +0 -1
- package/dist/compressed-texture-loader.js.map +1 -1
- package/dist/compressed-texture-worker.js +1110 -358
- package/dist/crunch-loader.d.ts +1 -5
- package/dist/crunch-loader.d.ts.map +1 -1
- package/dist/crunch-loader.js +1 -3
- package/dist/crunch-loader.js.map +1 -1
- package/dist/crunch-worker.js +168 -87
- package/dist/dist.dev.js +2647 -670
- package/dist/dist.min.js +1 -2
- package/dist/index.cjs +1642 -428
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/ktx2-basis-writer-worker-node.js +444 -9763
- package/dist/ktx2-basis-writer-worker.js +13 -3
- package/dist/lib/composite-image/image-texture-cube.d.ts +47 -0
- package/dist/lib/composite-image/image-texture-cube.d.ts.map +1 -0
- package/dist/lib/composite-image/image-texture-cube.js +42 -0
- package/dist/lib/composite-image/image-texture-cube.js.map +1 -0
- package/dist/lib/composite-image/parse-composite-image.d.ts +43 -0
- package/dist/lib/composite-image/parse-composite-image.d.ts.map +1 -0
- package/dist/lib/composite-image/parse-composite-image.js +437 -0
- package/dist/lib/composite-image/parse-composite-image.js.map +1 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +2 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/lib/gl-extensions.d.ts +166 -58
- package/dist/lib/gl-extensions.d.ts.map +1 -1
- package/dist/lib/gl-extensions.js +177 -66
- package/dist/lib/gl-extensions.js.map +1 -1
- package/dist/lib/gl-types.d.ts +4 -0
- package/dist/lib/gl-types.d.ts.map +1 -0
- package/dist/lib/gl-types.js +5 -0
- package/dist/lib/gl-types.js.map +1 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts +2 -2
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/lib/parsers/parse-basis.d.ts +24 -2
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +262 -64
- package/dist/lib/parsers/parse-basis.js.map +1 -1
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
- package/dist/lib/parsers/parse-crunch.js +6 -6
- package/dist/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dds.js +10 -11
- package/dist/lib/parsers/parse-dds.js.map +1 -1
- package/dist/lib/parsers/parse-hdr.d.ts +21 -0
- package/dist/lib/parsers/parse-hdr.d.ts.map +1 -0
- package/dist/lib/parsers/parse-hdr.js +305 -0
- package/dist/lib/parsers/parse-hdr.js.map +1 -0
- package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
- package/dist/lib/parsers/parse-ktx.js +10 -3
- package/dist/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
- package/dist/lib/parsers/parse-pvr.js +31 -74
- package/dist/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
- package/dist/lib/texture-api/generate-url.js +2 -10
- package/dist/lib/texture-api/generate-url.js.map +1 -1
- package/dist/lib/texture-api/load-image-array.d.ts +6 -3
- package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-array.js +5 -3
- package/dist/lib/texture-api/load-image-array.js.map +1 -1
- package/dist/lib/texture-api/load-image-cube.d.ts +7 -11
- package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-cube.js +8 -20
- package/dist/lib/texture-api/load-image-cube.js.map +1 -1
- package/dist/lib/texture-api/load-image.d.ts +6 -3
- package/dist/lib/texture-api/load-image.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image.js +8 -4
- package/dist/lib/texture-api/load-image.js.map +1 -1
- package/dist/lib/texture-api/texture-api-types.d.ts +13 -0
- package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -1
- package/dist/lib/utils/detect-supported-texture-formats.d.ts +14 -0
- package/dist/lib/utils/detect-supported-texture-formats.d.ts.map +1 -0
- package/dist/lib/utils/detect-supported-texture-formats.js +197 -0
- package/dist/lib/utils/detect-supported-texture-formats.js.map +1 -0
- package/dist/lib/utils/extract-mipmap-images.d.ts +6 -2
- package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
- package/dist/lib/utils/extract-mipmap-images.js +13 -2
- package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/lib/utils/ktx-format-helper.d.ts +9 -1
- package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
- package/dist/lib/utils/ktx-format-helper.js +76 -109
- package/dist/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/lib/utils/texture-format-map.d.ts +10 -0
- package/dist/lib/utils/texture-format-map.d.ts.map +1 -0
- package/dist/lib/utils/texture-format-map.js +87 -0
- package/dist/lib/utils/texture-format-map.js.map +1 -0
- package/dist/lib/utils/version.js +1 -1
- package/dist/lib/utils/version.js.map +1 -1
- package/dist/npy-loader.d.ts +2 -2
- package/dist/npy-worker.js +1 -1
- package/dist/radiance-hdr-loader.d.ts +25 -0
- package/dist/radiance-hdr-loader.d.ts.map +1 -0
- package/dist/radiance-hdr-loader.js +23 -0
- package/dist/radiance-hdr-loader.js.map +1 -0
- package/dist/texture-array-loader.d.ts +25 -0
- package/dist/texture-array-loader.d.ts.map +1 -0
- package/dist/texture-array-loader.js +24 -0
- package/dist/texture-array-loader.js.map +1 -0
- package/dist/texture-cube-array-loader.d.ts +25 -0
- package/dist/texture-cube-array-loader.d.ts.map +1 -0
- package/dist/texture-cube-array-loader.js +24 -0
- package/dist/texture-cube-array-loader.js.map +1 -0
- package/dist/texture-cube-loader.d.ts +25 -0
- package/dist/texture-cube-loader.d.ts.map +1 -0
- package/dist/texture-cube-loader.js +24 -0
- package/dist/texture-cube-loader.js.map +1 -0
- package/dist/texture-loader.d.ts +25 -0
- package/dist/texture-loader.d.ts.map +1 -0
- package/dist/texture-loader.js +24 -0
- package/dist/texture-loader.js.map +1 -0
- package/dist/workers/crunch-worker.d.ts +1 -3
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/basis-loader.ts +19 -9
- package/src/compressed-texture-loader.ts +0 -3
- package/src/crunch-loader.ts +1 -5
- package/src/index.ts +21 -4
- package/src/lib/composite-image/image-texture-cube.ts +49 -0
- package/src/lib/composite-image/parse-composite-image.ts +699 -0
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +2 -1
- package/src/lib/gl-extensions.ts +188 -81
- package/src/lib/gl-types.ts +136 -0
- package/src/lib/parsers/crunch-module-loader.ts +4 -4
- package/src/lib/parsers/parse-basis.ts +326 -62
- package/src/lib/parsers/parse-crunch.ts +11 -8
- package/src/lib/parsers/parse-dds.ts +11 -12
- package/src/lib/parsers/parse-hdr.ts +426 -0
- package/src/lib/parsers/parse-ktx.ts +13 -3
- package/src/lib/parsers/parse-pvr.ts +33 -75
- package/src/lib/texture-api/generate-url.ts +2 -12
- package/src/lib/texture-api/load-image-array.ts +15 -6
- package/src/lib/texture-api/load-image-cube.ts +20 -34
- package/src/lib/texture-api/load-image.ts +19 -8
- package/src/lib/texture-api/texture-api-types.ts +15 -0
- package/src/lib/utils/detect-supported-texture-formats.ts +210 -0
- package/src/lib/utils/extract-mipmap-images.ts +23 -4
- package/src/lib/utils/ktx-format-helper.ts +135 -111
- package/src/lib/utils/texture-format-map.ts +162 -0
- package/src/radiance-hdr-loader.ts +36 -0
- package/src/texture-array-loader.ts +46 -0
- package/src/texture-cube-array-loader.ts +49 -0
- package/src/texture-cube-loader.ts +46 -0
- package/src/texture-loader.ts +49 -0
- package/dist/lib/utils/texture-formats.d.ts +0 -8
- package/dist/lib/utils/texture-formats.d.ts.map +0 -1
- package/dist/lib/utils/texture-formats.js +0 -51
- package/dist/lib/utils/texture-formats.js.map +0 -1
- package/src/lib/utils/texture-formats.ts +0 -59
package/dist/index.cjs
CHANGED
|
@@ -29,21 +29,96 @@ __export(dist_exports, {
|
|
|
29
29
|
CompressedTextureWriter: () => CompressedTextureWriter,
|
|
30
30
|
CrunchLoader: () => CrunchLoader,
|
|
31
31
|
CrunchWorkerLoader: () => CrunchLoader,
|
|
32
|
+
GL_COMPRESSED_R11_EAC: () => GL_COMPRESSED_R11_EAC,
|
|
33
|
+
GL_COMPRESSED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
34
|
+
GL_COMPRESSED_RED_RGTC1_EXT: () => GL_COMPRESSED_RED_RGTC1_EXT,
|
|
35
|
+
GL_COMPRESSED_RG11_EAC: () => GL_COMPRESSED_RG11_EAC,
|
|
36
|
+
GL_COMPRESSED_RGB8_ETC2: () => GL_COMPRESSED_RGB8_ETC2,
|
|
37
|
+
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
38
|
+
GL_COMPRESSED_RGBA8_ETC2_EAC: () => GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
39
|
+
GL_COMPRESSED_RGBA_ASTC_10x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
40
|
+
GL_COMPRESSED_RGBA_ASTC_10x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
41
|
+
GL_COMPRESSED_RGBA_ASTC_10x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
42
|
+
GL_COMPRESSED_RGBA_ASTC_10x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
43
|
+
GL_COMPRESSED_RGBA_ASTC_12x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
44
|
+
GL_COMPRESSED_RGBA_ASTC_12x12_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
45
|
+
GL_COMPRESSED_RGBA_ASTC_4x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
46
|
+
GL_COMPRESSED_RGBA_ASTC_5x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
47
|
+
GL_COMPRESSED_RGBA_ASTC_5x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
48
|
+
GL_COMPRESSED_RGBA_ASTC_6x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
49
|
+
GL_COMPRESSED_RGBA_ASTC_6x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
50
|
+
GL_COMPRESSED_RGBA_ASTC_8x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
51
|
+
GL_COMPRESSED_RGBA_ASTC_8x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
52
|
+
GL_COMPRESSED_RGBA_ASTC_8x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
53
|
+
GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
54
|
+
GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
55
|
+
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT: () => GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
56
|
+
GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
57
|
+
GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
58
|
+
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
59
|
+
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
60
|
+
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
61
|
+
GL_COMPRESSED_RGB_ATC_WEBGL: () => GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
62
|
+
GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
63
|
+
GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
64
|
+
GL_COMPRESSED_RGB_ETC1_WEBGL: () => GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
65
|
+
GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
66
|
+
GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
67
|
+
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
68
|
+
GL_COMPRESSED_SIGNED_R11_EAC: () => GL_COMPRESSED_SIGNED_R11_EAC,
|
|
69
|
+
GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
70
|
+
GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: () => GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
71
|
+
GL_COMPRESSED_SIGNED_RG11_EAC: () => GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
72
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
73
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
74
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
75
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
76
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
77
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
78
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
79
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
80
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
81
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
82
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
83
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
84
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
85
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
86
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: () => GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
87
|
+
GL_COMPRESSED_SRGB8_ETC2: () => GL_COMPRESSED_SRGB8_ETC2,
|
|
88
|
+
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
89
|
+
GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: () => GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
90
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
91
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
92
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
93
|
+
GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
32
94
|
GL_EXTENSIONS_CONSTANTS: () => GL_EXTENSIONS_CONSTANTS,
|
|
95
|
+
GL_RGB: () => GL_RGB,
|
|
96
|
+
GL_RGB565: () => GL_RGB565,
|
|
97
|
+
GL_RGB5_A1: () => GL_RGB5_A1,
|
|
98
|
+
GL_RGBA: () => GL_RGBA,
|
|
99
|
+
GL_RGBA32F: () => GL_RGBA32F,
|
|
100
|
+
GL_RGBA4: () => GL_RGBA4,
|
|
101
|
+
GL_RGBA8: () => GL_RGBA8,
|
|
33
102
|
KTX2BasisWriter: () => KTX2BasisWriter,
|
|
34
103
|
KTX2BasisWriterWorker: () => KTX2BasisWriterWorker,
|
|
35
104
|
NPYLoader: () => NPYLoader,
|
|
36
105
|
NPYWorkerLoader: () => NPYWorkerLoader,
|
|
37
|
-
|
|
106
|
+
RadianceHDRLoader: () => RadianceHDRLoader,
|
|
107
|
+
TextureArrayLoader: () => TextureArrayLoader,
|
|
108
|
+
TextureCubeArrayLoader: () => TextureCubeArrayLoader,
|
|
109
|
+
TextureCubeLoader: () => TextureCubeLoader,
|
|
110
|
+
TextureLoader: () => TextureLoader,
|
|
38
111
|
loadImageTexture: () => loadImageTexture,
|
|
39
112
|
loadImageTextureArray: () => loadImageTextureArray,
|
|
40
|
-
loadImageTextureCube: () => loadImageTextureCube
|
|
41
|
-
selectSupportedBasisFormat: () => selectSupportedBasisFormat
|
|
113
|
+
loadImageTextureCube: () => loadImageTextureCube
|
|
42
114
|
});
|
|
43
115
|
module.exports = __toCommonJS(dist_exports);
|
|
44
116
|
|
|
45
117
|
// dist/lib/utils/version.js
|
|
46
|
-
var VERSION = true ? "4.4.0
|
|
118
|
+
var VERSION = true ? "4.4.0" : "latest";
|
|
119
|
+
|
|
120
|
+
// dist/lib/parsers/parse-basis.js
|
|
121
|
+
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
47
122
|
|
|
48
123
|
// dist/lib/parsers/basis-module-loader.js
|
|
49
124
|
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
@@ -125,104 +200,271 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
|
125
200
|
}
|
|
126
201
|
|
|
127
202
|
// dist/lib/gl-extensions.js
|
|
203
|
+
var GL_RGB = 6407;
|
|
204
|
+
var GL_RGBA = 6408;
|
|
205
|
+
var GL_RGBA4 = 32854;
|
|
206
|
+
var GL_RGB5_A1 = 32855;
|
|
207
|
+
var GL_RGBA8 = 32856;
|
|
208
|
+
var GL_RGB565 = 36194;
|
|
209
|
+
var GL_RGBA32F = 34836;
|
|
210
|
+
var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
|
|
211
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
|
|
212
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
|
|
213
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
|
|
214
|
+
var GL_COMPRESSED_R11_EAC = 37488;
|
|
215
|
+
var GL_COMPRESSED_SIGNED_R11_EAC = 37489;
|
|
216
|
+
var GL_COMPRESSED_RG11_EAC = 37490;
|
|
217
|
+
var GL_COMPRESSED_SIGNED_RG11_EAC = 37491;
|
|
218
|
+
var GL_COMPRESSED_RGB8_ETC2 = 37492;
|
|
219
|
+
var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
|
|
220
|
+
var GL_COMPRESSED_SRGB8_ETC2 = 37494;
|
|
221
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37495;
|
|
222
|
+
var GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37496;
|
|
223
|
+
var GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37497;
|
|
224
|
+
var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
|
|
225
|
+
var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841;
|
|
226
|
+
var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
|
|
227
|
+
var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843;
|
|
228
|
+
var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
|
|
229
|
+
var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
|
|
230
|
+
var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 35987;
|
|
231
|
+
var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
|
|
232
|
+
var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
|
|
233
|
+
var GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 37809;
|
|
234
|
+
var GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 37810;
|
|
235
|
+
var GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 37811;
|
|
236
|
+
var GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 37812;
|
|
237
|
+
var GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 37813;
|
|
238
|
+
var GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 37814;
|
|
239
|
+
var GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 37815;
|
|
240
|
+
var GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 37816;
|
|
241
|
+
var GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 37817;
|
|
242
|
+
var GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 37818;
|
|
243
|
+
var GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 37819;
|
|
244
|
+
var GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 37820;
|
|
245
|
+
var GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 37821;
|
|
246
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840;
|
|
247
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841;
|
|
248
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842;
|
|
249
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843;
|
|
250
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844;
|
|
251
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845;
|
|
252
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846;
|
|
253
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847;
|
|
254
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848;
|
|
255
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849;
|
|
256
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850;
|
|
257
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851;
|
|
258
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852;
|
|
259
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853;
|
|
260
|
+
var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
|
|
261
|
+
var GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 36284;
|
|
262
|
+
var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
|
|
263
|
+
var GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 36286;
|
|
264
|
+
var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
|
|
265
|
+
var GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 36493;
|
|
266
|
+
var GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 36494;
|
|
267
|
+
var GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 36495;
|
|
268
|
+
var GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916;
|
|
269
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917;
|
|
270
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918;
|
|
271
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919;
|
|
128
272
|
var GL_EXTENSIONS_CONSTANTS = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
COMPRESSED_RED_RGTC1_EXT:
|
|
187
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT:
|
|
188
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT:
|
|
189
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
273
|
+
RGB: GL_RGB,
|
|
274
|
+
RGBA: GL_RGBA,
|
|
275
|
+
RGBA4: GL_RGBA4,
|
|
276
|
+
RGB5_A1: GL_RGB5_A1,
|
|
277
|
+
RGBA8: GL_RGBA8,
|
|
278
|
+
RGB565: GL_RGB565,
|
|
279
|
+
RGBA32F: GL_RGBA32F,
|
|
280
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
281
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
282
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
283
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
284
|
+
COMPRESSED_R11_EAC: GL_COMPRESSED_R11_EAC,
|
|
285
|
+
COMPRESSED_SIGNED_R11_EAC: GL_COMPRESSED_SIGNED_R11_EAC,
|
|
286
|
+
COMPRESSED_RG11_EAC: GL_COMPRESSED_RG11_EAC,
|
|
287
|
+
COMPRESSED_SIGNED_RG11_EAC: GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
288
|
+
COMPRESSED_RGB8_ETC2: GL_COMPRESSED_RGB8_ETC2,
|
|
289
|
+
COMPRESSED_RGBA8_ETC2_EAC: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
290
|
+
COMPRESSED_SRGB8_ETC2: GL_COMPRESSED_SRGB8_ETC2,
|
|
291
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
292
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
293
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
294
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
295
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
296
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
297
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
298
|
+
COMPRESSED_RGB_ETC1_WEBGL: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
299
|
+
COMPRESSED_RGB_ATC_WEBGL: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
300
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
301
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
302
|
+
COMPRESSED_RGBA_ASTC_4x4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
303
|
+
COMPRESSED_RGBA_ASTC_5x4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
304
|
+
COMPRESSED_RGBA_ASTC_5x5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
305
|
+
COMPRESSED_RGBA_ASTC_6x5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
306
|
+
COMPRESSED_RGBA_ASTC_6x6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
307
|
+
COMPRESSED_RGBA_ASTC_8x5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
308
|
+
COMPRESSED_RGBA_ASTC_8x6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
309
|
+
COMPRESSED_RGBA_ASTC_8x8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
310
|
+
COMPRESSED_RGBA_ASTC_10x5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
311
|
+
COMPRESSED_RGBA_ASTC_10x6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
312
|
+
COMPRESSED_RGBA_ASTC_10x8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
313
|
+
COMPRESSED_RGBA_ASTC_10x10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
314
|
+
COMPRESSED_RGBA_ASTC_12x10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
315
|
+
COMPRESSED_RGBA_ASTC_12x12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
316
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
317
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
318
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
319
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
320
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
321
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
322
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
323
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
324
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
325
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
326
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
327
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
328
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
329
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
330
|
+
COMPRESSED_RED_RGTC1_EXT: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
331
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
332
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
333
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
334
|
+
COMPRESSED_RGBA_BPTC_UNORM_EXT: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
335
|
+
COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
336
|
+
COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
337
|
+
COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
338
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
339
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
340
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
341
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
342
|
+
// Deprecated legacy aliases with non-standard ASTC casing.
|
|
343
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
344
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
345
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
346
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
347
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
348
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
349
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
350
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
351
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
352
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
353
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
354
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
355
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
356
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
357
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
358
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
359
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
360
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
361
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
362
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
363
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
364
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
365
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
366
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
367
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
368
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
369
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
370
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
|
|
195
371
|
};
|
|
196
372
|
|
|
197
|
-
// dist/lib/utils/texture-formats.js
|
|
373
|
+
// dist/lib/utils/detect-supported-texture-formats.js
|
|
198
374
|
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
199
|
-
var
|
|
375
|
+
var WEBGL_TEXTURE_FORMATS = {
|
|
200
376
|
/* eslint-disable camelcase */
|
|
201
|
-
WEBGL_compressed_texture_s3tc:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
377
|
+
WEBGL_compressed_texture_s3tc: [
|
|
378
|
+
"bc1-rgb-unorm-webgl",
|
|
379
|
+
"bc1-rgba-unorm",
|
|
380
|
+
"bc2-rgba-unorm",
|
|
381
|
+
"bc3-rgba-unorm"
|
|
382
|
+
],
|
|
383
|
+
WEBGL_compressed_texture_s3tc_srgb: [
|
|
384
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
385
|
+
"bc1-rgba-unorm-srgb",
|
|
386
|
+
"bc2-rgba-unorm-srgb",
|
|
387
|
+
"bc3-rgba-unorm-srgb"
|
|
388
|
+
],
|
|
389
|
+
EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
|
|
390
|
+
EXT_texture_compression_bptc: [
|
|
391
|
+
"bc6h-rgb-ufloat",
|
|
392
|
+
"bc6h-rgb-float",
|
|
393
|
+
"bc7-rgba-unorm",
|
|
394
|
+
"bc7-rgba-unorm-srgb"
|
|
395
|
+
],
|
|
396
|
+
WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"],
|
|
397
|
+
WEBGL_compressed_texture_etc: [
|
|
398
|
+
"etc2-rgb8unorm",
|
|
399
|
+
"etc2-rgb8unorm-srgb",
|
|
400
|
+
"etc2-rgb8a1unorm",
|
|
401
|
+
"etc2-rgb8a1unorm-srgb",
|
|
402
|
+
"etc2-rgba8unorm",
|
|
403
|
+
"etc2-rgba8unorm-srgb",
|
|
404
|
+
"eac-r11unorm",
|
|
405
|
+
"eac-r11snorm",
|
|
406
|
+
"eac-rg11unorm",
|
|
407
|
+
"eac-rg11snorm"
|
|
408
|
+
],
|
|
409
|
+
WEBGL_compressed_texture_pvrtc: [
|
|
410
|
+
"pvrtc-rgb4unorm-webgl",
|
|
411
|
+
"pvrtc-rgba4unorm-webgl",
|
|
412
|
+
"pvrtc-rgb2unorm-webgl",
|
|
413
|
+
"pvrtc-rgba2unorm-webgl"
|
|
414
|
+
],
|
|
415
|
+
WEBGL_compressed_texture_atc: [
|
|
416
|
+
"atc-rgb-unorm-webgl",
|
|
417
|
+
"atc-rgba-unorm-webgl",
|
|
418
|
+
"atc-rgbai-unorm-webgl"
|
|
419
|
+
],
|
|
420
|
+
WEBGL_compressed_texture_astc: [
|
|
421
|
+
"astc-4x4-unorm",
|
|
422
|
+
"astc-4x4-unorm-srgb",
|
|
423
|
+
"astc-5x4-unorm",
|
|
424
|
+
"astc-5x4-unorm-srgb",
|
|
425
|
+
"astc-5x5-unorm",
|
|
426
|
+
"astc-5x5-unorm-srgb",
|
|
427
|
+
"astc-6x5-unorm",
|
|
428
|
+
"astc-6x5-unorm-srgb",
|
|
429
|
+
"astc-6x6-unorm",
|
|
430
|
+
"astc-6x6-unorm-srgb",
|
|
431
|
+
"astc-8x5-unorm",
|
|
432
|
+
"astc-8x5-unorm-srgb",
|
|
433
|
+
"astc-8x6-unorm",
|
|
434
|
+
"astc-8x6-unorm-srgb",
|
|
435
|
+
"astc-8x8-unorm",
|
|
436
|
+
"astc-8x8-unorm-srgb",
|
|
437
|
+
"astc-10x5-unorm",
|
|
438
|
+
"astc-10x5-unorm-srgb",
|
|
439
|
+
"astc-10x6-unorm",
|
|
440
|
+
"astc-10x6-unorm-srgb",
|
|
441
|
+
"astc-10x8-unorm",
|
|
442
|
+
"astc-10x8-unorm-srgb",
|
|
443
|
+
"astc-10x10-unorm",
|
|
444
|
+
"astc-10x10-unorm-srgb",
|
|
445
|
+
"astc-12x10-unorm",
|
|
446
|
+
"astc-12x10-unorm-srgb",
|
|
447
|
+
"astc-12x12-unorm",
|
|
448
|
+
"astc-12x12-unorm-srgb"
|
|
449
|
+
]
|
|
209
450
|
/* eslint-enable camelcase */
|
|
210
451
|
};
|
|
211
|
-
var
|
|
212
|
-
function
|
|
213
|
-
if (!
|
|
452
|
+
var textureFormats = null;
|
|
453
|
+
function detectSupportedTextureFormats(gl) {
|
|
454
|
+
if (!textureFormats) {
|
|
214
455
|
gl = gl || getWebGLContext() || void 0;
|
|
215
|
-
|
|
456
|
+
textureFormats = /* @__PURE__ */ new Set();
|
|
216
457
|
for (const prefix of BROWSER_PREFIXES) {
|
|
217
|
-
for (const extension in
|
|
458
|
+
for (const extension in WEBGL_TEXTURE_FORMATS) {
|
|
218
459
|
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
219
|
-
const
|
|
220
|
-
|
|
460
|
+
for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
|
|
461
|
+
textureFormats.add(textureFormat);
|
|
462
|
+
}
|
|
221
463
|
}
|
|
222
464
|
}
|
|
223
465
|
}
|
|
224
466
|
}
|
|
225
|
-
return
|
|
467
|
+
return textureFormats;
|
|
226
468
|
}
|
|
227
469
|
function getWebGLContext() {
|
|
228
470
|
try {
|
|
@@ -234,25 +476,114 @@ function getWebGLContext() {
|
|
|
234
476
|
}
|
|
235
477
|
|
|
236
478
|
// dist/lib/parsers/parse-ktx.js
|
|
479
|
+
var import_loader_utils2 = require("@loaders.gl/loader-utils");
|
|
237
480
|
var import_ktx_parse = require("ktx-parse");
|
|
238
481
|
|
|
482
|
+
// dist/lib/utils/texture-format-map.js
|
|
483
|
+
var WEBGL_TO_TEXTURE_FORMAT = {
|
|
484
|
+
[GL_RGBA32F]: "rgba32float",
|
|
485
|
+
[GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
|
|
486
|
+
[GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
|
|
487
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
|
|
488
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: "bc1-rgba-unorm-srgb",
|
|
489
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: "bc2-rgba-unorm",
|
|
490
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: "bc2-rgba-unorm-srgb",
|
|
491
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: "bc3-rgba-unorm",
|
|
492
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: "bc3-rgba-unorm-srgb",
|
|
493
|
+
[GL_COMPRESSED_RED_RGTC1_EXT]: "bc4-r-unorm",
|
|
494
|
+
[GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: "bc4-r-snorm",
|
|
495
|
+
[GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: "bc5-rg-unorm",
|
|
496
|
+
[GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: "bc5-rg-snorm",
|
|
497
|
+
[GL_COMPRESSED_RGB8_ETC2]: "etc2-rgb8unorm",
|
|
498
|
+
[GL_COMPRESSED_SRGB8_ETC2]: "etc2-rgb8unorm-srgb",
|
|
499
|
+
[GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm",
|
|
500
|
+
[GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm-srgb",
|
|
501
|
+
[GL_COMPRESSED_RGBA8_ETC2_EAC]: "etc2-rgba8unorm",
|
|
502
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: "etc2-rgba8unorm-srgb",
|
|
503
|
+
[GL_COMPRESSED_R11_EAC]: "eac-r11unorm",
|
|
504
|
+
[GL_COMPRESSED_SIGNED_R11_EAC]: "eac-r11snorm",
|
|
505
|
+
[GL_COMPRESSED_RG11_EAC]: "eac-rg11unorm",
|
|
506
|
+
[GL_COMPRESSED_SIGNED_RG11_EAC]: "eac-rg11snorm",
|
|
507
|
+
[GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: "astc-4x4-unorm",
|
|
508
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: "astc-4x4-unorm-srgb",
|
|
509
|
+
[GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: "astc-5x4-unorm",
|
|
510
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: "astc-5x4-unorm-srgb",
|
|
511
|
+
[GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: "astc-5x5-unorm",
|
|
512
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: "astc-5x5-unorm-srgb",
|
|
513
|
+
[GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: "astc-6x5-unorm",
|
|
514
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: "astc-6x5-unorm-srgb",
|
|
515
|
+
[GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: "astc-6x6-unorm",
|
|
516
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: "astc-6x6-unorm-srgb",
|
|
517
|
+
[GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: "astc-8x5-unorm",
|
|
518
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: "astc-8x5-unorm-srgb",
|
|
519
|
+
[GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: "astc-8x6-unorm",
|
|
520
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: "astc-8x6-unorm-srgb",
|
|
521
|
+
[GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: "astc-8x8-unorm",
|
|
522
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: "astc-8x8-unorm-srgb",
|
|
523
|
+
[GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: "astc-10x5-unorm",
|
|
524
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: "astc-10x5-unorm-srgb",
|
|
525
|
+
[GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: "astc-10x6-unorm",
|
|
526
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: "astc-10x6-unorm-srgb",
|
|
527
|
+
[GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: "astc-10x8-unorm",
|
|
528
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: "astc-10x8-unorm-srgb",
|
|
529
|
+
[GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: "astc-10x10-unorm",
|
|
530
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: "astc-10x10-unorm-srgb",
|
|
531
|
+
[GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: "astc-12x10-unorm",
|
|
532
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: "astc-12x10-unorm-srgb",
|
|
533
|
+
[GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: "astc-12x12-unorm",
|
|
534
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
|
|
535
|
+
[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
|
|
536
|
+
[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
|
|
537
|
+
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl",
|
|
538
|
+
[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
|
|
539
|
+
[GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl",
|
|
540
|
+
[GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
|
|
541
|
+
[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
|
|
542
|
+
[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
|
|
543
|
+
};
|
|
544
|
+
var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
|
|
545
|
+
textureFormat,
|
|
546
|
+
Number(format)
|
|
547
|
+
]));
|
|
548
|
+
function getTextureFormatFromWebGLFormat(format) {
|
|
549
|
+
if (format === void 0) {
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
return WEBGL_TO_TEXTURE_FORMAT[format];
|
|
553
|
+
}
|
|
554
|
+
function getWebGLFormatFromTextureFormat(textureFormat) {
|
|
555
|
+
if (textureFormat === void 0) {
|
|
556
|
+
return void 0;
|
|
557
|
+
}
|
|
558
|
+
return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
|
|
559
|
+
}
|
|
560
|
+
|
|
239
561
|
// dist/lib/utils/extract-mipmap-images.js
|
|
240
562
|
function extractMipmapImages(data, options) {
|
|
241
563
|
const images = new Array(options.mipMapLevels);
|
|
564
|
+
const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
|
|
565
|
+
const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
|
|
242
566
|
let levelWidth = options.width;
|
|
243
567
|
let levelHeight = options.height;
|
|
244
568
|
let offset = 0;
|
|
245
569
|
for (let i = 0; i < options.mipMapLevels; ++i) {
|
|
246
570
|
const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
|
|
247
571
|
const levelData = getLevelData(data, i, offset, levelSize);
|
|
248
|
-
|
|
572
|
+
const image = {
|
|
573
|
+
shape: "texture-level",
|
|
249
574
|
compressed: true,
|
|
250
|
-
format: options.internalFormat,
|
|
251
575
|
data: levelData,
|
|
252
576
|
width: levelWidth,
|
|
253
577
|
height: levelHeight,
|
|
254
578
|
levelSize
|
|
255
579
|
};
|
|
580
|
+
if (format !== void 0) {
|
|
581
|
+
image.format = format;
|
|
582
|
+
}
|
|
583
|
+
if (textureFormat) {
|
|
584
|
+
image.textureFormat = textureFormat;
|
|
585
|
+
}
|
|
586
|
+
images[i] = image;
|
|
256
587
|
levelWidth = Math.max(1, levelWidth >> 1);
|
|
257
588
|
levelHeight = Math.max(1, levelHeight >> 1);
|
|
258
589
|
offset += levelSize;
|
|
@@ -274,118 +605,79 @@ function getLevelSize(options, levelWidth, levelHeight, data, index) {
|
|
|
274
605
|
|
|
275
606
|
// dist/lib/utils/ktx-format-helper.js
|
|
276
607
|
var VULKAN_TO_WEBGL_FORMAT_MAP = {
|
|
277
|
-
131:
|
|
278
|
-
132:
|
|
279
|
-
133:
|
|
280
|
-
134:
|
|
281
|
-
135:
|
|
282
|
-
136:
|
|
283
|
-
137:
|
|
284
|
-
138:
|
|
285
|
-
139:
|
|
286
|
-
140:
|
|
287
|
-
141:
|
|
288
|
-
142:
|
|
289
|
-
147:
|
|
290
|
-
148:
|
|
291
|
-
149:
|
|
292
|
-
150:
|
|
293
|
-
151:
|
|
294
|
-
152:
|
|
295
|
-
153:
|
|
296
|
-
154:
|
|
297
|
-
155:
|
|
298
|
-
156:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// @ts-ignore
|
|
344
|
-
179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
345
|
-
// @ts-ignore
|
|
346
|
-
180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
347
|
-
// @ts-ignore
|
|
348
|
-
181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
349
|
-
// @ts-ignore
|
|
350
|
-
182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
351
|
-
// @ts-ignore
|
|
352
|
-
183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
353
|
-
// @ts-ignore
|
|
354
|
-
184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
355
|
-
1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
356
|
-
1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
357
|
-
// @ts-ignore
|
|
358
|
-
1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
359
|
-
// @ts-ignore
|
|
360
|
-
1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
361
|
-
// @ts-ignore
|
|
362
|
-
1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
363
|
-
// @ts-ignore
|
|
364
|
-
1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
365
|
-
// @ts-ignore
|
|
366
|
-
1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
367
|
-
// @ts-ignore
|
|
368
|
-
1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
369
|
-
// @ts-ignore
|
|
370
|
-
1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
371
|
-
// @ts-ignore
|
|
372
|
-
1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
373
|
-
// @ts-ignore
|
|
374
|
-
1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
375
|
-
// @ts-ignore
|
|
376
|
-
1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
377
|
-
// @ts-ignore
|
|
378
|
-
1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
379
|
-
// @ts-ignore
|
|
380
|
-
1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
381
|
-
// @ts-ignore
|
|
382
|
-
1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
383
|
-
// @ts-ignore
|
|
384
|
-
1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
608
|
+
131: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
609
|
+
132: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
610
|
+
133: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
611
|
+
134: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
612
|
+
135: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
613
|
+
136: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
614
|
+
137: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
615
|
+
138: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
616
|
+
139: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
617
|
+
140: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
618
|
+
141: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
619
|
+
142: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
620
|
+
147: GL_COMPRESSED_RGB8_ETC2,
|
|
621
|
+
148: GL_COMPRESSED_SRGB8_ETC2,
|
|
622
|
+
149: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
623
|
+
150: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
624
|
+
151: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
625
|
+
152: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
626
|
+
153: GL_COMPRESSED_R11_EAC,
|
|
627
|
+
154: GL_COMPRESSED_SIGNED_R11_EAC,
|
|
628
|
+
155: GL_COMPRESSED_RG11_EAC,
|
|
629
|
+
156: GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
630
|
+
157: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
631
|
+
158: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
632
|
+
159: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
633
|
+
160: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
634
|
+
161: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
635
|
+
162: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
636
|
+
163: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
637
|
+
164: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
638
|
+
165: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
639
|
+
166: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
640
|
+
167: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
641
|
+
168: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
642
|
+
169: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
643
|
+
170: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
644
|
+
171: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
645
|
+
172: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
646
|
+
173: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
647
|
+
174: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
648
|
+
175: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
649
|
+
176: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
650
|
+
177: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
651
|
+
178: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
652
|
+
179: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
653
|
+
180: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
654
|
+
181: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
655
|
+
182: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
656
|
+
183: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
657
|
+
184: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
658
|
+
1000054e3: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
659
|
+
1000054001: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
660
|
+
1000066e3: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
661
|
+
1000066001: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
662
|
+
1000066002: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
663
|
+
1000066003: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
664
|
+
1000066004: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
665
|
+
1000066005: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
666
|
+
1000066006: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
667
|
+
1000066007: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
668
|
+
1000066008: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
669
|
+
1000066009: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
670
|
+
1000066010: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
671
|
+
1000066011: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
672
|
+
1000066012: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
673
|
+
1000066013: GL_COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
385
674
|
};
|
|
386
675
|
function mapVkFormatToWebGL(vkFormat) {
|
|
387
676
|
return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
|
|
388
677
|
}
|
|
678
|
+
function mapVkFormatToTextureFormat(vkFormat) {
|
|
679
|
+
return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
|
|
680
|
+
}
|
|
389
681
|
|
|
390
682
|
// dist/lib/parsers/parse-ktx.js
|
|
391
683
|
var KTX2_ID = [
|
|
@@ -425,85 +717,167 @@ function parseKTX(arrayBuffer) {
|
|
|
425
717
|
const mipMapLevels = Math.max(1, ktx.levels.length);
|
|
426
718
|
const width = ktx.pixelWidth;
|
|
427
719
|
const height = ktx.pixelHeight;
|
|
428
|
-
const
|
|
720
|
+
const textureFormat = mapVkFormatToTextureFormat(ktx.vkFormat);
|
|
721
|
+
if (textureFormat === void 0) {
|
|
722
|
+
import_loader_utils2.log.warn(`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known texture format; returning texture levels without format metadata.`)();
|
|
723
|
+
}
|
|
429
724
|
return extractMipmapImages(ktx.levels, {
|
|
430
725
|
mipMapLevels,
|
|
431
726
|
width,
|
|
432
727
|
height,
|
|
433
728
|
sizeFunction: (level) => level.uncompressedByteLength,
|
|
434
|
-
|
|
729
|
+
textureFormat
|
|
435
730
|
});
|
|
436
731
|
}
|
|
437
732
|
|
|
438
733
|
// dist/lib/parsers/parse-basis.js
|
|
439
|
-
var
|
|
734
|
+
var basisTranscodingLock = Promise.resolve();
|
|
735
|
+
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
440
736
|
etc1: {
|
|
441
737
|
basisFormat: 0,
|
|
442
738
|
compressed: true,
|
|
443
|
-
format:
|
|
739
|
+
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
740
|
+
textureFormat: "etc1-rgb-unorm-webgl"
|
|
741
|
+
},
|
|
742
|
+
etc2: {
|
|
743
|
+
basisFormat: 1,
|
|
744
|
+
compressed: true,
|
|
745
|
+
format: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
746
|
+
textureFormat: "etc2-rgba8unorm"
|
|
444
747
|
},
|
|
445
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
446
748
|
bc1: {
|
|
447
749
|
basisFormat: 2,
|
|
448
750
|
compressed: true,
|
|
449
|
-
format:
|
|
751
|
+
format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
752
|
+
textureFormat: "bc1-rgb-unorm-webgl"
|
|
450
753
|
},
|
|
451
754
|
bc3: {
|
|
452
755
|
basisFormat: 3,
|
|
453
756
|
compressed: true,
|
|
454
|
-
format:
|
|
757
|
+
format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
758
|
+
textureFormat: "bc3-rgba-unorm"
|
|
759
|
+
},
|
|
760
|
+
bc4: {
|
|
761
|
+
basisFormat: 4,
|
|
762
|
+
compressed: true,
|
|
763
|
+
format: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
764
|
+
textureFormat: "bc4-r-unorm"
|
|
765
|
+
},
|
|
766
|
+
bc5: {
|
|
767
|
+
basisFormat: 5,
|
|
768
|
+
compressed: true,
|
|
769
|
+
format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
770
|
+
textureFormat: "bc5-rg-unorm"
|
|
771
|
+
},
|
|
772
|
+
"bc7-m6-opaque-only": {
|
|
773
|
+
basisFormat: 6,
|
|
774
|
+
compressed: true,
|
|
775
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
776
|
+
textureFormat: "bc7-rgba-unorm"
|
|
777
|
+
},
|
|
778
|
+
"bc7-m5": {
|
|
779
|
+
basisFormat: 7,
|
|
780
|
+
compressed: true,
|
|
781
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
782
|
+
textureFormat: "bc7-rgba-unorm"
|
|
455
783
|
},
|
|
456
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
457
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
458
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
459
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
460
784
|
"pvrtc1-4-rgb": {
|
|
461
785
|
basisFormat: 8,
|
|
462
786
|
compressed: true,
|
|
463
|
-
format:
|
|
787
|
+
format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
788
|
+
textureFormat: "pvrtc-rgb4unorm-webgl"
|
|
464
789
|
},
|
|
465
790
|
"pvrtc1-4-rgba": {
|
|
466
791
|
basisFormat: 9,
|
|
467
792
|
compressed: true,
|
|
468
|
-
format:
|
|
793
|
+
format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
794
|
+
textureFormat: "pvrtc-rgba4unorm-webgl"
|
|
469
795
|
},
|
|
470
796
|
"astc-4x4": {
|
|
471
797
|
basisFormat: 10,
|
|
472
798
|
compressed: true,
|
|
473
|
-
format:
|
|
799
|
+
format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
800
|
+
textureFormat: "astc-4x4-unorm"
|
|
474
801
|
},
|
|
475
|
-
"atc-rgb": {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
802
|
+
"atc-rgb": {
|
|
803
|
+
basisFormat: 11,
|
|
804
|
+
compressed: true,
|
|
805
|
+
format: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
806
|
+
textureFormat: "atc-rgb-unorm-webgl"
|
|
807
|
+
},
|
|
808
|
+
"atc-rgba-interpolated-alpha": {
|
|
809
|
+
basisFormat: 12,
|
|
810
|
+
compressed: true,
|
|
811
|
+
format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
812
|
+
textureFormat: "atc-rgbai-unorm-webgl"
|
|
813
|
+
},
|
|
814
|
+
rgba32: {
|
|
815
|
+
basisFormat: 13,
|
|
816
|
+
compressed: false,
|
|
817
|
+
format: GL_RGBA8,
|
|
818
|
+
textureFormat: "rgba8unorm"
|
|
819
|
+
},
|
|
820
|
+
rgb565: {
|
|
821
|
+
basisFormat: 14,
|
|
822
|
+
compressed: false,
|
|
823
|
+
format: GL_RGB565,
|
|
824
|
+
textureFormat: "rgb565unorm-webgl"
|
|
825
|
+
},
|
|
826
|
+
bgr565: {
|
|
827
|
+
basisFormat: 15,
|
|
828
|
+
compressed: false,
|
|
829
|
+
format: GL_RGB565,
|
|
830
|
+
textureFormat: "rgb565unorm-webgl"
|
|
831
|
+
},
|
|
832
|
+
rgba4444: {
|
|
833
|
+
basisFormat: 16,
|
|
834
|
+
compressed: false,
|
|
835
|
+
format: GL_RGBA4,
|
|
836
|
+
textureFormat: "rgba4unorm-webgl"
|
|
837
|
+
}
|
|
481
838
|
};
|
|
839
|
+
var BASIS_FORMATS = Object.freeze(Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS));
|
|
840
|
+
async function withBasisTranscodingLock(transcode) {
|
|
841
|
+
const previousLock = basisTranscodingLock;
|
|
842
|
+
let releaseLock;
|
|
843
|
+
basisTranscodingLock = new Promise((resolve) => {
|
|
844
|
+
releaseLock = resolve;
|
|
845
|
+
});
|
|
846
|
+
await previousLock;
|
|
847
|
+
try {
|
|
848
|
+
return await transcode();
|
|
849
|
+
} finally {
|
|
850
|
+
releaseLock();
|
|
851
|
+
}
|
|
852
|
+
}
|
|
482
853
|
async function parseBasis(data, options = {}) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return parseBasisFile(BasisFile, data, options);
|
|
491
|
-
}
|
|
492
|
-
switch (options.basis.module) {
|
|
493
|
-
case "encoder":
|
|
494
|
-
const fileConstructors = await loadBasisEncoderModule((options == null ? void 0 : options.core) || {});
|
|
495
|
-
switch (options.basis.containerFormat) {
|
|
496
|
-
case "ktx2":
|
|
497
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
498
|
-
case "basis":
|
|
499
|
-
default:
|
|
500
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
854
|
+
const loadLibraryOptions = (0, import_worker_utils2.extractLoadLibraryOptions)(options);
|
|
855
|
+
return await withBasisTranscodingLock(async () => {
|
|
856
|
+
var _a;
|
|
857
|
+
if (!((_a = options.basis) == null ? void 0 : _a.containerFormat) || options.basis.containerFormat === "auto") {
|
|
858
|
+
if (isKTX(data)) {
|
|
859
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
860
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
501
861
|
}
|
|
502
|
-
|
|
503
|
-
default:
|
|
504
|
-
const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
|
|
862
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
505
863
|
return parseBasisFile(BasisFile, data, options);
|
|
506
|
-
|
|
864
|
+
}
|
|
865
|
+
switch (options.basis.module) {
|
|
866
|
+
case "encoder":
|
|
867
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
868
|
+
switch (options.basis.containerFormat) {
|
|
869
|
+
case "ktx2":
|
|
870
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
871
|
+
case "basis":
|
|
872
|
+
default:
|
|
873
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
874
|
+
}
|
|
875
|
+
case "transcoder":
|
|
876
|
+
default:
|
|
877
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
878
|
+
return parseBasisFile(BasisFile, data, options);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
507
881
|
}
|
|
508
882
|
function parseBasisFile(BasisFile, data, options) {
|
|
509
883
|
const basisFile = new BasisFile(new Uint8Array(data));
|
|
@@ -533,7 +907,7 @@ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
|
533
907
|
const hasAlpha = basisFile.getHasAlpha(
|
|
534
908
|
/* imageIndex, levelIndex */
|
|
535
909
|
);
|
|
536
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
910
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
|
|
537
911
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
538
912
|
const decodedData = new Uint8Array(decodedSize);
|
|
539
913
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
@@ -541,11 +915,13 @@ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
|
541
915
|
}
|
|
542
916
|
return {
|
|
543
917
|
// standard loaders.gl image category payload
|
|
918
|
+
shape: "texture-level",
|
|
544
919
|
width,
|
|
545
920
|
height,
|
|
546
921
|
data: decodedData,
|
|
547
922
|
compressed,
|
|
548
|
-
format,
|
|
923
|
+
...format !== void 0 ? { format } : {},
|
|
924
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
549
925
|
// Additional fields
|
|
550
926
|
// Add levelSize field.
|
|
551
927
|
hasAlpha
|
|
@@ -570,7 +946,7 @@ function parseKTX2File(KTX2File, data, options) {
|
|
|
570
946
|
}
|
|
571
947
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
572
948
|
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
573
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
949
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
|
|
574
950
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
575
951
|
const decodedData = new Uint8Array(decodedSize);
|
|
576
952
|
if (!ktx2File.transcodeImage(
|
|
@@ -588,49 +964,97 @@ function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
|
588
964
|
}
|
|
589
965
|
return {
|
|
590
966
|
// standard loaders.gl image category payload
|
|
967
|
+
shape: "texture-level",
|
|
591
968
|
width,
|
|
592
969
|
height,
|
|
593
970
|
data: decodedData,
|
|
594
971
|
compressed,
|
|
972
|
+
...format !== void 0 ? { format } : {},
|
|
973
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
595
974
|
// Additional fields
|
|
596
975
|
levelSize: decodedSize,
|
|
597
|
-
hasAlpha: alphaFlag
|
|
598
|
-
format
|
|
976
|
+
hasAlpha: alphaFlag
|
|
599
977
|
};
|
|
600
978
|
}
|
|
601
979
|
function getBasisOptions(options, hasAlpha) {
|
|
602
|
-
var _a;
|
|
603
|
-
let format = (_a = options.basis) == null ? void 0 : _a.format;
|
|
980
|
+
var _a, _b;
|
|
981
|
+
let format = ((_a = options.basis) == null ? void 0 : _a.format) || "auto";
|
|
604
982
|
if (format === "auto") {
|
|
605
|
-
format = selectSupportedBasisFormat();
|
|
983
|
+
format = ((_b = options.basis) == null ? void 0 : _b.supportedTextureFormats) ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
|
|
606
984
|
}
|
|
607
985
|
if (typeof format === "object") {
|
|
608
986
|
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
609
987
|
}
|
|
610
|
-
|
|
611
|
-
|
|
988
|
+
const normalizedFormat = format.toLowerCase();
|
|
989
|
+
const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
|
|
990
|
+
if (!basisOutputOptions) {
|
|
991
|
+
throw new Error(`Unknown Basis format ${format}`);
|
|
992
|
+
}
|
|
993
|
+
return basisOutputOptions;
|
|
612
994
|
}
|
|
613
|
-
function selectSupportedBasisFormat() {
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
995
|
+
function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
|
|
996
|
+
const textureFormats2 = new Set(supportedTextureFormats);
|
|
997
|
+
if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
|
|
616
998
|
return "astc-4x4";
|
|
617
|
-
} else if (
|
|
999
|
+
} else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
|
|
1000
|
+
return {
|
|
1001
|
+
alpha: "bc7-m5",
|
|
1002
|
+
noAlpha: "bc7-m6-opaque-only"
|
|
1003
|
+
};
|
|
1004
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
1005
|
+
"bc1-rgb-unorm-webgl",
|
|
1006
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
1007
|
+
"bc1-rgba-unorm",
|
|
1008
|
+
"bc1-rgba-unorm-srgb",
|
|
1009
|
+
"bc2-rgba-unorm",
|
|
1010
|
+
"bc2-rgba-unorm-srgb",
|
|
1011
|
+
"bc3-rgba-unorm",
|
|
1012
|
+
"bc3-rgba-unorm-srgb"
|
|
1013
|
+
])) {
|
|
618
1014
|
return {
|
|
619
1015
|
alpha: "bc3",
|
|
620
1016
|
noAlpha: "bc1"
|
|
621
1017
|
};
|
|
622
|
-
} else if (
|
|
1018
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
1019
|
+
"pvrtc-rgb4unorm-webgl",
|
|
1020
|
+
"pvrtc-rgba4unorm-webgl",
|
|
1021
|
+
"pvrtc-rgb2unorm-webgl",
|
|
1022
|
+
"pvrtc-rgba2unorm-webgl"
|
|
1023
|
+
])) {
|
|
623
1024
|
return {
|
|
624
1025
|
alpha: "pvrtc1-4-rgba",
|
|
625
1026
|
noAlpha: "pvrtc1-4-rgb"
|
|
626
1027
|
};
|
|
627
|
-
} else if (
|
|
628
|
-
|
|
629
|
-
|
|
1028
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
1029
|
+
"etc2-rgb8unorm",
|
|
1030
|
+
"etc2-rgb8unorm-srgb",
|
|
1031
|
+
"etc2-rgb8a1unorm",
|
|
1032
|
+
"etc2-rgb8a1unorm-srgb",
|
|
1033
|
+
"etc2-rgba8unorm",
|
|
1034
|
+
"etc2-rgba8unorm-srgb",
|
|
1035
|
+
"eac-r11unorm",
|
|
1036
|
+
"eac-r11snorm",
|
|
1037
|
+
"eac-rg11unorm",
|
|
1038
|
+
"eac-rg11snorm"
|
|
1039
|
+
])) {
|
|
630
1040
|
return "etc2";
|
|
1041
|
+
} else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
|
|
1042
|
+
return "etc1";
|
|
1043
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
1044
|
+
"atc-rgb-unorm-webgl",
|
|
1045
|
+
"atc-rgba-unorm-webgl",
|
|
1046
|
+
"atc-rgbai-unorm-webgl"
|
|
1047
|
+
])) {
|
|
1048
|
+
return {
|
|
1049
|
+
alpha: "atc-rgba-interpolated-alpha",
|
|
1050
|
+
noAlpha: "atc-rgb"
|
|
1051
|
+
};
|
|
631
1052
|
}
|
|
632
1053
|
return "rgb565";
|
|
633
1054
|
}
|
|
1055
|
+
function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
|
|
1056
|
+
return candidateTextureFormats.some((textureFormat) => supportedTextureFormats.has(textureFormat));
|
|
1057
|
+
}
|
|
634
1058
|
|
|
635
1059
|
// dist/basis-loader.js
|
|
636
1060
|
var BasisWorkerLoader = {
|
|
@@ -648,7 +1072,6 @@ var BasisWorkerLoader = {
|
|
|
648
1072
|
options: {
|
|
649
1073
|
basis: {
|
|
650
1074
|
format: "auto",
|
|
651
|
-
libraryPath: "libs/",
|
|
652
1075
|
containerFormat: "auto",
|
|
653
1076
|
module: "transcoder"
|
|
654
1077
|
}
|
|
@@ -660,7 +1083,7 @@ var BasisLoader = {
|
|
|
660
1083
|
};
|
|
661
1084
|
|
|
662
1085
|
// dist/lib/parsers/parse-dds.js
|
|
663
|
-
var
|
|
1086
|
+
var import_loader_utils3 = require("@loaders.gl/loader-utils");
|
|
664
1087
|
var DDS_CONSTANTS = {
|
|
665
1088
|
MAGIC_NUMBER: 542327876,
|
|
666
1089
|
HEADER_LENGTH: 31,
|
|
@@ -675,13 +1098,13 @@ var DDS_CONSTANTS = {
|
|
|
675
1098
|
DDSD_MIPMAPCOUNT: 131072,
|
|
676
1099
|
DDPF_FOURCC: 4
|
|
677
1100
|
};
|
|
678
|
-
var
|
|
679
|
-
DXT1:
|
|
680
|
-
DXT3:
|
|
681
|
-
DXT5:
|
|
682
|
-
"ATC ":
|
|
683
|
-
ATCA:
|
|
684
|
-
ATCI:
|
|
1101
|
+
var DDS_TEXTURE_FORMATS = {
|
|
1102
|
+
DXT1: "bc1-rgb-unorm-webgl",
|
|
1103
|
+
DXT3: "bc2-rgba-unorm",
|
|
1104
|
+
DXT5: "bc3-rgba-unorm",
|
|
1105
|
+
"ATC ": "atc-rgb-unorm-webgl",
|
|
1106
|
+
ATCA: "atc-rgba-unorm-webgl",
|
|
1107
|
+
ATCI: "atc-rgbai-unorm-webgl"
|
|
685
1108
|
};
|
|
686
1109
|
var getATCLevelSize = getDxt1LevelSize;
|
|
687
1110
|
var getATCALevelSize = getDxtXLevelSize;
|
|
@@ -702,11 +1125,11 @@ function isDDS(data) {
|
|
|
702
1125
|
function parseDDS(data) {
|
|
703
1126
|
const header = new Int32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH);
|
|
704
1127
|
const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX];
|
|
705
|
-
(0,
|
|
1128
|
+
(0, import_loader_utils3.assert)(Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC), "DDS: Unsupported format, must contain a FourCC code");
|
|
706
1129
|
const fourCC = int32ToFourCC(pixelFormatNumber);
|
|
707
|
-
const
|
|
1130
|
+
const textureFormat = DDS_TEXTURE_FORMATS[fourCC];
|
|
708
1131
|
const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
|
|
709
|
-
(0,
|
|
1132
|
+
(0, import_loader_utils3.assert)(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
|
|
710
1133
|
let mipMapLevels = 1;
|
|
711
1134
|
if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
|
|
712
1135
|
mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
|
|
@@ -720,7 +1143,7 @@ function parseDDS(data) {
|
|
|
720
1143
|
width,
|
|
721
1144
|
height,
|
|
722
1145
|
sizeFunction,
|
|
723
|
-
|
|
1146
|
+
textureFormat
|
|
724
1147
|
});
|
|
725
1148
|
}
|
|
726
1149
|
function getDxt1LevelSize(width, height) {
|
|
@@ -747,76 +1170,34 @@ var PVR_CONSTANTS = {
|
|
|
747
1170
|
MIPMAPCOUNT_INDEX: 11,
|
|
748
1171
|
METADATA_SIZE_INDEX: 12
|
|
749
1172
|
};
|
|
750
|
-
var
|
|
751
|
-
0: [
|
|
752
|
-
1: [
|
|
753
|
-
2: [
|
|
754
|
-
3: [
|
|
755
|
-
6: [
|
|
756
|
-
7: [
|
|
757
|
-
9: [
|
|
758
|
-
11: [
|
|
759
|
-
22: [
|
|
760
|
-
23: [
|
|
761
|
-
24: [
|
|
762
|
-
25: [
|
|
763
|
-
26: [
|
|
764
|
-
27: [
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
],
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
],
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
],
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR
|
|
779
|
-
],
|
|
780
|
-
31: [
|
|
781
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6X6_KHR,
|
|
782
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR
|
|
783
|
-
],
|
|
784
|
-
32: [
|
|
785
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X5_KHR,
|
|
786
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR
|
|
787
|
-
],
|
|
788
|
-
33: [
|
|
789
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X6_KHR,
|
|
790
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR
|
|
791
|
-
],
|
|
792
|
-
34: [
|
|
793
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X8_KHR,
|
|
794
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR
|
|
795
|
-
],
|
|
796
|
-
35: [
|
|
797
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X5_KHR,
|
|
798
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR
|
|
799
|
-
],
|
|
800
|
-
36: [
|
|
801
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X6_KHR,
|
|
802
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR
|
|
803
|
-
],
|
|
804
|
-
37: [
|
|
805
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X8_KHR,
|
|
806
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR
|
|
807
|
-
],
|
|
808
|
-
38: [
|
|
809
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X10_KHR,
|
|
810
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR
|
|
811
|
-
],
|
|
812
|
-
39: [
|
|
813
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X10_KHR,
|
|
814
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR
|
|
815
|
-
],
|
|
816
|
-
40: [
|
|
817
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X12_KHR,
|
|
818
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR
|
|
819
|
-
]
|
|
1173
|
+
var PVR_TEXTURE_FORMATS = {
|
|
1174
|
+
0: ["pvrtc-rgb2unorm-webgl"],
|
|
1175
|
+
1: ["pvrtc-rgba2unorm-webgl"],
|
|
1176
|
+
2: ["pvrtc-rgb4unorm-webgl"],
|
|
1177
|
+
3: ["pvrtc-rgba4unorm-webgl"],
|
|
1178
|
+
6: ["etc1-rgb-unorm-webgl"],
|
|
1179
|
+
7: ["bc1-rgb-unorm-webgl"],
|
|
1180
|
+
9: ["bc2-rgba-unorm"],
|
|
1181
|
+
11: ["bc3-rgba-unorm"],
|
|
1182
|
+
22: ["etc2-rgb8unorm"],
|
|
1183
|
+
23: ["etc2-rgba8unorm"],
|
|
1184
|
+
24: ["etc2-rgb8a1unorm"],
|
|
1185
|
+
25: ["eac-r11unorm"],
|
|
1186
|
+
26: ["eac-rg11unorm"],
|
|
1187
|
+
27: ["astc-4x4-unorm", "astc-4x4-unorm-srgb"],
|
|
1188
|
+
28: ["astc-5x4-unorm", "astc-5x4-unorm-srgb"],
|
|
1189
|
+
29: ["astc-5x5-unorm", "astc-5x5-unorm-srgb"],
|
|
1190
|
+
30: ["astc-6x5-unorm", "astc-6x5-unorm-srgb"],
|
|
1191
|
+
31: ["astc-6x6-unorm", "astc-6x6-unorm-srgb"],
|
|
1192
|
+
32: ["astc-8x5-unorm", "astc-8x5-unorm-srgb"],
|
|
1193
|
+
33: ["astc-8x6-unorm", "astc-8x6-unorm-srgb"],
|
|
1194
|
+
34: ["astc-8x8-unorm", "astc-8x8-unorm-srgb"],
|
|
1195
|
+
35: ["astc-10x5-unorm", "astc-10x5-unorm-srgb"],
|
|
1196
|
+
36: ["astc-10x6-unorm", "astc-10x6-unorm-srgb"],
|
|
1197
|
+
37: ["astc-10x8-unorm", "astc-10x8-unorm-srgb"],
|
|
1198
|
+
38: ["astc-10x10-unorm", "astc-10x10-unorm-srgb"],
|
|
1199
|
+
39: ["astc-12x10-unorm", "astc-12x10-unorm-srgb"],
|
|
1200
|
+
40: ["astc-12x12-unorm", "astc-12x12-unorm-srgb"]
|
|
820
1201
|
};
|
|
821
1202
|
var PVR_SIZE_FUNCTIONS = {
|
|
822
1203
|
0: pvrtc2bppSize,
|
|
@@ -856,8 +1237,8 @@ function parsePVR(data) {
|
|
|
856
1237
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
857
1238
|
const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX];
|
|
858
1239
|
const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX];
|
|
859
|
-
const
|
|
860
|
-
const
|
|
1240
|
+
const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || [];
|
|
1241
|
+
const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0];
|
|
861
1242
|
const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat];
|
|
862
1243
|
const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX];
|
|
863
1244
|
const width = header[PVR_CONSTANTS.WIDTH_INDEX];
|
|
@@ -869,7 +1250,7 @@ function parsePVR(data) {
|
|
|
869
1250
|
width,
|
|
870
1251
|
height,
|
|
871
1252
|
sizeFunction,
|
|
872
|
-
|
|
1253
|
+
textureFormat
|
|
873
1254
|
});
|
|
874
1255
|
}
|
|
875
1256
|
function pvrtc2bppSize(width, height) {
|
|
@@ -969,7 +1350,6 @@ var CompressedTextureWorkerLoader = {
|
|
|
969
1350
|
binary: true,
|
|
970
1351
|
options: {
|
|
971
1352
|
"compressed-texture": {
|
|
972
|
-
libraryPath: "libs/",
|
|
973
1353
|
useBasis: false
|
|
974
1354
|
}
|
|
975
1355
|
}
|
|
@@ -1009,10 +1389,326 @@ var CrunchLoader = {
|
|
|
1009
1389
|
mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"],
|
|
1010
1390
|
binary: true,
|
|
1011
1391
|
options: {
|
|
1012
|
-
crunch: {
|
|
1013
|
-
|
|
1392
|
+
crunch: {}
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
// dist/lib/parsers/parse-hdr.js
|
|
1397
|
+
var HDR_MAGIC_HEADERS = ["#?RADIANCE", "#?RGBE"];
|
|
1398
|
+
var HDR_FORMAT = "32-bit_rle_rgbe";
|
|
1399
|
+
function isHDR(arrayBuffer) {
|
|
1400
|
+
const state = {
|
|
1401
|
+
data: new Uint8Array(arrayBuffer),
|
|
1402
|
+
offset: 0
|
|
1403
|
+
};
|
|
1404
|
+
const firstLine = readLine(state);
|
|
1405
|
+
return firstLine ? HDR_MAGIC_HEADERS.includes(firstLine) : false;
|
|
1406
|
+
}
|
|
1407
|
+
function parseHDR(arrayBuffer) {
|
|
1408
|
+
const state = {
|
|
1409
|
+
data: new Uint8Array(arrayBuffer),
|
|
1410
|
+
offset: 0
|
|
1411
|
+
};
|
|
1412
|
+
const header = readHeader(state);
|
|
1413
|
+
const { width, height } = header;
|
|
1414
|
+
const rgbeData = readPixels(state, header);
|
|
1415
|
+
const data = convertRGBEToFloat(rgbeData);
|
|
1416
|
+
const level = {
|
|
1417
|
+
shape: "texture-level",
|
|
1418
|
+
compressed: false,
|
|
1419
|
+
width,
|
|
1420
|
+
height,
|
|
1421
|
+
data,
|
|
1422
|
+
levelSize: data.byteLength,
|
|
1423
|
+
format: GL_RGBA32F,
|
|
1424
|
+
textureFormat: "rgba32float"
|
|
1425
|
+
};
|
|
1426
|
+
return {
|
|
1427
|
+
shape: "texture",
|
|
1428
|
+
type: "2d",
|
|
1429
|
+
format: "rgba32float",
|
|
1430
|
+
...header.metadata ? { metadata: header.metadata } : {},
|
|
1431
|
+
data: [level]
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
function readHeader(state) {
|
|
1435
|
+
const magicHeader = readLine(state);
|
|
1436
|
+
if (!magicHeader || !HDR_MAGIC_HEADERS.includes(magicHeader)) {
|
|
1437
|
+
throw new Error("RadianceHDRLoader: bad initial token");
|
|
1438
|
+
}
|
|
1439
|
+
let hasFormat = false;
|
|
1440
|
+
const metadata = {};
|
|
1441
|
+
while (state.offset < state.data.length) {
|
|
1442
|
+
const line = readLine(state);
|
|
1443
|
+
if (line === null) {
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
if (!line || line.startsWith("#")) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
if (line.startsWith("FORMAT=")) {
|
|
1450
|
+
hasFormat = line.slice("FORMAT=".length) === HDR_FORMAT;
|
|
1451
|
+
if (!hasFormat) {
|
|
1452
|
+
throw new Error("RadianceHDRLoader: unsupported format specifier");
|
|
1453
|
+
}
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
parseMetadataLine(metadata, line);
|
|
1457
|
+
const dimensions = parseDimensions(line);
|
|
1458
|
+
if (dimensions) {
|
|
1459
|
+
if (!hasFormat) {
|
|
1460
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
1461
|
+
}
|
|
1462
|
+
return {
|
|
1463
|
+
...dimensions,
|
|
1464
|
+
...hasMetadata(metadata) ? { metadata } : {}
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if (!hasFormat) {
|
|
1469
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
1470
|
+
}
|
|
1471
|
+
throw new Error("RadianceHDRLoader: missing image size specifier");
|
|
1472
|
+
}
|
|
1473
|
+
function parseDimensions(line) {
|
|
1474
|
+
const match = line.match(/^([+-])([YX])\s+(\d+)\s+([+-])([YX])\s+(\d+)$/);
|
|
1475
|
+
if (!match) {
|
|
1476
|
+
return null;
|
|
1477
|
+
}
|
|
1478
|
+
const majorSign = match[1] === "+" ? 1 : -1;
|
|
1479
|
+
const majorAxis = match[2];
|
|
1480
|
+
const majorLength = Number(match[3]);
|
|
1481
|
+
const minorSign = match[4] === "+" ? 1 : -1;
|
|
1482
|
+
const minorAxis = match[5];
|
|
1483
|
+
const minorLength = Number(match[6]);
|
|
1484
|
+
if (majorAxis === minorAxis) {
|
|
1485
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
1486
|
+
}
|
|
1487
|
+
const width = majorAxis === "X" ? majorLength : minorLength;
|
|
1488
|
+
const height = majorAxis === "Y" ? majorLength : minorLength;
|
|
1489
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
1490
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
1491
|
+
}
|
|
1492
|
+
return { width, height, majorAxis, majorSign, minorAxis, minorSign };
|
|
1493
|
+
}
|
|
1494
|
+
function readPixels(state, header) {
|
|
1495
|
+
const { width, height } = header;
|
|
1496
|
+
const pixelCount = width * height;
|
|
1497
|
+
const flatByteLength = pixelCount * 4;
|
|
1498
|
+
const scanlineLength = header.minorAxis === "X" ? width : height;
|
|
1499
|
+
const scanlineCount = header.majorAxis === "Y" ? height : width;
|
|
1500
|
+
if (scanlineLength < 8 || scanlineLength > 32767) {
|
|
1501
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1502
|
+
}
|
|
1503
|
+
if (state.offset + 4 > state.data.length) {
|
|
1504
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1505
|
+
}
|
|
1506
|
+
const data = state.data;
|
|
1507
|
+
const isRunLengthEncoded = data[state.offset] === 2 && data[state.offset + 1] === 2 && !(data[state.offset + 2] & 128);
|
|
1508
|
+
if (!isRunLengthEncoded) {
|
|
1509
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1510
|
+
}
|
|
1511
|
+
const scanlineWidth = data[state.offset + 2] << 8 | data[state.offset + 3];
|
|
1512
|
+
if (scanlineWidth !== scanlineLength) {
|
|
1513
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1514
|
+
}
|
|
1515
|
+
const pixels = new Uint8Array(flatByteLength);
|
|
1516
|
+
const scanlineBuffer = new Uint8Array(scanlineLength * 4);
|
|
1517
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
1518
|
+
if (state.offset + 4 > data.length) {
|
|
1519
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1520
|
+
}
|
|
1521
|
+
const red = data[state.offset++];
|
|
1522
|
+
const green = data[state.offset++];
|
|
1523
|
+
const blue = data[state.offset++];
|
|
1524
|
+
const exponent = data[state.offset++];
|
|
1525
|
+
if (red !== 2 || green !== 2 || (blue << 8 | exponent) !== scanlineLength) {
|
|
1526
|
+
throw new Error("RadianceHDRLoader: bad rgbe scanline format");
|
|
1527
|
+
}
|
|
1528
|
+
for (let channelIndex = 0; channelIndex < 4; channelIndex++) {
|
|
1529
|
+
const channelOffset = channelIndex * scanlineLength;
|
|
1530
|
+
const channelEnd = channelOffset + scanlineLength;
|
|
1531
|
+
let pixelOffset = channelOffset;
|
|
1532
|
+
while (pixelOffset < channelEnd) {
|
|
1533
|
+
if (state.offset >= data.length) {
|
|
1534
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1535
|
+
}
|
|
1536
|
+
let count = data[state.offset++];
|
|
1537
|
+
if (count > 128) {
|
|
1538
|
+
count -= 128;
|
|
1539
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset >= data.length) {
|
|
1540
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
1541
|
+
}
|
|
1542
|
+
const value = data[state.offset++];
|
|
1543
|
+
scanlineBuffer.fill(value, pixelOffset, pixelOffset + count);
|
|
1544
|
+
pixelOffset += count;
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset + count > data.length) {
|
|
1548
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
1549
|
+
}
|
|
1550
|
+
scanlineBuffer.set(data.subarray(state.offset, state.offset + count), pixelOffset);
|
|
1551
|
+
pixelOffset += count;
|
|
1552
|
+
state.offset += count;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
1556
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
1557
|
+
pixels[outputOffset] = scanlineBuffer[pixelIndex];
|
|
1558
|
+
pixels[outputOffset + 1] = scanlineBuffer[pixelIndex + scanlineLength];
|
|
1559
|
+
pixels[outputOffset + 2] = scanlineBuffer[pixelIndex + scanlineLength * 2];
|
|
1560
|
+
pixels[outputOffset + 3] = scanlineBuffer[pixelIndex + scanlineLength * 3];
|
|
1014
1561
|
}
|
|
1015
1562
|
}
|
|
1563
|
+
return pixels;
|
|
1564
|
+
}
|
|
1565
|
+
function reorderPixels(data, header) {
|
|
1566
|
+
const pixels = new Uint8Array(data.length);
|
|
1567
|
+
const scanlineLength = header.minorAxis === "X" ? header.width : header.height;
|
|
1568
|
+
const scanlineCount = header.majorAxis === "Y" ? header.height : header.width;
|
|
1569
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
1570
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
1571
|
+
const sourceOffset = (scanlineIndex * scanlineLength + pixelIndex) * 4;
|
|
1572
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
1573
|
+
pixels[outputOffset] = data[sourceOffset];
|
|
1574
|
+
pixels[outputOffset + 1] = data[sourceOffset + 1];
|
|
1575
|
+
pixels[outputOffset + 2] = data[sourceOffset + 2];
|
|
1576
|
+
pixels[outputOffset + 3] = data[sourceOffset + 3];
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
return pixels;
|
|
1580
|
+
}
|
|
1581
|
+
function getOutputOffset(header, scanlineIndex, pixelIndex) {
|
|
1582
|
+
const majorCoordinate = getCoordinate(header.majorAxis === "X" ? header.width : header.height, header.majorSign, scanlineIndex);
|
|
1583
|
+
const minorCoordinate = getCoordinate(header.minorAxis === "X" ? header.width : header.height, header.minorSign, pixelIndex);
|
|
1584
|
+
const x = header.majorAxis === "X" ? majorCoordinate : minorCoordinate;
|
|
1585
|
+
const y = header.majorAxis === "Y" ? majorCoordinate : minorCoordinate;
|
|
1586
|
+
return ((header.height - 1 - y) * header.width + x) * 4;
|
|
1587
|
+
}
|
|
1588
|
+
function getCoordinate(length, sign, index) {
|
|
1589
|
+
return sign === 1 ? index : length - 1 - index;
|
|
1590
|
+
}
|
|
1591
|
+
function readFlatPixels(state, byteLength) {
|
|
1592
|
+
if (state.offset + byteLength > state.data.length) {
|
|
1593
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1594
|
+
}
|
|
1595
|
+
const pixels = state.data.slice(state.offset, state.offset + byteLength);
|
|
1596
|
+
state.offset += byteLength;
|
|
1597
|
+
return pixels;
|
|
1598
|
+
}
|
|
1599
|
+
function convertRGBEToFloat(data) {
|
|
1600
|
+
const floatData = new Float32Array(data.length);
|
|
1601
|
+
for (let sourceOffset = 0; sourceOffset < data.length; sourceOffset += 4) {
|
|
1602
|
+
const exponent = data[sourceOffset + 3];
|
|
1603
|
+
const destinationOffset = sourceOffset;
|
|
1604
|
+
if (exponent > 0) {
|
|
1605
|
+
const scale = Math.pow(2, exponent - 128) / 255;
|
|
1606
|
+
floatData[destinationOffset] = data[sourceOffset] * scale;
|
|
1607
|
+
floatData[destinationOffset + 1] = data[sourceOffset + 1] * scale;
|
|
1608
|
+
floatData[destinationOffset + 2] = data[sourceOffset + 2] * scale;
|
|
1609
|
+
}
|
|
1610
|
+
floatData[destinationOffset + 3] = 1;
|
|
1611
|
+
}
|
|
1612
|
+
return floatData;
|
|
1613
|
+
}
|
|
1614
|
+
function readLine(state) {
|
|
1615
|
+
if (state.offset >= state.data.length) {
|
|
1616
|
+
return null;
|
|
1617
|
+
}
|
|
1618
|
+
const lineStart = state.offset;
|
|
1619
|
+
while (state.offset < state.data.length) {
|
|
1620
|
+
const byte = state.data[state.offset++];
|
|
1621
|
+
if (byte === 10) {
|
|
1622
|
+
const line2 = decodeASCII(state.data.subarray(lineStart, state.offset - 1));
|
|
1623
|
+
return line2.endsWith("\r") ? line2.slice(0, -1) : line2;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
const line = decodeASCII(state.data.subarray(lineStart, state.offset));
|
|
1627
|
+
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
1628
|
+
}
|
|
1629
|
+
function decodeASCII(data) {
|
|
1630
|
+
let line = "";
|
|
1631
|
+
for (const byte of data) {
|
|
1632
|
+
line += String.fromCharCode(byte);
|
|
1633
|
+
}
|
|
1634
|
+
return line;
|
|
1635
|
+
}
|
|
1636
|
+
function parseMetadataLine(metadata, line) {
|
|
1637
|
+
if (line.startsWith("COLORCORR=")) {
|
|
1638
|
+
const values = parseNumberList(line.slice("COLORCORR=".length), 3);
|
|
1639
|
+
if (values) {
|
|
1640
|
+
metadata.colorCorrection = values;
|
|
1641
|
+
}
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (line.startsWith("EXPOSURE=")) {
|
|
1645
|
+
const value = parseNumber(line.slice("EXPOSURE=".length));
|
|
1646
|
+
if (value !== null) {
|
|
1647
|
+
metadata.exposure = value;
|
|
1648
|
+
}
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
if (line.startsWith("GAMMA=")) {
|
|
1652
|
+
const value = parseNumber(line.slice("GAMMA=".length));
|
|
1653
|
+
if (value !== null) {
|
|
1654
|
+
metadata.gamma = value;
|
|
1655
|
+
}
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if (line.startsWith("PIXASPECT=")) {
|
|
1659
|
+
const value = parseNumber(line.slice("PIXASPECT=".length));
|
|
1660
|
+
if (value !== null) {
|
|
1661
|
+
metadata.pixelAspectRatio = value;
|
|
1662
|
+
}
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (line.startsWith("PRIMARIES=")) {
|
|
1666
|
+
const values = parseNumberList(line.slice("PRIMARIES=".length), 8);
|
|
1667
|
+
if (values) {
|
|
1668
|
+
metadata.primaries = values;
|
|
1669
|
+
}
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (line.startsWith("SOFTWARE=")) {
|
|
1673
|
+
metadata.software = line.slice("SOFTWARE=".length).trim();
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if (line.startsWith("VIEW=")) {
|
|
1677
|
+
metadata.view = line.slice("VIEW=".length).trim();
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
function parseNumber(text) {
|
|
1681
|
+
const value = Number(text.trim());
|
|
1682
|
+
return Number.isFinite(value) ? value : null;
|
|
1683
|
+
}
|
|
1684
|
+
function parseNumberList(text, count) {
|
|
1685
|
+
const values = text.trim().split(/\s+/).map((value) => Number(value));
|
|
1686
|
+
if (values.length !== count || values.some((value) => !Number.isFinite(value))) {
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
return values;
|
|
1690
|
+
}
|
|
1691
|
+
function hasMetadata(metadata) {
|
|
1692
|
+
return Object.keys(metadata).length > 0;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// dist/radiance-hdr-loader.js
|
|
1696
|
+
var RadianceHDRLoader = {
|
|
1697
|
+
dataType: null,
|
|
1698
|
+
batchType: null,
|
|
1699
|
+
name: "Radiance HDR",
|
|
1700
|
+
id: "hdr",
|
|
1701
|
+
module: "textures",
|
|
1702
|
+
version: VERSION,
|
|
1703
|
+
extensions: ["hdr"],
|
|
1704
|
+
mimeTypes: ["image/vnd.radiance", "image/x-hdr", "application/octet-stream"],
|
|
1705
|
+
binary: true,
|
|
1706
|
+
tests: [isHDR],
|
|
1707
|
+
options: {
|
|
1708
|
+
hdr: {}
|
|
1709
|
+
},
|
|
1710
|
+
parseSync: parseHDR,
|
|
1711
|
+
parse: async (arrayBuffer) => parseHDR(arrayBuffer)
|
|
1016
1712
|
};
|
|
1017
1713
|
|
|
1018
1714
|
// dist/lib/parsers/parse-npy.js
|
|
@@ -1096,16 +1792,597 @@ var NPYLoader = {
|
|
|
1096
1792
|
parse: async (arrayBuffer, options) => parseNPY(arrayBuffer, options)
|
|
1097
1793
|
};
|
|
1098
1794
|
|
|
1795
|
+
// dist/lib/composite-image/parse-composite-image.js
|
|
1796
|
+
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
1797
|
+
var import_images = require("@loaders.gl/images");
|
|
1798
|
+
|
|
1799
|
+
// dist/lib/texture-api/async-deep-map.js
|
|
1800
|
+
var isObject = (value) => value && typeof value === "object";
|
|
1801
|
+
async function asyncDeepMap(tree, func, options = {}) {
|
|
1802
|
+
return await mapSubtree(tree, func, options);
|
|
1803
|
+
}
|
|
1804
|
+
async function mapSubtree(object, func, options) {
|
|
1805
|
+
if (Array.isArray(object)) {
|
|
1806
|
+
return await mapArray(object, func, options);
|
|
1807
|
+
}
|
|
1808
|
+
if (isObject(object)) {
|
|
1809
|
+
return await mapObject(object, func, options);
|
|
1810
|
+
}
|
|
1811
|
+
const url = object;
|
|
1812
|
+
return await func(url, options);
|
|
1813
|
+
}
|
|
1814
|
+
async function mapObject(object, func, options) {
|
|
1815
|
+
const promises = [];
|
|
1816
|
+
const values = {};
|
|
1817
|
+
for (const key in object) {
|
|
1818
|
+
const url = object[key];
|
|
1819
|
+
const promise = mapSubtree(url, func, options).then((value) => {
|
|
1820
|
+
values[key] = value;
|
|
1821
|
+
});
|
|
1822
|
+
promises.push(promise);
|
|
1823
|
+
}
|
|
1824
|
+
await Promise.all(promises);
|
|
1825
|
+
return values;
|
|
1826
|
+
}
|
|
1827
|
+
async function mapArray(urlArray, func, options = {}) {
|
|
1828
|
+
const promises = urlArray.map((url) => mapSubtree(url, func, options));
|
|
1829
|
+
return await Promise.all(promises);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// dist/lib/composite-image/image-texture-cube.js
|
|
1833
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
1834
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
1835
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
1836
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
1837
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
1838
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
1839
|
+
var IMAGE_TEXTURE_CUBE_FACES = [
|
|
1840
|
+
{
|
|
1841
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
1842
|
+
name: "+X",
|
|
1843
|
+
direction: "right",
|
|
1844
|
+
axis: "x",
|
|
1845
|
+
sign: "positive"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
1849
|
+
name: "-X",
|
|
1850
|
+
direction: "left",
|
|
1851
|
+
axis: "x",
|
|
1852
|
+
sign: "negative"
|
|
1853
|
+
},
|
|
1854
|
+
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, name: "+Y", direction: "top", axis: "y", sign: "positive" },
|
|
1855
|
+
{
|
|
1856
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
1857
|
+
name: "-Y",
|
|
1858
|
+
direction: "bottom",
|
|
1859
|
+
axis: "y",
|
|
1860
|
+
sign: "negative"
|
|
1861
|
+
},
|
|
1862
|
+
{
|
|
1863
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
1864
|
+
name: "+Z",
|
|
1865
|
+
direction: "front",
|
|
1866
|
+
axis: "z",
|
|
1867
|
+
sign: "positive"
|
|
1868
|
+
},
|
|
1869
|
+
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, name: "-Z", direction: "back", axis: "z", sign: "negative" }
|
|
1870
|
+
];
|
|
1871
|
+
|
|
1872
|
+
// dist/lib/composite-image/parse-composite-image.js
|
|
1873
|
+
async function parseCompositeImageManifest(text, expectedShape, options = {}, context) {
|
|
1874
|
+
const manifest = parseCompositeImageManifestJSON(text);
|
|
1875
|
+
if (manifest.shape !== expectedShape) {
|
|
1876
|
+
throw new Error(`Expected ${expectedShape} manifest, got ${manifest.shape}`);
|
|
1877
|
+
}
|
|
1878
|
+
return await loadCompositeImageManifest(manifest, options, context);
|
|
1879
|
+
}
|
|
1880
|
+
function testCompositeImageManifestShape(text, shape) {
|
|
1881
|
+
try {
|
|
1882
|
+
return parseCompositeImageManifestJSON(text).shape === shape;
|
|
1883
|
+
} catch {
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
async function loadCompositeImageManifest(manifest, options = {}, context) {
|
|
1888
|
+
const normalizedOptions = normalizeCompositeImageManifestOptions(options);
|
|
1889
|
+
const urlTree = await getCompositeImageUrlTree(manifest, normalizedOptions, context);
|
|
1890
|
+
const imageData = await loadCompositeImageUrlTree(urlTree, normalizedOptions, context);
|
|
1891
|
+
return convertCompositeImageToTexture(manifest.shape, imageData);
|
|
1892
|
+
}
|
|
1893
|
+
async function loadCompositeImageUrlTree(urlTree, options = {}, context) {
|
|
1894
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
1895
|
+
return await asyncDeepMap(urlTree, async (url) => await loadCompositeImageMember(url, normalizedOptions, context));
|
|
1896
|
+
}
|
|
1897
|
+
async function loadCompositeImageMember(url, options = {}, context) {
|
|
1898
|
+
const resolvedUrl = resolveCompositeImageUrl(url, options, context);
|
|
1899
|
+
const fetch2 = getCompositeImageFetch(options, context);
|
|
1900
|
+
const response = await fetch2(resolvedUrl);
|
|
1901
|
+
const subloaderOptions = getCompositeImageSubloaderOptions(options);
|
|
1902
|
+
if (context) {
|
|
1903
|
+
const childContext = getCompositeImageMemberContext(resolvedUrl, response, context);
|
|
1904
|
+
return await (0, import_loader_utils4.parseFromContext)(response, [import_images.ImageLoader], subloaderOptions, childContext);
|
|
1905
|
+
}
|
|
1906
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
1907
|
+
return await import_images.ImageLoader.parse(arrayBuffer, subloaderOptions);
|
|
1908
|
+
}
|
|
1909
|
+
async function getCompositeImageUrlTree(manifest, options = {}, context) {
|
|
1910
|
+
switch (manifest.shape) {
|
|
1911
|
+
case "image-texture":
|
|
1912
|
+
return await getImageTextureSource(manifest, options, context);
|
|
1913
|
+
case "image-texture-array":
|
|
1914
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
1915
|
+
throw new Error("image-texture-array manifest must define one or more layers");
|
|
1916
|
+
}
|
|
1917
|
+
return await Promise.all(manifest.layers.map(async (layer, index) => await getNormalizedImageTextureSource(layer, options, context, { index })));
|
|
1918
|
+
case "image-texture-cube":
|
|
1919
|
+
return await getImageTextureCubeUrls(manifest, options, context);
|
|
1920
|
+
case "image-texture-cube-array":
|
|
1921
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
1922
|
+
throw new Error("image-texture-cube-array manifest must define one or more layers");
|
|
1923
|
+
}
|
|
1924
|
+
return await Promise.all(manifest.layers.map(async (layer, index) => await getImageTextureCubeUrls(layer, options, context, { index })));
|
|
1925
|
+
default:
|
|
1926
|
+
throw new Error("Unsupported composite image manifest");
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function normalizeCompositeImageOptions(options = {}) {
|
|
1930
|
+
var _a;
|
|
1931
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUrl) {
|
|
1932
|
+
return options;
|
|
1933
|
+
}
|
|
1934
|
+
const fallbackBaseUrl = options.baseUrl;
|
|
1935
|
+
if (!fallbackBaseUrl) {
|
|
1936
|
+
return options;
|
|
1937
|
+
}
|
|
1938
|
+
return {
|
|
1939
|
+
...options,
|
|
1940
|
+
core: {
|
|
1941
|
+
...options.core,
|
|
1942
|
+
baseUrl: fallbackBaseUrl
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
function resolveCompositeImageUrl(url, options = {}, context) {
|
|
1947
|
+
const resolvedUrl = (0, import_loader_utils4.resolvePath)(url);
|
|
1948
|
+
if (isAbsoluteCompositeImageUrl(url)) {
|
|
1949
|
+
return resolvedUrl;
|
|
1950
|
+
}
|
|
1951
|
+
const baseUrl = getCompositeImageBaseUrl(options, context);
|
|
1952
|
+
if (!baseUrl) {
|
|
1953
|
+
if (resolvedUrl !== url || url.startsWith("@")) {
|
|
1954
|
+
return resolvedUrl;
|
|
1955
|
+
}
|
|
1956
|
+
throw new Error(`Unable to resolve relative image URL ${url} without a base URL`);
|
|
1957
|
+
}
|
|
1958
|
+
return (0, import_loader_utils4.resolvePath)(joinCompositeImageUrl(baseUrl, url));
|
|
1959
|
+
}
|
|
1960
|
+
function parseCompositeImageManifestJSON(text) {
|
|
1961
|
+
const manifest = JSON.parse(text);
|
|
1962
|
+
if (!(manifest == null ? void 0 : manifest.shape)) {
|
|
1963
|
+
throw new Error("Composite image manifest must contain a shape field");
|
|
1964
|
+
}
|
|
1965
|
+
return manifest;
|
|
1966
|
+
}
|
|
1967
|
+
async function getImageTextureSource(manifest, options, context) {
|
|
1968
|
+
var _a;
|
|
1969
|
+
if ((manifest.image || manifest.mipmaps) && manifest.template) {
|
|
1970
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1971
|
+
}
|
|
1972
|
+
if (manifest.image && manifest.mipmaps) {
|
|
1973
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1974
|
+
}
|
|
1975
|
+
if (manifest.image) {
|
|
1976
|
+
return manifest.image;
|
|
1977
|
+
}
|
|
1978
|
+
if ((_a = manifest.mipmaps) == null ? void 0 : _a.length) {
|
|
1979
|
+
return manifest.mipmaps;
|
|
1980
|
+
}
|
|
1981
|
+
if (manifest.template) {
|
|
1982
|
+
return await expandImageTextureSource({ mipLevels: manifest.mipLevels ?? "auto", template: manifest.template }, options, context, {});
|
|
1983
|
+
}
|
|
1984
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1985
|
+
}
|
|
1986
|
+
async function getImageTextureCubeUrls(manifest, options, context, templateOptions = {}) {
|
|
1987
|
+
var _a, _b;
|
|
1988
|
+
const urls = {};
|
|
1989
|
+
for (const { face, name, direction, axis, sign } of IMAGE_TEXTURE_CUBE_FACES) {
|
|
1990
|
+
const source = ((_a = manifest.faces) == null ? void 0 : _a[name]) || ((_b = manifest.faces) == null ? void 0 : _b[direction]);
|
|
1991
|
+
if (!source) {
|
|
1992
|
+
throw new Error(`image-texture-cube manifest is missing ${name} face`);
|
|
1993
|
+
}
|
|
1994
|
+
urls[face] = await getNormalizedImageTextureSource(source, options, context, {
|
|
1995
|
+
...templateOptions,
|
|
1996
|
+
face: name,
|
|
1997
|
+
direction,
|
|
1998
|
+
axis,
|
|
1999
|
+
sign
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
return urls;
|
|
2003
|
+
}
|
|
2004
|
+
async function getNormalizedImageTextureSource(source, options, context, templateOptions) {
|
|
2005
|
+
if (typeof source === "string") {
|
|
2006
|
+
return source;
|
|
2007
|
+
}
|
|
2008
|
+
if (Array.isArray(source) && source.length > 0) {
|
|
2009
|
+
return source;
|
|
2010
|
+
}
|
|
2011
|
+
if (isImageTextureTemplateSource(source)) {
|
|
2012
|
+
return await expandImageTextureSource(source, options, context, templateOptions);
|
|
2013
|
+
}
|
|
2014
|
+
throw new Error("Composite image source entries must be strings or non-empty mip arrays");
|
|
2015
|
+
}
|
|
2016
|
+
async function expandImageTextureSource(source, options, context, templateOptions) {
|
|
2017
|
+
const mipLevels = source.mipLevels === "auto" ? await getAutoMipLevels(source.template, options, context, templateOptions) : source.mipLevels;
|
|
2018
|
+
if (!Number.isFinite(mipLevels) || mipLevels <= 0) {
|
|
2019
|
+
throw new Error(`Invalid mipLevels value ${source.mipLevels}`);
|
|
2020
|
+
}
|
|
2021
|
+
const urls = [];
|
|
2022
|
+
for (let lod = 0; lod < mipLevels; lod++) {
|
|
2023
|
+
urls.push(expandTemplate(source.template, { ...templateOptions, lod }));
|
|
2024
|
+
}
|
|
2025
|
+
return urls;
|
|
2026
|
+
}
|
|
2027
|
+
async function getAutoMipLevels(template, options, context, templateOptions) {
|
|
2028
|
+
if (!template.includes("{lod}")) {
|
|
2029
|
+
throw new Error("Template sources with mipLevels: auto must include a {lod} placeholder");
|
|
2030
|
+
}
|
|
2031
|
+
const level0Url = expandTemplate(template, { ...templateOptions, lod: 0 });
|
|
2032
|
+
const image = await loadCompositeImageMember(level0Url, normalizeCompositeImageOptions(options), context);
|
|
2033
|
+
const { width, height } = (0, import_images.getImageSize)(image);
|
|
2034
|
+
return 1 + Math.floor(Math.log2(Math.max(width, height)));
|
|
2035
|
+
}
|
|
2036
|
+
function expandTemplate(template, templateOptions) {
|
|
2037
|
+
let expanded = "";
|
|
2038
|
+
for (let index = 0; index < template.length; index++) {
|
|
2039
|
+
const character = template[index];
|
|
2040
|
+
if (character === "\\") {
|
|
2041
|
+
const nextCharacter = template[index + 1];
|
|
2042
|
+
if (nextCharacter === "{" || nextCharacter === "}" || nextCharacter === "\\") {
|
|
2043
|
+
expanded += nextCharacter;
|
|
2044
|
+
index++;
|
|
2045
|
+
continue;
|
|
2046
|
+
}
|
|
2047
|
+
throw new Error(`Invalid escape sequence \\${nextCharacter || ""} in template ${template}`);
|
|
2048
|
+
}
|
|
2049
|
+
if (character === "}") {
|
|
2050
|
+
throw new Error(`Unexpected } in template ${template}`);
|
|
2051
|
+
}
|
|
2052
|
+
if (character !== "{") {
|
|
2053
|
+
expanded += character;
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
const closingBraceIndex = findClosingBraceIndex(template, index + 1);
|
|
2057
|
+
if (closingBraceIndex < 0) {
|
|
2058
|
+
throw new Error(`Unterminated placeholder in template ${template}`);
|
|
2059
|
+
}
|
|
2060
|
+
const placeholder = template.slice(index + 1, closingBraceIndex);
|
|
2061
|
+
if (!/^[a-z][a-zA-Z0-9]*$/.test(placeholder)) {
|
|
2062
|
+
throw new Error(`Invalid placeholder {${placeholder}} in template ${template}`);
|
|
2063
|
+
}
|
|
2064
|
+
const value = getTemplateValue(placeholder, templateOptions);
|
|
2065
|
+
if (value === void 0) {
|
|
2066
|
+
throw new Error(`Template ${template} uses unsupported placeholder {${placeholder}} for this source`);
|
|
2067
|
+
}
|
|
2068
|
+
expanded += String(value);
|
|
2069
|
+
index = closingBraceIndex;
|
|
2070
|
+
}
|
|
2071
|
+
return expanded;
|
|
2072
|
+
}
|
|
2073
|
+
function findClosingBraceIndex(template, startIndex) {
|
|
2074
|
+
for (let index = startIndex; index < template.length; index++) {
|
|
2075
|
+
const character = template[index];
|
|
2076
|
+
if (character === "\\") {
|
|
2077
|
+
index++;
|
|
2078
|
+
continue;
|
|
2079
|
+
}
|
|
2080
|
+
if (character === "{") {
|
|
2081
|
+
throw new Error(`Nested placeholders are not supported in template ${template}`);
|
|
2082
|
+
}
|
|
2083
|
+
if (character === "}") {
|
|
2084
|
+
return index;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
return -1;
|
|
2088
|
+
}
|
|
2089
|
+
function getTemplateValue(placeholder, templateOptions) {
|
|
2090
|
+
switch (placeholder) {
|
|
2091
|
+
case "lod":
|
|
2092
|
+
return templateOptions.lod;
|
|
2093
|
+
case "index":
|
|
2094
|
+
return templateOptions.index;
|
|
2095
|
+
case "face":
|
|
2096
|
+
return templateOptions.face;
|
|
2097
|
+
case "direction":
|
|
2098
|
+
return templateOptions.direction;
|
|
2099
|
+
case "axis":
|
|
2100
|
+
return templateOptions.axis;
|
|
2101
|
+
case "sign":
|
|
2102
|
+
return templateOptions.sign;
|
|
2103
|
+
default:
|
|
2104
|
+
return void 0;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
function isImageTextureTemplateSource(source) {
|
|
2108
|
+
return typeof source === "object" && source !== null && !Array.isArray(source);
|
|
2109
|
+
}
|
|
2110
|
+
function getCompositeImageBaseUrl(options, context) {
|
|
2111
|
+
var _a;
|
|
2112
|
+
if (context == null ? void 0 : context.baseUrl) {
|
|
2113
|
+
return context.baseUrl;
|
|
2114
|
+
}
|
|
2115
|
+
if (options.baseUrl) {
|
|
2116
|
+
return stripTrailingSlash(options.baseUrl);
|
|
2117
|
+
}
|
|
2118
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUrl) {
|
|
2119
|
+
return getSourceUrlDirectory(options.core.baseUrl);
|
|
2120
|
+
}
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
function stripTrailingSlash(baseUrl) {
|
|
2124
|
+
if (baseUrl.endsWith("/")) {
|
|
2125
|
+
return baseUrl.slice(0, -1);
|
|
2126
|
+
}
|
|
2127
|
+
return baseUrl;
|
|
2128
|
+
}
|
|
2129
|
+
function getSourceUrlDirectory(baseUrl) {
|
|
2130
|
+
return stripTrailingSlash(import_loader_utils4.path.dirname(baseUrl));
|
|
2131
|
+
}
|
|
2132
|
+
function joinCompositeImageUrl(baseUrl, url) {
|
|
2133
|
+
if (isRequestLikeUrl(baseUrl)) {
|
|
2134
|
+
return new URL(url, `${stripTrailingSlash(baseUrl)}/`).toString();
|
|
2135
|
+
}
|
|
2136
|
+
const normalizedBaseUrl = baseUrl.startsWith("/") ? baseUrl : `/${baseUrl}`;
|
|
2137
|
+
const normalizedUrl = import_loader_utils4.path.resolve(normalizedBaseUrl, url);
|
|
2138
|
+
return baseUrl.startsWith("/") ? normalizedUrl : normalizedUrl.slice(1);
|
|
2139
|
+
}
|
|
2140
|
+
function isRequestLikeUrl(url) {
|
|
2141
|
+
return url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:") || url.startsWith("blob:");
|
|
2142
|
+
}
|
|
2143
|
+
function getCompositeImageFetch(options, context) {
|
|
2144
|
+
var _a;
|
|
2145
|
+
const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
|
|
2146
|
+
if (context == null ? void 0 : context.fetch) {
|
|
2147
|
+
return context.fetch;
|
|
2148
|
+
}
|
|
2149
|
+
if (typeof fetchOption === "function") {
|
|
2150
|
+
return fetchOption;
|
|
2151
|
+
}
|
|
2152
|
+
if (fetchOption && typeof fetchOption === "object") {
|
|
2153
|
+
return (url) => fetch(url, fetchOption);
|
|
2154
|
+
}
|
|
2155
|
+
return fetch;
|
|
2156
|
+
}
|
|
2157
|
+
function getCompositeImageSubloaderOptions(options) {
|
|
2158
|
+
const core = options.core;
|
|
2159
|
+
const rest = { ...options };
|
|
2160
|
+
delete rest.baseUrl;
|
|
2161
|
+
if (!(core == null ? void 0 : core.baseUrl)) {
|
|
2162
|
+
return rest;
|
|
2163
|
+
}
|
|
2164
|
+
const restCore = { ...core };
|
|
2165
|
+
delete restCore.baseUrl;
|
|
2166
|
+
return {
|
|
2167
|
+
...rest,
|
|
2168
|
+
core: restCore
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
function normalizeCompositeImageManifestOptions(options) {
|
|
2172
|
+
var _a;
|
|
2173
|
+
if (((_a = options.image) == null ? void 0 : _a.type) || typeof ImageBitmap === "undefined") {
|
|
2174
|
+
return options;
|
|
2175
|
+
}
|
|
2176
|
+
return {
|
|
2177
|
+
...options,
|
|
2178
|
+
image: {
|
|
2179
|
+
...options.image,
|
|
2180
|
+
type: "imagebitmap"
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
function getCompositeImageMemberContext(resolvedUrl, response, context) {
|
|
2185
|
+
const url = response.url || resolvedUrl;
|
|
2186
|
+
const [urlWithoutQueryString, queryString = ""] = url.split("?");
|
|
2187
|
+
return {
|
|
2188
|
+
...context,
|
|
2189
|
+
url,
|
|
2190
|
+
response,
|
|
2191
|
+
filename: import_loader_utils4.path.filename(urlWithoutQueryString),
|
|
2192
|
+
baseUrl: import_loader_utils4.path.dirname(urlWithoutQueryString),
|
|
2193
|
+
queryString
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
function convertCompositeImageToTexture(shape, imageData) {
|
|
2197
|
+
switch (shape) {
|
|
2198
|
+
case "image-texture": {
|
|
2199
|
+
const data = normalizeCompositeImageMember(imageData);
|
|
2200
|
+
return {
|
|
2201
|
+
shape: "texture",
|
|
2202
|
+
type: "2d",
|
|
2203
|
+
format: getCompositeTextureFormat(data),
|
|
2204
|
+
data
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
case "image-texture-array": {
|
|
2208
|
+
const data = imageData.map((layer) => normalizeCompositeImageMember(layer));
|
|
2209
|
+
return {
|
|
2210
|
+
shape: "texture",
|
|
2211
|
+
type: "2d-array",
|
|
2212
|
+
format: getCompositeTextureFormat(data[0]),
|
|
2213
|
+
data
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
case "image-texture-cube": {
|
|
2217
|
+
const data = IMAGE_TEXTURE_CUBE_FACES.map(({ face }) => normalizeCompositeImageMember(imageData[face]));
|
|
2218
|
+
return {
|
|
2219
|
+
shape: "texture",
|
|
2220
|
+
type: "cube",
|
|
2221
|
+
format: getCompositeTextureFormat(data[0]),
|
|
2222
|
+
data
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
case "image-texture-cube-array": {
|
|
2226
|
+
const data = imageData.map((layer) => IMAGE_TEXTURE_CUBE_FACES.map(({ face }) => normalizeCompositeImageMember(layer[face])));
|
|
2227
|
+
return {
|
|
2228
|
+
shape: "texture",
|
|
2229
|
+
type: "cube-array",
|
|
2230
|
+
format: getCompositeTextureFormat(data[0][0]),
|
|
2231
|
+
data
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
default:
|
|
2235
|
+
throw new Error(`Unsupported composite image shape ${shape}`);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
function normalizeCompositeImageMember(imageData) {
|
|
2239
|
+
if (Array.isArray(imageData)) {
|
|
2240
|
+
if (imageData.length === 0) {
|
|
2241
|
+
throw new Error("Composite image members must not be empty");
|
|
2242
|
+
}
|
|
2243
|
+
if (imageData.every(isTextureLevel)) {
|
|
2244
|
+
return imageData;
|
|
2245
|
+
}
|
|
2246
|
+
if (imageData.every(import_images.isImage)) {
|
|
2247
|
+
return imageData.map((image) => getTextureLevelFromImage(image));
|
|
2248
|
+
}
|
|
2249
|
+
if (imageData.every((entry) => Array.isArray(entry) && entry.every(isTextureLevel))) {
|
|
2250
|
+
if (imageData.length !== 1) {
|
|
2251
|
+
throw new Error("Composite image members must resolve to a single image or mip chain");
|
|
2252
|
+
}
|
|
2253
|
+
return imageData[0];
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
if (isTexture(imageData)) {
|
|
2257
|
+
if (imageData.type !== "2d") {
|
|
2258
|
+
throw new Error(`Composite image members must resolve to 2d textures, got ${imageData.type}`);
|
|
2259
|
+
}
|
|
2260
|
+
return imageData.data;
|
|
2261
|
+
}
|
|
2262
|
+
if (isTextureLevel(imageData)) {
|
|
2263
|
+
return [imageData];
|
|
2264
|
+
}
|
|
2265
|
+
if ((0, import_images.isImage)(imageData)) {
|
|
2266
|
+
return [getTextureLevelFromImage(imageData)];
|
|
2267
|
+
}
|
|
2268
|
+
throw new Error("Composite image members must resolve to an image, mip chain, or texture");
|
|
2269
|
+
}
|
|
2270
|
+
function getTextureLevelFromImage(image) {
|
|
2271
|
+
const { width, height } = (0, import_images.getImageSize)(image);
|
|
2272
|
+
return {
|
|
2273
|
+
shape: "texture-level",
|
|
2274
|
+
compressed: false,
|
|
2275
|
+
width,
|
|
2276
|
+
height,
|
|
2277
|
+
imageBitmap: typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap ? image : void 0,
|
|
2278
|
+
data: new Uint8Array(0),
|
|
2279
|
+
textureFormat: "rgba8unorm"
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
function getCompositeTextureFormat(textureLevels) {
|
|
2283
|
+
var _a;
|
|
2284
|
+
return ((_a = textureLevels[0]) == null ? void 0 : _a.textureFormat) || "rgba8unorm";
|
|
2285
|
+
}
|
|
2286
|
+
function isTextureLevel(textureLevel) {
|
|
2287
|
+
return Boolean(textureLevel && typeof textureLevel === "object" && "shape" in textureLevel && textureLevel.shape === "texture-level");
|
|
2288
|
+
}
|
|
2289
|
+
function isTexture(texture) {
|
|
2290
|
+
return Boolean(texture && typeof texture === "object" && "shape" in texture && texture.shape === "texture");
|
|
2291
|
+
}
|
|
2292
|
+
function isAbsoluteCompositeImageUrl(url) {
|
|
2293
|
+
return url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("file:") || url.startsWith("http:") || url.startsWith("https:") || url.startsWith("/");
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// dist/texture-loader.js
|
|
2297
|
+
var TextureLoader = {
|
|
2298
|
+
dataType: null,
|
|
2299
|
+
batchType: null,
|
|
2300
|
+
id: "texture",
|
|
2301
|
+
name: "Texture",
|
|
2302
|
+
module: "textures",
|
|
2303
|
+
version: VERSION,
|
|
2304
|
+
extensions: [],
|
|
2305
|
+
mimeTypes: [],
|
|
2306
|
+
text: true,
|
|
2307
|
+
worker: false,
|
|
2308
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture"),
|
|
2309
|
+
options: {
|
|
2310
|
+
image: {}
|
|
2311
|
+
},
|
|
2312
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture", options, context),
|
|
2313
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture", options, context)
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
// dist/texture-array-loader.js
|
|
2317
|
+
var TextureArrayLoader = {
|
|
2318
|
+
dataType: null,
|
|
2319
|
+
batchType: null,
|
|
2320
|
+
id: "texture-array",
|
|
2321
|
+
name: "Texture Array",
|
|
2322
|
+
module: "textures",
|
|
2323
|
+
version: VERSION,
|
|
2324
|
+
extensions: [],
|
|
2325
|
+
mimeTypes: [],
|
|
2326
|
+
text: true,
|
|
2327
|
+
worker: false,
|
|
2328
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-array"),
|
|
2329
|
+
options: {
|
|
2330
|
+
image: {}
|
|
2331
|
+
},
|
|
2332
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-array", options, context),
|
|
2333
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-array", options, context)
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
// dist/texture-cube-loader.js
|
|
2337
|
+
var TextureCubeLoader = {
|
|
2338
|
+
dataType: null,
|
|
2339
|
+
batchType: null,
|
|
2340
|
+
id: "texture-cube",
|
|
2341
|
+
name: "Texture Cube",
|
|
2342
|
+
module: "textures",
|
|
2343
|
+
version: VERSION,
|
|
2344
|
+
extensions: [],
|
|
2345
|
+
mimeTypes: [],
|
|
2346
|
+
text: true,
|
|
2347
|
+
worker: false,
|
|
2348
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube"),
|
|
2349
|
+
options: {
|
|
2350
|
+
image: {}
|
|
2351
|
+
},
|
|
2352
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-cube", options, context),
|
|
2353
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube", options, context)
|
|
2354
|
+
};
|
|
2355
|
+
|
|
2356
|
+
// dist/texture-cube-array-loader.js
|
|
2357
|
+
var TextureCubeArrayLoader = {
|
|
2358
|
+
dataType: null,
|
|
2359
|
+
batchType: null,
|
|
2360
|
+
id: "texture-cube-array",
|
|
2361
|
+
name: "Texture Cube Array",
|
|
2362
|
+
module: "textures",
|
|
2363
|
+
version: VERSION,
|
|
2364
|
+
extensions: [],
|
|
2365
|
+
mimeTypes: [],
|
|
2366
|
+
text: true,
|
|
2367
|
+
worker: false,
|
|
2368
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube-array"),
|
|
2369
|
+
options: {
|
|
2370
|
+
image: {}
|
|
2371
|
+
},
|
|
2372
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-cube-array", options, context),
|
|
2373
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube-array", options, context)
|
|
2374
|
+
};
|
|
2375
|
+
|
|
1099
2376
|
// dist/lib/parsers/crunch-module-loader.js
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
2377
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
2378
|
+
var import_worker_utils3 = require("@loaders.gl/worker-utils");
|
|
1102
2379
|
var CRUNCH_EXTERNAL_LIBRARIES = {
|
|
1103
2380
|
/** Crunch decoder library. It is used as dynamically imported script */
|
|
1104
2381
|
DECODER: "crunch.js"
|
|
1105
2382
|
};
|
|
1106
2383
|
|
|
1107
2384
|
// dist/lib/encoders/encode-texture.js
|
|
1108
|
-
var
|
|
2385
|
+
var import_worker_utils4 = require("@loaders.gl/worker-utils");
|
|
1109
2386
|
async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options) {
|
|
1110
2387
|
const args = [
|
|
1111
2388
|
// Note: our actual executable is `npx`, so `texture-compressor` is an argument
|
|
@@ -1121,7 +2398,7 @@ async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options
|
|
|
1121
2398
|
"--output",
|
|
1122
2399
|
outputUrl
|
|
1123
2400
|
];
|
|
1124
|
-
const childProcess = new
|
|
2401
|
+
const childProcess = new import_worker_utils4.ChildProcessProxy();
|
|
1125
2402
|
await childProcess.start({
|
|
1126
2403
|
command: "npx",
|
|
1127
2404
|
arguments: args,
|
|
@@ -1155,9 +2432,10 @@ var CompressedTextureWriter = {
|
|
|
1155
2432
|
};
|
|
1156
2433
|
|
|
1157
2434
|
// dist/lib/encoders/encode-ktx2-basis-texture.js
|
|
2435
|
+
var import_worker_utils5 = require("@loaders.gl/worker-utils");
|
|
1158
2436
|
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
1159
2437
|
const { useSRGB = false, qualityLevel = 10, encodeUASTC = false, mipmaps = false } = (options == null ? void 0 : options["ktx2-basis-writer"]) || {};
|
|
1160
|
-
const { BasisEncoder } = await loadBasisEncoderModule(
|
|
2438
|
+
const { BasisEncoder } = await loadBasisEncoderModule((0, import_worker_utils5.extractLoadLibraryOptions)(options));
|
|
1161
2439
|
const basisEncoder = new BasisEncoder();
|
|
1162
2440
|
try {
|
|
1163
2441
|
const basisFileData = new Uint8Array(image.width * image.height * 4);
|
|
@@ -1201,67 +2479,18 @@ var KTX2BasisWriter = {
|
|
|
1201
2479
|
};
|
|
1202
2480
|
|
|
1203
2481
|
// dist/lib/texture-api/load-image.js
|
|
1204
|
-
var
|
|
1205
|
-
var
|
|
2482
|
+
var import_loader_utils6 = require("@loaders.gl/loader-utils");
|
|
2483
|
+
var import_images2 = require("@loaders.gl/images");
|
|
1206
2484
|
|
|
1207
2485
|
// dist/lib/texture-api/generate-url.js
|
|
1208
|
-
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
1209
2486
|
function generateUrl(getUrl, options, urlOptions) {
|
|
1210
|
-
|
|
1211
|
-
const baseUrl = options.baseUrl;
|
|
1212
|
-
if (baseUrl) {
|
|
1213
|
-
url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
1214
|
-
}
|
|
1215
|
-
return (0, import_loader_utils4.resolvePath)(url);
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
// dist/lib/texture-api/async-deep-map.js
|
|
1219
|
-
var isObject = (value) => value && typeof value === "object";
|
|
1220
|
-
async function asyncDeepMap(tree, func, options = {}) {
|
|
1221
|
-
return await mapSubtree(tree, func, options);
|
|
1222
|
-
}
|
|
1223
|
-
async function mapSubtree(object, func, options) {
|
|
1224
|
-
if (Array.isArray(object)) {
|
|
1225
|
-
return await mapArray(object, func, options);
|
|
1226
|
-
}
|
|
1227
|
-
if (isObject(object)) {
|
|
1228
|
-
return await mapObject(object, func, options);
|
|
1229
|
-
}
|
|
1230
|
-
const url = object;
|
|
1231
|
-
return await func(url, options);
|
|
1232
|
-
}
|
|
1233
|
-
async function mapObject(object, func, options) {
|
|
1234
|
-
const promises = [];
|
|
1235
|
-
const values = {};
|
|
1236
|
-
for (const key in object) {
|
|
1237
|
-
const url = object[key];
|
|
1238
|
-
const promise = mapSubtree(url, func, options).then((value) => {
|
|
1239
|
-
values[key] = value;
|
|
1240
|
-
});
|
|
1241
|
-
promises.push(promise);
|
|
1242
|
-
}
|
|
1243
|
-
await Promise.all(promises);
|
|
1244
|
-
return values;
|
|
1245
|
-
}
|
|
1246
|
-
async function mapArray(urlArray, func, options = {}) {
|
|
1247
|
-
const promises = urlArray.map((url) => mapSubtree(url, func, options));
|
|
1248
|
-
return await Promise.all(promises);
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
// dist/lib/texture-api/deep-load.js
|
|
1252
|
-
async function deepLoad(urlTree, load, options) {
|
|
1253
|
-
return await asyncDeepMap(urlTree, (url) => shallowLoad(url, load, options));
|
|
1254
|
-
}
|
|
1255
|
-
async function shallowLoad(url, load, options) {
|
|
1256
|
-
const response = await fetch(url, options.fetch);
|
|
1257
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
1258
|
-
return await load(arrayBuffer, options);
|
|
2487
|
+
return typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
|
|
1259
2488
|
}
|
|
1260
2489
|
|
|
1261
2490
|
// dist/lib/texture-api/load-image.js
|
|
1262
2491
|
async function loadImageTexture(getUrl, options = {}) {
|
|
1263
2492
|
const imageUrls = await getImageUrls(getUrl, options);
|
|
1264
|
-
return await
|
|
2493
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
1265
2494
|
}
|
|
1266
2495
|
async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
1267
2496
|
const mipLevels = options && options.image && options.image.mipLevels || 0;
|
|
@@ -1269,14 +2498,15 @@ async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
|
1269
2498
|
}
|
|
1270
2499
|
async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
|
|
1271
2500
|
const urls = [];
|
|
2501
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
1272
2502
|
if (mipLevels === "auto") {
|
|
1273
2503
|
const url = generateUrl(getUrl, options, { ...urlOptions, lod: 0 });
|
|
1274
|
-
const image = await
|
|
1275
|
-
const { width, height } = (0,
|
|
2504
|
+
const image = await loadCompositeImageMember(url, normalizedOptions);
|
|
2505
|
+
const { width, height } = (0, import_images2.getImageSize)(image);
|
|
1276
2506
|
mipLevels = getMipLevels({ width, height });
|
|
1277
2507
|
urls.push(url);
|
|
1278
2508
|
}
|
|
1279
|
-
(0,
|
|
2509
|
+
(0, import_loader_utils6.assert)(mipLevels > 0);
|
|
1280
2510
|
for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
|
|
1281
2511
|
const url = generateUrl(getUrl, options, { ...urlOptions, lod: mipLevel });
|
|
1282
2512
|
urls.push(url);
|
|
@@ -1288,10 +2518,9 @@ function getMipLevels(size) {
|
|
|
1288
2518
|
}
|
|
1289
2519
|
|
|
1290
2520
|
// dist/lib/texture-api/load-image-array.js
|
|
1291
|
-
var import_images2 = require("@loaders.gl/images");
|
|
1292
2521
|
async function loadImageTextureArray(count, getUrl, options = {}) {
|
|
1293
2522
|
const imageUrls = await getImageArrayUrls(count, getUrl, options);
|
|
1294
|
-
return await
|
|
2523
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
1295
2524
|
}
|
|
1296
2525
|
async function getImageArrayUrls(count, getUrl, options = {}) {
|
|
1297
2526
|
const promises = [];
|
|
@@ -1303,27 +2532,12 @@ async function getImageArrayUrls(count, getUrl, options = {}) {
|
|
|
1303
2532
|
}
|
|
1304
2533
|
|
|
1305
2534
|
// dist/lib/texture-api/load-image-cube.js
|
|
1306
|
-
var import_images3 = require("@loaders.gl/images");
|
|
1307
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
1308
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
1309
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
1310
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
1311
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
1312
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
1313
|
-
var CUBE_FACES = [
|
|
1314
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_X, direction: "right", axis: "x", sign: "positive" },
|
|
1315
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X, direction: "left", axis: "x", sign: "negative" },
|
|
1316
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, direction: "top", axis: "y", sign: "positive" },
|
|
1317
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, direction: "bottom", axis: "y", sign: "negative" },
|
|
1318
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z, direction: "front", axis: "z", sign: "positive" },
|
|
1319
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, direction: "back", axis: "z", sign: "negative" }
|
|
1320
|
-
];
|
|
1321
2535
|
async function getImageCubeUrls(getUrl, options) {
|
|
1322
2536
|
const urls = {};
|
|
1323
2537
|
const promises = [];
|
|
1324
2538
|
let index = 0;
|
|
1325
|
-
for (let i = 0; i <
|
|
1326
|
-
const face =
|
|
2539
|
+
for (let i = 0; i < IMAGE_TEXTURE_CUBE_FACES.length; ++i) {
|
|
2540
|
+
const face = IMAGE_TEXTURE_CUBE_FACES[index];
|
|
1327
2541
|
const promise = getImageUrls(getUrl, options, { ...face, index: index++ }).then((url) => {
|
|
1328
2542
|
urls[face.face] = url;
|
|
1329
2543
|
});
|
|
@@ -1334,7 +2548,7 @@ async function getImageCubeUrls(getUrl, options) {
|
|
|
1334
2548
|
}
|
|
1335
2549
|
async function loadImageTextureCube(getUrl, options = {}) {
|
|
1336
2550
|
const urls = await getImageCubeUrls(getUrl, options);
|
|
1337
|
-
return await
|
|
2551
|
+
return await loadCompositeImageUrlTree(urls, normalizeCompositeImageOptions(options));
|
|
1338
2552
|
}
|
|
1339
2553
|
|
|
1340
2554
|
// dist/index.js
|