@loaders.gl/textures 4.4.0-alpha.9 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +197 -1
  2. package/dist/basis-loader.d.ts +15 -10
  3. package/dist/basis-loader.d.ts.map +1 -1
  4. package/dist/basis-loader.js +0 -1
  5. package/dist/basis-loader.js.map +1 -1
  6. package/dist/basis-worker-node.js +797 -9971
  7. package/dist/basis-worker.js +300 -145
  8. package/dist/compressed-texture-loader.d.ts +0 -4
  9. package/dist/compressed-texture-loader.d.ts.map +1 -1
  10. package/dist/compressed-texture-loader.js +0 -1
  11. package/dist/compressed-texture-loader.js.map +1 -1
  12. package/dist/compressed-texture-worker.js +1110 -358
  13. package/dist/crunch-loader.d.ts +1 -5
  14. package/dist/crunch-loader.d.ts.map +1 -1
  15. package/dist/crunch-loader.js +1 -3
  16. package/dist/crunch-loader.js.map +1 -1
  17. package/dist/crunch-worker.js +168 -87
  18. package/dist/dist.dev.js +2647 -670
  19. package/dist/dist.min.js +1 -2
  20. package/dist/index.cjs +1642 -428
  21. package/dist/index.cjs.map +4 -4
  22. package/dist/index.d.ts +13 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +6 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/ktx2-basis-writer-worker-node.js +444 -9763
  27. package/dist/ktx2-basis-writer-worker.js +13 -3
  28. package/dist/lib/composite-image/image-texture-cube.d.ts +47 -0
  29. package/dist/lib/composite-image/image-texture-cube.d.ts.map +1 -0
  30. package/dist/lib/composite-image/image-texture-cube.js +42 -0
  31. package/dist/lib/composite-image/image-texture-cube.js.map +1 -0
  32. package/dist/lib/composite-image/parse-composite-image.d.ts +43 -0
  33. package/dist/lib/composite-image/parse-composite-image.d.ts.map +1 -0
  34. package/dist/lib/composite-image/parse-composite-image.js +437 -0
  35. package/dist/lib/composite-image/parse-composite-image.js.map +1 -0
  36. package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
  37. package/dist/lib/encoders/encode-ktx2-basis-texture.js +2 -1
  38. package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
  39. package/dist/lib/gl-extensions.d.ts +166 -58
  40. package/dist/lib/gl-extensions.d.ts.map +1 -1
  41. package/dist/lib/gl-extensions.js +177 -66
  42. package/dist/lib/gl-extensions.js.map +1 -1
  43. package/dist/lib/gl-types.d.ts +4 -0
  44. package/dist/lib/gl-types.d.ts.map +1 -0
  45. package/dist/lib/gl-types.js +5 -0
  46. package/dist/lib/gl-types.js.map +1 -0
  47. package/dist/lib/parsers/crunch-module-loader.d.ts +2 -2
  48. package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
  49. package/dist/lib/parsers/crunch-module-loader.js.map +1 -1
  50. package/dist/lib/parsers/parse-basis.d.ts +24 -2
  51. package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
  52. package/dist/lib/parsers/parse-basis.js +262 -64
  53. package/dist/lib/parsers/parse-basis.js.map +1 -1
  54. package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
  55. package/dist/lib/parsers/parse-crunch.js +6 -6
  56. package/dist/lib/parsers/parse-crunch.js.map +1 -1
  57. package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
  58. package/dist/lib/parsers/parse-dds.js +10 -11
  59. package/dist/lib/parsers/parse-dds.js.map +1 -1
  60. package/dist/lib/parsers/parse-hdr.d.ts +21 -0
  61. package/dist/lib/parsers/parse-hdr.d.ts.map +1 -0
  62. package/dist/lib/parsers/parse-hdr.js +305 -0
  63. package/dist/lib/parsers/parse-hdr.js.map +1 -0
  64. package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
  65. package/dist/lib/parsers/parse-ktx.js +10 -3
  66. package/dist/lib/parsers/parse-ktx.js.map +1 -1
  67. package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
  68. package/dist/lib/parsers/parse-pvr.js +31 -74
  69. package/dist/lib/parsers/parse-pvr.js.map +1 -1
  70. package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
  71. package/dist/lib/texture-api/generate-url.js +2 -10
  72. package/dist/lib/texture-api/generate-url.js.map +1 -1
  73. package/dist/lib/texture-api/load-image-array.d.ts +6 -3
  74. package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
  75. package/dist/lib/texture-api/load-image-array.js +5 -3
  76. package/dist/lib/texture-api/load-image-array.js.map +1 -1
  77. package/dist/lib/texture-api/load-image-cube.d.ts +7 -11
  78. package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
  79. package/dist/lib/texture-api/load-image-cube.js +8 -20
  80. package/dist/lib/texture-api/load-image-cube.js.map +1 -1
  81. package/dist/lib/texture-api/load-image.d.ts +6 -3
  82. package/dist/lib/texture-api/load-image.d.ts.map +1 -1
  83. package/dist/lib/texture-api/load-image.js +8 -4
  84. package/dist/lib/texture-api/load-image.js.map +1 -1
  85. package/dist/lib/texture-api/texture-api-types.d.ts +13 -0
  86. package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -1
  87. package/dist/lib/utils/detect-supported-texture-formats.d.ts +14 -0
  88. package/dist/lib/utils/detect-supported-texture-formats.d.ts.map +1 -0
  89. package/dist/lib/utils/detect-supported-texture-formats.js +197 -0
  90. package/dist/lib/utils/detect-supported-texture-formats.js.map +1 -0
  91. package/dist/lib/utils/extract-mipmap-images.d.ts +6 -2
  92. package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
  93. package/dist/lib/utils/extract-mipmap-images.js +13 -2
  94. package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
  95. package/dist/lib/utils/ktx-format-helper.d.ts +9 -1
  96. package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
  97. package/dist/lib/utils/ktx-format-helper.js +76 -109
  98. package/dist/lib/utils/ktx-format-helper.js.map +1 -1
  99. package/dist/lib/utils/texture-format-map.d.ts +10 -0
  100. package/dist/lib/utils/texture-format-map.d.ts.map +1 -0
  101. package/dist/lib/utils/texture-format-map.js +87 -0
  102. package/dist/lib/utils/texture-format-map.js.map +1 -0
  103. package/dist/lib/utils/version.js +1 -1
  104. package/dist/lib/utils/version.js.map +1 -1
  105. package/dist/npy-loader.d.ts +2 -2
  106. package/dist/npy-worker.js +1 -1
  107. package/dist/radiance-hdr-loader.d.ts +25 -0
  108. package/dist/radiance-hdr-loader.d.ts.map +1 -0
  109. package/dist/radiance-hdr-loader.js +23 -0
  110. package/dist/radiance-hdr-loader.js.map +1 -0
  111. package/dist/texture-array-loader.d.ts +25 -0
  112. package/dist/texture-array-loader.d.ts.map +1 -0
  113. package/dist/texture-array-loader.js +24 -0
  114. package/dist/texture-array-loader.js.map +1 -0
  115. package/dist/texture-cube-array-loader.d.ts +25 -0
  116. package/dist/texture-cube-array-loader.d.ts.map +1 -0
  117. package/dist/texture-cube-array-loader.js +24 -0
  118. package/dist/texture-cube-array-loader.js.map +1 -0
  119. package/dist/texture-cube-loader.d.ts +25 -0
  120. package/dist/texture-cube-loader.d.ts.map +1 -0
  121. package/dist/texture-cube-loader.js +24 -0
  122. package/dist/texture-cube-loader.js.map +1 -0
  123. package/dist/texture-loader.d.ts +25 -0
  124. package/dist/texture-loader.d.ts.map +1 -0
  125. package/dist/texture-loader.js +24 -0
  126. package/dist/texture-loader.js.map +1 -0
  127. package/dist/workers/crunch-worker.d.ts +1 -3
  128. package/dist/workers/crunch-worker.d.ts.map +1 -1
  129. package/package.json +6 -6
  130. package/src/basis-loader.ts +19 -9
  131. package/src/compressed-texture-loader.ts +0 -3
  132. package/src/crunch-loader.ts +1 -5
  133. package/src/index.ts +21 -4
  134. package/src/lib/composite-image/image-texture-cube.ts +49 -0
  135. package/src/lib/composite-image/parse-composite-image.ts +699 -0
  136. package/src/lib/encoders/encode-ktx2-basis-texture.ts +2 -1
  137. package/src/lib/gl-extensions.ts +188 -81
  138. package/src/lib/gl-types.ts +136 -0
  139. package/src/lib/parsers/crunch-module-loader.ts +4 -4
  140. package/src/lib/parsers/parse-basis.ts +326 -62
  141. package/src/lib/parsers/parse-crunch.ts +11 -8
  142. package/src/lib/parsers/parse-dds.ts +11 -12
  143. package/src/lib/parsers/parse-hdr.ts +426 -0
  144. package/src/lib/parsers/parse-ktx.ts +13 -3
  145. package/src/lib/parsers/parse-pvr.ts +33 -75
  146. package/src/lib/texture-api/generate-url.ts +2 -12
  147. package/src/lib/texture-api/load-image-array.ts +15 -6
  148. package/src/lib/texture-api/load-image-cube.ts +20 -34
  149. package/src/lib/texture-api/load-image.ts +19 -8
  150. package/src/lib/texture-api/texture-api-types.ts +15 -0
  151. package/src/lib/utils/detect-supported-texture-formats.ts +210 -0
  152. package/src/lib/utils/extract-mipmap-images.ts +23 -4
  153. package/src/lib/utils/ktx-format-helper.ts +135 -111
  154. package/src/lib/utils/texture-format-map.ts +162 -0
  155. package/src/radiance-hdr-loader.ts +36 -0
  156. package/src/texture-array-loader.ts +46 -0
  157. package/src/texture-cube-array-loader.ts +49 -0
  158. package/src/texture-cube-loader.ts +46 -0
  159. package/src/texture-loader.ts +49 -0
  160. package/dist/lib/utils/texture-formats.d.ts +0 -8
  161. package/dist/lib/utils/texture-formats.d.ts.map +0 -1
  162. package/dist/lib/utils/texture-formats.js +0 -51
  163. package/dist/lib/utils/texture-formats.js.map +0 -1
  164. 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,58 +57,94 @@ 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
