@loaders.gl/textures 4.4.0-alpha.2 → 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 +1 -1
- package/dist/basis-loader.js.map +1 -0
- package/dist/basis-worker-node.js +932 -10040
- package/dist/basis-worker.d.ts +2 -0
- package/dist/basis-worker.d.ts.map +1 -0
- package/dist/basis-worker.js +337 -151
- package/dist/basis-worker.js.map +1 -0
- package/dist/compressed-texture-loader.d.ts +2 -5
- package/dist/compressed-texture-loader.d.ts.map +1 -1
- package/dist/compressed-texture-loader.js +2 -3
- package/dist/compressed-texture-loader.js.map +1 -0
- package/dist/compressed-texture-worker.d.ts +2 -0
- package/dist/compressed-texture-worker.d.ts.map +1 -0
- package/dist/compressed-texture-worker.js +1148 -365
- package/dist/compressed-texture-worker.js.map +1 -0
- package/dist/compressed-texture-writer.js +1 -0
- package/dist/compressed-texture-writer.js.map +1 -0
- package/dist/crunch-loader.d.ts +1 -5
- package/dist/crunch-loader.d.ts.map +1 -1
- package/dist/crunch-loader.js +2 -3
- package/dist/crunch-loader.js.map +1 -0
- package/dist/crunch-worker.d.ts +2 -0
- package/dist/crunch-worker.d.ts.map +1 -0
- package/dist/crunch-worker.js +204 -92
- package/dist/crunch-worker.js.map +1 -0
- package/dist/dist.dev.js +2687 -677
- package/dist/dist.min.js +1 -2
- package/dist/index.cjs +1644 -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 +7 -3
- package/dist/index.js.map +1 -0
- package/dist/ktx2-basis-writer-worker-node.js +574 -9832
- package/dist/ktx2-basis-writer-worker.d.ts +2 -0
- package/dist/ktx2-basis-writer-worker.d.ts.map +1 -0
- package/dist/ktx2-basis-writer-worker.js +45 -7
- package/dist/ktx2-basis-writer-worker.js.map +1 -0
- package/dist/ktx2-basis-writer.js +1 -0
- package/dist/ktx2-basis-writer.js.map +1 -0
- 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-ktx.d.ts +1 -1
- package/dist/lib/encoders/encode-ktx.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx.js +1 -0
- package/dist/lib/encoders/encode-ktx.js.map +1 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts +2 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +3 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -0
- package/dist/lib/encoders/encode-texture.js +1 -0
- package/dist/lib/encoders/encode-texture.js.map +1 -0
- 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 +178 -66
- package/dist/lib/gl-extensions.js.map +1 -0
- 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/basis-module-loader.d.ts +3 -2
- package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/basis-module-loader.js +1 -0
- package/dist/lib/parsers/basis-module-loader.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 +1 -0
- package/dist/lib/parsers/crunch-module-loader.js.map +1 -0
- package/dist/lib/parsers/parse-basis.d.ts +34 -2
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +265 -64
- package/dist/lib/parsers/parse-basis.js.map +1 -0
- package/dist/lib/parsers/parse-compressed-texture.js +1 -0
- package/dist/lib/parsers/parse-compressed-texture.js.map +1 -0
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
- package/dist/lib/parsers/parse-crunch.js +7 -6
- package/dist/lib/parsers/parse-crunch.js.map +1 -0
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dds.js +11 -11
- package/dist/lib/parsers/parse-dds.js.map +1 -0
- 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 +11 -3
- package/dist/lib/parsers/parse-ktx.js.map +1 -0
- package/dist/lib/parsers/parse-npy.js +1 -0
- package/dist/lib/parsers/parse-npy.js.map +1 -0
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
- package/dist/lib/parsers/parse-pvr.js +32 -74
- package/dist/lib/parsers/parse-pvr.js.map +1 -0
- package/dist/lib/texture-api/async-deep-map.js +1 -0
- package/dist/lib/texture-api/async-deep-map.js.map +1 -0
- package/dist/lib/texture-api/deep-load.js +1 -0
- package/dist/lib/texture-api/deep-load.js.map +1 -0
- package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
- package/dist/lib/texture-api/generate-url.js +3 -10
- package/dist/lib/texture-api/generate-url.js.map +1 -0
- 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 +6 -3
- package/dist/lib/texture-api/load-image-array.js.map +1 -0
- 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 +9 -20
- package/dist/lib/texture-api/load-image-cube.js.map +1 -0
- 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 +9 -4
- package/dist/lib/texture-api/load-image.js.map +1 -0
- 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/texture-api/texture-api-types.js +1 -0
- package/dist/lib/texture-api/texture-api-types.js.map +1 -0
- 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 +14 -2
- package/dist/lib/utils/extract-mipmap-images.js.map +1 -0
- 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 +77 -109
- package/dist/lib/utils/ktx-format-helper.js.map +1 -0
- 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 +2 -1
- package/dist/lib/utils/version.js.map +1 -0
- package/dist/libs/libs/README.md +9 -0
- package/dist/libs/libs/basis_encoder.js +21 -0
- package/dist/libs/libs/basis_encoder.wasm +0 -0
- package/dist/libs/libs/basis_transcoder.js +22 -0
- package/dist/libs/libs/basis_transcoder.wasm +0 -0
- package/dist/libs/libs/crunch.js +136 -0
- package/dist/npy-loader.d.ts +2 -2
- package/dist/npy-loader.js +1 -0
- package/dist/npy-loader.js.map +1 -0
- package/dist/npy-worker.d.ts +2 -0
- package/dist/npy-worker.d.ts.map +1 -0
- package/dist/npy-worker.js +5 -2
- package/dist/npy-worker.js.map +1 -0
- 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/basis-worker-node.js +1 -0
- package/dist/workers/basis-worker-node.js.map +1 -0
- package/dist/workers/basis-worker.js +1 -0
- package/dist/workers/basis-worker.js.map +1 -0
- package/dist/workers/compressed-texture-worker.js +1 -1
- package/dist/workers/compressed-texture-worker.js.map +1 -0
- package/dist/workers/crunch-worker.d.ts +1 -3
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/dist/workers/crunch-worker.js +1 -0
- package/dist/workers/crunch-worker.js.map +1 -0
- package/dist/workers/ktx2-basis-writer-worker-node.js +1 -0
- package/dist/workers/ktx2-basis-writer-worker-node.js.map +1 -0
- package/dist/workers/ktx2-basis-writer-worker.js +1 -0
- package/dist/workers/ktx2-basis-writer-worker.js.map +1 -0
- package/dist/workers/npy-worker.js +1 -0
- package/dist/workers/npy-worker.js.map +1 -0
- package/package.json +27 -6
- package/src/basis-loader.ts +19 -9
- package/src/basis-worker.ts +7 -0
- package/src/compressed-texture-loader.ts +3 -7
- package/src/compressed-texture-worker.ts +6 -0
- package/src/crunch-loader.ts +1 -5
- package/src/crunch-worker.ts +6 -0
- package/src/index.ts +21 -4
- package/src/ktx2-basis-writer-worker.ts +6 -0
- 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-ktx.ts +1 -1
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +4 -2
- package/src/lib/gl-extensions.ts +188 -81
- package/src/lib/gl-types.ts +136 -0
- package/src/lib/parsers/basis-module-loader.ts +5 -5
- package/src/lib/parsers/crunch-module-loader.ts +4 -4
- package/src/lib/parsers/parse-basis.ts +358 -66
- 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/npy-worker.ts +6 -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/src/workers/compressed-texture-worker.ts +0 -1
- 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 -50
- package/src/lib/utils/texture-formats.ts +0 -59
package/dist/dist.dev.js
CHANGED
|
@@ -45,13 +45,6 @@ var __exports__ = (() => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
// (disabled):../worker-utils/src/lib/process-utils/child-process-proxy
|
|
49
|
-
var require_child_process_proxy = __commonJS({
|
|
50
|
-
"(disabled):../worker-utils/src/lib/process-utils/child-process-proxy"() {
|
|
51
|
-
"use strict";
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
48
|
// bundle.ts
|
|
56
49
|
var bundle_exports = {};
|
|
57
50
|
__export(bundle_exports, {
|
|
@@ -64,70 +57,108 @@ var __exports__ = (() => {
|
|
|
64
57
|
CompressedTextureWriter: () => CompressedTextureWriter,
|
|
65
58
|
CrunchLoader: () => CrunchLoader,
|
|
66
59
|
CrunchWorkerLoader: () => CrunchLoader,
|
|
60
|
+
GL_COMPRESSED_R11_EAC: () => GL_COMPRESSED_R11_EAC,
|
|
61
|
+
GL_COMPRESSED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
62
|
+
GL_COMPRESSED_RED_RGTC1_EXT: () => GL_COMPRESSED_RED_RGTC1_EXT,
|
|
63
|
+
GL_COMPRESSED_RG11_EAC: () => GL_COMPRESSED_RG11_EAC,
|
|
64
|
+
GL_COMPRESSED_RGB8_ETC2: () => GL_COMPRESSED_RGB8_ETC2,
|
|
65
|
+
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
66
|
+
GL_COMPRESSED_RGBA8_ETC2_EAC: () => GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
67
|
+
GL_COMPRESSED_RGBA_ASTC_10x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
68
|
+
GL_COMPRESSED_RGBA_ASTC_10x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
69
|
+
GL_COMPRESSED_RGBA_ASTC_10x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
70
|
+
GL_COMPRESSED_RGBA_ASTC_10x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
71
|
+
GL_COMPRESSED_RGBA_ASTC_12x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
72
|
+
GL_COMPRESSED_RGBA_ASTC_12x12_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
73
|
+
GL_COMPRESSED_RGBA_ASTC_4x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
74
|
+
GL_COMPRESSED_RGBA_ASTC_5x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
75
|
+
GL_COMPRESSED_RGBA_ASTC_5x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
76
|
+
GL_COMPRESSED_RGBA_ASTC_6x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
77
|
+
GL_COMPRESSED_RGBA_ASTC_6x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
78
|
+
GL_COMPRESSED_RGBA_ASTC_8x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
79
|
+
GL_COMPRESSED_RGBA_ASTC_8x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
80
|
+
GL_COMPRESSED_RGBA_ASTC_8x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
81
|
+
GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
82
|
+
GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
83
|
+
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT: () => GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
84
|
+
GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
85
|
+
GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
86
|
+
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
87
|
+
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
88
|
+
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
89
|
+
GL_COMPRESSED_RGB_ATC_WEBGL: () => GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
90
|
+
GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
91
|
+
GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
92
|
+
GL_COMPRESSED_RGB_ETC1_WEBGL: () => GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
93
|
+
GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
94
|
+
GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
95
|
+
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
96
|
+
GL_COMPRESSED_SIGNED_R11_EAC: () => GL_COMPRESSED_SIGNED_R11_EAC,
|
|
97
|
+
GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
98
|
+
GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: () => GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
99
|
+
GL_COMPRESSED_SIGNED_RG11_EAC: () => GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
100
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
101
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
102
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
103
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
104
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
105
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
106
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
107
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
108
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
109
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
110
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
111
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
112
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
113
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
114
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: () => GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
115
|
+
GL_COMPRESSED_SRGB8_ETC2: () => GL_COMPRESSED_SRGB8_ETC2,
|
|
116
|
+
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
117
|
+
GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: () => GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
118
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
119
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
120
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
121
|
+
GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
67
122
|
GL_EXTENSIONS_CONSTANTS: () => GL_EXTENSIONS_CONSTANTS,
|
|
123
|
+
GL_RGB: () => GL_RGB,
|
|
124
|
+
GL_RGB565: () => GL_RGB565,
|
|
125
|
+
GL_RGB5_A1: () => GL_RGB5_A1,
|
|
126
|
+
GL_RGBA: () => GL_RGBA,
|
|
127
|
+
GL_RGBA32F: () => GL_RGBA32F,
|
|
128
|
+
GL_RGBA4: () => GL_RGBA4,
|
|
129
|
+
GL_RGBA8: () => GL_RGBA8,
|
|
68
130
|
KTX2BasisWriter: () => KTX2BasisWriter,
|
|
69
131
|
KTX2BasisWriterWorker: () => KTX2BasisWriterWorker,
|
|
70
132
|
NPYLoader: () => NPYLoader,
|
|
71
133
|
NPYWorkerLoader: () => NPYWorkerLoader,
|
|
72
|
-
|
|
134
|
+
RadianceHDRLoader: () => RadianceHDRLoader,
|
|
135
|
+
TextureArrayLoader: () => TextureArrayLoader,
|
|
136
|
+
TextureCubeArrayLoader: () => TextureCubeArrayLoader,
|
|
137
|
+
TextureCubeLoader: () => TextureCubeLoader,
|
|
138
|
+
TextureLoader: () => TextureLoader,
|
|
73
139
|
loadImageTexture: () => loadImageTexture,
|
|
74
140
|
loadImageTextureArray: () => loadImageTextureArray,
|
|
75
|
-
loadImageTextureCube: () => loadImageTextureCube
|
|
76
|
-
selectSupportedBasisFormat: () => selectSupportedBasisFormat
|
|
141
|
+
loadImageTextureCube: () => loadImageTextureCube
|
|
77
142
|
});
|
|
78
143
|
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
79
144
|
|
|
80
145
|
// src/lib/utils/version.ts
|
|
81
146
|
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
82
147
|
|
|
83
|
-
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
84
|
-
function assert(condition, message) {
|
|
85
|
-
if (!condition) {
|
|
86
|
-
throw new Error(message || "loader assertion failed.");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ../loader-utils/src/lib/env-utils/globals.ts
|
|
91
|
-
var globals = {
|
|
92
|
-
self: typeof self !== "undefined" && self,
|
|
93
|
-
window: typeof window !== "undefined" && window,
|
|
94
|
-
global: typeof global !== "undefined" && global,
|
|
95
|
-
document: typeof document !== "undefined" && document
|
|
96
|
-
};
|
|
97
|
-
var self_ = globals.self || globals.window || globals.global || {};
|
|
98
|
-
var window_ = globals.window || globals.self || globals.global || {};
|
|
99
|
-
var global_ = globals.global || globals.self || globals.window || {};
|
|
100
|
-
var document_ = globals.document || {};
|
|
101
|
-
var isBrowser = (
|
|
102
|
-
// @ts-ignore process does not exist on browser
|
|
103
|
-
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
104
|
-
);
|
|
105
|
-
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
106
|
-
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
107
|
-
|
|
108
|
-
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
109
|
-
function registerJSModules(modules) {
|
|
110
|
-
globalThis.loaders ||= {};
|
|
111
|
-
globalThis.loaders.modules ||= {};
|
|
112
|
-
Object.assign(globalThis.loaders.modules, modules);
|
|
113
|
-
}
|
|
114
|
-
function getJSModuleOrNull(name) {
|
|
115
|
-
const module = globalThis.loaders?.modules?.[name];
|
|
116
|
-
return module || null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
148
|
// ../worker-utils/src/lib/npm-tag.ts
|
|
120
149
|
var NPM_TAG = "beta";
|
|
121
150
|
|
|
122
151
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
152
|
+
var warningIssued = false;
|
|
123
153
|
function getVersion() {
|
|
124
154
|
if (!globalThis._loadersgl_?.version) {
|
|
125
155
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
126
|
-
if (typeof __VERSION__ === "undefined") {
|
|
156
|
+
if (typeof __VERSION__ === "undefined" && !warningIssued) {
|
|
127
157
|
console.warn(
|
|
128
158
|
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
129
159
|
);
|
|
130
160
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
161
|
+
warningIssued = true;
|
|
131
162
|
} else {
|
|
132
163
|
globalThis._loadersgl_.version = __VERSION__;
|
|
133
164
|
}
|
|
@@ -137,34 +168,44 @@ var __exports__ = (() => {
|
|
|
137
168
|
var VERSION2 = getVersion();
|
|
138
169
|
|
|
139
170
|
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
140
|
-
function
|
|
171
|
+
function assert(condition, message) {
|
|
141
172
|
if (!condition) {
|
|
142
173
|
throw new Error(message || "loaders.gl assertion failed.");
|
|
143
174
|
}
|
|
144
175
|
}
|
|
145
176
|
|
|
146
177
|
// ../worker-utils/src/lib/env-utils/globals.ts
|
|
147
|
-
var
|
|
178
|
+
var globals = {
|
|
148
179
|
self: typeof self !== "undefined" && self,
|
|
149
180
|
window: typeof window !== "undefined" && window,
|
|
150
181
|
global: typeof global !== "undefined" && global,
|
|
151
182
|
document: typeof document !== "undefined" && document
|
|
152
183
|
};
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
var
|
|
184
|
+
var self_ = globals.self || globals.window || globals.global || {};
|
|
185
|
+
var window_ = globals.window || globals.self || globals.global || {};
|
|
186
|
+
var global_ = globals.global || globals.self || globals.window || {};
|
|
187
|
+
var document_ = globals.document || {};
|
|
188
|
+
var isBrowser = (
|
|
158
189
|
// @ts-ignore process.browser
|
|
159
190
|
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
160
191
|
);
|
|
161
192
|
var isWorker = typeof importScripts === "function";
|
|
162
193
|
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
163
|
-
var
|
|
164
|
-
var
|
|
194
|
+
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
195
|
+
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
165
196
|
|
|
166
197
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
167
198
|
var loadLibraryPromises = {};
|
|
199
|
+
function extractLoadLibraryOptions(options = {}) {
|
|
200
|
+
const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries;
|
|
201
|
+
const CDN = options.CDN ?? options.core?.CDN;
|
|
202
|
+
const modules = options.modules;
|
|
203
|
+
return {
|
|
204
|
+
...useLocalLibraries !== void 0 ? { useLocalLibraries } : {},
|
|
205
|
+
...CDN !== void 0 ? { CDN } : {},
|
|
206
|
+
...modules !== void 0 ? { modules } : {}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
168
209
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
169
210
|
if (moduleName) {
|
|
170
211
|
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
@@ -174,6 +215,9 @@ var __exports__ = (() => {
|
|
|
174
215
|
return await loadLibraryPromises[libraryUrl];
|
|
175
216
|
}
|
|
176
217
|
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
218
|
+
if (options?.core) {
|
|
219
|
+
throw new Error("loadLibrary: options.core must be pre-normalized");
|
|
220
|
+
}
|
|
177
221
|
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
178
222
|
return library;
|
|
179
223
|
}
|
|
@@ -182,11 +226,11 @@ var __exports__ = (() => {
|
|
|
182
226
|
if (modules[libraryName]) {
|
|
183
227
|
return modules[libraryName];
|
|
184
228
|
}
|
|
185
|
-
if (!
|
|
229
|
+
if (!isBrowser) {
|
|
186
230
|
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
187
231
|
}
|
|
188
232
|
if (options.CDN) {
|
|
189
|
-
|
|
233
|
+
assert(options.CDN.startsWith("http"));
|
|
190
234
|
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
191
235
|
}
|
|
192
236
|
if (isWorker) {
|
|
@@ -198,11 +242,21 @@ var __exports__ = (() => {
|
|
|
198
242
|
if (libraryUrl.endsWith("wasm")) {
|
|
199
243
|
return await loadAsArrayBuffer(libraryUrl);
|
|
200
244
|
}
|
|
201
|
-
if (!
|
|
245
|
+
if (!isBrowser) {
|
|
246
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
202
247
|
try {
|
|
203
|
-
const
|
|
204
|
-
|
|
248
|
+
const result = await requireFromFile?.(libraryUrl);
|
|
249
|
+
if (result || !libraryUrl.includes("/dist/libs/")) {
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
|
|
205
253
|
} catch (error) {
|
|
254
|
+
if (libraryUrl.includes("/dist/libs/")) {
|
|
255
|
+
try {
|
|
256
|
+
return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
|
|
257
|
+
} catch {
|
|
258
|
+
}
|
|
259
|
+
}
|
|
206
260
|
console.error(error);
|
|
207
261
|
return null;
|
|
208
262
|
}
|
|
@@ -214,7 +268,7 @@ var __exports__ = (() => {
|
|
|
214
268
|
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
215
269
|
}
|
|
216
270
|
function loadLibraryFromString(scriptSource, id) {
|
|
217
|
-
if (!
|
|
271
|
+
if (!isBrowser) {
|
|
218
272
|
const { requireFromString } = globalThis.loaders || {};
|
|
219
273
|
return requireFromString?.(scriptSource, id);
|
|
220
274
|
}
|
|
@@ -234,230 +288,1143 @@ var __exports__ = (() => {
|
|
|
234
288
|
}
|
|
235
289
|
async function loadAsArrayBuffer(url) {
|
|
236
290
|
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
237
|
-
if (
|
|
291
|
+
if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
238
292
|
const response = await fetch(url);
|
|
239
293
|
return await response.arrayBuffer();
|
|
240
294
|
}
|
|
241
|
-
|
|
295
|
+
try {
|
|
296
|
+
return await readFileAsArrayBuffer(url);
|
|
297
|
+
} catch {
|
|
298
|
+
if (url.includes("/dist/libs/")) {
|
|
299
|
+
return await readFileAsArrayBuffer(url.replace("/dist/libs/", "/src/libs/"));
|
|
300
|
+
}
|
|
301
|
+
throw new Error(`Failed to load ArrayBuffer from ${url}`);
|
|
302
|
+
}
|
|
242
303
|
}
|
|
243
304
|
async function loadAsText(url) {
|
|
244
305
|
const { readFileAsText } = globalThis.loaders || {};
|
|
245
|
-
if (
|
|
306
|
+
if (isBrowser || !readFileAsText || url.startsWith("http")) {
|
|
246
307
|
const response = await fetch(url);
|
|
247
308
|
return await response.text();
|
|
248
309
|
}
|
|
249
|
-
|
|
310
|
+
try {
|
|
311
|
+
return await readFileAsText(url);
|
|
312
|
+
} catch {
|
|
313
|
+
if (url.includes("/dist/libs/")) {
|
|
314
|
+
return await readFileAsText(url.replace("/dist/libs/", "/src/libs/"));
|
|
315
|
+
}
|
|
316
|
+
throw new Error(`Failed to load text from ${url}`);
|
|
317
|
+
}
|
|
250
318
|
}
|
|
251
319
|
|
|
252
|
-
// ../worker-utils/src/
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
filename = filename.replace(alias, replacement);
|
|
263
|
-
}
|
|
320
|
+
// ../worker-utils/src/lib/process-utils/child-process-proxy.browser.ts
|
|
321
|
+
var ChildProcessProxy = class {
|
|
322
|
+
constructor() {
|
|
323
|
+
throw new Error("ChildProcessProxy is not available in browser environments");
|
|
324
|
+
}
|
|
325
|
+
async start(props) {
|
|
326
|
+
return await Promise.resolve({});
|
|
327
|
+
}
|
|
328
|
+
async stop() {
|
|
329
|
+
return await Promise.resolve();
|
|
264
330
|
}
|
|
265
|
-
|
|
266
|
-
|
|
331
|
+
async exit() {
|
|
332
|
+
return await Promise.resolve();
|
|
267
333
|
}
|
|
268
|
-
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// ../loader-utils/src/loader-types.ts
|
|
337
|
+
async function parseFromContext(data, loaders, options, context) {
|
|
338
|
+
return context._parse(data, loaders, options, context);
|
|
269
339
|
}
|
|
270
340
|
|
|
271
|
-
// src/lib/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
341
|
+
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
342
|
+
function assert2(condition, message) {
|
|
343
|
+
if (!condition) {
|
|
344
|
+
throw new Error(message || "loader assertion failed.");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// ../loader-utils/src/lib/env-utils/globals.ts
|
|
349
|
+
var globals2 = {
|
|
350
|
+
self: typeof self !== "undefined" && self,
|
|
351
|
+
window: typeof window !== "undefined" && window,
|
|
352
|
+
global: typeof global !== "undefined" && global,
|
|
353
|
+
document: typeof document !== "undefined" && document
|
|
281
354
|
};
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
355
|
+
var self_2 = globals2.self || globals2.window || globals2.global || {};
|
|
356
|
+
var window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
357
|
+
var global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
358
|
+
var document_2 = globals2.document || {};
|
|
359
|
+
var isBrowser2 = (
|
|
360
|
+
// @ts-ignore process does not exist on browser
|
|
361
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
362
|
+
);
|
|
363
|
+
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
364
|
+
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
365
|
+
|
|
366
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
367
|
+
var window_3 = globalThis;
|
|
368
|
+
var document_3 = globalThis.document || {};
|
|
369
|
+
var process_ = globalThis.process || {};
|
|
370
|
+
var console_ = globalThis.console;
|
|
371
|
+
var navigator_ = globalThis.navigator || {};
|
|
372
|
+
|
|
373
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
374
|
+
function isElectron(mockUserAgent) {
|
|
375
|
+
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
376
|
+
return true;
|
|
288
377
|
}
|
|
289
|
-
|
|
290
|
-
|
|
378
|
+
if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
|
|
382
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
383
|
+
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
291
384
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
385
|
+
|
|
386
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
387
|
+
function isBrowser3() {
|
|
388
|
+
const isNode = (
|
|
389
|
+
// @ts-expect-error
|
|
390
|
+
typeof process === "object" && String(process) === "[object process]" && !process?.browser
|
|
391
|
+
);
|
|
392
|
+
return !isNode || isElectron();
|
|
301
393
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
394
|
+
|
|
395
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
396
|
+
var VERSION3 = true ? "4.1.1" : "untranspiled source";
|
|
397
|
+
|
|
398
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
399
|
+
function assert3(condition, message) {
|
|
400
|
+
if (!condition) {
|
|
401
|
+
throw new Error(message || "Assertion failed");
|
|
306
402
|
}
|
|
307
|
-
return new Promise((resolve) => {
|
|
308
|
-
BasisModule(options).then((module) => {
|
|
309
|
-
const { BasisFile, initializeBasis } = module;
|
|
310
|
-
initializeBasis();
|
|
311
|
-
resolve({ BasisFile });
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
403
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
return
|
|
404
|
+
|
|
405
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js
|
|
406
|
+
function normalizeLogLevel(logLevel) {
|
|
407
|
+
if (!logLevel) {
|
|
408
|
+
return 0;
|
|
320
409
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
410
|
+
let resolvedLevel;
|
|
411
|
+
switch (typeof logLevel) {
|
|
412
|
+
case "number":
|
|
413
|
+
resolvedLevel = logLevel;
|
|
414
|
+
break;
|
|
415
|
+
case "object":
|
|
416
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
417
|
+
break;
|
|
418
|
+
default:
|
|
419
|
+
return 0;
|
|
420
|
+
}
|
|
421
|
+
assert3(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
422
|
+
return resolvedLevel;
|
|
333
423
|
}
|
|
334
|
-
function
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
424
|
+
function normalizeArguments(opts) {
|
|
425
|
+
const { logLevel, message } = opts;
|
|
426
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
427
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
428
|
+
while (args.length && args.shift() !== message) {
|
|
338
429
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
430
|
+
switch (typeof logLevel) {
|
|
431
|
+
case "string":
|
|
432
|
+
case "function":
|
|
433
|
+
if (message !== void 0) {
|
|
434
|
+
args.unshift(message);
|
|
435
|
+
}
|
|
436
|
+
opts.message = logLevel;
|
|
437
|
+
break;
|
|
438
|
+
case "object":
|
|
439
|
+
Object.assign(opts, logLevel);
|
|
440
|
+
break;
|
|
441
|
+
default:
|
|
442
|
+
}
|
|
443
|
+
if (typeof opts.message === "function") {
|
|
444
|
+
opts.message = opts.message();
|
|
445
|
+
}
|
|
446
|
+
const messageType = typeof opts.message;
|
|
447
|
+
assert3(messageType === "string" || messageType === "object");
|
|
448
|
+
return Object.assign(opts, { args }, opts.opts);
|
|
346
449
|
}
|
|
347
450
|
|
|
348
|
-
//
|
|
349
|
-
var
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
451
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/base-log.js
|
|
452
|
+
var noop = () => {
|
|
453
|
+
};
|
|
454
|
+
var BaseLog = class {
|
|
455
|
+
constructor({ level = 0 } = {}) {
|
|
456
|
+
this.userData = {};
|
|
457
|
+
this._onceCache = /* @__PURE__ */ new Set();
|
|
458
|
+
this._level = level;
|
|
459
|
+
}
|
|
460
|
+
set level(newLevel) {
|
|
461
|
+
this.setLevel(newLevel);
|
|
462
|
+
}
|
|
463
|
+
get level() {
|
|
464
|
+
return this.getLevel();
|
|
465
|
+
}
|
|
466
|
+
setLevel(level) {
|
|
467
|
+
this._level = level;
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
getLevel() {
|
|
471
|
+
return this._level;
|
|
472
|
+
}
|
|
473
|
+
// Unconditional logging
|
|
474
|
+
warn(message, ...args) {
|
|
475
|
+
return this._log("warn", 0, message, args, { once: true });
|
|
476
|
+
}
|
|
477
|
+
error(message, ...args) {
|
|
478
|
+
return this._log("error", 0, message, args);
|
|
479
|
+
}
|
|
480
|
+
// Conditional logging
|
|
481
|
+
log(logLevel, message, ...args) {
|
|
482
|
+
return this._log("log", logLevel, message, args);
|
|
483
|
+
}
|
|
484
|
+
info(logLevel, message, ...args) {
|
|
485
|
+
return this._log("info", logLevel, message, args);
|
|
486
|
+
}
|
|
487
|
+
once(logLevel, message, ...args) {
|
|
488
|
+
return this._log("once", logLevel, message, args, { once: true });
|
|
489
|
+
}
|
|
490
|
+
_log(type, logLevel, message, args, options = {}) {
|
|
491
|
+
const normalized = normalizeArguments({
|
|
492
|
+
logLevel,
|
|
493
|
+
message,
|
|
494
|
+
args: this._buildArgs(logLevel, message, args),
|
|
495
|
+
opts: options
|
|
496
|
+
});
|
|
497
|
+
return this._createLogFunction(type, normalized, options);
|
|
498
|
+
}
|
|
499
|
+
_buildArgs(logLevel, message, args) {
|
|
500
|
+
return [logLevel, message, ...args];
|
|
501
|
+
}
|
|
502
|
+
_createLogFunction(type, normalized, options) {
|
|
503
|
+
if (!this._shouldLog(normalized.logLevel)) {
|
|
504
|
+
return noop;
|
|
505
|
+
}
|
|
506
|
+
const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message);
|
|
507
|
+
if ((options.once || normalized.once) && tag !== void 0) {
|
|
508
|
+
if (this._onceCache.has(tag)) {
|
|
509
|
+
return noop;
|
|
510
|
+
}
|
|
511
|
+
this._onceCache.add(tag);
|
|
512
|
+
}
|
|
513
|
+
return this._emit(type, normalized);
|
|
514
|
+
}
|
|
515
|
+
_shouldLog(logLevel) {
|
|
516
|
+
return this.getLevel() >= normalizeLogLevel(logLevel);
|
|
517
|
+
}
|
|
518
|
+
_getOnceTag(tag) {
|
|
519
|
+
if (tag === void 0) {
|
|
520
|
+
return void 0;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
return typeof tag === "string" ? tag : String(tag);
|
|
524
|
+
} catch {
|
|
525
|
+
return void 0;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
416
528
|
};
|
|
417
529
|
|
|
418
|
-
//
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
530
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
531
|
+
function getStorage(type) {
|
|
532
|
+
try {
|
|
533
|
+
const storage = window[type];
|
|
534
|
+
const x = "__storage_test__";
|
|
535
|
+
storage.setItem(x, x);
|
|
536
|
+
storage.removeItem(x);
|
|
537
|
+
return storage;
|
|
538
|
+
} catch (e) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
var LocalStorage = class {
|
|
543
|
+
constructor(id, defaultConfig, type = "sessionStorage") {
|
|
544
|
+
this.storage = getStorage(type);
|
|
545
|
+
this.id = id;
|
|
546
|
+
this.config = defaultConfig;
|
|
547
|
+
this._loadConfiguration();
|
|
548
|
+
}
|
|
549
|
+
getConfiguration() {
|
|
550
|
+
return this.config;
|
|
551
|
+
}
|
|
552
|
+
setConfiguration(configuration) {
|
|
553
|
+
Object.assign(this.config, configuration);
|
|
554
|
+
if (this.storage) {
|
|
555
|
+
const serialized = JSON.stringify(this.config);
|
|
556
|
+
this.storage.setItem(this.id, serialized);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
// Get config from persistent store, if available
|
|
560
|
+
_loadConfiguration() {
|
|
561
|
+
let configuration = {};
|
|
562
|
+
if (this.storage) {
|
|
563
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
564
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
565
|
+
}
|
|
566
|
+
Object.assign(this.config, configuration);
|
|
567
|
+
return this;
|
|
568
|
+
}
|
|
431
569
|
};
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
570
|
+
|
|
571
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
572
|
+
function formatTime(ms) {
|
|
573
|
+
let formatted;
|
|
574
|
+
if (ms < 10) {
|
|
575
|
+
formatted = `${ms.toFixed(2)}ms`;
|
|
576
|
+
} else if (ms < 100) {
|
|
577
|
+
formatted = `${ms.toFixed(1)}ms`;
|
|
578
|
+
} else if (ms < 1e3) {
|
|
579
|
+
formatted = `${ms.toFixed(0)}ms`;
|
|
580
|
+
} else {
|
|
581
|
+
formatted = `${(ms / 1e3).toFixed(2)}s`;
|
|
582
|
+
}
|
|
583
|
+
return formatted;
|
|
584
|
+
}
|
|
585
|
+
function leftPad(string, length = 8) {
|
|
586
|
+
const padLength = Math.max(length - string.length, 0);
|
|
587
|
+
return `${" ".repeat(padLength)}${string}`;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
591
|
+
var COLOR;
|
|
592
|
+
(function(COLOR2) {
|
|
593
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
594
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
595
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
596
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
597
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
598
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
599
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
600
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
601
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
602
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
603
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
604
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
605
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
606
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
607
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
608
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
609
|
+
})(COLOR || (COLOR = {}));
|
|
610
|
+
var BACKGROUND_INCREMENT = 10;
|
|
611
|
+
function getColor(color) {
|
|
612
|
+
if (typeof color !== "string") {
|
|
613
|
+
return color;
|
|
614
|
+
}
|
|
615
|
+
color = color.toUpperCase();
|
|
616
|
+
return COLOR[color] || COLOR.WHITE;
|
|
617
|
+
}
|
|
618
|
+
function addColor(string, color, background) {
|
|
619
|
+
if (!isBrowser3 && typeof string === "string") {
|
|
620
|
+
if (color) {
|
|
621
|
+
const colorCode = getColor(color);
|
|
622
|
+
string = `\x1B[${colorCode}m${string}\x1B[39m`;
|
|
623
|
+
}
|
|
624
|
+
if (background) {
|
|
625
|
+
const colorCode = getColor(background);
|
|
626
|
+
string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return string;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
633
|
+
function autobind(obj, predefined = ["constructor"]) {
|
|
634
|
+
const proto = Object.getPrototypeOf(obj);
|
|
635
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
636
|
+
const object = obj;
|
|
637
|
+
for (const key of propNames) {
|
|
638
|
+
const value = object[key];
|
|
639
|
+
if (typeof value === "function") {
|
|
640
|
+
if (!predefined.find((name) => key === name)) {
|
|
641
|
+
object[key] = value.bind(obj);
|
|
443
642
|
}
|
|
444
643
|
}
|
|
445
644
|
}
|
|
446
|
-
return formats;
|
|
447
645
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
646
|
+
|
|
647
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
648
|
+
function getHiResTimestamp() {
|
|
649
|
+
let timestamp;
|
|
650
|
+
if (isBrowser3() && window_3.performance) {
|
|
651
|
+
timestamp = window_3?.performance?.now?.();
|
|
652
|
+
} else if ("hrtime" in process_) {
|
|
653
|
+
const timeParts = process_?.hrtime?.();
|
|
654
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
655
|
+
} else {
|
|
656
|
+
timestamp = Date.now();
|
|
454
657
|
}
|
|
658
|
+
return timestamp;
|
|
455
659
|
}
|
|
456
660
|
|
|
457
|
-
// ../../node_modules/
|
|
458
|
-
var
|
|
459
|
-
|
|
460
|
-
|
|
661
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/probe-log.js
|
|
662
|
+
var originalConsole = {
|
|
663
|
+
debug: isBrowser3() ? console.debug || console.log : console.log,
|
|
664
|
+
log: console.log,
|
|
665
|
+
info: console.info,
|
|
666
|
+
warn: console.warn,
|
|
667
|
+
error: console.error
|
|
668
|
+
};
|
|
669
|
+
var DEFAULT_LOG_CONFIGURATION = {
|
|
670
|
+
enabled: true,
|
|
671
|
+
level: 0
|
|
672
|
+
};
|
|
673
|
+
var ProbeLog = class extends BaseLog {
|
|
674
|
+
constructor({ id } = { id: "" }) {
|
|
675
|
+
super({ level: 0 });
|
|
676
|
+
this.VERSION = VERSION3;
|
|
677
|
+
this._startTs = getHiResTimestamp();
|
|
678
|
+
this._deltaTs = getHiResTimestamp();
|
|
679
|
+
this.userData = {};
|
|
680
|
+
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
681
|
+
this.id = id;
|
|
682
|
+
this.userData = {};
|
|
683
|
+
this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION });
|
|
684
|
+
this.timeStamp(`${this.id} started`);
|
|
685
|
+
autobind(this);
|
|
686
|
+
Object.seal(this);
|
|
687
|
+
}
|
|
688
|
+
isEnabled() {
|
|
689
|
+
return this._getConfiguration().enabled;
|
|
690
|
+
}
|
|
691
|
+
getLevel() {
|
|
692
|
+
return this._getConfiguration().level;
|
|
693
|
+
}
|
|
694
|
+
/** @return milliseconds, with fractions */
|
|
695
|
+
getTotal() {
|
|
696
|
+
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
697
|
+
}
|
|
698
|
+
/** @return milliseconds, with fractions */
|
|
699
|
+
getDelta() {
|
|
700
|
+
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
701
|
+
}
|
|
702
|
+
/** @deprecated use logLevel */
|
|
703
|
+
set priority(newPriority) {
|
|
704
|
+
this.level = newPriority;
|
|
705
|
+
}
|
|
706
|
+
/** @deprecated use logLevel */
|
|
707
|
+
get priority() {
|
|
708
|
+
return this.level;
|
|
709
|
+
}
|
|
710
|
+
/** @deprecated use logLevel */
|
|
711
|
+
getPriority() {
|
|
712
|
+
return this.level;
|
|
713
|
+
}
|
|
714
|
+
// Configure
|
|
715
|
+
enable(enabled = true) {
|
|
716
|
+
this._updateConfiguration({ enabled });
|
|
717
|
+
return this;
|
|
718
|
+
}
|
|
719
|
+
setLevel(level) {
|
|
720
|
+
this._updateConfiguration({ level });
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
723
|
+
/** return the current status of the setting */
|
|
724
|
+
get(setting) {
|
|
725
|
+
return this._getConfiguration()[setting];
|
|
726
|
+
}
|
|
727
|
+
// update the status of the setting
|
|
728
|
+
set(setting, value) {
|
|
729
|
+
this._updateConfiguration({ [setting]: value });
|
|
730
|
+
}
|
|
731
|
+
/** Logs the current settings as a table */
|
|
732
|
+
settings() {
|
|
733
|
+
if (console.table) {
|
|
734
|
+
console.table(this._storage.config);
|
|
735
|
+
} else {
|
|
736
|
+
console.log(this._storage.config);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
// Unconditional logging
|
|
740
|
+
assert(condition, message) {
|
|
741
|
+
if (!condition) {
|
|
742
|
+
throw new Error(message || "Assertion failed");
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
warn(message, ...args) {
|
|
746
|
+
return this._log("warn", 0, message, args, {
|
|
747
|
+
method: originalConsole.warn,
|
|
748
|
+
once: true
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
error(message, ...args) {
|
|
752
|
+
return this._log("error", 0, message, args, {
|
|
753
|
+
method: originalConsole.error
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
/** Print a deprecation warning */
|
|
757
|
+
deprecated(oldUsage, newUsage) {
|
|
758
|
+
return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
|
|
759
|
+
}
|
|
760
|
+
/** Print a removal warning */
|
|
761
|
+
removed(oldUsage, newUsage) {
|
|
762
|
+
return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
|
|
763
|
+
}
|
|
764
|
+
probe(logLevel, message, ...args) {
|
|
765
|
+
return this._log("log", logLevel, message, args, {
|
|
766
|
+
method: originalConsole.log,
|
|
767
|
+
time: true,
|
|
768
|
+
once: true
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
log(logLevel, message, ...args) {
|
|
772
|
+
return this._log("log", logLevel, message, args, {
|
|
773
|
+
method: originalConsole.debug
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
info(logLevel, message, ...args) {
|
|
777
|
+
return this._log("info", logLevel, message, args, { method: console.info });
|
|
778
|
+
}
|
|
779
|
+
once(logLevel, message, ...args) {
|
|
780
|
+
return this._log("once", logLevel, message, args, {
|
|
781
|
+
method: originalConsole.debug || originalConsole.info,
|
|
782
|
+
once: true
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
/** Logs an object as a table */
|
|
786
|
+
table(logLevel, table, columns) {
|
|
787
|
+
if (table) {
|
|
788
|
+
return this._log("table", logLevel, table, columns && [columns] || [], {
|
|
789
|
+
method: console.table || noop,
|
|
790
|
+
tag: getTableHeader(table)
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
return noop;
|
|
794
|
+
}
|
|
795
|
+
time(logLevel, message) {
|
|
796
|
+
return this._log("time", logLevel, message, [], {
|
|
797
|
+
method: console.time ? console.time : console.info
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
timeEnd(logLevel, message) {
|
|
801
|
+
return this._log("time", logLevel, message, [], {
|
|
802
|
+
method: console.timeEnd ? console.timeEnd : console.info
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
timeStamp(logLevel, message) {
|
|
806
|
+
return this._log("time", logLevel, message, [], {
|
|
807
|
+
method: console.timeStamp || noop
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
group(logLevel, message, opts = { collapsed: false }) {
|
|
811
|
+
const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
812
|
+
return this._log("group", logLevel, message, [], { method });
|
|
813
|
+
}
|
|
814
|
+
groupCollapsed(logLevel, message, opts = {}) {
|
|
815
|
+
return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
|
|
816
|
+
}
|
|
817
|
+
groupEnd(logLevel) {
|
|
818
|
+
return this._log("groupEnd", logLevel, "", [], {
|
|
819
|
+
method: console.groupEnd || noop
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
// EXPERIMENTAL
|
|
823
|
+
withGroup(logLevel, message, func) {
|
|
824
|
+
this.group(logLevel, message)();
|
|
825
|
+
try {
|
|
826
|
+
func();
|
|
827
|
+
} finally {
|
|
828
|
+
this.groupEnd(logLevel)();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
trace() {
|
|
832
|
+
if (console.trace) {
|
|
833
|
+
console.trace();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
_shouldLog(logLevel) {
|
|
837
|
+
return this.isEnabled() && super._shouldLog(logLevel);
|
|
838
|
+
}
|
|
839
|
+
_emit(_type, normalized) {
|
|
840
|
+
const method = normalized.method;
|
|
841
|
+
assert3(method);
|
|
842
|
+
normalized.total = this.getTotal();
|
|
843
|
+
normalized.delta = this.getDelta();
|
|
844
|
+
this._deltaTs = getHiResTimestamp();
|
|
845
|
+
const message = decorateMessage(this.id, normalized.message, normalized);
|
|
846
|
+
return method.bind(console, message, ...normalized.args);
|
|
847
|
+
}
|
|
848
|
+
_getConfiguration() {
|
|
849
|
+
if (!this._storage.config[this.id]) {
|
|
850
|
+
this._updateConfiguration(DEFAULT_LOG_CONFIGURATION);
|
|
851
|
+
}
|
|
852
|
+
return this._storage.config[this.id];
|
|
853
|
+
}
|
|
854
|
+
_updateConfiguration(configuration) {
|
|
855
|
+
const currentConfiguration = this._storage.config[this.id] || {
|
|
856
|
+
...DEFAULT_LOG_CONFIGURATION
|
|
857
|
+
};
|
|
858
|
+
this._storage.setConfiguration({
|
|
859
|
+
[this.id]: { ...currentConfiguration, ...configuration }
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
ProbeLog.VERSION = VERSION3;
|
|
864
|
+
function decorateMessage(id, message, opts) {
|
|
865
|
+
if (typeof message === "string") {
|
|
866
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
867
|
+
message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`;
|
|
868
|
+
message = addColor(message, opts.color, opts.background);
|
|
869
|
+
}
|
|
870
|
+
return message;
|
|
871
|
+
}
|
|
872
|
+
function getTableHeader(table) {
|
|
873
|
+
for (const key in table) {
|
|
874
|
+
for (const title in table[key]) {
|
|
875
|
+
return title || "untitled";
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return "empty";
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// ../../node_modules/@probe.gl/log/dist/init.js
|
|
882
|
+
globalThis.probe = {};
|
|
883
|
+
|
|
884
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
885
|
+
var dist_default = new ProbeLog({ id: "@probe.gl/log" });
|
|
886
|
+
|
|
887
|
+
// ../loader-utils/src/lib/log-utils/log.ts
|
|
888
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
889
|
+
var version = VERSION4[0] >= "0" && VERSION4[0] <= "9" ? `v${VERSION4}` : "";
|
|
890
|
+
function createLog() {
|
|
891
|
+
const log2 = new ProbeLog({ id: "loaders.gl" });
|
|
892
|
+
globalThis.loaders ||= {};
|
|
893
|
+
globalThis.loaders.log = log2;
|
|
894
|
+
globalThis.loaders.version = version;
|
|
895
|
+
globalThis.probe ||= {};
|
|
896
|
+
globalThis.probe.loaders = log2;
|
|
897
|
+
return log2;
|
|
898
|
+
}
|
|
899
|
+
var log = createLog();
|
|
900
|
+
|
|
901
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
902
|
+
function registerJSModules(modules) {
|
|
903
|
+
globalThis.loaders ||= {};
|
|
904
|
+
globalThis.loaders.modules ||= {};
|
|
905
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
906
|
+
}
|
|
907
|
+
function getJSModuleOrNull(name) {
|
|
908
|
+
const module = globalThis.loaders?.modules?.[name];
|
|
909
|
+
return module || null;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
913
|
+
var pathPrefix = "";
|
|
914
|
+
var fileAliases = {};
|
|
915
|
+
function resolvePath(filename2) {
|
|
916
|
+
for (const alias in fileAliases) {
|
|
917
|
+
if (filename2.startsWith(alias)) {
|
|
918
|
+
const replacement = fileAliases[alias];
|
|
919
|
+
filename2 = filename2.replace(alias, replacement);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
923
|
+
filename2 = `${pathPrefix}${filename2}`;
|
|
924
|
+
}
|
|
925
|
+
return filename2;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
929
|
+
var path_exports = {};
|
|
930
|
+
__export(path_exports, {
|
|
931
|
+
dirname: () => dirname,
|
|
932
|
+
filename: () => filename,
|
|
933
|
+
join: () => join,
|
|
934
|
+
resolve: () => resolve
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
938
|
+
function getCWD() {
|
|
939
|
+
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
940
|
+
return process.cwd();
|
|
941
|
+
}
|
|
942
|
+
const pathname = window.location?.pathname;
|
|
943
|
+
return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
947
|
+
function filename(url) {
|
|
948
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
949
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
|
|
950
|
+
}
|
|
951
|
+
function dirname(url) {
|
|
952
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
953
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
954
|
+
}
|
|
955
|
+
function join(...parts) {
|
|
956
|
+
const separator = "/";
|
|
957
|
+
parts = parts.map((part, index) => {
|
|
958
|
+
if (index) {
|
|
959
|
+
part = part.replace(new RegExp(`^${separator}`), "");
|
|
960
|
+
}
|
|
961
|
+
if (index !== parts.length - 1) {
|
|
962
|
+
part = part.replace(new RegExp(`${separator}$`), "");
|
|
963
|
+
}
|
|
964
|
+
return part;
|
|
965
|
+
});
|
|
966
|
+
return parts.join(separator);
|
|
967
|
+
}
|
|
968
|
+
function resolve(...components) {
|
|
969
|
+
const paths = [];
|
|
970
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
971
|
+
paths[_i] = components[_i];
|
|
972
|
+
}
|
|
973
|
+
let resolvedPath = "";
|
|
974
|
+
let resolvedAbsolute = false;
|
|
975
|
+
let cwd;
|
|
976
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
977
|
+
let path;
|
|
978
|
+
if (i >= 0) {
|
|
979
|
+
path = paths[i];
|
|
980
|
+
} else {
|
|
981
|
+
if (cwd === void 0) {
|
|
982
|
+
cwd = getCWD();
|
|
983
|
+
}
|
|
984
|
+
path = cwd;
|
|
985
|
+
}
|
|
986
|
+
if (path.length === 0) {
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
990
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
991
|
+
}
|
|
992
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
993
|
+
if (resolvedAbsolute) {
|
|
994
|
+
return `/${resolvedPath}`;
|
|
995
|
+
} else if (resolvedPath.length > 0) {
|
|
996
|
+
return resolvedPath;
|
|
997
|
+
}
|
|
998
|
+
return ".";
|
|
999
|
+
}
|
|
1000
|
+
var SLASH = 47;
|
|
1001
|
+
var DOT = 46;
|
|
1002
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1003
|
+
let res = "";
|
|
1004
|
+
let lastSlash = -1;
|
|
1005
|
+
let dots = 0;
|
|
1006
|
+
let code;
|
|
1007
|
+
let isAboveRoot = false;
|
|
1008
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
1009
|
+
if (i < path.length) {
|
|
1010
|
+
code = path.charCodeAt(i);
|
|
1011
|
+
} else if (code === SLASH) {
|
|
1012
|
+
break;
|
|
1013
|
+
} else {
|
|
1014
|
+
code = SLASH;
|
|
1015
|
+
}
|
|
1016
|
+
if (code === SLASH) {
|
|
1017
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
1018
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1019
|
+
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
1020
|
+
if (res.length > 2) {
|
|
1021
|
+
const start = res.length - 1;
|
|
1022
|
+
let j = start;
|
|
1023
|
+
for (; j >= 0; --j) {
|
|
1024
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
if (j !== start) {
|
|
1029
|
+
res = j === -1 ? "" : res.slice(0, j);
|
|
1030
|
+
lastSlash = i;
|
|
1031
|
+
dots = 0;
|
|
1032
|
+
isAboveRoot = false;
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1036
|
+
res = "";
|
|
1037
|
+
lastSlash = i;
|
|
1038
|
+
dots = 0;
|
|
1039
|
+
isAboveRoot = false;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
if (allowAboveRoot) {
|
|
1044
|
+
if (res.length > 0) {
|
|
1045
|
+
res += "/..";
|
|
1046
|
+
} else {
|
|
1047
|
+
res = "..";
|
|
1048
|
+
}
|
|
1049
|
+
isAboveRoot = true;
|
|
1050
|
+
}
|
|
1051
|
+
} else {
|
|
1052
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
1053
|
+
if (res.length > 0) {
|
|
1054
|
+
res += `/${slice}`;
|
|
1055
|
+
} else {
|
|
1056
|
+
res = slice;
|
|
1057
|
+
}
|
|
1058
|
+
isAboveRoot = false;
|
|
1059
|
+
}
|
|
1060
|
+
lastSlash = i;
|
|
1061
|
+
dots = 0;
|
|
1062
|
+
} else if (code === DOT && dots !== -1) {
|
|
1063
|
+
++dots;
|
|
1064
|
+
} else {
|
|
1065
|
+
dots = -1;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return res;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/lib/parsers/basis-module-loader.ts
|
|
1072
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
1073
|
+
/** Basis transcoder, javascript wrapper part */
|
|
1074
|
+
TRANSCODER: "basis_transcoder.js",
|
|
1075
|
+
/** Basis transcoder, compiled web assembly part */
|
|
1076
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
1077
|
+
/** Basis encoder, javascript wrapper part */
|
|
1078
|
+
ENCODER: "basis_encoder.js",
|
|
1079
|
+
/** Basis encoder, compiled web assembly part */
|
|
1080
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
1081
|
+
};
|
|
1082
|
+
var loadBasisTranscoderPromise;
|
|
1083
|
+
async function loadBasisTranscoderModule(options) {
|
|
1084
|
+
registerJSModules(options.modules);
|
|
1085
|
+
const basis = getJSModuleOrNull("basis");
|
|
1086
|
+
if (basis) {
|
|
1087
|
+
return basis;
|
|
1088
|
+
}
|
|
1089
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
1090
|
+
return await loadBasisTranscoderPromise;
|
|
1091
|
+
}
|
|
1092
|
+
async function loadBasisTranscoder(options) {
|
|
1093
|
+
let BASIS = null;
|
|
1094
|
+
let wasmBinary = null;
|
|
1095
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
1096
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
1097
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
1098
|
+
]);
|
|
1099
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
1100
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
1101
|
+
}
|
|
1102
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
1103
|
+
const options = {};
|
|
1104
|
+
if (wasmBinary) {
|
|
1105
|
+
options.wasmBinary = wasmBinary;
|
|
1106
|
+
}
|
|
1107
|
+
return new Promise((resolve2) => {
|
|
1108
|
+
BasisModule(options).then((module) => {
|
|
1109
|
+
const { BasisFile, initializeBasis } = module;
|
|
1110
|
+
initializeBasis();
|
|
1111
|
+
resolve2({ BasisFile });
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
var loadBasisEncoderPromise;
|
|
1116
|
+
async function loadBasisEncoderModule(options) {
|
|
1117
|
+
const modules = options.modules || {};
|
|
1118
|
+
if (modules.basisEncoder) {
|
|
1119
|
+
return modules.basisEncoder;
|
|
1120
|
+
}
|
|
1121
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
1122
|
+
return await loadBasisEncoderPromise;
|
|
1123
|
+
}
|
|
1124
|
+
async function loadBasisEncoder(options) {
|
|
1125
|
+
let BASIS_ENCODER = null;
|
|
1126
|
+
let wasmBinary = null;
|
|
1127
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
1128
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
1129
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
1130
|
+
]);
|
|
1131
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
1132
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
1133
|
+
}
|
|
1134
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
1135
|
+
const options = {};
|
|
1136
|
+
if (wasmBinary) {
|
|
1137
|
+
options.wasmBinary = wasmBinary;
|
|
1138
|
+
}
|
|
1139
|
+
return new Promise((resolve2) => {
|
|
1140
|
+
BasisEncoderModule(options).then((module) => {
|
|
1141
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
1142
|
+
initializeBasis();
|
|
1143
|
+
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
1144
|
+
});
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/lib/gl-extensions.ts
|
|
1149
|
+
var GL_RGB = 6407;
|
|
1150
|
+
var GL_RGBA = 6408;
|
|
1151
|
+
var GL_RGBA4 = 32854;
|
|
1152
|
+
var GL_RGB5_A1 = 32855;
|
|
1153
|
+
var GL_RGBA8 = 32856;
|
|
1154
|
+
var GL_RGB565 = 36194;
|
|
1155
|
+
var GL_RGBA32F = 34836;
|
|
1156
|
+
var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
|
|
1157
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
|
|
1158
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
|
|
1159
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
|
|
1160
|
+
var GL_COMPRESSED_R11_EAC = 37488;
|
|
1161
|
+
var GL_COMPRESSED_SIGNED_R11_EAC = 37489;
|
|
1162
|
+
var GL_COMPRESSED_RG11_EAC = 37490;
|
|
1163
|
+
var GL_COMPRESSED_SIGNED_RG11_EAC = 37491;
|
|
1164
|
+
var GL_COMPRESSED_RGB8_ETC2 = 37492;
|
|
1165
|
+
var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
|
|
1166
|
+
var GL_COMPRESSED_SRGB8_ETC2 = 37494;
|
|
1167
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37495;
|
|
1168
|
+
var GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37496;
|
|
1169
|
+
var GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37497;
|
|
1170
|
+
var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
|
|
1171
|
+
var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841;
|
|
1172
|
+
var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
|
|
1173
|
+
var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843;
|
|
1174
|
+
var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
|
|
1175
|
+
var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
|
|
1176
|
+
var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 35987;
|
|
1177
|
+
var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
|
|
1178
|
+
var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
|
|
1179
|
+
var GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 37809;
|
|
1180
|
+
var GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 37810;
|
|
1181
|
+
var GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 37811;
|
|
1182
|
+
var GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 37812;
|
|
1183
|
+
var GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 37813;
|
|
1184
|
+
var GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 37814;
|
|
1185
|
+
var GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 37815;
|
|
1186
|
+
var GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 37816;
|
|
1187
|
+
var GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 37817;
|
|
1188
|
+
var GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 37818;
|
|
1189
|
+
var GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 37819;
|
|
1190
|
+
var GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 37820;
|
|
1191
|
+
var GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 37821;
|
|
1192
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840;
|
|
1193
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841;
|
|
1194
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842;
|
|
1195
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843;
|
|
1196
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844;
|
|
1197
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845;
|
|
1198
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846;
|
|
1199
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847;
|
|
1200
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848;
|
|
1201
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849;
|
|
1202
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850;
|
|
1203
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851;
|
|
1204
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852;
|
|
1205
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853;
|
|
1206
|
+
var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
|
|
1207
|
+
var GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 36284;
|
|
1208
|
+
var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
|
|
1209
|
+
var GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 36286;
|
|
1210
|
+
var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
|
|
1211
|
+
var GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 36493;
|
|
1212
|
+
var GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 36494;
|
|
1213
|
+
var GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 36495;
|
|
1214
|
+
var GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916;
|
|
1215
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917;
|
|
1216
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918;
|
|
1217
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919;
|
|
1218
|
+
var GL_EXTENSIONS_CONSTANTS = {
|
|
1219
|
+
RGB: GL_RGB,
|
|
1220
|
+
RGBA: GL_RGBA,
|
|
1221
|
+
RGBA4: GL_RGBA4,
|
|
1222
|
+
RGB5_A1: GL_RGB5_A1,
|
|
1223
|
+
RGBA8: GL_RGBA8,
|
|
1224
|
+
RGB565: GL_RGB565,
|
|
1225
|
+
RGBA32F: GL_RGBA32F,
|
|
1226
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1227
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
1228
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
1229
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1230
|
+
COMPRESSED_R11_EAC: GL_COMPRESSED_R11_EAC,
|
|
1231
|
+
COMPRESSED_SIGNED_R11_EAC: GL_COMPRESSED_SIGNED_R11_EAC,
|
|
1232
|
+
COMPRESSED_RG11_EAC: GL_COMPRESSED_RG11_EAC,
|
|
1233
|
+
COMPRESSED_SIGNED_RG11_EAC: GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
1234
|
+
COMPRESSED_RGB8_ETC2: GL_COMPRESSED_RGB8_ETC2,
|
|
1235
|
+
COMPRESSED_RGBA8_ETC2_EAC: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
1236
|
+
COMPRESSED_SRGB8_ETC2: GL_COMPRESSED_SRGB8_ETC2,
|
|
1237
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
1238
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1239
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1240
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
1241
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
1242
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
1243
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
1244
|
+
COMPRESSED_RGB_ETC1_WEBGL: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
1245
|
+
COMPRESSED_RGB_ATC_WEBGL: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
1246
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
1247
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
1248
|
+
COMPRESSED_RGBA_ASTC_4x4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1249
|
+
COMPRESSED_RGBA_ASTC_5x4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1250
|
+
COMPRESSED_RGBA_ASTC_5x5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1251
|
+
COMPRESSED_RGBA_ASTC_6x5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1252
|
+
COMPRESSED_RGBA_ASTC_6x6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1253
|
+
COMPRESSED_RGBA_ASTC_8x5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1254
|
+
COMPRESSED_RGBA_ASTC_8x6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1255
|
+
COMPRESSED_RGBA_ASTC_8x8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1256
|
+
COMPRESSED_RGBA_ASTC_10x5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1257
|
+
COMPRESSED_RGBA_ASTC_10x6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1258
|
+
COMPRESSED_RGBA_ASTC_10x8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1259
|
+
COMPRESSED_RGBA_ASTC_10x10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1260
|
+
COMPRESSED_RGBA_ASTC_12x10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1261
|
+
COMPRESSED_RGBA_ASTC_12x12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
1262
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
1263
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
1264
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
1265
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
1266
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
1267
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
1268
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
1269
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
1270
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
1271
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
1272
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
1273
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
1274
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
1275
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
1276
|
+
COMPRESSED_RED_RGTC1_EXT: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
1277
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
1278
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
1279
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
1280
|
+
COMPRESSED_RGBA_BPTC_UNORM_EXT: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
1281
|
+
COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
1282
|
+
COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
1283
|
+
COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
1284
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
1285
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
1286
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
1287
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
1288
|
+
// Deprecated legacy aliases with non-standard ASTC casing.
|
|
1289
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1290
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1291
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1292
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1293
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1294
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1295
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1296
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1297
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1298
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1299
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1300
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1301
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1302
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
1303
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
1304
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
1305
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
1306
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
1307
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
1308
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
1309
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
1310
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
1311
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
1312
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
1313
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
1314
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
1315
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
1316
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// src/lib/utils/detect-supported-texture-formats.ts
|
|
1320
|
+
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
1321
|
+
var WEBGL_TEXTURE_FORMATS = {
|
|
1322
|
+
/* eslint-disable camelcase */
|
|
1323
|
+
WEBGL_compressed_texture_s3tc: [
|
|
1324
|
+
"bc1-rgb-unorm-webgl",
|
|
1325
|
+
"bc1-rgba-unorm",
|
|
1326
|
+
"bc2-rgba-unorm",
|
|
1327
|
+
"bc3-rgba-unorm"
|
|
1328
|
+
],
|
|
1329
|
+
WEBGL_compressed_texture_s3tc_srgb: [
|
|
1330
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
1331
|
+
"bc1-rgba-unorm-srgb",
|
|
1332
|
+
"bc2-rgba-unorm-srgb",
|
|
1333
|
+
"bc3-rgba-unorm-srgb"
|
|
1334
|
+
],
|
|
1335
|
+
EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
|
|
1336
|
+
EXT_texture_compression_bptc: [
|
|
1337
|
+
"bc6h-rgb-ufloat",
|
|
1338
|
+
"bc6h-rgb-float",
|
|
1339
|
+
"bc7-rgba-unorm",
|
|
1340
|
+
"bc7-rgba-unorm-srgb"
|
|
1341
|
+
],
|
|
1342
|
+
WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"],
|
|
1343
|
+
WEBGL_compressed_texture_etc: [
|
|
1344
|
+
"etc2-rgb8unorm",
|
|
1345
|
+
"etc2-rgb8unorm-srgb",
|
|
1346
|
+
"etc2-rgb8a1unorm",
|
|
1347
|
+
"etc2-rgb8a1unorm-srgb",
|
|
1348
|
+
"etc2-rgba8unorm",
|
|
1349
|
+
"etc2-rgba8unorm-srgb",
|
|
1350
|
+
"eac-r11unorm",
|
|
1351
|
+
"eac-r11snorm",
|
|
1352
|
+
"eac-rg11unorm",
|
|
1353
|
+
"eac-rg11snorm"
|
|
1354
|
+
],
|
|
1355
|
+
WEBGL_compressed_texture_pvrtc: [
|
|
1356
|
+
"pvrtc-rgb4unorm-webgl",
|
|
1357
|
+
"pvrtc-rgba4unorm-webgl",
|
|
1358
|
+
"pvrtc-rgb2unorm-webgl",
|
|
1359
|
+
"pvrtc-rgba2unorm-webgl"
|
|
1360
|
+
],
|
|
1361
|
+
WEBGL_compressed_texture_atc: [
|
|
1362
|
+
"atc-rgb-unorm-webgl",
|
|
1363
|
+
"atc-rgba-unorm-webgl",
|
|
1364
|
+
"atc-rgbai-unorm-webgl"
|
|
1365
|
+
],
|
|
1366
|
+
WEBGL_compressed_texture_astc: [
|
|
1367
|
+
"astc-4x4-unorm",
|
|
1368
|
+
"astc-4x4-unorm-srgb",
|
|
1369
|
+
"astc-5x4-unorm",
|
|
1370
|
+
"astc-5x4-unorm-srgb",
|
|
1371
|
+
"astc-5x5-unorm",
|
|
1372
|
+
"astc-5x5-unorm-srgb",
|
|
1373
|
+
"astc-6x5-unorm",
|
|
1374
|
+
"astc-6x5-unorm-srgb",
|
|
1375
|
+
"astc-6x6-unorm",
|
|
1376
|
+
"astc-6x6-unorm-srgb",
|
|
1377
|
+
"astc-8x5-unorm",
|
|
1378
|
+
"astc-8x5-unorm-srgb",
|
|
1379
|
+
"astc-8x6-unorm",
|
|
1380
|
+
"astc-8x6-unorm-srgb",
|
|
1381
|
+
"astc-8x8-unorm",
|
|
1382
|
+
"astc-8x8-unorm-srgb",
|
|
1383
|
+
"astc-10x5-unorm",
|
|
1384
|
+
"astc-10x5-unorm-srgb",
|
|
1385
|
+
"astc-10x6-unorm",
|
|
1386
|
+
"astc-10x6-unorm-srgb",
|
|
1387
|
+
"astc-10x8-unorm",
|
|
1388
|
+
"astc-10x8-unorm-srgb",
|
|
1389
|
+
"astc-10x10-unorm",
|
|
1390
|
+
"astc-10x10-unorm-srgb",
|
|
1391
|
+
"astc-12x10-unorm",
|
|
1392
|
+
"astc-12x10-unorm-srgb",
|
|
1393
|
+
"astc-12x12-unorm",
|
|
1394
|
+
"astc-12x12-unorm-srgb"
|
|
1395
|
+
]
|
|
1396
|
+
/* eslint-enable camelcase */
|
|
1397
|
+
};
|
|
1398
|
+
var textureFormats = null;
|
|
1399
|
+
function detectSupportedTextureFormats(gl) {
|
|
1400
|
+
if (!textureFormats) {
|
|
1401
|
+
gl = gl || getWebGLContext() || void 0;
|
|
1402
|
+
textureFormats = /* @__PURE__ */ new Set();
|
|
1403
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
1404
|
+
for (const extension in WEBGL_TEXTURE_FORMATS) {
|
|
1405
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
1406
|
+
for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
|
|
1407
|
+
textureFormats.add(textureFormat);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return textureFormats;
|
|
1414
|
+
}
|
|
1415
|
+
function getWebGLContext() {
|
|
1416
|
+
try {
|
|
1417
|
+
const canvas = document.createElement("canvas");
|
|
1418
|
+
return canvas.getContext("webgl");
|
|
1419
|
+
} catch (error) {
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
1425
|
+
var KHR_SUPERCOMPRESSION_NONE = 0;
|
|
1426
|
+
var KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
|
|
1427
|
+
var KHR_DF_VENDORID_KHRONOS = 0;
|
|
461
1428
|
var KHR_DF_VERSION = 2;
|
|
462
1429
|
var KHR_DF_MODEL_UNSPECIFIED = 0;
|
|
463
1430
|
var KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
|
|
@@ -703,23 +1670,113 @@ var __exports__ = (() => {
|
|
|
703
1670
|
return container;
|
|
704
1671
|
}
|
|
705
1672
|
|
|
1673
|
+
// src/lib/utils/texture-format-map.ts
|
|
1674
|
+
var WEBGL_TO_TEXTURE_FORMAT = {
|
|
1675
|
+
[GL_RGBA32F]: "rgba32float",
|
|
1676
|
+
[GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
|
|
1677
|
+
[GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
|
|
1678
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
|
|
1679
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: "bc1-rgba-unorm-srgb",
|
|
1680
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: "bc2-rgba-unorm",
|
|
1681
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: "bc2-rgba-unorm-srgb",
|
|
1682
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: "bc3-rgba-unorm",
|
|
1683
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: "bc3-rgba-unorm-srgb",
|
|
1684
|
+
[GL_COMPRESSED_RED_RGTC1_EXT]: "bc4-r-unorm",
|
|
1685
|
+
[GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: "bc4-r-snorm",
|
|
1686
|
+
[GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: "bc5-rg-unorm",
|
|
1687
|
+
[GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: "bc5-rg-snorm",
|
|
1688
|
+
[GL_COMPRESSED_RGB8_ETC2]: "etc2-rgb8unorm",
|
|
1689
|
+
[GL_COMPRESSED_SRGB8_ETC2]: "etc2-rgb8unorm-srgb",
|
|
1690
|
+
[GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm",
|
|
1691
|
+
[GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm-srgb",
|
|
1692
|
+
[GL_COMPRESSED_RGBA8_ETC2_EAC]: "etc2-rgba8unorm",
|
|
1693
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: "etc2-rgba8unorm-srgb",
|
|
1694
|
+
[GL_COMPRESSED_R11_EAC]: "eac-r11unorm",
|
|
1695
|
+
[GL_COMPRESSED_SIGNED_R11_EAC]: "eac-r11snorm",
|
|
1696
|
+
[GL_COMPRESSED_RG11_EAC]: "eac-rg11unorm",
|
|
1697
|
+
[GL_COMPRESSED_SIGNED_RG11_EAC]: "eac-rg11snorm",
|
|
1698
|
+
[GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: "astc-4x4-unorm",
|
|
1699
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: "astc-4x4-unorm-srgb",
|
|
1700
|
+
[GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: "astc-5x4-unorm",
|
|
1701
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: "astc-5x4-unorm-srgb",
|
|
1702
|
+
[GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: "astc-5x5-unorm",
|
|
1703
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: "astc-5x5-unorm-srgb",
|
|
1704
|
+
[GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: "astc-6x5-unorm",
|
|
1705
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: "astc-6x5-unorm-srgb",
|
|
1706
|
+
[GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: "astc-6x6-unorm",
|
|
1707
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: "astc-6x6-unorm-srgb",
|
|
1708
|
+
[GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: "astc-8x5-unorm",
|
|
1709
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: "astc-8x5-unorm-srgb",
|
|
1710
|
+
[GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: "astc-8x6-unorm",
|
|
1711
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: "astc-8x6-unorm-srgb",
|
|
1712
|
+
[GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: "astc-8x8-unorm",
|
|
1713
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: "astc-8x8-unorm-srgb",
|
|
1714
|
+
[GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: "astc-10x5-unorm",
|
|
1715
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: "astc-10x5-unorm-srgb",
|
|
1716
|
+
[GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: "astc-10x6-unorm",
|
|
1717
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: "astc-10x6-unorm-srgb",
|
|
1718
|
+
[GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: "astc-10x8-unorm",
|
|
1719
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: "astc-10x8-unorm-srgb",
|
|
1720
|
+
[GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: "astc-10x10-unorm",
|
|
1721
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: "astc-10x10-unorm-srgb",
|
|
1722
|
+
[GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: "astc-12x10-unorm",
|
|
1723
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: "astc-12x10-unorm-srgb",
|
|
1724
|
+
[GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: "astc-12x12-unorm",
|
|
1725
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
|
|
1726
|
+
[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
|
|
1727
|
+
[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
|
|
1728
|
+
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl",
|
|
1729
|
+
[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
|
|
1730
|
+
[GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl",
|
|
1731
|
+
[GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
|
|
1732
|
+
[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
|
|
1733
|
+
[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
|
|
1734
|
+
};
|
|
1735
|
+
var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(
|
|
1736
|
+
Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
|
|
1737
|
+
textureFormat,
|
|
1738
|
+
Number(format)
|
|
1739
|
+
])
|
|
1740
|
+
);
|
|
1741
|
+
function getTextureFormatFromWebGLFormat(format) {
|
|
1742
|
+
if (format === void 0) {
|
|
1743
|
+
return void 0;
|
|
1744
|
+
}
|
|
1745
|
+
return WEBGL_TO_TEXTURE_FORMAT[format];
|
|
1746
|
+
}
|
|
1747
|
+
function getWebGLFormatFromTextureFormat(textureFormat) {
|
|
1748
|
+
if (textureFormat === void 0) {
|
|
1749
|
+
return void 0;
|
|
1750
|
+
}
|
|
1751
|
+
return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
|
|
1752
|
+
}
|
|
1753
|
+
|
|
706
1754
|
// src/lib/utils/extract-mipmap-images.ts
|
|
707
1755
|
function extractMipmapImages(data, options) {
|
|
708
1756
|
const images = new Array(options.mipMapLevels);
|
|
1757
|
+
const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
|
|
1758
|
+
const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
|
|
709
1759
|
let levelWidth = options.width;
|
|
710
1760
|
let levelHeight = options.height;
|
|
711
1761
|
let offset = 0;
|
|
712
1762
|
for (let i = 0; i < options.mipMapLevels; ++i) {
|
|
713
1763
|
const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
|
|
714
1764
|
const levelData = getLevelData(data, i, offset, levelSize);
|
|
715
|
-
|
|
1765
|
+
const image = {
|
|
1766
|
+
shape: "texture-level",
|
|
716
1767
|
compressed: true,
|
|
717
|
-
format: options.internalFormat,
|
|
718
1768
|
data: levelData,
|
|
719
1769
|
width: levelWidth,
|
|
720
1770
|
height: levelHeight,
|
|
721
1771
|
levelSize
|
|
722
1772
|
};
|
|
1773
|
+
if (format !== void 0) {
|
|
1774
|
+
image.format = format;
|
|
1775
|
+
}
|
|
1776
|
+
if (textureFormat) {
|
|
1777
|
+
image.textureFormat = textureFormat;
|
|
1778
|
+
}
|
|
1779
|
+
images[i] = image;
|
|
723
1780
|
levelWidth = Math.max(1, levelWidth >> 1);
|
|
724
1781
|
levelHeight = Math.max(1, levelHeight >> 1);
|
|
725
1782
|
offset += levelSize;
|
|
@@ -741,118 +1798,79 @@ var __exports__ = (() => {
|
|
|
741
1798
|
|
|
742
1799
|
// src/lib/utils/ktx-format-helper.ts
|
|
743
1800
|
var VULKAN_TO_WEBGL_FORMAT_MAP = {
|
|
744
|
-
131:
|
|
745
|
-
132:
|
|
746
|
-
133:
|
|
747
|
-
134:
|
|
748
|
-
135:
|
|
749
|
-
136:
|
|
750
|
-
137:
|
|
751
|
-
138:
|
|
752
|
-
139:
|
|
753
|
-
140:
|
|
754
|
-
141:
|
|
755
|
-
142:
|
|
756
|
-
147:
|
|
757
|
-
148:
|
|
758
|
-
149:
|
|
759
|
-
150:
|
|
760
|
-
151:
|
|
761
|
-
152:
|
|
762
|
-
153:
|
|
763
|
-
154:
|
|
764
|
-
155:
|
|
765
|
-
156:
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
// @ts-ignore
|
|
811
|
-
179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
812
|
-
// @ts-ignore
|
|
813
|
-
180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
814
|
-
// @ts-ignore
|
|
815
|
-
181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
816
|
-
// @ts-ignore
|
|
817
|
-
182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
818
|
-
// @ts-ignore
|
|
819
|
-
183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
820
|
-
// @ts-ignore
|
|
821
|
-
184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
822
|
-
1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
823
|
-
1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
824
|
-
// @ts-ignore
|
|
825
|
-
1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
826
|
-
// @ts-ignore
|
|
827
|
-
1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
828
|
-
// @ts-ignore
|
|
829
|
-
1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
830
|
-
// @ts-ignore
|
|
831
|
-
1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
832
|
-
// @ts-ignore
|
|
833
|
-
1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
834
|
-
// @ts-ignore
|
|
835
|
-
1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
836
|
-
// @ts-ignore
|
|
837
|
-
1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
838
|
-
// @ts-ignore
|
|
839
|
-
1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
840
|
-
// @ts-ignore
|
|
841
|
-
1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
842
|
-
// @ts-ignore
|
|
843
|
-
1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
844
|
-
// @ts-ignore
|
|
845
|
-
1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
846
|
-
// @ts-ignore
|
|
847
|
-
1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
848
|
-
// @ts-ignore
|
|
849
|
-
1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
850
|
-
// @ts-ignore
|
|
851
|
-
1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
1801
|
+
131: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1802
|
+
132: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
1803
|
+
133: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
1804
|
+
134: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
1805
|
+
135: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
1806
|
+
136: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
1807
|
+
137: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1808
|
+
138: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
1809
|
+
139: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
1810
|
+
140: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
1811
|
+
141: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
1812
|
+
142: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
1813
|
+
147: GL_COMPRESSED_RGB8_ETC2,
|
|
1814
|
+
148: GL_COMPRESSED_SRGB8_ETC2,
|
|
1815
|
+
149: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1816
|
+
150: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1817
|
+
151: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
1818
|
+
152: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
1819
|
+
153: GL_COMPRESSED_R11_EAC,
|
|
1820
|
+
154: GL_COMPRESSED_SIGNED_R11_EAC,
|
|
1821
|
+
155: GL_COMPRESSED_RG11_EAC,
|
|
1822
|
+
156: GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
1823
|
+
157: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1824
|
+
158: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
1825
|
+
159: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1826
|
+
160: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
1827
|
+
161: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1828
|
+
162: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
1829
|
+
163: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1830
|
+
164: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
1831
|
+
165: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1832
|
+
166: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
1833
|
+
167: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1834
|
+
168: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
1835
|
+
169: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1836
|
+
170: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
1837
|
+
171: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1838
|
+
172: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
1839
|
+
173: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1840
|
+
174: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
1841
|
+
175: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1842
|
+
176: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
1843
|
+
177: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1844
|
+
178: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
1845
|
+
179: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1846
|
+
180: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
1847
|
+
181: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1848
|
+
182: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
1849
|
+
183: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
1850
|
+
184: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
1851
|
+
1000054e3: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
1852
|
+
1000054001: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
1853
|
+
1000066e3: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1854
|
+
1000066001: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1855
|
+
1000066002: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1856
|
+
1000066003: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1857
|
+
1000066004: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1858
|
+
1000066005: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1859
|
+
1000066006: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1860
|
+
1000066007: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1861
|
+
1000066008: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1862
|
+
1000066009: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1863
|
+
1000066010: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1864
|
+
1000066011: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1865
|
+
1000066012: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1866
|
+
1000066013: GL_COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
852
1867
|
};
|
|
853
1868
|
function mapVkFormatToWebGL(vkFormat) {
|
|
854
1869
|
return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
|
|
855
1870
|
}
|
|
1871
|
+
function mapVkFormatToTextureFormat(vkFormat) {
|
|
1872
|
+
return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
|
|
1873
|
+
}
|
|
856
1874
|
|
|
857
1875
|
// src/lib/parsers/parse-ktx.ts
|
|
858
1876
|
var KTX2_ID2 = [
|
|
@@ -892,85 +1910,171 @@ var __exports__ = (() => {
|
|
|
892
1910
|
const mipMapLevels = Math.max(1, ktx.levels.length);
|
|
893
1911
|
const width = ktx.pixelWidth;
|
|
894
1912
|
const height = ktx.pixelHeight;
|
|
895
|
-
const
|
|
1913
|
+
const textureFormat = mapVkFormatToTextureFormat(ktx.vkFormat);
|
|
1914
|
+
if (textureFormat === void 0) {
|
|
1915
|
+
log.warn(
|
|
1916
|
+
`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known texture format; returning texture levels without format metadata.`
|
|
1917
|
+
)();
|
|
1918
|
+
}
|
|
896
1919
|
return extractMipmapImages(ktx.levels, {
|
|
897
1920
|
mipMapLevels,
|
|
898
1921
|
width,
|
|
899
1922
|
height,
|
|
900
1923
|
sizeFunction: (level) => level.uncompressedByteLength,
|
|
901
|
-
|
|
1924
|
+
textureFormat
|
|
902
1925
|
});
|
|
903
1926
|
}
|
|
904
1927
|
|
|
905
1928
|
// src/lib/parsers/parse-basis.ts
|
|
906
|
-
var
|
|
1929
|
+
var basisTranscodingLock = Promise.resolve();
|
|
1930
|
+
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
907
1931
|
etc1: {
|
|
908
1932
|
basisFormat: 0,
|
|
909
1933
|
compressed: true,
|
|
910
|
-
format:
|
|
1934
|
+
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
1935
|
+
textureFormat: "etc1-rgb-unorm-webgl"
|
|
1936
|
+
},
|
|
1937
|
+
etc2: {
|
|
1938
|
+
basisFormat: 1,
|
|
1939
|
+
compressed: true,
|
|
1940
|
+
format: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
1941
|
+
textureFormat: "etc2-rgba8unorm"
|
|
911
1942
|
},
|
|
912
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
913
1943
|
bc1: {
|
|
914
1944
|
basisFormat: 2,
|
|
915
1945
|
compressed: true,
|
|
916
|
-
format:
|
|
1946
|
+
format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1947
|
+
textureFormat: "bc1-rgb-unorm-webgl"
|
|
917
1948
|
},
|
|
918
1949
|
bc3: {
|
|
919
1950
|
basisFormat: 3,
|
|
920
1951
|
compressed: true,
|
|
921
|
-
format:
|
|
1952
|
+
format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1953
|
+
textureFormat: "bc3-rgba-unorm"
|
|
1954
|
+
},
|
|
1955
|
+
bc4: {
|
|
1956
|
+
basisFormat: 4,
|
|
1957
|
+
compressed: true,
|
|
1958
|
+
format: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
1959
|
+
textureFormat: "bc4-r-unorm"
|
|
1960
|
+
},
|
|
1961
|
+
bc5: {
|
|
1962
|
+
basisFormat: 5,
|
|
1963
|
+
compressed: true,
|
|
1964
|
+
format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
1965
|
+
textureFormat: "bc5-rg-unorm"
|
|
1966
|
+
},
|
|
1967
|
+
"bc7-m6-opaque-only": {
|
|
1968
|
+
basisFormat: 6,
|
|
1969
|
+
compressed: true,
|
|
1970
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
1971
|
+
textureFormat: "bc7-rgba-unorm"
|
|
1972
|
+
},
|
|
1973
|
+
"bc7-m5": {
|
|
1974
|
+
basisFormat: 7,
|
|
1975
|
+
compressed: true,
|
|
1976
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
1977
|
+
textureFormat: "bc7-rgba-unorm"
|
|
922
1978
|
},
|
|
923
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
924
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
925
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
926
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
927
1979
|
"pvrtc1-4-rgb": {
|
|
928
1980
|
basisFormat: 8,
|
|
929
1981
|
compressed: true,
|
|
930
|
-
format:
|
|
1982
|
+
format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
1983
|
+
textureFormat: "pvrtc-rgb4unorm-webgl"
|
|
931
1984
|
},
|
|
932
1985
|
"pvrtc1-4-rgba": {
|
|
933
1986
|
basisFormat: 9,
|
|
934
1987
|
compressed: true,
|
|
935
|
-
format:
|
|
1988
|
+
format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
1989
|
+
textureFormat: "pvrtc-rgba4unorm-webgl"
|
|
936
1990
|
},
|
|
937
1991
|
"astc-4x4": {
|
|
938
1992
|
basisFormat: 10,
|
|
939
1993
|
compressed: true,
|
|
940
|
-
format:
|
|
1994
|
+
format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1995
|
+
textureFormat: "astc-4x4-unorm"
|
|
941
1996
|
},
|
|
942
|
-
"atc-rgb": {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1997
|
+
"atc-rgb": {
|
|
1998
|
+
basisFormat: 11,
|
|
1999
|
+
compressed: true,
|
|
2000
|
+
format: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
2001
|
+
textureFormat: "atc-rgb-unorm-webgl"
|
|
2002
|
+
},
|
|
2003
|
+
"atc-rgba-interpolated-alpha": {
|
|
2004
|
+
basisFormat: 12,
|
|
2005
|
+
compressed: true,
|
|
2006
|
+
format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
2007
|
+
textureFormat: "atc-rgbai-unorm-webgl"
|
|
2008
|
+
},
|
|
2009
|
+
rgba32: {
|
|
2010
|
+
basisFormat: 13,
|
|
2011
|
+
compressed: false,
|
|
2012
|
+
format: GL_RGBA8,
|
|
2013
|
+
textureFormat: "rgba8unorm"
|
|
2014
|
+
},
|
|
2015
|
+
rgb565: {
|
|
2016
|
+
basisFormat: 14,
|
|
2017
|
+
compressed: false,
|
|
2018
|
+
format: GL_RGB565,
|
|
2019
|
+
textureFormat: "rgb565unorm-webgl"
|
|
2020
|
+
},
|
|
2021
|
+
bgr565: {
|
|
2022
|
+
basisFormat: 15,
|
|
2023
|
+
compressed: false,
|
|
2024
|
+
format: GL_RGB565,
|
|
2025
|
+
textureFormat: "rgb565unorm-webgl"
|
|
2026
|
+
},
|
|
2027
|
+
rgba4444: {
|
|
2028
|
+
basisFormat: 16,
|
|
2029
|
+
compressed: false,
|
|
2030
|
+
format: GL_RGBA4,
|
|
2031
|
+
textureFormat: "rgba4unorm-webgl"
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
2034
|
+
var BASIS_FORMATS = Object.freeze(
|
|
2035
|
+
Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
|
|
2036
|
+
);
|
|
2037
|
+
async function withBasisTranscodingLock(transcode) {
|
|
2038
|
+
const previousLock = basisTranscodingLock;
|
|
2039
|
+
let releaseLock;
|
|
2040
|
+
basisTranscodingLock = new Promise((resolve2) => {
|
|
2041
|
+
releaseLock = resolve2;
|
|
2042
|
+
});
|
|
2043
|
+
await previousLock;
|
|
2044
|
+
try {
|
|
2045
|
+
return await transcode();
|
|
2046
|
+
} finally {
|
|
2047
|
+
releaseLock();
|
|
972
2048
|
}
|
|
973
2049
|
}
|
|
2050
|
+
async function parseBasis(data, options = {}) {
|
|
2051
|
+
const loadLibraryOptions = extractLoadLibraryOptions(options);
|
|
2052
|
+
return await withBasisTranscodingLock(async () => {
|
|
2053
|
+
if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
|
|
2054
|
+
if (isKTX(data)) {
|
|
2055
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
2056
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2057
|
+
}
|
|
2058
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
2059
|
+
return parseBasisFile(BasisFile, data, options);
|
|
2060
|
+
}
|
|
2061
|
+
switch (options.basis.module) {
|
|
2062
|
+
case "encoder":
|
|
2063
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
2064
|
+
switch (options.basis.containerFormat) {
|
|
2065
|
+
case "ktx2":
|
|
2066
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2067
|
+
case "basis":
|
|
2068
|
+
default:
|
|
2069
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
2070
|
+
}
|
|
2071
|
+
case "transcoder":
|
|
2072
|
+
default:
|
|
2073
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
2074
|
+
return parseBasisFile(BasisFile, data, options);
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
974
2078
|
function parseBasisFile(BasisFile, data, options) {
|
|
975
2079
|
const basisFile = new BasisFile(new Uint8Array(data));
|
|
976
2080
|
try {
|
|
@@ -999,7 +2103,7 @@ var __exports__ = (() => {
|
|
|
999
2103
|
const hasAlpha = basisFile.getHasAlpha(
|
|
1000
2104
|
/* imageIndex, levelIndex */
|
|
1001
2105
|
);
|
|
1002
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
2106
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
|
|
1003
2107
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
1004
2108
|
const decodedData = new Uint8Array(decodedSize);
|
|
1005
2109
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
@@ -1007,11 +2111,13 @@ var __exports__ = (() => {
|
|
|
1007
2111
|
}
|
|
1008
2112
|
return {
|
|
1009
2113
|
// standard loaders.gl image category payload
|
|
2114
|
+
shape: "texture-level",
|
|
1010
2115
|
width,
|
|
1011
2116
|
height,
|
|
1012
2117
|
data: decodedData,
|
|
1013
2118
|
compressed,
|
|
1014
|
-
format,
|
|
2119
|
+
...format !== void 0 ? { format } : {},
|
|
2120
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
1015
2121
|
// Additional fields
|
|
1016
2122
|
// Add levelSize field.
|
|
1017
2123
|
hasAlpha
|
|
@@ -1036,7 +2142,7 @@ var __exports__ = (() => {
|
|
|
1036
2142
|
}
|
|
1037
2143
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
1038
2144
|
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
1039
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
2145
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
|
|
1040
2146
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
|
|
1041
2147
|
levelIndex,
|
|
1042
2148
|
0,
|
|
@@ -1059,48 +2165,98 @@ var __exports__ = (() => {
|
|
|
1059
2165
|
}
|
|
1060
2166
|
return {
|
|
1061
2167
|
// standard loaders.gl image category payload
|
|
2168
|
+
shape: "texture-level",
|
|
1062
2169
|
width,
|
|
1063
2170
|
height,
|
|
1064
2171
|
data: decodedData,
|
|
1065
2172
|
compressed,
|
|
2173
|
+
...format !== void 0 ? { format } : {},
|
|
2174
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
1066
2175
|
// Additional fields
|
|
1067
2176
|
levelSize: decodedSize,
|
|
1068
|
-
hasAlpha: alphaFlag
|
|
1069
|
-
format
|
|
2177
|
+
hasAlpha: alphaFlag
|
|
1070
2178
|
};
|
|
1071
2179
|
}
|
|
1072
2180
|
function getBasisOptions(options, hasAlpha) {
|
|
1073
|
-
let format = options
|
|
2181
|
+
let format = options.basis?.format || "auto";
|
|
1074
2182
|
if (format === "auto") {
|
|
1075
|
-
format = selectSupportedBasisFormat();
|
|
2183
|
+
format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
|
|
1076
2184
|
}
|
|
1077
2185
|
if (typeof format === "object") {
|
|
1078
2186
|
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
1079
2187
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
2188
|
+
const normalizedFormat = format.toLowerCase();
|
|
2189
|
+
const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
|
|
2190
|
+
if (!basisOutputOptions) {
|
|
2191
|
+
throw new Error(`Unknown Basis format ${format}`);
|
|
2192
|
+
}
|
|
2193
|
+
return basisOutputOptions;
|
|
1082
2194
|
}
|
|
1083
|
-
function selectSupportedBasisFormat() {
|
|
1084
|
-
const
|
|
1085
|
-
if (
|
|
2195
|
+
function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
|
|
2196
|
+
const textureFormats2 = new Set(supportedTextureFormats);
|
|
2197
|
+
if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
|
|
1086
2198
|
return "astc-4x4";
|
|
1087
|
-
} else if (
|
|
2199
|
+
} else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
|
|
2200
|
+
return {
|
|
2201
|
+
alpha: "bc7-m5",
|
|
2202
|
+
noAlpha: "bc7-m6-opaque-only"
|
|
2203
|
+
};
|
|
2204
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2205
|
+
"bc1-rgb-unorm-webgl",
|
|
2206
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
2207
|
+
"bc1-rgba-unorm",
|
|
2208
|
+
"bc1-rgba-unorm-srgb",
|
|
2209
|
+
"bc2-rgba-unorm",
|
|
2210
|
+
"bc2-rgba-unorm-srgb",
|
|
2211
|
+
"bc3-rgba-unorm",
|
|
2212
|
+
"bc3-rgba-unorm-srgb"
|
|
2213
|
+
])) {
|
|
1088
2214
|
return {
|
|
1089
2215
|
alpha: "bc3",
|
|
1090
2216
|
noAlpha: "bc1"
|
|
1091
2217
|
};
|
|
1092
|
-
} else if (
|
|
2218
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2219
|
+
"pvrtc-rgb4unorm-webgl",
|
|
2220
|
+
"pvrtc-rgba4unorm-webgl",
|
|
2221
|
+
"pvrtc-rgb2unorm-webgl",
|
|
2222
|
+
"pvrtc-rgba2unorm-webgl"
|
|
2223
|
+
])) {
|
|
1093
2224
|
return {
|
|
1094
2225
|
alpha: "pvrtc1-4-rgba",
|
|
1095
2226
|
noAlpha: "pvrtc1-4-rgb"
|
|
1096
2227
|
};
|
|
1097
|
-
} else if (
|
|
1098
|
-
|
|
1099
|
-
|
|
2228
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2229
|
+
"etc2-rgb8unorm",
|
|
2230
|
+
"etc2-rgb8unorm-srgb",
|
|
2231
|
+
"etc2-rgb8a1unorm",
|
|
2232
|
+
"etc2-rgb8a1unorm-srgb",
|
|
2233
|
+
"etc2-rgba8unorm",
|
|
2234
|
+
"etc2-rgba8unorm-srgb",
|
|
2235
|
+
"eac-r11unorm",
|
|
2236
|
+
"eac-r11snorm",
|
|
2237
|
+
"eac-rg11unorm",
|
|
2238
|
+
"eac-rg11snorm"
|
|
2239
|
+
])) {
|
|
1100
2240
|
return "etc2";
|
|
2241
|
+
} else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
|
|
2242
|
+
return "etc1";
|
|
2243
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2244
|
+
"atc-rgb-unorm-webgl",
|
|
2245
|
+
"atc-rgba-unorm-webgl",
|
|
2246
|
+
"atc-rgbai-unorm-webgl"
|
|
2247
|
+
])) {
|
|
2248
|
+
return {
|
|
2249
|
+
alpha: "atc-rgba-interpolated-alpha",
|
|
2250
|
+
noAlpha: "atc-rgb"
|
|
2251
|
+
};
|
|
1101
2252
|
}
|
|
1102
2253
|
return "rgb565";
|
|
1103
2254
|
}
|
|
2255
|
+
function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
|
|
2256
|
+
return candidateTextureFormats.some(
|
|
2257
|
+
(textureFormat) => supportedTextureFormats.has(textureFormat)
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
1104
2260
|
|
|
1105
2261
|
// src/basis-loader.ts
|
|
1106
2262
|
var BasisWorkerLoader = {
|
|
@@ -1118,7 +2274,6 @@ var __exports__ = (() => {
|
|
|
1118
2274
|
options: {
|
|
1119
2275
|
basis: {
|
|
1120
2276
|
format: "auto",
|
|
1121
|
-
libraryPath: "libs/",
|
|
1122
2277
|
containerFormat: "auto",
|
|
1123
2278
|
module: "transcoder"
|
|
1124
2279
|
}
|
|
@@ -1144,13 +2299,13 @@ var __exports__ = (() => {
|
|
|
1144
2299
|
DDSD_MIPMAPCOUNT: 131072,
|
|
1145
2300
|
DDPF_FOURCC: 4
|
|
1146
2301
|
};
|
|
1147
|
-
var
|
|
1148
|
-
DXT1:
|
|
1149
|
-
DXT3:
|
|
1150
|
-
DXT5:
|
|
1151
|
-
"ATC ":
|
|
1152
|
-
ATCA:
|
|
1153
|
-
ATCI:
|
|
2302
|
+
var DDS_TEXTURE_FORMATS = {
|
|
2303
|
+
DXT1: "bc1-rgb-unorm-webgl",
|
|
2304
|
+
DXT3: "bc2-rgba-unorm",
|
|
2305
|
+
DXT5: "bc3-rgba-unorm",
|
|
2306
|
+
"ATC ": "atc-rgb-unorm-webgl",
|
|
2307
|
+
ATCA: "atc-rgba-unorm-webgl",
|
|
2308
|
+
ATCI: "atc-rgbai-unorm-webgl"
|
|
1154
2309
|
};
|
|
1155
2310
|
var getATCLevelSize = getDxt1LevelSize;
|
|
1156
2311
|
var getATCALevelSize = getDxtXLevelSize;
|
|
@@ -1171,14 +2326,14 @@ var __exports__ = (() => {
|
|
|
1171
2326
|
function parseDDS(data) {
|
|
1172
2327
|
const header = new Int32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH);
|
|
1173
2328
|
const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX];
|
|
1174
|
-
|
|
2329
|
+
assert2(
|
|
1175
2330
|
Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC),
|
|
1176
2331
|
"DDS: Unsupported format, must contain a FourCC code"
|
|
1177
2332
|
);
|
|
1178
2333
|
const fourCC = int32ToFourCC(pixelFormatNumber);
|
|
1179
|
-
const
|
|
2334
|
+
const textureFormat = DDS_TEXTURE_FORMATS[fourCC];
|
|
1180
2335
|
const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
|
|
1181
|
-
|
|
2336
|
+
assert2(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
|
|
1182
2337
|
let mipMapLevels = 1;
|
|
1183
2338
|
if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
|
|
1184
2339
|
mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
|
|
@@ -1192,7 +2347,7 @@ var __exports__ = (() => {
|
|
|
1192
2347
|
width,
|
|
1193
2348
|
height,
|
|
1194
2349
|
sizeFunction,
|
|
1195
|
-
|
|
2350
|
+
textureFormat
|
|
1196
2351
|
});
|
|
1197
2352
|
}
|
|
1198
2353
|
function getDxt1LevelSize(width, height) {
|
|
@@ -1224,76 +2379,34 @@ var __exports__ = (() => {
|
|
|
1224
2379
|
MIPMAPCOUNT_INDEX: 11,
|
|
1225
2380
|
METADATA_SIZE_INDEX: 12
|
|
1226
2381
|
};
|
|
1227
|
-
var
|
|
1228
|
-
0: [
|
|
1229
|
-
1: [
|
|
1230
|
-
2: [
|
|
1231
|
-
3: [
|
|
1232
|
-
6: [
|
|
1233
|
-
7: [
|
|
1234
|
-
9: [
|
|
1235
|
-
11: [
|
|
1236
|
-
22: [
|
|
1237
|
-
23: [
|
|
1238
|
-
24: [
|
|
1239
|
-
25: [
|
|
1240
|
-
26: [
|
|
1241
|
-
27: [
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
],
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
],
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
],
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR
|
|
1256
|
-
],
|
|
1257
|
-
31: [
|
|
1258
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6X6_KHR,
|
|
1259
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR
|
|
1260
|
-
],
|
|
1261
|
-
32: [
|
|
1262
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X5_KHR,
|
|
1263
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR
|
|
1264
|
-
],
|
|
1265
|
-
33: [
|
|
1266
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X6_KHR,
|
|
1267
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR
|
|
1268
|
-
],
|
|
1269
|
-
34: [
|
|
1270
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X8_KHR,
|
|
1271
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR
|
|
1272
|
-
],
|
|
1273
|
-
35: [
|
|
1274
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X5_KHR,
|
|
1275
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR
|
|
1276
|
-
],
|
|
1277
|
-
36: [
|
|
1278
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X6_KHR,
|
|
1279
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR
|
|
1280
|
-
],
|
|
1281
|
-
37: [
|
|
1282
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X8_KHR,
|
|
1283
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR
|
|
1284
|
-
],
|
|
1285
|
-
38: [
|
|
1286
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X10_KHR,
|
|
1287
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR
|
|
1288
|
-
],
|
|
1289
|
-
39: [
|
|
1290
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X10_KHR,
|
|
1291
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR
|
|
1292
|
-
],
|
|
1293
|
-
40: [
|
|
1294
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X12_KHR,
|
|
1295
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR
|
|
1296
|
-
]
|
|
2382
|
+
var PVR_TEXTURE_FORMATS = {
|
|
2383
|
+
0: ["pvrtc-rgb2unorm-webgl"],
|
|
2384
|
+
1: ["pvrtc-rgba2unorm-webgl"],
|
|
2385
|
+
2: ["pvrtc-rgb4unorm-webgl"],
|
|
2386
|
+
3: ["pvrtc-rgba4unorm-webgl"],
|
|
2387
|
+
6: ["etc1-rgb-unorm-webgl"],
|
|
2388
|
+
7: ["bc1-rgb-unorm-webgl"],
|
|
2389
|
+
9: ["bc2-rgba-unorm"],
|
|
2390
|
+
11: ["bc3-rgba-unorm"],
|
|
2391
|
+
22: ["etc2-rgb8unorm"],
|
|
2392
|
+
23: ["etc2-rgba8unorm"],
|
|
2393
|
+
24: ["etc2-rgb8a1unorm"],
|
|
2394
|
+
25: ["eac-r11unorm"],
|
|
2395
|
+
26: ["eac-rg11unorm"],
|
|
2396
|
+
27: ["astc-4x4-unorm", "astc-4x4-unorm-srgb"],
|
|
2397
|
+
28: ["astc-5x4-unorm", "astc-5x4-unorm-srgb"],
|
|
2398
|
+
29: ["astc-5x5-unorm", "astc-5x5-unorm-srgb"],
|
|
2399
|
+
30: ["astc-6x5-unorm", "astc-6x5-unorm-srgb"],
|
|
2400
|
+
31: ["astc-6x6-unorm", "astc-6x6-unorm-srgb"],
|
|
2401
|
+
32: ["astc-8x5-unorm", "astc-8x5-unorm-srgb"],
|
|
2402
|
+
33: ["astc-8x6-unorm", "astc-8x6-unorm-srgb"],
|
|
2403
|
+
34: ["astc-8x8-unorm", "astc-8x8-unorm-srgb"],
|
|
2404
|
+
35: ["astc-10x5-unorm", "astc-10x5-unorm-srgb"],
|
|
2405
|
+
36: ["astc-10x6-unorm", "astc-10x6-unorm-srgb"],
|
|
2406
|
+
37: ["astc-10x8-unorm", "astc-10x8-unorm-srgb"],
|
|
2407
|
+
38: ["astc-10x10-unorm", "astc-10x10-unorm-srgb"],
|
|
2408
|
+
39: ["astc-12x10-unorm", "astc-12x10-unorm-srgb"],
|
|
2409
|
+
40: ["astc-12x12-unorm", "astc-12x12-unorm-srgb"]
|
|
1297
2410
|
};
|
|
1298
2411
|
var PVR_SIZE_FUNCTIONS = {
|
|
1299
2412
|
0: pvrtc2bppSize,
|
|
@@ -1326,15 +2439,15 @@ var __exports__ = (() => {
|
|
|
1326
2439
|
};
|
|
1327
2440
|
function isPVR(data) {
|
|
1328
2441
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
1329
|
-
const
|
|
1330
|
-
return
|
|
2442
|
+
const version2 = header[PVR_CONSTANTS.MAGIC_NUMBER_INDEX];
|
|
2443
|
+
return version2 === PVR_CONSTANTS.MAGIC_NUMBER || version2 === PVR_CONSTANTS.MAGIC_NUMBER_EXTRA;
|
|
1331
2444
|
}
|
|
1332
2445
|
function parsePVR(data) {
|
|
1333
2446
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
1334
2447
|
const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX];
|
|
1335
2448
|
const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX];
|
|
1336
|
-
const
|
|
1337
|
-
const
|
|
2449
|
+
const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || [];
|
|
2450
|
+
const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0];
|
|
1338
2451
|
const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat];
|
|
1339
2452
|
const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX];
|
|
1340
2453
|
const width = header[PVR_CONSTANTS.WIDTH_INDEX];
|
|
@@ -1346,7 +2459,7 @@ var __exports__ = (() => {
|
|
|
1346
2459
|
width,
|
|
1347
2460
|
height,
|
|
1348
2461
|
sizeFunction,
|
|
1349
|
-
|
|
2462
|
+
textureFormat
|
|
1350
2463
|
});
|
|
1351
2464
|
}
|
|
1352
2465
|
function pvrtc2bppSize(width, height) {
|
|
@@ -1446,7 +2559,6 @@ var __exports__ = (() => {
|
|
|
1446
2559
|
binary: true,
|
|
1447
2560
|
options: {
|
|
1448
2561
|
"compressed-texture": {
|
|
1449
|
-
libraryPath: "libs/",
|
|
1450
2562
|
useBasis: false
|
|
1451
2563
|
}
|
|
1452
2564
|
}
|
|
@@ -1454,13 +2566,13 @@ var __exports__ = (() => {
|
|
|
1454
2566
|
var CompressedTextureLoader = {
|
|
1455
2567
|
...CompressedTextureWorkerLoader,
|
|
1456
2568
|
parse: async (arrayBuffer, options) => {
|
|
2569
|
+
options = { ...options };
|
|
1457
2570
|
if (options?.["compressed-texture"]?.useBasis) {
|
|
1458
2571
|
options.basis = {
|
|
1459
2572
|
format: {
|
|
1460
2573
|
alpha: "BC3",
|
|
1461
2574
|
noAlpha: "BC1"
|
|
1462
2575
|
},
|
|
1463
|
-
// @ts-expect-error TODO not allowed to modify inputs
|
|
1464
2576
|
...options.basis,
|
|
1465
2577
|
containerFormat: "ktx2",
|
|
1466
2578
|
module: "encoder"
|
|
@@ -1485,10 +2597,334 @@ var __exports__ = (() => {
|
|
|
1485
2597
|
mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"],
|
|
1486
2598
|
binary: true,
|
|
1487
2599
|
options: {
|
|
1488
|
-
crunch: {
|
|
1489
|
-
|
|
2600
|
+
crunch: {}
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
|
|
2604
|
+
// src/lib/parsers/parse-hdr.ts
|
|
2605
|
+
var HDR_MAGIC_HEADERS = ["#?RADIANCE", "#?RGBE"];
|
|
2606
|
+
var HDR_FORMAT = "32-bit_rle_rgbe";
|
|
2607
|
+
function isHDR(arrayBuffer) {
|
|
2608
|
+
const state = {
|
|
2609
|
+
data: new Uint8Array(arrayBuffer),
|
|
2610
|
+
offset: 0
|
|
2611
|
+
};
|
|
2612
|
+
const firstLine = readLine(state);
|
|
2613
|
+
return firstLine ? HDR_MAGIC_HEADERS.includes(firstLine) : false;
|
|
2614
|
+
}
|
|
2615
|
+
function parseHDR(arrayBuffer) {
|
|
2616
|
+
const state = {
|
|
2617
|
+
data: new Uint8Array(arrayBuffer),
|
|
2618
|
+
offset: 0
|
|
2619
|
+
};
|
|
2620
|
+
const header = readHeader(state);
|
|
2621
|
+
const { width, height } = header;
|
|
2622
|
+
const rgbeData = readPixels(state, header);
|
|
2623
|
+
const data = convertRGBEToFloat(rgbeData);
|
|
2624
|
+
const level = {
|
|
2625
|
+
shape: "texture-level",
|
|
2626
|
+
compressed: false,
|
|
2627
|
+
width,
|
|
2628
|
+
height,
|
|
2629
|
+
data,
|
|
2630
|
+
levelSize: data.byteLength,
|
|
2631
|
+
format: GL_RGBA32F,
|
|
2632
|
+
textureFormat: "rgba32float"
|
|
2633
|
+
};
|
|
2634
|
+
return {
|
|
2635
|
+
shape: "texture",
|
|
2636
|
+
type: "2d",
|
|
2637
|
+
format: "rgba32float",
|
|
2638
|
+
...header.metadata ? { metadata: header.metadata } : {},
|
|
2639
|
+
data: [level]
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
function readHeader(state) {
|
|
2643
|
+
const magicHeader = readLine(state);
|
|
2644
|
+
if (!magicHeader || !HDR_MAGIC_HEADERS.includes(magicHeader)) {
|
|
2645
|
+
throw new Error("RadianceHDRLoader: bad initial token");
|
|
2646
|
+
}
|
|
2647
|
+
let hasFormat = false;
|
|
2648
|
+
const metadata = {};
|
|
2649
|
+
while (state.offset < state.data.length) {
|
|
2650
|
+
const line = readLine(state);
|
|
2651
|
+
if (line === null) {
|
|
2652
|
+
break;
|
|
2653
|
+
}
|
|
2654
|
+
if (!line || line.startsWith("#")) {
|
|
2655
|
+
continue;
|
|
2656
|
+
}
|
|
2657
|
+
if (line.startsWith("FORMAT=")) {
|
|
2658
|
+
hasFormat = line.slice("FORMAT=".length) === HDR_FORMAT;
|
|
2659
|
+
if (!hasFormat) {
|
|
2660
|
+
throw new Error("RadianceHDRLoader: unsupported format specifier");
|
|
2661
|
+
}
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
parseMetadataLine(metadata, line);
|
|
2665
|
+
const dimensions = parseDimensions(line);
|
|
2666
|
+
if (dimensions) {
|
|
2667
|
+
if (!hasFormat) {
|
|
2668
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
2669
|
+
}
|
|
2670
|
+
return {
|
|
2671
|
+
...dimensions,
|
|
2672
|
+
...hasMetadata(metadata) ? { metadata } : {}
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
if (!hasFormat) {
|
|
2677
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
2678
|
+
}
|
|
2679
|
+
throw new Error("RadianceHDRLoader: missing image size specifier");
|
|
2680
|
+
}
|
|
2681
|
+
function parseDimensions(line) {
|
|
2682
|
+
const match = line.match(/^([+-])([YX])\s+(\d+)\s+([+-])([YX])\s+(\d+)$/);
|
|
2683
|
+
if (!match) {
|
|
2684
|
+
return null;
|
|
2685
|
+
}
|
|
2686
|
+
const majorSign = match[1] === "+" ? 1 : -1;
|
|
2687
|
+
const majorAxis = match[2];
|
|
2688
|
+
const majorLength = Number(match[3]);
|
|
2689
|
+
const minorSign = match[4] === "+" ? 1 : -1;
|
|
2690
|
+
const minorAxis = match[5];
|
|
2691
|
+
const minorLength = Number(match[6]);
|
|
2692
|
+
if (majorAxis === minorAxis) {
|
|
2693
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
2694
|
+
}
|
|
2695
|
+
const width = majorAxis === "X" ? majorLength : minorLength;
|
|
2696
|
+
const height = majorAxis === "Y" ? majorLength : minorLength;
|
|
2697
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
2698
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
2699
|
+
}
|
|
2700
|
+
return { width, height, majorAxis, majorSign, minorAxis, minorSign };
|
|
2701
|
+
}
|
|
2702
|
+
function readPixels(state, header) {
|
|
2703
|
+
const { width, height } = header;
|
|
2704
|
+
const pixelCount = width * height;
|
|
2705
|
+
const flatByteLength = pixelCount * 4;
|
|
2706
|
+
const scanlineLength = header.minorAxis === "X" ? width : height;
|
|
2707
|
+
const scanlineCount = header.majorAxis === "Y" ? height : width;
|
|
2708
|
+
if (scanlineLength < 8 || scanlineLength > 32767) {
|
|
2709
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
2710
|
+
}
|
|
2711
|
+
if (state.offset + 4 > state.data.length) {
|
|
2712
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
2713
|
+
}
|
|
2714
|
+
const data = state.data;
|
|
2715
|
+
const isRunLengthEncoded = data[state.offset] === 2 && data[state.offset + 1] === 2 && !(data[state.offset + 2] & 128);
|
|
2716
|
+
if (!isRunLengthEncoded) {
|
|
2717
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
2718
|
+
}
|
|
2719
|
+
const scanlineWidth = data[state.offset + 2] << 8 | data[state.offset + 3];
|
|
2720
|
+
if (scanlineWidth !== scanlineLength) {
|
|
2721
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
2722
|
+
}
|
|
2723
|
+
const pixels = new Uint8Array(flatByteLength);
|
|
2724
|
+
const scanlineBuffer = new Uint8Array(scanlineLength * 4);
|
|
2725
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
2726
|
+
if (state.offset + 4 > data.length) {
|
|
2727
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
2728
|
+
}
|
|
2729
|
+
const red = data[state.offset++];
|
|
2730
|
+
const green = data[state.offset++];
|
|
2731
|
+
const blue = data[state.offset++];
|
|
2732
|
+
const exponent = data[state.offset++];
|
|
2733
|
+
if (red !== 2 || green !== 2 || (blue << 8 | exponent) !== scanlineLength) {
|
|
2734
|
+
throw new Error("RadianceHDRLoader: bad rgbe scanline format");
|
|
2735
|
+
}
|
|
2736
|
+
for (let channelIndex = 0; channelIndex < 4; channelIndex++) {
|
|
2737
|
+
const channelOffset = channelIndex * scanlineLength;
|
|
2738
|
+
const channelEnd = channelOffset + scanlineLength;
|
|
2739
|
+
let pixelOffset = channelOffset;
|
|
2740
|
+
while (pixelOffset < channelEnd) {
|
|
2741
|
+
if (state.offset >= data.length) {
|
|
2742
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
2743
|
+
}
|
|
2744
|
+
let count = data[state.offset++];
|
|
2745
|
+
if (count > 128) {
|
|
2746
|
+
count -= 128;
|
|
2747
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset >= data.length) {
|
|
2748
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
2749
|
+
}
|
|
2750
|
+
const value = data[state.offset++];
|
|
2751
|
+
scanlineBuffer.fill(value, pixelOffset, pixelOffset + count);
|
|
2752
|
+
pixelOffset += count;
|
|
2753
|
+
continue;
|
|
2754
|
+
}
|
|
2755
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset + count > data.length) {
|
|
2756
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
2757
|
+
}
|
|
2758
|
+
scanlineBuffer.set(data.subarray(state.offset, state.offset + count), pixelOffset);
|
|
2759
|
+
pixelOffset += count;
|
|
2760
|
+
state.offset += count;
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
2764
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
2765
|
+
pixels[outputOffset] = scanlineBuffer[pixelIndex];
|
|
2766
|
+
pixels[outputOffset + 1] = scanlineBuffer[pixelIndex + scanlineLength];
|
|
2767
|
+
pixels[outputOffset + 2] = scanlineBuffer[pixelIndex + scanlineLength * 2];
|
|
2768
|
+
pixels[outputOffset + 3] = scanlineBuffer[pixelIndex + scanlineLength * 3];
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
return pixels;
|
|
2772
|
+
}
|
|
2773
|
+
function reorderPixels(data, header) {
|
|
2774
|
+
const pixels = new Uint8Array(data.length);
|
|
2775
|
+
const scanlineLength = header.minorAxis === "X" ? header.width : header.height;
|
|
2776
|
+
const scanlineCount = header.majorAxis === "Y" ? header.height : header.width;
|
|
2777
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
2778
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
2779
|
+
const sourceOffset = (scanlineIndex * scanlineLength + pixelIndex) * 4;
|
|
2780
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
2781
|
+
pixels[outputOffset] = data[sourceOffset];
|
|
2782
|
+
pixels[outputOffset + 1] = data[sourceOffset + 1];
|
|
2783
|
+
pixels[outputOffset + 2] = data[sourceOffset + 2];
|
|
2784
|
+
pixels[outputOffset + 3] = data[sourceOffset + 3];
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
return pixels;
|
|
2788
|
+
}
|
|
2789
|
+
function getOutputOffset(header, scanlineIndex, pixelIndex) {
|
|
2790
|
+
const majorCoordinate = getCoordinate(
|
|
2791
|
+
header.majorAxis === "X" ? header.width : header.height,
|
|
2792
|
+
header.majorSign,
|
|
2793
|
+
scanlineIndex
|
|
2794
|
+
);
|
|
2795
|
+
const minorCoordinate = getCoordinate(
|
|
2796
|
+
header.minorAxis === "X" ? header.width : header.height,
|
|
2797
|
+
header.minorSign,
|
|
2798
|
+
pixelIndex
|
|
2799
|
+
);
|
|
2800
|
+
const x = header.majorAxis === "X" ? majorCoordinate : minorCoordinate;
|
|
2801
|
+
const y = header.majorAxis === "Y" ? majorCoordinate : minorCoordinate;
|
|
2802
|
+
return ((header.height - 1 - y) * header.width + x) * 4;
|
|
2803
|
+
}
|
|
2804
|
+
function getCoordinate(length, sign, index) {
|
|
2805
|
+
return sign === 1 ? index : length - 1 - index;
|
|
2806
|
+
}
|
|
2807
|
+
function readFlatPixels(state, byteLength) {
|
|
2808
|
+
if (state.offset + byteLength > state.data.length) {
|
|
2809
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
2810
|
+
}
|
|
2811
|
+
const pixels = state.data.slice(state.offset, state.offset + byteLength);
|
|
2812
|
+
state.offset += byteLength;
|
|
2813
|
+
return pixels;
|
|
2814
|
+
}
|
|
2815
|
+
function convertRGBEToFloat(data) {
|
|
2816
|
+
const floatData = new Float32Array(data.length);
|
|
2817
|
+
for (let sourceOffset = 0; sourceOffset < data.length; sourceOffset += 4) {
|
|
2818
|
+
const exponent = data[sourceOffset + 3];
|
|
2819
|
+
const destinationOffset = sourceOffset;
|
|
2820
|
+
if (exponent > 0) {
|
|
2821
|
+
const scale = Math.pow(2, exponent - 128) / 255;
|
|
2822
|
+
floatData[destinationOffset] = data[sourceOffset] * scale;
|
|
2823
|
+
floatData[destinationOffset + 1] = data[sourceOffset + 1] * scale;
|
|
2824
|
+
floatData[destinationOffset + 2] = data[sourceOffset + 2] * scale;
|
|
2825
|
+
}
|
|
2826
|
+
floatData[destinationOffset + 3] = 1;
|
|
2827
|
+
}
|
|
2828
|
+
return floatData;
|
|
2829
|
+
}
|
|
2830
|
+
function readLine(state) {
|
|
2831
|
+
if (state.offset >= state.data.length) {
|
|
2832
|
+
return null;
|
|
2833
|
+
}
|
|
2834
|
+
const lineStart = state.offset;
|
|
2835
|
+
while (state.offset < state.data.length) {
|
|
2836
|
+
const byte = state.data[state.offset++];
|
|
2837
|
+
if (byte === 10) {
|
|
2838
|
+
const line2 = decodeASCII(state.data.subarray(lineStart, state.offset - 1));
|
|
2839
|
+
return line2.endsWith("\r") ? line2.slice(0, -1) : line2;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
const line = decodeASCII(state.data.subarray(lineStart, state.offset));
|
|
2843
|
+
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
2844
|
+
}
|
|
2845
|
+
function decodeASCII(data) {
|
|
2846
|
+
let line = "";
|
|
2847
|
+
for (const byte of data) {
|
|
2848
|
+
line += String.fromCharCode(byte);
|
|
2849
|
+
}
|
|
2850
|
+
return line;
|
|
2851
|
+
}
|
|
2852
|
+
function parseMetadataLine(metadata, line) {
|
|
2853
|
+
if (line.startsWith("COLORCORR=")) {
|
|
2854
|
+
const values = parseNumberList(line.slice("COLORCORR=".length), 3);
|
|
2855
|
+
if (values) {
|
|
2856
|
+
metadata.colorCorrection = values;
|
|
2857
|
+
}
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2860
|
+
if (line.startsWith("EXPOSURE=")) {
|
|
2861
|
+
const value = parseNumber(line.slice("EXPOSURE=".length));
|
|
2862
|
+
if (value !== null) {
|
|
2863
|
+
metadata.exposure = value;
|
|
2864
|
+
}
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
if (line.startsWith("GAMMA=")) {
|
|
2868
|
+
const value = parseNumber(line.slice("GAMMA=".length));
|
|
2869
|
+
if (value !== null) {
|
|
2870
|
+
metadata.gamma = value;
|
|
2871
|
+
}
|
|
2872
|
+
return;
|
|
2873
|
+
}
|
|
2874
|
+
if (line.startsWith("PIXASPECT=")) {
|
|
2875
|
+
const value = parseNumber(line.slice("PIXASPECT=".length));
|
|
2876
|
+
if (value !== null) {
|
|
2877
|
+
metadata.pixelAspectRatio = value;
|
|
2878
|
+
}
|
|
2879
|
+
return;
|
|
2880
|
+
}
|
|
2881
|
+
if (line.startsWith("PRIMARIES=")) {
|
|
2882
|
+
const values = parseNumberList(line.slice("PRIMARIES=".length), 8);
|
|
2883
|
+
if (values) {
|
|
2884
|
+
metadata.primaries = values;
|
|
1490
2885
|
}
|
|
2886
|
+
return;
|
|
2887
|
+
}
|
|
2888
|
+
if (line.startsWith("SOFTWARE=")) {
|
|
2889
|
+
metadata.software = line.slice("SOFTWARE=".length).trim();
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
if (line.startsWith("VIEW=")) {
|
|
2893
|
+
metadata.view = line.slice("VIEW=".length).trim();
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
function parseNumber(text) {
|
|
2897
|
+
const value = Number(text.trim());
|
|
2898
|
+
return Number.isFinite(value) ? value : null;
|
|
2899
|
+
}
|
|
2900
|
+
function parseNumberList(text, count) {
|
|
2901
|
+
const values = text.trim().split(/\s+/).map((value) => Number(value));
|
|
2902
|
+
if (values.length !== count || values.some((value) => !Number.isFinite(value))) {
|
|
2903
|
+
return null;
|
|
1491
2904
|
}
|
|
2905
|
+
return values;
|
|
2906
|
+
}
|
|
2907
|
+
function hasMetadata(metadata) {
|
|
2908
|
+
return Object.keys(metadata).length > 0;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
// src/radiance-hdr-loader.ts
|
|
2912
|
+
var RadianceHDRLoader = {
|
|
2913
|
+
dataType: null,
|
|
2914
|
+
batchType: null,
|
|
2915
|
+
name: "Radiance HDR",
|
|
2916
|
+
id: "hdr",
|
|
2917
|
+
module: "textures",
|
|
2918
|
+
version: VERSION,
|
|
2919
|
+
extensions: ["hdr"],
|
|
2920
|
+
mimeTypes: ["image/vnd.radiance", "image/x-hdr", "application/octet-stream"],
|
|
2921
|
+
binary: true,
|
|
2922
|
+
tests: [isHDR],
|
|
2923
|
+
options: {
|
|
2924
|
+
hdr: {}
|
|
2925
|
+
},
|
|
2926
|
+
parseSync: parseHDR,
|
|
2927
|
+
parse: async (arrayBuffer) => parseHDR(arrayBuffer)
|
|
1492
2928
|
};
|
|
1493
2929
|
|
|
1494
2930
|
// src/lib/parsers/parse-npy.ts
|
|
@@ -1573,121 +3009,15 @@ var __exports__ = (() => {
|
|
|
1573
3009
|
parse: async (arrayBuffer, options) => parseNPY(arrayBuffer, options)
|
|
1574
3010
|
};
|
|
1575
3011
|
|
|
1576
|
-
// src/lib/parsers/crunch-module-loader.ts
|
|
1577
|
-
var CRUNCH_EXTERNAL_LIBRARIES = {
|
|
1578
|
-
/** Crunch decoder library. It is used as dynamically imported script */
|
|
1579
|
-
DECODER: "crunch.js"
|
|
1580
|
-
};
|
|
1581
|
-
|
|
1582
|
-
// src/lib/encoders/encode-texture.ts
|
|
1583
|
-
async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options) {
|
|
1584
|
-
const args = [
|
|
1585
|
-
// Note: our actual executable is `npx`, so `texture-compressor` is an argument
|
|
1586
|
-
"texture-compressor",
|
|
1587
|
-
"--type",
|
|
1588
|
-
"s3tc",
|
|
1589
|
-
"--compression",
|
|
1590
|
-
"DXT1",
|
|
1591
|
-
"--quality",
|
|
1592
|
-
"normal",
|
|
1593
|
-
"--input",
|
|
1594
|
-
inputUrl,
|
|
1595
|
-
"--output",
|
|
1596
|
-
outputUrl
|
|
1597
|
-
];
|
|
1598
|
-
const childProcess = new import_child_process_proxy.default();
|
|
1599
|
-
await childProcess.start({
|
|
1600
|
-
command: "npx",
|
|
1601
|
-
arguments: args,
|
|
1602
|
-
spawn: options
|
|
1603
|
-
});
|
|
1604
|
-
return outputUrl;
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
// src/compressed-texture-writer.ts
|
|
1608
|
-
var CompressedTextureWriter = {
|
|
1609
|
-
name: "DDS Texture Container",
|
|
1610
|
-
id: "dds",
|
|
1611
|
-
module: "textures",
|
|
1612
|
-
version: VERSION,
|
|
1613
|
-
extensions: ["dds"],
|
|
1614
|
-
mimeTypes: ["image/vnd-ms.dds", "image/x-dds", "application/octet-stream"],
|
|
1615
|
-
options: {
|
|
1616
|
-
texture: {
|
|
1617
|
-
format: "auto",
|
|
1618
|
-
compression: "auto",
|
|
1619
|
-
quality: "auto",
|
|
1620
|
-
mipmap: false,
|
|
1621
|
-
flipY: false,
|
|
1622
|
-
toolFlags: ""
|
|
1623
|
-
}
|
|
1624
|
-
},
|
|
1625
|
-
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
1626
|
-
encode() {
|
|
1627
|
-
throw new Error("Not implemented");
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
|
|
1631
|
-
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
|
1632
|
-
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
1633
|
-
const {
|
|
1634
|
-
useSRGB = false,
|
|
1635
|
-
qualityLevel = 10,
|
|
1636
|
-
encodeUASTC = false,
|
|
1637
|
-
mipmaps = false
|
|
1638
|
-
} = options?.["ktx2-basis-writer"] || {};
|
|
1639
|
-
const { BasisEncoder } = await loadBasisEncoderModule(options);
|
|
1640
|
-
const basisEncoder = new BasisEncoder();
|
|
1641
|
-
try {
|
|
1642
|
-
const basisFileData = new Uint8Array(image.width * image.height * 4);
|
|
1643
|
-
basisEncoder.setCreateKTX2File(true);
|
|
1644
|
-
basisEncoder.setKTX2UASTCSupercompression(true);
|
|
1645
|
-
basisEncoder.setKTX2SRGBTransferFunc(true);
|
|
1646
|
-
basisEncoder.setSliceSourceImage(0, image.data, image.width, image.height, false);
|
|
1647
|
-
basisEncoder.setPerceptual(useSRGB);
|
|
1648
|
-
basisEncoder.setMipSRGB(useSRGB);
|
|
1649
|
-
basisEncoder.setQualityLevel(qualityLevel);
|
|
1650
|
-
basisEncoder.setUASTC(encodeUASTC);
|
|
1651
|
-
basisEncoder.setMipGen(mipmaps);
|
|
1652
|
-
const numOutputBytes = basisEncoder.encode(basisFileData);
|
|
1653
|
-
const actualKTX2FileData = basisFileData.subarray(0, numOutputBytes).buffer;
|
|
1654
|
-
return actualKTX2FileData;
|
|
1655
|
-
} catch (error) {
|
|
1656
|
-
console.error("Basis Universal Supercompressed GPU Texture encoder Error: ", error);
|
|
1657
|
-
throw error;
|
|
1658
|
-
} finally {
|
|
1659
|
-
basisEncoder.delete();
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
// src/ktx2-basis-writer.ts
|
|
1664
|
-
var KTX2BasisWriter = {
|
|
1665
|
-
name: "Basis Universal Supercompressed GPU Texture",
|
|
1666
|
-
id: "ktx2-basis-writer",
|
|
1667
|
-
module: "textures",
|
|
1668
|
-
version: VERSION,
|
|
1669
|
-
extensions: ["ktx2"],
|
|
1670
|
-
mimeTypes: ["image/ktx2"],
|
|
1671
|
-
options: {
|
|
1672
|
-
["ktx2-basis-writer"]: {
|
|
1673
|
-
useSRGB: false,
|
|
1674
|
-
qualityLevel: 10,
|
|
1675
|
-
encodeUASTC: false,
|
|
1676
|
-
mipmaps: false
|
|
1677
|
-
}
|
|
1678
|
-
},
|
|
1679
|
-
encode: encodeKTX2BasisTexture
|
|
1680
|
-
};
|
|
1681
|
-
|
|
1682
3012
|
// ../images/src/lib/utils/version.ts
|
|
1683
|
-
var
|
|
3013
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1684
3014
|
|
|
1685
3015
|
// ../images/src/lib/category-api/image-type.ts
|
|
1686
3016
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
1687
3017
|
var IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
1688
3018
|
var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
1689
3019
|
var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
|
|
1690
|
-
var DATA_SUPPORTED =
|
|
3020
|
+
var DATA_SUPPORTED = isBrowser2 ? true : NODE_IMAGE_SUPPORTED;
|
|
1691
3021
|
function isImageTypeSupported(type) {
|
|
1692
3022
|
switch (type) {
|
|
1693
3023
|
case "auto":
|
|
@@ -1716,6 +3046,9 @@ var __exports__ = (() => {
|
|
|
1716
3046
|
}
|
|
1717
3047
|
|
|
1718
3048
|
// ../images/src/lib/category-api/parsed-image-api.ts
|
|
3049
|
+
function isImage(image) {
|
|
3050
|
+
return Boolean(getImageTypeOrNull(image));
|
|
3051
|
+
}
|
|
1719
3052
|
function getImageType(image) {
|
|
1720
3053
|
const format = getImageTypeOrNull(image);
|
|
1721
3054
|
if (!format) {
|
|
@@ -1790,13 +3123,13 @@ var __exports__ = (() => {
|
|
|
1790
3123
|
// ../images/src/lib/parsers/parse-to-image.ts
|
|
1791
3124
|
async function parseToImage(arrayBuffer, options, url) {
|
|
1792
3125
|
const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
|
|
1793
|
-
const
|
|
1794
|
-
const objectUrl = typeof blobOrDataUrl !== "string" &&
|
|
3126
|
+
const URL2 = self.URL || self.webkitURL;
|
|
3127
|
+
const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
|
|
1795
3128
|
try {
|
|
1796
3129
|
return await loadToImage(objectUrl || blobOrDataUrl, options);
|
|
1797
3130
|
} finally {
|
|
1798
3131
|
if (objectUrl) {
|
|
1799
|
-
|
|
3132
|
+
URL2.revokeObjectURL(objectUrl);
|
|
1800
3133
|
}
|
|
1801
3134
|
}
|
|
1802
3135
|
}
|
|
@@ -1807,9 +3140,9 @@ var __exports__ = (() => {
|
|
|
1807
3140
|
await image.decode();
|
|
1808
3141
|
return image;
|
|
1809
3142
|
}
|
|
1810
|
-
return await new Promise((
|
|
3143
|
+
return await new Promise((resolve2, reject) => {
|
|
1811
3144
|
try {
|
|
1812
|
-
image.onload = () =>
|
|
3145
|
+
image.onload = () => resolve2(image);
|
|
1813
3146
|
image.onerror = (error) => {
|
|
1814
3147
|
const message = error instanceof Error ? error.message : "error";
|
|
1815
3148
|
reject(new Error(message));
|
|
@@ -1821,7 +3154,6 @@ var __exports__ = (() => {
|
|
|
1821
3154
|
}
|
|
1822
3155
|
|
|
1823
3156
|
// ../images/src/lib/parsers/parse-to-image-bitmap.ts
|
|
1824
|
-
var EMPTY_OBJECT = {};
|
|
1825
3157
|
var imagebitmapOptionsSupported = true;
|
|
1826
3158
|
async function parseToImageBitmap(arrayBuffer, options, url) {
|
|
1827
3159
|
let blob;
|
|
@@ -1849,8 +3181,13 @@ var __exports__ = (() => {
|
|
|
1849
3181
|
return await createImageBitmap(blob);
|
|
1850
3182
|
}
|
|
1851
3183
|
function isEmptyObject(object) {
|
|
1852
|
-
|
|
1853
|
-
return
|
|
3184
|
+
if (!object) {
|
|
3185
|
+
return true;
|
|
3186
|
+
}
|
|
3187
|
+
for (const key in object) {
|
|
3188
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
3189
|
+
return false;
|
|
3190
|
+
}
|
|
1854
3191
|
}
|
|
1855
3192
|
return true;
|
|
1856
3193
|
}
|
|
@@ -2014,7 +3351,7 @@ var __exports__ = (() => {
|
|
|
2014
3351
|
async function parseToNodeImage(arrayBuffer, options) {
|
|
2015
3352
|
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
2016
3353
|
const parseImageNode2 = globalThis.loaders?.parseImageNode;
|
|
2017
|
-
|
|
3354
|
+
assert2(parseImageNode2);
|
|
2018
3355
|
return await parseImageNode2(arrayBuffer, mimeType);
|
|
2019
3356
|
}
|
|
2020
3357
|
|
|
@@ -2037,7 +3374,7 @@ var __exports__ = (() => {
|
|
|
2037
3374
|
image = await parseToNodeImage(arrayBuffer, options);
|
|
2038
3375
|
break;
|
|
2039
3376
|
default:
|
|
2040
|
-
|
|
3377
|
+
assert2(false);
|
|
2041
3378
|
}
|
|
2042
3379
|
if (imageType === "data") {
|
|
2043
3380
|
image = getImageData(image);
|
|
@@ -2081,7 +3418,7 @@ var __exports__ = (() => {
|
|
|
2081
3418
|
id: "image",
|
|
2082
3419
|
module: "images",
|
|
2083
3420
|
name: "Images",
|
|
2084
|
-
version:
|
|
3421
|
+
version: VERSION5,
|
|
2085
3422
|
mimeTypes: MIME_TYPES,
|
|
2086
3423
|
extensions: EXTENSIONS,
|
|
2087
3424
|
parse: parseImage,
|
|
@@ -2090,16 +3427,6 @@ var __exports__ = (() => {
|
|
|
2090
3427
|
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
2091
3428
|
};
|
|
2092
3429
|
|
|
2093
|
-
// src/lib/texture-api/generate-url.ts
|
|
2094
|
-
function generateUrl(getUrl, options, urlOptions) {
|
|
2095
|
-
let url = typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
|
|
2096
|
-
const baseUrl = options.baseUrl;
|
|
2097
|
-
if (baseUrl) {
|
|
2098
|
-
url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
2099
|
-
}
|
|
2100
|
-
return resolvePath(url);
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
3430
|
// src/lib/texture-api/async-deep-map.ts
|
|
2104
3431
|
var isObject = (value) => value && typeof value === "object";
|
|
2105
3432
|
async function asyncDeepMap(tree, func, options = {}) {
|
|
@@ -2133,35 +3460,729 @@ var __exports__ = (() => {
|
|
|
2133
3460
|
return await Promise.all(promises);
|
|
2134
3461
|
}
|
|
2135
3462
|
|
|
2136
|
-
// src/lib/
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
3463
|
+
// src/lib/composite-image/image-texture-cube.ts
|
|
3464
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
3465
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
3466
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
3467
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
3468
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
3469
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
3470
|
+
var IMAGE_TEXTURE_CUBE_FACES = [
|
|
3471
|
+
{
|
|
3472
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
3473
|
+
name: "+X",
|
|
3474
|
+
direction: "right",
|
|
3475
|
+
axis: "x",
|
|
3476
|
+
sign: "positive"
|
|
3477
|
+
},
|
|
3478
|
+
{
|
|
3479
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
3480
|
+
name: "-X",
|
|
3481
|
+
direction: "left",
|
|
3482
|
+
axis: "x",
|
|
3483
|
+
sign: "negative"
|
|
3484
|
+
},
|
|
3485
|
+
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, name: "+Y", direction: "top", axis: "y", sign: "positive" },
|
|
3486
|
+
{
|
|
3487
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
3488
|
+
name: "-Y",
|
|
3489
|
+
direction: "bottom",
|
|
3490
|
+
axis: "y",
|
|
3491
|
+
sign: "negative"
|
|
3492
|
+
},
|
|
3493
|
+
{
|
|
3494
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
3495
|
+
name: "+Z",
|
|
3496
|
+
direction: "front",
|
|
3497
|
+
axis: "z",
|
|
3498
|
+
sign: "positive"
|
|
3499
|
+
},
|
|
3500
|
+
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, name: "-Z", direction: "back", axis: "z", sign: "negative" }
|
|
3501
|
+
];
|
|
3502
|
+
|
|
3503
|
+
// src/lib/composite-image/parse-composite-image.ts
|
|
3504
|
+
async function parseCompositeImageManifest(text, expectedShape, options = {}, context) {
|
|
3505
|
+
const manifest = parseCompositeImageManifestJSON(text);
|
|
3506
|
+
if (manifest.shape !== expectedShape) {
|
|
3507
|
+
throw new Error(`Expected ${expectedShape} manifest, got ${manifest.shape}`);
|
|
3508
|
+
}
|
|
3509
|
+
return await loadCompositeImageManifest(manifest, options, context);
|
|
3510
|
+
}
|
|
3511
|
+
function testCompositeImageManifestShape(text, shape) {
|
|
3512
|
+
try {
|
|
3513
|
+
return parseCompositeImageManifestJSON(text).shape === shape;
|
|
3514
|
+
} catch {
|
|
3515
|
+
return false;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
async function loadCompositeImageManifest(manifest, options = {}, context) {
|
|
3519
|
+
const normalizedOptions = normalizeCompositeImageManifestOptions(options);
|
|
3520
|
+
const urlTree = await getCompositeImageUrlTree(manifest, normalizedOptions, context);
|
|
3521
|
+
const imageData = await loadCompositeImageUrlTree(urlTree, normalizedOptions, context);
|
|
3522
|
+
return convertCompositeImageToTexture(manifest.shape, imageData);
|
|
3523
|
+
}
|
|
3524
|
+
async function loadCompositeImageUrlTree(urlTree, options = {}, context) {
|
|
3525
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
3526
|
+
return await asyncDeepMap(
|
|
3527
|
+
urlTree,
|
|
3528
|
+
async (url) => await loadCompositeImageMember(url, normalizedOptions, context)
|
|
3529
|
+
);
|
|
3530
|
+
}
|
|
3531
|
+
async function loadCompositeImageMember(url, options = {}, context) {
|
|
3532
|
+
const resolvedUrl = resolveCompositeImageUrl(url, options, context);
|
|
3533
|
+
const fetch2 = getCompositeImageFetch(options, context);
|
|
3534
|
+
const response = await fetch2(resolvedUrl);
|
|
3535
|
+
const subloaderOptions = getCompositeImageSubloaderOptions(options);
|
|
3536
|
+
if (context) {
|
|
3537
|
+
const childContext = getCompositeImageMemberContext(resolvedUrl, response, context);
|
|
3538
|
+
return await parseFromContext(
|
|
3539
|
+
response,
|
|
3540
|
+
[ImageLoader],
|
|
3541
|
+
subloaderOptions,
|
|
3542
|
+
childContext
|
|
3543
|
+
);
|
|
3544
|
+
}
|
|
3545
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3546
|
+
return await ImageLoader.parse(arrayBuffer, subloaderOptions);
|
|
3547
|
+
}
|
|
3548
|
+
async function getCompositeImageUrlTree(manifest, options = {}, context) {
|
|
3549
|
+
switch (manifest.shape) {
|
|
3550
|
+
case "image-texture":
|
|
3551
|
+
return await getImageTextureSource(manifest, options, context);
|
|
3552
|
+
case "image-texture-array":
|
|
3553
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
3554
|
+
throw new Error("image-texture-array manifest must define one or more layers");
|
|
3555
|
+
}
|
|
3556
|
+
return await Promise.all(
|
|
3557
|
+
manifest.layers.map(
|
|
3558
|
+
async (layer, index) => await getNormalizedImageTextureSource(layer, options, context, { index })
|
|
3559
|
+
)
|
|
3560
|
+
);
|
|
3561
|
+
case "image-texture-cube":
|
|
3562
|
+
return await getImageTextureCubeUrls(manifest, options, context);
|
|
3563
|
+
case "image-texture-cube-array":
|
|
3564
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
3565
|
+
throw new Error("image-texture-cube-array manifest must define one or more layers");
|
|
3566
|
+
}
|
|
3567
|
+
return await Promise.all(
|
|
3568
|
+
manifest.layers.map(
|
|
3569
|
+
async (layer, index) => await getImageTextureCubeUrls(layer, options, context, { index })
|
|
3570
|
+
)
|
|
3571
|
+
);
|
|
3572
|
+
default:
|
|
3573
|
+
throw new Error("Unsupported composite image manifest");
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
function normalizeCompositeImageOptions(options = {}) {
|
|
3577
|
+
if (options.core?.baseUrl) {
|
|
3578
|
+
return options;
|
|
3579
|
+
}
|
|
3580
|
+
const fallbackBaseUrl = options.baseUrl;
|
|
3581
|
+
if (!fallbackBaseUrl) {
|
|
3582
|
+
return options;
|
|
3583
|
+
}
|
|
3584
|
+
return {
|
|
3585
|
+
...options,
|
|
3586
|
+
core: {
|
|
3587
|
+
...options.core,
|
|
3588
|
+
baseUrl: fallbackBaseUrl
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
function resolveCompositeImageUrl(url, options = {}, context) {
|
|
3593
|
+
const resolvedUrl = resolvePath(url);
|
|
3594
|
+
if (isAbsoluteCompositeImageUrl(url)) {
|
|
3595
|
+
return resolvedUrl;
|
|
3596
|
+
}
|
|
3597
|
+
const baseUrl = getCompositeImageBaseUrl(options, context);
|
|
3598
|
+
if (!baseUrl) {
|
|
3599
|
+
if (resolvedUrl !== url || url.startsWith("@")) {
|
|
3600
|
+
return resolvedUrl;
|
|
3601
|
+
}
|
|
3602
|
+
throw new Error(`Unable to resolve relative image URL ${url} without a base URL`);
|
|
3603
|
+
}
|
|
3604
|
+
return resolvePath(joinCompositeImageUrl(baseUrl, url));
|
|
3605
|
+
}
|
|
3606
|
+
function parseCompositeImageManifestJSON(text) {
|
|
3607
|
+
const manifest = JSON.parse(text);
|
|
3608
|
+
if (!manifest?.shape) {
|
|
3609
|
+
throw new Error("Composite image manifest must contain a shape field");
|
|
3610
|
+
}
|
|
3611
|
+
return manifest;
|
|
3612
|
+
}
|
|
3613
|
+
async function getImageTextureSource(manifest, options, context) {
|
|
3614
|
+
if ((manifest.image || manifest.mipmaps) && manifest.template) {
|
|
3615
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
3616
|
+
}
|
|
3617
|
+
if (manifest.image && manifest.mipmaps) {
|
|
3618
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
3619
|
+
}
|
|
3620
|
+
if (manifest.image) {
|
|
3621
|
+
return manifest.image;
|
|
3622
|
+
}
|
|
3623
|
+
if (manifest.mipmaps?.length) {
|
|
3624
|
+
return manifest.mipmaps;
|
|
3625
|
+
}
|
|
3626
|
+
if (manifest.template) {
|
|
3627
|
+
return await expandImageTextureSource(
|
|
3628
|
+
{ mipLevels: manifest.mipLevels ?? "auto", template: manifest.template },
|
|
3629
|
+
options,
|
|
3630
|
+
context,
|
|
3631
|
+
{}
|
|
3632
|
+
);
|
|
3633
|
+
}
|
|
3634
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
3635
|
+
}
|
|
3636
|
+
async function getImageTextureCubeUrls(manifest, options, context, templateOptions = {}) {
|
|
3637
|
+
const urls = {};
|
|
3638
|
+
for (const { face, name, direction, axis, sign } of IMAGE_TEXTURE_CUBE_FACES) {
|
|
3639
|
+
const source = manifest.faces?.[name] || manifest.faces?.[direction];
|
|
3640
|
+
if (!source) {
|
|
3641
|
+
throw new Error(`image-texture-cube manifest is missing ${name} face`);
|
|
3642
|
+
}
|
|
3643
|
+
urls[face] = await getNormalizedImageTextureSource(source, options, context, {
|
|
3644
|
+
...templateOptions,
|
|
3645
|
+
face: name,
|
|
3646
|
+
direction,
|
|
3647
|
+
axis,
|
|
3648
|
+
sign
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
return urls;
|
|
3652
|
+
}
|
|
3653
|
+
async function getNormalizedImageTextureSource(source, options, context, templateOptions) {
|
|
3654
|
+
if (typeof source === "string") {
|
|
3655
|
+
return source;
|
|
3656
|
+
}
|
|
3657
|
+
if (Array.isArray(source) && source.length > 0) {
|
|
3658
|
+
return source;
|
|
3659
|
+
}
|
|
3660
|
+
if (isImageTextureTemplateSource(source)) {
|
|
3661
|
+
return await expandImageTextureSource(source, options, context, templateOptions);
|
|
3662
|
+
}
|
|
3663
|
+
throw new Error("Composite image source entries must be strings or non-empty mip arrays");
|
|
3664
|
+
}
|
|
3665
|
+
async function expandImageTextureSource(source, options, context, templateOptions) {
|
|
3666
|
+
const mipLevels = source.mipLevels === "auto" ? await getAutoMipLevels(source.template, options, context, templateOptions) : source.mipLevels;
|
|
3667
|
+
if (!Number.isFinite(mipLevels) || mipLevels <= 0) {
|
|
3668
|
+
throw new Error(`Invalid mipLevels value ${source.mipLevels}`);
|
|
3669
|
+
}
|
|
3670
|
+
const urls = [];
|
|
3671
|
+
for (let lod = 0; lod < mipLevels; lod++) {
|
|
3672
|
+
urls.push(expandTemplate(source.template, { ...templateOptions, lod }));
|
|
3673
|
+
}
|
|
3674
|
+
return urls;
|
|
3675
|
+
}
|
|
3676
|
+
async function getAutoMipLevels(template, options, context, templateOptions) {
|
|
3677
|
+
if (!template.includes("{lod}")) {
|
|
3678
|
+
throw new Error("Template sources with mipLevels: auto must include a {lod} placeholder");
|
|
3679
|
+
}
|
|
3680
|
+
const level0Url = expandTemplate(template, { ...templateOptions, lod: 0 });
|
|
3681
|
+
const image = await loadCompositeImageMember(
|
|
3682
|
+
level0Url,
|
|
3683
|
+
normalizeCompositeImageOptions(options),
|
|
3684
|
+
context
|
|
3685
|
+
);
|
|
3686
|
+
const { width, height } = getImageSize(image);
|
|
3687
|
+
return 1 + Math.floor(Math.log2(Math.max(width, height)));
|
|
3688
|
+
}
|
|
3689
|
+
function expandTemplate(template, templateOptions) {
|
|
3690
|
+
let expanded = "";
|
|
3691
|
+
for (let index = 0; index < template.length; index++) {
|
|
3692
|
+
const character = template[index];
|
|
3693
|
+
if (character === "\\") {
|
|
3694
|
+
const nextCharacter = template[index + 1];
|
|
3695
|
+
if (nextCharacter === "{" || nextCharacter === "}" || nextCharacter === "\\") {
|
|
3696
|
+
expanded += nextCharacter;
|
|
3697
|
+
index++;
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
3700
|
+
throw new Error(`Invalid escape sequence \\${nextCharacter || ""} in template ${template}`);
|
|
3701
|
+
}
|
|
3702
|
+
if (character === "}") {
|
|
3703
|
+
throw new Error(`Unexpected } in template ${template}`);
|
|
3704
|
+
}
|
|
3705
|
+
if (character !== "{") {
|
|
3706
|
+
expanded += character;
|
|
3707
|
+
continue;
|
|
3708
|
+
}
|
|
3709
|
+
const closingBraceIndex = findClosingBraceIndex(template, index + 1);
|
|
3710
|
+
if (closingBraceIndex < 0) {
|
|
3711
|
+
throw new Error(`Unterminated placeholder in template ${template}`);
|
|
3712
|
+
}
|
|
3713
|
+
const placeholder = template.slice(index + 1, closingBraceIndex);
|
|
3714
|
+
if (!/^[a-z][a-zA-Z0-9]*$/.test(placeholder)) {
|
|
3715
|
+
throw new Error(`Invalid placeholder {${placeholder}} in template ${template}`);
|
|
3716
|
+
}
|
|
3717
|
+
const value = getTemplateValue(placeholder, templateOptions);
|
|
3718
|
+
if (value === void 0) {
|
|
3719
|
+
throw new Error(
|
|
3720
|
+
`Template ${template} uses unsupported placeholder {${placeholder}} for this source`
|
|
3721
|
+
);
|
|
3722
|
+
}
|
|
3723
|
+
expanded += String(value);
|
|
3724
|
+
index = closingBraceIndex;
|
|
3725
|
+
}
|
|
3726
|
+
return expanded;
|
|
3727
|
+
}
|
|
3728
|
+
function findClosingBraceIndex(template, startIndex) {
|
|
3729
|
+
for (let index = startIndex; index < template.length; index++) {
|
|
3730
|
+
const character = template[index];
|
|
3731
|
+
if (character === "\\") {
|
|
3732
|
+
index++;
|
|
3733
|
+
continue;
|
|
3734
|
+
}
|
|
3735
|
+
if (character === "{") {
|
|
3736
|
+
throw new Error(`Nested placeholders are not supported in template ${template}`);
|
|
3737
|
+
}
|
|
3738
|
+
if (character === "}") {
|
|
3739
|
+
return index;
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
return -1;
|
|
3743
|
+
}
|
|
3744
|
+
function getTemplateValue(placeholder, templateOptions) {
|
|
3745
|
+
switch (placeholder) {
|
|
3746
|
+
case "lod":
|
|
3747
|
+
return templateOptions.lod;
|
|
3748
|
+
case "index":
|
|
3749
|
+
return templateOptions.index;
|
|
3750
|
+
case "face":
|
|
3751
|
+
return templateOptions.face;
|
|
3752
|
+
case "direction":
|
|
3753
|
+
return templateOptions.direction;
|
|
3754
|
+
case "axis":
|
|
3755
|
+
return templateOptions.axis;
|
|
3756
|
+
case "sign":
|
|
3757
|
+
return templateOptions.sign;
|
|
3758
|
+
default:
|
|
3759
|
+
return void 0;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
function isImageTextureTemplateSource(source) {
|
|
3763
|
+
return typeof source === "object" && source !== null && !Array.isArray(source);
|
|
3764
|
+
}
|
|
3765
|
+
function getCompositeImageBaseUrl(options, context) {
|
|
3766
|
+
if (context?.baseUrl) {
|
|
3767
|
+
return context.baseUrl;
|
|
3768
|
+
}
|
|
3769
|
+
if (options.baseUrl) {
|
|
3770
|
+
return stripTrailingSlash(options.baseUrl);
|
|
3771
|
+
}
|
|
3772
|
+
if (options.core?.baseUrl) {
|
|
3773
|
+
return getSourceUrlDirectory(options.core.baseUrl);
|
|
3774
|
+
}
|
|
3775
|
+
return null;
|
|
3776
|
+
}
|
|
3777
|
+
function stripTrailingSlash(baseUrl) {
|
|
3778
|
+
if (baseUrl.endsWith("/")) {
|
|
3779
|
+
return baseUrl.slice(0, -1);
|
|
3780
|
+
}
|
|
3781
|
+
return baseUrl;
|
|
3782
|
+
}
|
|
3783
|
+
function getSourceUrlDirectory(baseUrl) {
|
|
3784
|
+
return stripTrailingSlash(path_exports.dirname(baseUrl));
|
|
3785
|
+
}
|
|
3786
|
+
function joinCompositeImageUrl(baseUrl, url) {
|
|
3787
|
+
if (isRequestLikeUrl(baseUrl)) {
|
|
3788
|
+
return new URL(url, `${stripTrailingSlash(baseUrl)}/`).toString();
|
|
3789
|
+
}
|
|
3790
|
+
const normalizedBaseUrl = baseUrl.startsWith("/") ? baseUrl : `/${baseUrl}`;
|
|
3791
|
+
const normalizedUrl = path_exports.resolve(normalizedBaseUrl, url);
|
|
3792
|
+
return baseUrl.startsWith("/") ? normalizedUrl : normalizedUrl.slice(1);
|
|
3793
|
+
}
|
|
3794
|
+
function isRequestLikeUrl(url) {
|
|
3795
|
+
return url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:") || url.startsWith("blob:");
|
|
3796
|
+
}
|
|
3797
|
+
function getCompositeImageFetch(options, context) {
|
|
3798
|
+
const fetchOption = options.fetch ?? options.core?.fetch;
|
|
3799
|
+
if (context?.fetch) {
|
|
3800
|
+
return context.fetch;
|
|
3801
|
+
}
|
|
3802
|
+
if (typeof fetchOption === "function") {
|
|
3803
|
+
return fetchOption;
|
|
3804
|
+
}
|
|
3805
|
+
if (fetchOption && typeof fetchOption === "object") {
|
|
3806
|
+
return (url) => fetch(url, fetchOption);
|
|
3807
|
+
}
|
|
3808
|
+
return fetch;
|
|
3809
|
+
}
|
|
3810
|
+
function getCompositeImageSubloaderOptions(options) {
|
|
3811
|
+
const core = options.core;
|
|
3812
|
+
const rest = { ...options };
|
|
3813
|
+
delete rest.baseUrl;
|
|
3814
|
+
if (!core?.baseUrl) {
|
|
3815
|
+
return rest;
|
|
3816
|
+
}
|
|
3817
|
+
const restCore = { ...core };
|
|
3818
|
+
delete restCore.baseUrl;
|
|
3819
|
+
return {
|
|
3820
|
+
...rest,
|
|
3821
|
+
core: restCore
|
|
3822
|
+
};
|
|
3823
|
+
}
|
|
3824
|
+
function normalizeCompositeImageManifestOptions(options) {
|
|
3825
|
+
if (options.image?.type || typeof ImageBitmap === "undefined") {
|
|
3826
|
+
return options;
|
|
3827
|
+
}
|
|
3828
|
+
return {
|
|
3829
|
+
...options,
|
|
3830
|
+
image: {
|
|
3831
|
+
...options.image,
|
|
3832
|
+
type: "imagebitmap"
|
|
3833
|
+
}
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
function getCompositeImageMemberContext(resolvedUrl, response, context) {
|
|
3837
|
+
const url = response.url || resolvedUrl;
|
|
3838
|
+
const [urlWithoutQueryString, queryString = ""] = url.split("?");
|
|
3839
|
+
return {
|
|
3840
|
+
...context,
|
|
3841
|
+
url,
|
|
3842
|
+
response,
|
|
3843
|
+
filename: path_exports.filename(urlWithoutQueryString),
|
|
3844
|
+
baseUrl: path_exports.dirname(urlWithoutQueryString),
|
|
3845
|
+
queryString
|
|
3846
|
+
};
|
|
3847
|
+
}
|
|
3848
|
+
function convertCompositeImageToTexture(shape, imageData) {
|
|
3849
|
+
switch (shape) {
|
|
3850
|
+
case "image-texture": {
|
|
3851
|
+
const data = normalizeCompositeImageMember(imageData);
|
|
3852
|
+
return {
|
|
3853
|
+
shape: "texture",
|
|
3854
|
+
type: "2d",
|
|
3855
|
+
format: getCompositeTextureFormat(data),
|
|
3856
|
+
data
|
|
3857
|
+
};
|
|
3858
|
+
}
|
|
3859
|
+
case "image-texture-array": {
|
|
3860
|
+
const data = imageData.map((layer) => normalizeCompositeImageMember(layer));
|
|
3861
|
+
return {
|
|
3862
|
+
shape: "texture",
|
|
3863
|
+
type: "2d-array",
|
|
3864
|
+
format: getCompositeTextureFormat(data[0]),
|
|
3865
|
+
data
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
case "image-texture-cube": {
|
|
3869
|
+
const data = IMAGE_TEXTURE_CUBE_FACES.map(
|
|
3870
|
+
({ face }) => normalizeCompositeImageMember(imageData[face])
|
|
3871
|
+
);
|
|
3872
|
+
return {
|
|
3873
|
+
shape: "texture",
|
|
3874
|
+
type: "cube",
|
|
3875
|
+
format: getCompositeTextureFormat(data[0]),
|
|
3876
|
+
data
|
|
3877
|
+
};
|
|
3878
|
+
}
|
|
3879
|
+
case "image-texture-cube-array": {
|
|
3880
|
+
const data = imageData.map(
|
|
3881
|
+
(layer) => IMAGE_TEXTURE_CUBE_FACES.map(({ face }) => normalizeCompositeImageMember(layer[face]))
|
|
3882
|
+
);
|
|
3883
|
+
return {
|
|
3884
|
+
shape: "texture",
|
|
3885
|
+
type: "cube-array",
|
|
3886
|
+
format: getCompositeTextureFormat(data[0][0]),
|
|
3887
|
+
data
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3890
|
+
default:
|
|
3891
|
+
throw new Error(`Unsupported composite image shape ${shape}`);
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
function normalizeCompositeImageMember(imageData) {
|
|
3895
|
+
if (Array.isArray(imageData)) {
|
|
3896
|
+
if (imageData.length === 0) {
|
|
3897
|
+
throw new Error("Composite image members must not be empty");
|
|
3898
|
+
}
|
|
3899
|
+
if (imageData.every(isTextureLevel)) {
|
|
3900
|
+
return imageData;
|
|
3901
|
+
}
|
|
3902
|
+
if (imageData.every(isImage)) {
|
|
3903
|
+
return imageData.map((image) => getTextureLevelFromImage(image));
|
|
3904
|
+
}
|
|
3905
|
+
if (imageData.every((entry) => Array.isArray(entry) && entry.every(isTextureLevel))) {
|
|
3906
|
+
if (imageData.length !== 1) {
|
|
3907
|
+
throw new Error("Composite image members must resolve to a single image or mip chain");
|
|
3908
|
+
}
|
|
3909
|
+
return imageData[0];
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
if (isTexture(imageData)) {
|
|
3913
|
+
if (imageData.type !== "2d") {
|
|
3914
|
+
throw new Error(`Composite image members must resolve to 2d textures, got ${imageData.type}`);
|
|
3915
|
+
}
|
|
3916
|
+
return imageData.data;
|
|
3917
|
+
}
|
|
3918
|
+
if (isTextureLevel(imageData)) {
|
|
3919
|
+
return [imageData];
|
|
3920
|
+
}
|
|
3921
|
+
if (isImage(imageData)) {
|
|
3922
|
+
return [getTextureLevelFromImage(imageData)];
|
|
3923
|
+
}
|
|
3924
|
+
throw new Error("Composite image members must resolve to an image, mip chain, or texture");
|
|
3925
|
+
}
|
|
3926
|
+
function getTextureLevelFromImage(image) {
|
|
3927
|
+
const { width, height } = getImageSize(image);
|
|
3928
|
+
return {
|
|
3929
|
+
shape: "texture-level",
|
|
3930
|
+
compressed: false,
|
|
3931
|
+
width,
|
|
3932
|
+
height,
|
|
3933
|
+
imageBitmap: typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap ? image : void 0,
|
|
3934
|
+
data: new Uint8Array(0),
|
|
3935
|
+
textureFormat: "rgba8unorm"
|
|
3936
|
+
};
|
|
3937
|
+
}
|
|
3938
|
+
function getCompositeTextureFormat(textureLevels) {
|
|
3939
|
+
return textureLevels[0]?.textureFormat || "rgba8unorm";
|
|
3940
|
+
}
|
|
3941
|
+
function isTextureLevel(textureLevel) {
|
|
3942
|
+
return Boolean(
|
|
3943
|
+
textureLevel && typeof textureLevel === "object" && "shape" in textureLevel && textureLevel.shape === "texture-level"
|
|
3944
|
+
);
|
|
3945
|
+
}
|
|
3946
|
+
function isTexture(texture) {
|
|
3947
|
+
return Boolean(
|
|
3948
|
+
texture && typeof texture === "object" && "shape" in texture && texture.shape === "texture"
|
|
3949
|
+
);
|
|
3950
|
+
}
|
|
3951
|
+
function isAbsoluteCompositeImageUrl(url) {
|
|
3952
|
+
return url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("file:") || url.startsWith("http:") || url.startsWith("https:") || url.startsWith("/");
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
// src/texture-loader.ts
|
|
3956
|
+
var TextureLoader = {
|
|
3957
|
+
dataType: null,
|
|
3958
|
+
batchType: null,
|
|
3959
|
+
id: "texture",
|
|
3960
|
+
name: "Texture",
|
|
3961
|
+
module: "textures",
|
|
3962
|
+
version: VERSION,
|
|
3963
|
+
extensions: [],
|
|
3964
|
+
mimeTypes: [],
|
|
3965
|
+
text: true,
|
|
3966
|
+
worker: false,
|
|
3967
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture"),
|
|
3968
|
+
options: {
|
|
3969
|
+
image: {}
|
|
3970
|
+
},
|
|
3971
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(
|
|
3972
|
+
new TextDecoder().decode(arrayBuffer),
|
|
3973
|
+
"image-texture",
|
|
3974
|
+
options,
|
|
3975
|
+
context
|
|
3976
|
+
),
|
|
3977
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture", options, context)
|
|
3978
|
+
};
|
|
3979
|
+
|
|
3980
|
+
// src/texture-array-loader.ts
|
|
3981
|
+
var TextureArrayLoader = {
|
|
3982
|
+
dataType: null,
|
|
3983
|
+
batchType: null,
|
|
3984
|
+
id: "texture-array",
|
|
3985
|
+
name: "Texture Array",
|
|
3986
|
+
module: "textures",
|
|
3987
|
+
version: VERSION,
|
|
3988
|
+
extensions: [],
|
|
3989
|
+
mimeTypes: [],
|
|
3990
|
+
text: true,
|
|
3991
|
+
worker: false,
|
|
3992
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-array"),
|
|
3993
|
+
options: {
|
|
3994
|
+
image: {}
|
|
3995
|
+
},
|
|
3996
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(
|
|
3997
|
+
new TextDecoder().decode(arrayBuffer),
|
|
3998
|
+
"image-texture-array",
|
|
3999
|
+
options,
|
|
4000
|
+
context
|
|
4001
|
+
),
|
|
4002
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-array", options, context)
|
|
4003
|
+
};
|
|
4004
|
+
|
|
4005
|
+
// src/texture-cube-loader.ts
|
|
4006
|
+
var TextureCubeLoader = {
|
|
4007
|
+
dataType: null,
|
|
4008
|
+
batchType: null,
|
|
4009
|
+
id: "texture-cube",
|
|
4010
|
+
name: "Texture Cube",
|
|
4011
|
+
module: "textures",
|
|
4012
|
+
version: VERSION,
|
|
4013
|
+
extensions: [],
|
|
4014
|
+
mimeTypes: [],
|
|
4015
|
+
text: true,
|
|
4016
|
+
worker: false,
|
|
4017
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube"),
|
|
4018
|
+
options: {
|
|
4019
|
+
image: {}
|
|
4020
|
+
},
|
|
4021
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(
|
|
4022
|
+
new TextDecoder().decode(arrayBuffer),
|
|
4023
|
+
"image-texture-cube",
|
|
4024
|
+
options,
|
|
4025
|
+
context
|
|
4026
|
+
),
|
|
4027
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube", options, context)
|
|
4028
|
+
};
|
|
4029
|
+
|
|
4030
|
+
// src/texture-cube-array-loader.ts
|
|
4031
|
+
var TextureCubeArrayLoader = {
|
|
4032
|
+
dataType: null,
|
|
4033
|
+
batchType: null,
|
|
4034
|
+
id: "texture-cube-array",
|
|
4035
|
+
name: "Texture Cube Array",
|
|
4036
|
+
module: "textures",
|
|
4037
|
+
version: VERSION,
|
|
4038
|
+
extensions: [],
|
|
4039
|
+
mimeTypes: [],
|
|
4040
|
+
text: true,
|
|
4041
|
+
worker: false,
|
|
4042
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube-array"),
|
|
4043
|
+
options: {
|
|
4044
|
+
image: {}
|
|
4045
|
+
},
|
|
4046
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(
|
|
4047
|
+
new TextDecoder().decode(arrayBuffer),
|
|
4048
|
+
"image-texture-cube-array",
|
|
4049
|
+
options,
|
|
4050
|
+
context
|
|
4051
|
+
),
|
|
4052
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube-array", options, context)
|
|
4053
|
+
};
|
|
4054
|
+
|
|
4055
|
+
// src/lib/parsers/crunch-module-loader.ts
|
|
4056
|
+
var CRUNCH_EXTERNAL_LIBRARIES = {
|
|
4057
|
+
/** Crunch decoder library. It is used as dynamically imported script */
|
|
4058
|
+
DECODER: "crunch.js"
|
|
4059
|
+
};
|
|
4060
|
+
|
|
4061
|
+
// src/lib/encoders/encode-texture.ts
|
|
4062
|
+
async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options) {
|
|
4063
|
+
const args = [
|
|
4064
|
+
// Note: our actual executable is `npx`, so `texture-compressor` is an argument
|
|
4065
|
+
"texture-compressor",
|
|
4066
|
+
"--type",
|
|
4067
|
+
"s3tc",
|
|
4068
|
+
"--compression",
|
|
4069
|
+
"DXT1",
|
|
4070
|
+
"--quality",
|
|
4071
|
+
"normal",
|
|
4072
|
+
"--input",
|
|
4073
|
+
inputUrl,
|
|
4074
|
+
"--output",
|
|
4075
|
+
outputUrl
|
|
4076
|
+
];
|
|
4077
|
+
const childProcess = new ChildProcessProxy();
|
|
4078
|
+
await childProcess.start({
|
|
4079
|
+
command: "npx",
|
|
4080
|
+
arguments: args,
|
|
4081
|
+
spawn: options
|
|
4082
|
+
});
|
|
4083
|
+
return outputUrl;
|
|
4084
|
+
}
|
|
4085
|
+
|
|
4086
|
+
// src/compressed-texture-writer.ts
|
|
4087
|
+
var CompressedTextureWriter = {
|
|
4088
|
+
name: "DDS Texture Container",
|
|
4089
|
+
id: "dds",
|
|
4090
|
+
module: "textures",
|
|
4091
|
+
version: VERSION,
|
|
4092
|
+
extensions: ["dds"],
|
|
4093
|
+
mimeTypes: ["image/vnd-ms.dds", "image/x-dds", "application/octet-stream"],
|
|
4094
|
+
options: {
|
|
4095
|
+
texture: {
|
|
4096
|
+
format: "auto",
|
|
4097
|
+
compression: "auto",
|
|
4098
|
+
quality: "auto",
|
|
4099
|
+
mipmap: false,
|
|
4100
|
+
flipY: false,
|
|
4101
|
+
toolFlags: ""
|
|
4102
|
+
}
|
|
4103
|
+
},
|
|
4104
|
+
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
4105
|
+
encode() {
|
|
4106
|
+
throw new Error("Not implemented");
|
|
4107
|
+
}
|
|
4108
|
+
};
|
|
4109
|
+
|
|
4110
|
+
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
|
4111
|
+
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
4112
|
+
const {
|
|
4113
|
+
useSRGB = false,
|
|
4114
|
+
qualityLevel = 10,
|
|
4115
|
+
encodeUASTC = false,
|
|
4116
|
+
mipmaps = false
|
|
4117
|
+
} = options?.["ktx2-basis-writer"] || {};
|
|
4118
|
+
const { BasisEncoder } = await loadBasisEncoderModule(extractLoadLibraryOptions(options));
|
|
4119
|
+
const basisEncoder = new BasisEncoder();
|
|
4120
|
+
try {
|
|
4121
|
+
const basisFileData = new Uint8Array(image.width * image.height * 4);
|
|
4122
|
+
basisEncoder.setCreateKTX2File(true);
|
|
4123
|
+
basisEncoder.setKTX2UASTCSupercompression(true);
|
|
4124
|
+
basisEncoder.setKTX2SRGBTransferFunc(true);
|
|
4125
|
+
basisEncoder.setSliceSourceImage(0, image.data, image.width, image.height, false);
|
|
4126
|
+
basisEncoder.setPerceptual(useSRGB);
|
|
4127
|
+
basisEncoder.setMipSRGB(useSRGB);
|
|
4128
|
+
basisEncoder.setQualityLevel(qualityLevel);
|
|
4129
|
+
basisEncoder.setUASTC(encodeUASTC);
|
|
4130
|
+
basisEncoder.setMipGen(mipmaps);
|
|
4131
|
+
const numOutputBytes = basisEncoder.encode(basisFileData);
|
|
4132
|
+
const actualKTX2FileData = basisFileData.subarray(0, numOutputBytes).buffer;
|
|
4133
|
+
return actualKTX2FileData;
|
|
4134
|
+
} catch (error) {
|
|
4135
|
+
console.error("Basis Universal Supercompressed GPU Texture encoder Error: ", error);
|
|
4136
|
+
throw error;
|
|
4137
|
+
} finally {
|
|
4138
|
+
basisEncoder.delete();
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
// src/ktx2-basis-writer.ts
|
|
4143
|
+
var KTX2BasisWriter = {
|
|
4144
|
+
name: "Basis Universal Supercompressed GPU Texture",
|
|
4145
|
+
id: "ktx2-basis-writer",
|
|
4146
|
+
module: "textures",
|
|
4147
|
+
version: VERSION,
|
|
4148
|
+
extensions: ["ktx2"],
|
|
4149
|
+
mimeTypes: ["image/ktx2"],
|
|
4150
|
+
options: {
|
|
4151
|
+
["ktx2-basis-writer"]: {
|
|
4152
|
+
useSRGB: false,
|
|
4153
|
+
qualityLevel: 10,
|
|
4154
|
+
encodeUASTC: false,
|
|
4155
|
+
mipmaps: false
|
|
4156
|
+
}
|
|
4157
|
+
},
|
|
4158
|
+
encode: encodeKTX2BasisTexture
|
|
4159
|
+
};
|
|
4160
|
+
|
|
4161
|
+
// src/lib/texture-api/generate-url.ts
|
|
4162
|
+
function generateUrl(getUrl, options, urlOptions) {
|
|
4163
|
+
return typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
// src/lib/texture-api/load-image.ts
|
|
4167
|
+
async function loadImageTexture(getUrl, options = {}) {
|
|
4168
|
+
const imageUrls = await getImageUrls(getUrl, options);
|
|
4169
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
4170
|
+
}
|
|
4171
|
+
async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
2152
4172
|
const mipLevels = options && options.image && options.image.mipLevels || 0;
|
|
2153
4173
|
return mipLevels !== 0 ? await getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) : generateUrl(getUrl, options, urlOptions);
|
|
2154
4174
|
}
|
|
2155
4175
|
async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
|
|
2156
4176
|
const urls = [];
|
|
4177
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
2157
4178
|
if (mipLevels === "auto") {
|
|
2158
4179
|
const url = generateUrl(getUrl, options, { ...urlOptions, lod: 0 });
|
|
2159
|
-
const image = await
|
|
4180
|
+
const image = await loadCompositeImageMember(url, normalizedOptions);
|
|
2160
4181
|
const { width, height } = getImageSize(image);
|
|
2161
4182
|
mipLevels = getMipLevels({ width, height });
|
|
2162
4183
|
urls.push(url);
|
|
2163
4184
|
}
|
|
2164
|
-
|
|
4185
|
+
assert2(mipLevels > 0);
|
|
2165
4186
|
for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
|
|
2166
4187
|
const url = generateUrl(getUrl, options, { ...urlOptions, lod: mipLevel });
|
|
2167
4188
|
urls.push(url);
|
|
@@ -2175,7 +4196,7 @@ var __exports__ = (() => {
|
|
|
2175
4196
|
// src/lib/texture-api/load-image-array.ts
|
|
2176
4197
|
async function loadImageTextureArray(count, getUrl, options = {}) {
|
|
2177
4198
|
const imageUrls = await getImageArrayUrls(count, getUrl, options);
|
|
2178
|
-
return await
|
|
4199
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
2179
4200
|
}
|
|
2180
4201
|
async function getImageArrayUrls(count, getUrl, options = {}) {
|
|
2181
4202
|
const promises = [];
|
|
@@ -2187,26 +4208,12 @@ var __exports__ = (() => {
|
|
|
2187
4208
|
}
|
|
2188
4209
|
|
|
2189
4210
|
// src/lib/texture-api/load-image-cube.ts
|
|
2190
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
2191
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
2192
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
2193
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
2194
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
2195
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
2196
|
-
var CUBE_FACES = [
|
|
2197
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_X, direction: "right", axis: "x", sign: "positive" },
|
|
2198
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X, direction: "left", axis: "x", sign: "negative" },
|
|
2199
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, direction: "top", axis: "y", sign: "positive" },
|
|
2200
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, direction: "bottom", axis: "y", sign: "negative" },
|
|
2201
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z, direction: "front", axis: "z", sign: "positive" },
|
|
2202
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, direction: "back", axis: "z", sign: "negative" }
|
|
2203
|
-
];
|
|
2204
4211
|
async function getImageCubeUrls(getUrl, options) {
|
|
2205
4212
|
const urls = {};
|
|
2206
4213
|
const promises = [];
|
|
2207
4214
|
let index = 0;
|
|
2208
|
-
for (let i = 0; i <
|
|
2209
|
-
const face =
|
|
4215
|
+
for (let i = 0; i < IMAGE_TEXTURE_CUBE_FACES.length; ++i) {
|
|
4216
|
+
const face = IMAGE_TEXTURE_CUBE_FACES[index];
|
|
2210
4217
|
const promise = getImageUrls(getUrl, options, { ...face, index: index++ }).then((url) => {
|
|
2211
4218
|
urls[face.face] = url;
|
|
2212
4219
|
});
|
|
@@ -2217,7 +4224,10 @@ var __exports__ = (() => {
|
|
|
2217
4224
|
}
|
|
2218
4225
|
async function loadImageTextureCube(getUrl, options = {}) {
|
|
2219
4226
|
const urls = await getImageCubeUrls(getUrl, options);
|
|
2220
|
-
return await
|
|
4227
|
+
return await loadCompositeImageUrlTree(
|
|
4228
|
+
urls,
|
|
4229
|
+
normalizeCompositeImageOptions(options)
|
|
4230
|
+
);
|
|
2221
4231
|
}
|
|
2222
4232
|
|
|
2223
4233
|
// src/index.ts
|