- getSupportedGPUTextureFormats: () => getSupportedGPUTextureFormats,
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
 
@@ -139,34 +168,44 @@ var __exports__ = (() => {
139
168
  var VERSION2 = getVersion();
140
169
 
141
170
  // ../worker-utils/src/lib/env-utils/assert.ts
142
- function assert2(condition, message) {
171
+ function assert(condition, message) {
143
172
  if (!condition) {
144
173
  throw new Error(message || "loaders.gl assertion failed.");
145
174
  }
146
175
  }
147
176
 
148
177
  // ../worker-utils/src/lib/env-utils/globals.ts
149
- var globals2 = {
178
+ var globals = {
150
179
  self: typeof self !== "undefined" && self,
151
180
  window: typeof window !== "undefined" && window,
152
181
  global: typeof global !== "undefined" && global,
153
182
  document: typeof document !== "undefined" && document
154
183
  };
155
- var self_2 = globals2.self || globals2.window || globals2.global || {};
156
- var window_2 = globals2.window || globals2.self || globals2.global || {};
157
- var global_2 = globals2.global || globals2.self || globals2.window || {};
158
- var document_2 = globals2.document || {};
159
- var isBrowser2 = (
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 = (
160
189
  // @ts-ignore process.browser
161
190
  typeof process !== "object" || String(process) !== "[object process]" || process.browser
162
191
  );
163
192
  var isWorker = typeof importScripts === "function";
164
193
  var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
165
- var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
166
- var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
194
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
195
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
167
196
 
168
197
  // ../worker-utils/src/lib/library-utils/library-utils.ts
169
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
+ }
170
209
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
171
210
  if (moduleName) {
172
211
  libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
@@ -187,11 +226,11 @@ var __exports__ = (() => {
187
226
  if (modules[libraryName]) {
188
227
  return modules[libraryName];
189
228
  }
190
- if (!isBrowser2) {
229
+ if (!isBrowser) {
191
230
  return `modules/${moduleName}/dist/libs/${libraryName}`;
192
231
  }
193
232
  if (options.CDN) {
194
- assert2(options.CDN.startsWith("http"));
233
+ assert(options.CDN.startsWith("http"));
195
234
  return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
196
235
  }
197
236
  if (isWorker) {
@@ -203,7 +242,7 @@ var __exports__ = (() => {
203
242
  if (libraryUrl.endsWith("wasm")) {
204
243
  return await loadAsArrayBuffer(libraryUrl);
205
244
  }
206
- if (!isBrowser2) {
245
+ if (!isBrowser) {
207
246
  const { requireFromFile } = globalThis.loaders || {};
208
247
  try {
209
248
  const result = await requireFromFile?.(libraryUrl);
@@ -229,7 +268,7 @@ var __exports__ = (() => {
229
268
  return loadLibraryFromString(scriptSource, libraryUrl);
230
269
  }
231
270
  function loadLibraryFromString(scriptSource, id) {
232
- if (!isBrowser2) {
271
+ if (!isBrowser) {
233
272
  const { requireFromString } = globalThis.loaders || {};
234
273
  return requireFromString?.(scriptSource, id);
235
274
  }
@@ -249,7 +288,7 @@ var __exports__ = (() => {
249
288
  }
250
289
  async function loadAsArrayBuffer(url) {
251
290
  const { readFileAsArrayBuffer } = globalThis.loaders || {};
252
- if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
291
+ if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
253
292
  const response = await fetch(url);
254
293
  return await response.arrayBuffer();
255
294
  }
@@ -264,7 +303,7 @@ var __exports__ = (() => {
264
303
  }
265
304
  async function loadAsText(url) {
266
305
  const { readFileAsText } = globalThis.loaders || {};
267
- if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
306
+ if (isBrowser || !readFileAsText || url.startsWith("http")) {
268
307
  const response = await fetch(url);
269
308
  return await response.text();
270
309
  }
@@ -278,223 +317,1122 @@ var __exports__ = (() => {
278
317
  }
279
318
  }
280
319
 
281
- // ../worker-utils/src/index.ts
282
- var import_child_process_proxy = __toESM(require_child_process_proxy(), 1);
283
-
284
- // ../loader-utils/src/lib/path-utils/file-aliases.ts
285
- var pathPrefix = "";
286
- var fileAliases = {};
287
- function resolvePath(filename) {
288
- for (const alias in fileAliases) {
289
- if (filename.startsWith(alias)) {
290
- const replacement = fileAliases[alias];
291
- filename = filename.replace(alias, replacement);
292
- }
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");
293
324
  }
294
- if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
295
- filename = `${pathPrefix}${filename}`;
325
+ async start(props) {
326
+ return await Promise.resolve({});
296
327
  }
297
- return filename;
328
+ async stop() {
329
+ return await Promise.resolve();
330
+ }
331
+ async exit() {
332
+ return await Promise.resolve();
333
+ }
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);
298
339
  }
299
340
 
300
- // src/lib/parsers/basis-module-loader.ts
301
- var BASIS_EXTERNAL_LIBRARIES = {
302
- /** Basis transcoder, javascript wrapper part */
303
- TRANSCODER: "basis_transcoder.js",
304
- /** Basis transcoder, compiled web assembly part */
305
- TRANSCODER_WASM: "basis_transcoder.wasm",
306
- /** Basis encoder, javascript wrapper part */
307
- ENCODER: "basis_encoder.js",
308
- /** Basis encoder, compiled web assembly part */
309
- ENCODER_WASM: "basis_encoder.wasm"
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
310
354
  };
311
- var loadBasisTranscoderPromise;
312
- async function loadBasisTranscoderModule(options) {
313
- registerJSModules(options.modules);
314
- const basis = getJSModuleOrNull("basis");
315
- if (basis) {
316
- return basis;
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;
317
377
  }
318
- loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
319
- return await loadBasisTranscoderPromise;
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);
320
384
  }
321
- async function loadBasisTranscoder(options) {
322
- let BASIS = null;
323
- let wasmBinary = null;
324
- [BASIS, wasmBinary] = await Promise.all([
325
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
326
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
327
- ]);
328
- BASIS = BASIS || globalThis.BASIS;
329
- 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();
330
393
  }
331
- function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
332
- const options = {};
333
- if (wasmBinary) {
334
- options.wasmBinary = wasmBinary;
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");
335
402
  }
336
- return new Promise((resolve) => {
337
- BasisModule(options).then((module) => {
338
- const { BasisFile, initializeBasis } = module;
339
- initializeBasis();
340
- resolve({ BasisFile });
341
- });
342
- });
343
403
  }
344
- var loadBasisEncoderPromise;
345
- async function loadBasisEncoderModule(options) {
346
- const modules = options.modules || {};
347
- if (modules.basisEncoder) {
348
- return modules.basisEncoder;
404
+
405
+ // ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js
406
+ function normalizeLogLevel(logLevel) {
407
+ if (!logLevel) {
408
+ return 0;
349
409
  }
350
- loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
351
- return await loadBasisEncoderPromise;
352
- }
353
- async function loadBasisEncoder(options) {
354
- let BASIS_ENCODER = null;
355
- let wasmBinary = null;
356
- [BASIS_ENCODER, wasmBinary] = await Promise.all([
357
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
358
- await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
359
- ]);
360
- BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
361
- return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
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;
362
423
  }
363
- function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
364
- const options = {};
365
- if (wasmBinary) {
366
- options.wasmBinary = wasmBinary;
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) {
367
429
  }
368
- return new Promise((resolve) => {
369
- BasisEncoderModule(options).then((module) => {
370
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
371
- initializeBasis();
372
- resolve({ BasisFile, KTX2File, BasisEncoder });
373
- });
374
- });
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);
375
449
  }
376
450
 
377
- // src/lib/gl-extensions.ts
378
- var GL_EXTENSIONS_CONSTANTS = {
379
- // WEBGL_compressed_texture_s3tc
380
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
381
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
382
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
383
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
384
- // WEBGL_compressed_texture_es3
385
- COMPRESSED_R11_EAC: 37488,
386
- COMPRESSED_SIGNED_R11_EAC: 37489,
387
- COMPRESSED_RG11_EAC: 37490,
388
- COMPRESSED_SIGNED_RG11_EAC: 37491,
389
- COMPRESSED_RGB8_ETC2: 37492,
390
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
391
- COMPRESSED_SRGB8_ETC2: 37494,
392
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
393
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
394
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
395
- // WEBGL_compressed_texture_pvrtc
396
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
397
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
398
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
399
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
400
- // WEBGL_compressed_texture_etc1
401
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
402
- // WEBGL_compressed_texture_atc
403
- COMPRESSED_RGB_ATC_WEBGL: 35986,
404
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
405
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
406
- // WEBGL_compressed_texture_astc
407
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
408
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
409
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
410
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
411
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
412
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
413
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
414
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
415
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
416
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
417
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
418
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
419
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
420
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
421
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
422
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
423
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
424
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
425
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
426
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
427
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
428
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
429
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
430
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
431
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
432
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
433
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
434
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
435
- // EXT_texture_compression_rgtc
436
- COMPRESSED_RED_RGTC1_EXT: 36283,
437
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
438
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
439
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
440
- // WEBGL_compressed_texture_s3tc_srgb
441
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
442
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
443
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
444
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
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
+ }
445
528
  };
446
529
 
447
- // src/lib/utils/texture-formats.ts
448
- var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
449
- var WEBGL_EXTENSIONS = {
450
- /* eslint-disable camelcase */
451
- WEBGL_compressed_texture_s3tc: "dxt",
452
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
453
- WEBGL_compressed_texture_etc1: "etc1",
454
- WEBGL_compressed_texture_etc: "etc2",
455
- WEBGL_compressed_texture_pvrtc: "pvrtc",
456
- WEBGL_compressed_texture_atc: "atc",
457
- WEBGL_compressed_texture_astc: "astc",
458
- EXT_texture_compression_rgtc: "rgtc"
459
- /* eslint-enable camelcase */
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
+ }
460
569
  };
461
- var formats = null;
462
- function getSupportedGPUTextureFormats(gl) {
463
- if (!formats) {
464
- gl = gl || getWebGLContext() || void 0;
465
- formats = /* @__PURE__ */ new Set();
466
- for (const prefix of BROWSER_PREFIXES) {
467
- for (const extension in WEBGL_EXTENSIONS) {
468
- if (gl && gl.getExtension(`${prefix}${extension}`)) {
469
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
470
- formats.add(gpuTextureFormat);
471
- }
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);
472
642
  }
473
643
  }
474
644
  }
475
- return formats;
476
645
  }
477
- function getWebGLContext() {
478
- try {
479
- const canvas = document.createElement("canvas");
480
- return canvas.getContext("webgl");
481
- } catch (error) {
482
- return null;
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();
483
657
  }
658
+ return timestamp;
484
659
  }
485
660
 
486
- // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
487
- var KHR_SUPERCOMPRESSION_NONE = 0;
488
- var KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
489
- var KHR_DF_VENDORID_KHRONOS = 0;
490
- var KHR_DF_VERSION = 2;
491
- var KHR_DF_MODEL_UNSPECIFIED = 0;
492
- var KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
493
- var KHR_DF_TRANSFER_SRGB = 2;
494
- var KHR_DF_PRIMARIES_BT709 = 1;
495
- var KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
496
- var VK_FORMAT_UNDEFINED = 0;
497
- var KTX2Container = class {
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;
1428
+ var KHR_DF_VERSION = 2;
1429
+ var KHR_DF_MODEL_UNSPECIFIED = 0;
1430
+ var KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
1431
+ var KHR_DF_TRANSFER_SRGB = 2;
1432
+ var KHR_DF_PRIMARIES_BT709 = 1;
1433
+ var KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
1434
+ var VK_FORMAT_UNDEFINED = 0;
1435
+ var KTX2Container = class {
498
1436
  constructor() {
499
1437
  this.vkFormat = VK_FORMAT_UNDEFINED;
500
1438
  this.typeSize = 1;
@@ -732,23 +1670,113 @@ var __exports__ = (() => {
732
1670
  return container;
733
1671
  }
734
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
+
735
1754
  // src/lib/utils/extract-mipmap-images.ts
736
1755
  function extractMipmapImages(data, options) {
737
1756
  const images = new Array(options.mipMapLevels);
1757
+ const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
1758
+ const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
738
1759
  let levelWidth = options.width;
739
1760
  let levelHeight = options.height;
740
1761
  let offset = 0;
741
1762
  for (let i = 0; i < options.mipMapLevels; ++i) {
742
1763
  const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
743
1764
  const levelData = getLevelData(data, i, offset, levelSize);
744
- images[i] = {
1765
+ const image = {
1766
+ shape: "texture-level",
745
1767
  compressed: true,
746
- format: options.internalFormat,
747
1768
  data: levelData,
748
1769
  width: levelWidth,
749
1770
  height: levelHeight,
750
1771
  levelSize
751
1772
  };
1773
+ if (format !== void 0) {
1774
+ image.format = format;
1775
+ }
1776
+ if (textureFormat) {
1777
+ image.textureFormat = textureFormat;
1778
+ }
1779
+ images[i] = image;
752
1780
  levelWidth = Math.max(1, levelWidth >> 1);
753
1781
  levelHeight = Math.max(1, levelHeight >> 1);
754
1782
  offset += levelSize;
@@ -770,118 +1798,79 @@ var __exports__ = (() => {
770
1798
 
771
1799
  // src/lib/utils/ktx-format-helper.ts
772
1800
  var VULKAN_TO_WEBGL_FORMAT_MAP = {
773
- 131: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
774
- 132: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_S3TC_DXT1_EXT,
775
- 133: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT1_EXT,
776
- 134: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
777
- 135: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
778
- 136: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
779
- 137: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
780
- 138: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
781
- 139: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_RGTC1_EXT,
782
- 140: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_RGTC1_EXT,
783
- 141: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_GREEN_RGTC2_EXT,
784
- 142: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
785
- 147: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_ETC2,
786
- 148: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ETC2,
787
- 149: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
788
- 150: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
789
- 151: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA8_ETC2_EAC,
790
- 152: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
791
- 153: GL_EXTENSIONS_CONSTANTS.COMPRESSED_R11_EAC,
792
- 154: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_R11_EAC,
793
- 155: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RG11_EAC,
794
- 156: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RG11_EAC,
795
- // @ts-ignore
796
- 157: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
797
- // @ts-ignore
798
- 158: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
799
- // @ts-ignore
800
- 159: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
801
- // @ts-ignore
802
- 160: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,
803
- // @ts-ignore
804
- 161: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
805
- // @ts-ignore
806
- 162: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
807
- // @ts-ignore
808
- 163: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
809
- // @ts-ignore
810
- 164: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
811
- // @ts-ignore
812
- 165: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
813
- // @ts-ignore
814
- 166: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
815
- // @ts-ignore
816
- 167: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
817
- // @ts-ignore
818
- 168: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
819
- // @ts-ignore
820
- 169: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
821
- // @ts-ignore
822
- 170: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
823
- // @ts-ignore
824
- 171: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
825
- // @ts-ignore
826
- 172: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
827
- // @ts-ignore
828
- 173: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
829
- // @ts-ignore
830
- 174: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
831
- // @ts-ignore
832
- 175: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
833
- // @ts-ignore
834
- 176: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
835
- // @ts-ignore
836
- 177: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
837
- // @ts-ignore
838
- 178: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
839
- // @ts-ignore
840
- 179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
841
- // @ts-ignore
842
- 180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
843
- // @ts-ignore
844
- 181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
845
- // @ts-ignore
846
- 182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
847
- // @ts-ignore
848
- 183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
849
- // @ts-ignore
850
- 184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
851
- 1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
852
- 1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
853
- // @ts-ignore
854
- 1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
855
- // @ts-ignore
856
- 1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
857
- // @ts-ignore
858
- 1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
859
- // @ts-ignore
860
- 1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
861
- // @ts-ignore
862
- 1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
863
- // @ts-ignore
864
- 1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
865
- // @ts-ignore
866
- 1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
867
- // @ts-ignore
868
- 1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
869
- // @ts-ignore
870
- 1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
871
- // @ts-ignore
872
- 1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
873
- // @ts-ignore
874
- 1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
875
- // @ts-ignore
876
- 1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
877
- // @ts-ignore
878
- 1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
879
- // @ts-ignore
880
- 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
881
1867
  };
882
1868
  function mapVkFormatToWebGL(vkFormat) {
883
1869
  return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
884
1870
  }
1871
+ function mapVkFormatToTextureFormat(vkFormat) {
1872
+ return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
1873
+ }
885
1874
 
886
1875
  // src/lib/parsers/parse-ktx.ts
887
1876
  var KTX2_ID2 = [
@@ -921,84 +1910,170 @@ var __exports__ = (() => {
921
1910
  const mipMapLevels = Math.max(1, ktx.levels.length);
922
1911
  const width = ktx.pixelWidth;
923
1912
  const height = ktx.pixelHeight;
924
- const internalFormat = mapVkFormatToWebGL(ktx.vkFormat);
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
+ }
925
1919
  return extractMipmapImages(ktx.levels, {
926
1920
  mipMapLevels,
927
1921
  width,
928
1922
  height,
929
1923
  sizeFunction: (level) => level.uncompressedByteLength,
930
- internalFormat
1924
+ textureFormat
931
1925
  });
932
1926
  }
933
1927
 
934
1928
  // src/lib/parsers/parse-basis.ts
935
- var OutputFormat = {
1929
+ var basisTranscodingLock = Promise.resolve();
1930
+ var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
936
1931
  etc1: {
937
1932
  basisFormat: 0,
938
1933
  compressed: true,
939
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
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"
940
1942
  },
941
- etc2: { basisFormat: 1, compressed: true },
942
1943
  bc1: {
943
1944
  basisFormat: 2,
944
1945
  compressed: true,
945
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
1946
+ format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
1947
+ textureFormat: "bc1-rgb-unorm-webgl"
946
1948
  },
947
1949
  bc3: {
948
1950
  basisFormat: 3,
949
1951
  compressed: true,
950
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
1952
+ format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
1953
+ textureFormat: "bc3-rgba-unorm"
951
1954
  },
952
- bc4: { basisFormat: 4, compressed: true },
953
- bc5: { basisFormat: 5, compressed: true },
954
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
955
- "bc7-m5": { basisFormat: 7, compressed: true },
956
- "pvrtc1-4-rgb": {
957
- basisFormat: 8,
1955
+ bc4: {
1956
+ basisFormat: 4,
958
1957
  compressed: true,
959
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
1958
+ format: GL_COMPRESSED_RED_RGTC1_EXT,
1959
+ textureFormat: "bc4-r-unorm"
960
1960
  },
961
- "pvrtc1-4-rgba": {
962
- basisFormat: 9,
1961
+ bc5: {
1962
+ basisFormat: 5,
963
1963
  compressed: true,
964
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
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"
1978
+ },
1979
+ "pvrtc1-4-rgb": {
1980
+ basisFormat: 8,
1981
+ compressed: true,
1982
+ format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
1983
+ textureFormat: "pvrtc-rgb4unorm-webgl"
1984
+ },
1985
+ "pvrtc1-4-rgba": {
1986
+ basisFormat: 9,
1987
+ compressed: true,
1988
+ format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
1989
+ textureFormat: "pvrtc-rgba4unorm-webgl"
965
1990
  },
966
1991
  "astc-4x4": {
967
1992
  basisFormat: 10,
968
1993
  compressed: true,
969
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
1994
+ format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
1995
+ textureFormat: "astc-4x4-unorm"
1996
+ },
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"
970
2008
  },
971
- "atc-rgb": { basisFormat: 11, compressed: true },
972
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
973
- rgba32: { basisFormat: 13, compressed: false },
974
- rgb565: { basisFormat: 14, compressed: false },
975
- bgr565: { basisFormat: 15, compressed: false },
976
- rgba4444: { basisFormat: 16, compressed: false }
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
+ }
977
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();
2048
+ }
2049
+ }
978
2050
  async function parseBasis(data, options = {}) {
979
- if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
980
- if (isKTX(data)) {
981
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
982
- return parseKTX2File(fileConstructors.KTX2File, data, options);
983
- }
984
- const { BasisFile } = await loadBasisTranscoderModule(options?.core || {});
985
- return parseBasisFile(BasisFile, data, options);
986
- }
987
- switch (options.basis.module) {
988
- case "encoder":
989
- const fileConstructors = await loadBasisEncoderModule(options?.core || {});
990
- switch (options.basis.containerFormat) {
991
- case "ktx2":
992
- return parseKTX2File(fileConstructors.KTX2File, data, options);
993
- case "basis":
994
- default:
995
- return parseBasisFile(fileConstructors.BasisFile, 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);
996
2057
  }
997
- case "transcoder":
998
- default:
999
- const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
2058
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
1000
2059
  return parseBasisFile(BasisFile, data, options);
1001
- }
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
+ });
1002
2077
  }
1003
2078
  function parseBasisFile(BasisFile, data, options) {
1004
2079
  const basisFile = new BasisFile(new Uint8Array(data));
@@ -1028,7 +2103,7 @@ var __exports__ = (() => {
1028
2103
  const hasAlpha = basisFile.getHasAlpha(
1029
2104
  /* imageIndex, levelIndex */
1030
2105
  );
1031
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
2106
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
1032
2107
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
1033
2108
  const decodedData = new Uint8Array(decodedSize);
1034
2109
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
@@ -1036,11 +2111,13 @@ var __exports__ = (() => {
1036
2111
  }
1037
2112
  return {
1038
2113
  // standard loaders.gl image category payload
2114
+ shape: "texture-level",
1039
2115
  width,
1040
2116
  height,
1041
2117
  data: decodedData,
1042
2118
  compressed,
1043
- format,
2119
+ ...format !== void 0 ? { format } : {},
2120
+ ...textureFormat !== void 0 ? { textureFormat } : {},
1044
2121
  // Additional fields
1045
2122
  // Add levelSize field.
1046
2123
  hasAlpha
@@ -1065,7 +2142,7 @@ var __exports__ = (() => {
1065
2142
  }
1066
2143
  function transcodeKTX2Image(ktx2File, levelIndex, options) {
1067
2144
  const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
1068
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
2145
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
1069
2146
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
1070
2147
  levelIndex,
1071
2148
  0,
@@ -1088,48 +2165,98 @@ var __exports__ = (() => {
1088
2165
  }
1089
2166
  return {
1090
2167
  // standard loaders.gl image category payload
2168
+ shape: "texture-level",
1091
2169
  width,
1092
2170
  height,
1093
2171
  data: decodedData,
1094
2172
  compressed,
2173
+ ...format !== void 0 ? { format } : {},
2174
+ ...textureFormat !== void 0 ? { textureFormat } : {},
1095
2175
  // Additional fields
1096
2176
  levelSize: decodedSize,
1097
- hasAlpha: alphaFlag,
1098
- format
2177
+ hasAlpha: alphaFlag
1099
2178
  };
1100
2179
  }
1101
2180
  function getBasisOptions(options, hasAlpha) {
1102
- let format = options.basis?.format;
2181
+ let format = options.basis?.format || "auto";
1103
2182
  if (format === "auto") {
1104
- format = selectSupportedBasisFormat();
2183
+ format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
1105
2184
  }
1106
2185
  if (typeof format === "object") {
1107
2186
  format = hasAlpha ? format.alpha : format.noAlpha;
1108
2187
  }
1109
- format = format.toLowerCase();
1110
- return OutputFormat[format];
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;
1111
2194
  }
1112
- function selectSupportedBasisFormat() {
1113
- const supportedFormats = getSupportedGPUTextureFormats();
1114
- if (supportedFormats.has("astc")) {
2195
+ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
2196
+ const textureFormats2 = new Set(supportedTextureFormats);
2197
+ if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
1115
2198
  return "astc-4x4";
1116
- } else if (supportedFormats.has("dxt")) {
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
+ ])) {
1117
2214
  return {
1118
2215
  alpha: "bc3",
1119
2216
  noAlpha: "bc1"
1120
2217
  };
1121
- } else if (supportedFormats.has("pvrtc")) {
2218
+ } else if (hasSupportedTextureFormat(textureFormats2, [
2219
+ "pvrtc-rgb4unorm-webgl",
2220
+ "pvrtc-rgba4unorm-webgl",
2221
+ "pvrtc-rgb2unorm-webgl",
2222
+ "pvrtc-rgba2unorm-webgl"
2223
+ ])) {
1122
2224
  return {
1123
2225
  alpha: "pvrtc1-4-rgba",
1124
2226
  noAlpha: "pvrtc1-4-rgb"
1125
2227
  };
1126
- } else if (supportedFormats.has("etc1")) {
1127
- return "etc1";
1128
- } else if (supportedFormats.has("etc2")) {
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
+ ])) {
1129
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
+ };
1130
2252
  }
1131
2253
  return "rgb565";
1132
2254
  }
2255
+ function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
2256
+ return candidateTextureFormats.some(
2257
+ (textureFormat) => supportedTextureFormats.has(textureFormat)
2258
+ );
2259
+ }
1133
2260
 
1134
2261
  // src/basis-loader.ts
1135
2262
  var BasisWorkerLoader = {
@@ -1147,7 +2274,6 @@ var __exports__ = (() => {
1147
2274
  options: {
1148
2275
  basis: {
1149
2276
  format: "auto",
1150
- libraryPath: "libs/",
1151
2277
  containerFormat: "auto",
1152
2278
  module: "transcoder"
1153
2279
  }
@@ -1173,13 +2299,13 @@ var __exports__ = (() => {
1173
2299
  DDSD_MIPMAPCOUNT: 131072,
1174
2300
  DDPF_FOURCC: 4
1175
2301
  };
1176
- var DDS_PIXEL_FORMATS = {
1177
- DXT1: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
1178
- DXT3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
1179
- DXT5: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
1180
- "ATC ": GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ATC_WEBGL,
1181
- ATCA: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
1182
- ATCI: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL
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"
1183
2309
  };
1184
2310
  var getATCLevelSize = getDxt1LevelSize;
1185
2311
  var getATCALevelSize = getDxtXLevelSize;
@@ -1200,14 +2326,14 @@ var __exports__ = (() => {
1200
2326
  function parseDDS(data) {
1201
2327
  const header = new Int32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH);
1202
2328
  const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX];
1203
- assert(
2329
+ assert2(
1204
2330
  Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC),
1205
2331
  "DDS: Unsupported format, must contain a FourCC code"
1206
2332
  );
1207
2333
  const fourCC = int32ToFourCC(pixelFormatNumber);
1208
- const internalFormat = DDS_PIXEL_FORMATS[fourCC];
2334
+ const textureFormat = DDS_TEXTURE_FORMATS[fourCC];
1209
2335
  const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
1210
- assert(internalFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
2336
+ assert2(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
1211
2337
  let mipMapLevels = 1;
1212
2338
  if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
1213
2339
  mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
@@ -1221,7 +2347,7 @@ var __exports__ = (() => {
1221
2347
  width,
1222
2348
  height,
1223
2349
  sizeFunction,
1224
- internalFormat
2350
+ textureFormat
1225
2351
  });
1226
2352
  }
1227
2353
  function getDxt1LevelSize(width, height) {
@@ -1253,76 +2379,34 @@ var __exports__ = (() => {
1253
2379
  MIPMAPCOUNT_INDEX: 11,
1254
2380
  METADATA_SIZE_INDEX: 12
1255
2381
  };
1256
- var PVR_PIXEL_FORMATS = {
1257
- 0: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG],
1258
- 1: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],
1259
- 2: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG],
1260
- 3: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],
1261
- 6: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL],
1262
- 7: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT],
1263
- 9: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT],
1264
- 11: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT],
1265
- 22: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_ETC2],
1266
- 23: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA8_ETC2_EAC],
1267
- 24: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],
1268
- 25: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_R11_EAC],
1269
- 26: [GL_EXTENSIONS_CONSTANTS.COMPRESSED_RG11_EAC],
1270
- 27: [
1271
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR,
1272
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR
1273
- ],
1274
- 28: [
1275
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5X4_KHR,
1276
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR
1277
- ],
1278
- 29: [
1279
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5X5_KHR,
1280
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR
1281
- ],
1282
- 30: [
1283
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6X5_KHR,
1284
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR
1285
- ],
1286
- 31: [
1287
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6X6_KHR,
1288
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR
1289
- ],
1290
- 32: [
1291
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X5_KHR,
1292
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR
1293
- ],
1294
- 33: [
1295
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X6_KHR,
1296
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR
1297
- ],
1298
- 34: [
1299
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X8_KHR,
1300
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR
1301
- ],
1302
- 35: [
1303
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X5_KHR,
1304
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR
1305
- ],
1306
- 36: [
1307
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X6_KHR,
1308
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR
1309
- ],
1310
- 37: [
1311
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X8_KHR,
1312
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR
1313
- ],
1314
- 38: [
1315
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X10_KHR,
1316
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR
1317
- ],
1318
- 39: [
1319
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X10_KHR,
1320
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR
1321
- ],
1322
- 40: [
1323
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X12_KHR,
1324
- GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR
1325
- ]
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"]
1326
2410
  };
1327
2411
  var PVR_SIZE_FUNCTIONS = {
1328
2412
  0: pvrtc2bppSize,
@@ -1355,15 +2439,15 @@ var __exports__ = (() => {
1355
2439
  };
1356
2440
  function isPVR(data) {
1357
2441
  const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
1358
- const version = header[PVR_CONSTANTS.MAGIC_NUMBER_INDEX];
1359
- return version === PVR_CONSTANTS.MAGIC_NUMBER || version === PVR_CONSTANTS.MAGIC_NUMBER_EXTRA;
2442
+ const version2 = header[PVR_CONSTANTS.MAGIC_NUMBER_INDEX];
2443
+ return version2 === PVR_CONSTANTS.MAGIC_NUMBER || version2 === PVR_CONSTANTS.MAGIC_NUMBER_EXTRA;
1360
2444
  }
1361
2445
  function parsePVR(data) {
1362
2446
  const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
1363
2447
  const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX];
1364
2448
  const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX];
1365
- const pixelFormats = PVR_PIXEL_FORMATS[pvrFormat] || [];
1366
- const internalFormat = pixelFormats.length > 1 && colourSpace ? pixelFormats[1] : pixelFormats[0];
2449
+ const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || [];
2450
+ const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0];
1367
2451
  const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat];
1368
2452
  const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX];
1369
2453
  const width = header[PVR_CONSTANTS.WIDTH_INDEX];
@@ -1375,7 +2459,7 @@ var __exports__ = (() => {
1375
2459
  width,
1376
2460
  height,
1377
2461
  sizeFunction,
1378
- internalFormat
2462
+ textureFormat
1379
2463
  });
1380
2464
  }
1381
2465
  function pvrtc2bppSize(width, height) {
@@ -1475,7 +2559,6 @@ var __exports__ = (() => {
1475
2559
  binary: true,
1476
2560
  options: {
1477
2561
  "compressed-texture": {
1478
- libraryPath: "libs/",
1479
2562
  useBasis: false
1480
2563
  }
1481
2564
  }
@@ -1514,10 +2597,334 @@ var __exports__ = (() => {
1514
2597
  mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"],
1515
2598
  binary: true,
1516
2599
  options: {
1517
- crunch: {
1518
- libraryPath: "libs/"
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
+ }
1519
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;
2885
+ }
2886
+ return;
2887
+ }
2888
+ if (line.startsWith("SOFTWARE=")) {
2889
+ metadata.software = line.slice("SOFTWARE=".length).trim();
2890
+ return;
1520
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;
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)
1521
2928
  };
1522
2929
 
1523
2930
  // src/lib/parsers/parse-npy.ts
@@ -1602,121 +3009,15 @@ var __exports__ = (() => {
1602
3009
  parse: async (arrayBuffer, options) => parseNPY(arrayBuffer, options)
1603
3010
  };
1604
3011
 
1605
- // src/lib/parsers/crunch-module-loader.ts
1606
- var CRUNCH_EXTERNAL_LIBRARIES = {
1607
- /** Crunch decoder library. It is used as dynamically imported script */
1608
- DECODER: "crunch.js"
1609
- };
1610
-
1611
- // src/lib/encoders/encode-texture.ts
1612
- async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options) {
1613
- const args = [
1614
- // Note: our actual executable is `npx`, so `texture-compressor` is an argument
1615
- "texture-compressor",
1616
- "--type",
1617
- "s3tc",
1618
- "--compression",
1619
- "DXT1",
1620
- "--quality",
1621
- "normal",
1622
- "--input",
1623
- inputUrl,
1624
- "--output",
1625
- outputUrl
1626
- ];
1627
- const childProcess = new import_child_process_proxy.default();
1628
- await childProcess.start({
1629
- command: "npx",
1630
- arguments: args,
1631
- spawn: options
1632
- });
1633
- return outputUrl;
1634
- }
1635
-
1636
- // src/compressed-texture-writer.ts
1637
- var CompressedTextureWriter = {
1638
- name: "DDS Texture Container",
1639
- id: "dds",
1640
- module: "textures",
1641
- version: VERSION,
1642
- extensions: ["dds"],
1643
- mimeTypes: ["image/vnd-ms.dds", "image/x-dds", "application/octet-stream"],
1644
- options: {
1645
- texture: {
1646
- format: "auto",
1647
- compression: "auto",
1648
- quality: "auto",
1649
- mipmap: false,
1650
- flipY: false,
1651
- toolFlags: ""
1652
- }
1653
- },
1654
- encodeURLtoURL: encodeImageURLToCompressedTextureURL,
1655
- encode() {
1656
- throw new Error("Not implemented");
1657
- }
1658
- };
1659
-
1660
- // src/lib/encoders/encode-ktx2-basis-texture.ts
1661
- async function encodeKTX2BasisTexture(image, options = {}) {
1662
- const {
1663
- useSRGB = false,
1664
- qualityLevel = 10,
1665
- encodeUASTC = false,
1666
- mipmaps = false
1667
- } = options?.["ktx2-basis-writer"] || {};
1668
- const { BasisEncoder } = await loadBasisEncoderModule(options.core || {});
1669
- const basisEncoder = new BasisEncoder();
1670
- try {
1671
- const basisFileData = new Uint8Array(image.width * image.height * 4);
1672
- basisEncoder.setCreateKTX2File(true);
1673
- basisEncoder.setKTX2UASTCSupercompression(true);
1674
- basisEncoder.setKTX2SRGBTransferFunc(true);
1675
- basisEncoder.setSliceSourceImage(0, image.data, image.width, image.height, false);
1676
- basisEncoder.setPerceptual(useSRGB);
1677
- basisEncoder.setMipSRGB(useSRGB);
1678
- basisEncoder.setQualityLevel(qualityLevel);
1679
- basisEncoder.setUASTC(encodeUASTC);
1680
- basisEncoder.setMipGen(mipmaps);
1681
- const numOutputBytes = basisEncoder.encode(basisFileData);
1682
- const actualKTX2FileData = basisFileData.subarray(0, numOutputBytes).buffer;
1683
- return actualKTX2FileData;
1684
- } catch (error) {
1685
- console.error("Basis Universal Supercompressed GPU Texture encoder Error: ", error);
1686
- throw error;
1687
- } finally {
1688
- basisEncoder.delete();
1689
- }
1690
- }
1691
-
1692
- // src/ktx2-basis-writer.ts
1693
- var KTX2BasisWriter = {
1694
- name: "Basis Universal Supercompressed GPU Texture",
1695
- id: "ktx2-basis-writer",
1696
- module: "textures",
1697
- version: VERSION,
1698
- extensions: ["ktx2"],
1699
- mimeTypes: ["image/ktx2"],
1700
- options: {
1701
- ["ktx2-basis-writer"]: {
1702
- useSRGB: false,
1703
- qualityLevel: 10,
1704
- encodeUASTC: false,
1705
- mipmaps: false
1706
- }
1707
- },
1708
- encode: encodeKTX2BasisTexture
1709
- };
1710
-
1711
3012
  // ../images/src/lib/utils/version.ts
1712
- var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3013
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1713
3014
 
1714
3015
  // ../images/src/lib/category-api/image-type.ts
1715
3016
  var parseImageNode = globalThis.loaders?.parseImageNode;
1716
3017
  var IMAGE_SUPPORTED = typeof Image !== "undefined";
1717
3018
  var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
1718
3019
  var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
1719
- var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
3020
+ var DATA_SUPPORTED = isBrowser2 ? true : NODE_IMAGE_SUPPORTED;
1720
3021
  function isImageTypeSupported(type) {
1721
3022
  switch (type) {
1722
3023
  case "auto":
@@ -1745,6 +3046,9 @@ var __exports__ = (() => {
1745
3046
  }
1746
3047
 
1747
3048
  // ../images/src/lib/category-api/parsed-image-api.ts
3049
+ function isImage(image) {
3050
+ return Boolean(getImageTypeOrNull(image));
3051
+ }
1748
3052
  function getImageType(image) {
1749
3053
  const format = getImageTypeOrNull(image);
1750
3054
  if (!format) {
@@ -1819,13 +3123,13 @@ var __exports__ = (() => {
1819
3123
  // ../images/src/lib/parsers/parse-to-image.ts
1820
3124
  async function parseToImage(arrayBuffer, options, url) {
1821
3125
  const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
1822
- const URL = self.URL || self.webkitURL;
1823
- const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
3126
+ const URL2 = self.URL || self.webkitURL;
3127
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
1824
3128
  try {
1825
3129
  return await loadToImage(objectUrl || blobOrDataUrl, options);
1826
3130
  } finally {
1827
3131
  if (objectUrl) {
1828
- URL.revokeObjectURL(objectUrl);
3132
+ URL2.revokeObjectURL(objectUrl);
1829
3133
  }
1830
3134
  }
1831
3135
  }
@@ -1836,9 +3140,9 @@ var __exports__ = (() => {
1836
3140
  await image.decode();
1837
3141
  return image;
1838
3142
  }
1839
- return await new Promise((resolve, reject) => {
3143
+ return await new Promise((resolve2, reject) => {
1840
3144
  try {
1841
- image.onload = () => resolve(image);
3145
+ image.onload = () => resolve2(image);
1842
3146
  image.onerror = (error) => {
1843
3147
  const message = error instanceof Error ? error.message : "error";
1844
3148
  reject(new Error(message));
@@ -2047,7 +3351,7 @@ var __exports__ = (() => {
2047
3351
  async function parseToNodeImage(arrayBuffer, options) {
2048
3352
  const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
2049
3353
  const parseImageNode2 = globalThis.loaders?.parseImageNode;
2050
- assert(parseImageNode2);
3354
+ assert2(parseImageNode2);
2051
3355
  return await parseImageNode2(arrayBuffer, mimeType);
2052
3356
  }
2053
3357
 
@@ -2070,7 +3374,7 @@ var __exports__ = (() => {
2070
3374
  image = await parseToNodeImage(arrayBuffer, options);
2071
3375
  break;
2072
3376
  default:
2073
- assert(false);
3377
+ assert2(false);
2074
3378
  }
2075
3379
  if (imageType === "data") {
2076
3380
  image = getImageData(image);
@@ -2114,7 +3418,7 @@ var __exports__ = (() => {
2114
3418
  id: "image",
2115
3419
  module: "images",
2116
3420
  name: "Images",
2117
- version: VERSION3,
3421
+ version: VERSION5,
2118
3422
  mimeTypes: MIME_TYPES,
2119
3423
  extensions: EXTENSIONS,
2120
3424
  parse: parseImage,
@@ -2123,16 +3427,6 @@ var __exports__ = (() => {
2123
3427
  options: DEFAULT_IMAGE_LOADER_OPTIONS
2124
3428
  };
2125
3429
 
2126
- // src/lib/texture-api/generate-url.ts
2127
- function generateUrl(getUrl, options, urlOptions) {
2128
- let url = typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
2129
- const baseUrl = options.baseUrl;
2130
- if (baseUrl) {
2131
- url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
2132
- }
2133
- return resolvePath(url);
2134
- }
2135
-
2136
3430
  // src/lib/texture-api/async-deep-map.ts
2137
3431
  var isObject = (value) => value && typeof value === "object";
2138
3432
  async function asyncDeepMap(tree, func, options = {}) {
@@ -2166,20 +3460,713 @@ var __exports__ = (() => {
2166
3460
  return await Promise.all(promises);
2167
3461
  }
2168
3462
 
2169
- // src/lib/texture-api/deep-load.ts
2170
- async function deepLoad(urlTree, load, options) {
2171
- return await asyncDeepMap(urlTree, (url) => shallowLoad(url, load, options));
2172
- }
2173
- async function shallowLoad(url, load, options) {
2174
- const response = await fetch(url, options.fetch);
2175
- const arrayBuffer = await response.arrayBuffer();
2176
- return await load(arrayBuffer, options);
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;
2177
4164
  }
2178
4165
 
2179
4166
  // src/lib/texture-api/load-image.ts
2180
4167
  async function loadImageTexture(getUrl, options = {}) {
2181
4168
  const imageUrls = await getImageUrls(getUrl, options);
2182
- return await deepLoad(imageUrls, ImageLoader.parse, options);
4169
+ return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
2183
4170
  }
2184
4171
  async function getImageUrls(getUrl, options, urlOptions = {}) {
2185
4172
  const mipLevels = options && options.image && options.image.mipLevels || 0;
@@ -2187,14 +4174,15 @@ var __exports__ = (() => {
2187
4174
  }
2188
4175
  async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
2189
4176
  const urls = [];
4177
+ const normalizedOptions = normalizeCompositeImageOptions(options);
2190
4178
  if (mipLevels === "auto") {
2191
4179
  const url = generateUrl(getUrl, options, { ...urlOptions, lod: 0 });
2192
- const image = await shallowLoad(url, ImageLoader.parse, options);
4180
+ const image = await loadCompositeImageMember(url, normalizedOptions);
2193
4181
  const { width, height } = getImageSize(image);
2194
4182
  mipLevels = getMipLevels({ width, height });
2195
4183
  urls.push(url);
2196
4184
  }
2197
- assert(mipLevels > 0);
4185
+ assert2(mipLevels > 0);
2198
4186
  for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
2199
4187
  const url = generateUrl(getUrl, options, { ...urlOptions, lod: mipLevel });
2200
4188
  urls.push(url);
@@ -2208,7 +4196,7 @@ var __exports__ = (() => {
2208
4196
  // src/lib/texture-api/load-image-array.ts
2209
4197
  async function loadImageTextureArray(count, getUrl, options = {}) {
2210
4198
  const imageUrls = await getImageArrayUrls(count, getUrl, options);
2211
- return await deepLoad(imageUrls, ImageLoader.parse, options);
4199
+ return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
2212
4200
  }
2213
4201
  async function getImageArrayUrls(count, getUrl, options = {}) {
2214
4202
  const promises = [];
@@ -2220,26 +4208,12 @@ var __exports__ = (() => {
2220
4208
  }
2221
4209
 
2222
4210
  // src/lib/texture-api/load-image-cube.ts
2223
- var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
2224
- var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
2225
- var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
2226
- var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
2227
- var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
2228
- var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
2229
- var CUBE_FACES = [
2230
- { face: GL_TEXTURE_CUBE_MAP_POSITIVE_X, direction: "right", axis: "x", sign: "positive" },
2231
- { face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X, direction: "left", axis: "x", sign: "negative" },
2232
- { face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, direction: "top", axis: "y", sign: "positive" },
2233
- { face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, direction: "bottom", axis: "y", sign: "negative" },
2234
- { face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z, direction: "front", axis: "z", sign: "positive" },
2235
- { face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, direction: "back", axis: "z", sign: "negative" }
2236
- ];
2237
4211
  async function getImageCubeUrls(getUrl, options) {
2238
4212
  const urls = {};
2239
4213
  const promises = [];
2240
4214
  let index = 0;
2241
- for (let i = 0; i < CUBE_FACES.length; ++i) {
2242
- const face = CUBE_FACES[index];
4215
+ for (let i = 0; i < IMAGE_TEXTURE_CUBE_FACES.length; ++i) {
4216
+ const face = IMAGE_TEXTURE_CUBE_FACES[index];
2243
4217
  const promise = getImageUrls(getUrl, options, { ...face, index: index++ }).then((url) => {
2244
4218
  urls[face.face] = url;
2245
4219
  });
@@ -2250,7 +4224,10 @@ var __exports__ = (() => {
2250
4224
  }
2251
4225
  async function loadImageTextureCube(getUrl, options = {}) {
2252
4226
  const urls = await getImageCubeUrls(getUrl, options);
2253
- return await deepLoad(urls, ImageLoader.parse, options);
4227
+ return await loadCompositeImageUrlTree(
4228
+ urls,
4229
+ normalizeCompositeImageOptions(options)
4230
+ );
2254
4231
  }
2255
4232
 
2256
4233
  // src/index.ts