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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) 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 +1 -1
  5. package/dist/basis-loader.js.map +1 -0
  6. package/dist/basis-worker-node.js +932 -10040
  7. package/dist/basis-worker.d.ts +2 -0
  8. package/dist/basis-worker.d.ts.map +1 -0
  9. package/dist/basis-worker.js +337 -151
  10. package/dist/basis-worker.js.map +1 -0
  11. package/dist/compressed-texture-loader.d.ts +2 -5
  12. package/dist/compressed-texture-loader.d.ts.map +1 -1
  13. package/dist/compressed-texture-loader.js +2 -3
  14. package/dist/compressed-texture-loader.js.map +1 -0
  15. package/dist/compressed-texture-worker.d.ts +2 -0
  16. package/dist/compressed-texture-worker.d.ts.map +1 -0
  17. package/dist/compressed-texture-worker.js +1148 -365
  18. package/dist/compressed-texture-worker.js.map +1 -0
  19. package/dist/compressed-texture-writer.js +1 -0
  20. package/dist/compressed-texture-writer.js.map +1 -0
  21. package/dist/crunch-loader.d.ts +1 -5
  22. package/dist/crunch-loader.d.ts.map +1 -1
  23. package/dist/crunch-loader.js +2 -3
  24. package/dist/crunch-loader.js.map +1 -0
  25. package/dist/crunch-worker.d.ts +2 -0
  26. package/dist/crunch-worker.d.ts.map +1 -0
  27. package/dist/crunch-worker.js +204 -92
  28. package/dist/crunch-worker.js.map +1 -0
  29. package/dist/dist.dev.js +2687 -677
  30. package/dist/dist.min.js +1 -2
  31. package/dist/index.cjs +1644 -428
  32. package/dist/index.cjs.map +4 -4
  33. package/dist/index.d.ts +13 -4
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +7 -3
  36. package/dist/index.js.map +1 -0
  37. package/dist/ktx2-basis-writer-worker-node.js +574 -9832
  38. package/dist/ktx2-basis-writer-worker.d.ts +2 -0
  39. package/dist/ktx2-basis-writer-worker.d.ts.map +1 -0
  40. package/dist/ktx2-basis-writer-worker.js +45 -7
  41. package/dist/ktx2-basis-writer-worker.js.map +1 -0
  42. package/dist/ktx2-basis-writer.js +1 -0
  43. package/dist/ktx2-basis-writer.js.map +1 -0
  44. package/dist/lib/composite-image/image-texture-cube.d.ts +47 -0
  45. package/dist/lib/composite-image/image-texture-cube.d.ts.map +1 -0
  46. package/dist/lib/composite-image/image-texture-cube.js +42 -0
  47. package/dist/lib/composite-image/image-texture-cube.js.map +1 -0
  48. package/dist/lib/composite-image/parse-composite-image.d.ts +43 -0
  49. package/dist/lib/composite-image/parse-composite-image.d.ts.map +1 -0
  50. package/dist/lib/composite-image/parse-composite-image.js +437 -0
  51. package/dist/lib/composite-image/parse-composite-image.js.map +1 -0
  52. package/dist/lib/encoders/encode-ktx.d.ts +1 -1
  53. package/dist/lib/encoders/encode-ktx.d.ts.map +1 -1
  54. package/dist/lib/encoders/encode-ktx.js +1 -0
  55. package/dist/lib/encoders/encode-ktx.js.map +1 -0
  56. package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts +2 -1
  57. package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
  58. package/dist/lib/encoders/encode-ktx2-basis-texture.js +3 -1
  59. package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -0
  60. package/dist/lib/encoders/encode-texture.js +1 -0
  61. package/dist/lib/encoders/encode-texture.js.map +1 -0
  62. package/dist/lib/gl-extensions.d.ts +166 -58
  63. package/dist/lib/gl-extensions.d.ts.map +1 -1
  64. package/dist/lib/gl-extensions.js +178 -66
  65. package/dist/lib/gl-extensions.js.map +1 -0
  66. package/dist/lib/gl-types.d.ts +4 -0
  67. package/dist/lib/gl-types.d.ts.map +1 -0
  68. package/dist/lib/gl-types.js +5 -0
  69. package/dist/lib/gl-types.js.map +1 -0
  70. package/dist/lib/parsers/basis-module-loader.d.ts +3 -2
  71. package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
  72. package/dist/lib/parsers/basis-module-loader.js +1 -0
  73. package/dist/lib/parsers/basis-module-loader.js.map +1 -0
  74. package/dist/lib/parsers/crunch-module-loader.d.ts +2 -2
  75. package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
  76. package/dist/lib/parsers/crunch-module-loader.js +1 -0
  77. package/dist/lib/parsers/crunch-module-loader.js.map +1 -0
  78. package/dist/lib/parsers/parse-basis.d.ts +34 -2
  79. package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
  80. package/dist/lib/parsers/parse-basis.js +265 -64
  81. package/dist/lib/parsers/parse-basis.js.map +1 -0
  82. package/dist/lib/parsers/parse-compressed-texture.js +1 -0
  83. package/dist/lib/parsers/parse-compressed-texture.js.map +1 -0
  84. package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
  85. package/dist/lib/parsers/parse-crunch.js +7 -6
  86. package/dist/lib/parsers/parse-crunch.js.map +1 -0
  87. package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
  88. package/dist/lib/parsers/parse-dds.js +11 -11
  89. package/dist/lib/parsers/parse-dds.js.map +1 -0
  90. package/dist/lib/parsers/parse-hdr.d.ts +21 -0
  91. package/dist/lib/parsers/parse-hdr.d.ts.map +1 -0
  92. package/dist/lib/parsers/parse-hdr.js +305 -0
  93. package/dist/lib/parsers/parse-hdr.js.map +1 -0
  94. package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
  95. package/dist/lib/parsers/parse-ktx.js +11 -3
  96. package/dist/lib/parsers/parse-ktx.js.map +1 -0
  97. package/dist/lib/parsers/parse-npy.js +1 -0
  98. package/dist/lib/parsers/parse-npy.js.map +1 -0
  99. package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
  100. package/dist/lib/parsers/parse-pvr.js +32 -74
  101. package/dist/lib/parsers/parse-pvr.js.map +1 -0
  102. package/dist/lib/texture-api/async-deep-map.js +1 -0
  103. package/dist/lib/texture-api/async-deep-map.js.map +1 -0
  104. package/dist/lib/texture-api/deep-load.js +1 -0
  105. package/dist/lib/texture-api/deep-load.js.map +1 -0
  106. package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
  107. package/dist/lib/texture-api/generate-url.js +3 -10
  108. package/dist/lib/texture-api/generate-url.js.map +1 -0
  109. package/dist/lib/texture-api/load-image-array.d.ts +6 -3
  110. package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
  111. package/dist/lib/texture-api/load-image-array.js +6 -3
  112. package/dist/lib/texture-api/load-image-array.js.map +1 -0
  113. package/dist/lib/texture-api/load-image-cube.d.ts +7 -11
  114. package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
  115. package/dist/lib/texture-api/load-image-cube.js +9 -20
  116. package/dist/lib/texture-api/load-image-cube.js.map +1 -0
  117. package/dist/lib/texture-api/load-image.d.ts +6 -3
  118. package/dist/lib/texture-api/load-image.d.ts.map +1 -1
  119. package/dist/lib/texture-api/load-image.js +9 -4
  120. package/dist/lib/texture-api/load-image.js.map +1 -0
  121. package/dist/lib/texture-api/texture-api-types.d.ts +13 -0
  122. package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -1
  123. package/dist/lib/texture-api/texture-api-types.js +1 -0
  124. package/dist/lib/texture-api/texture-api-types.js.map +1 -0
  125. package/dist/lib/utils/detect-supported-texture-formats.d.ts +14 -0
  126. package/dist/lib/utils/detect-supported-texture-formats.d.ts.map +1 -0
  127. package/dist/lib/utils/detect-supported-texture-formats.js +197 -0
  128. package/dist/lib/utils/detect-supported-texture-formats.js.map +1 -0
  129. package/dist/lib/utils/extract-mipmap-images.d.ts +6 -2
  130. package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
  131. package/dist/lib/utils/extract-mipmap-images.js +14 -2
  132. package/dist/lib/utils/extract-mipmap-images.js.map +1 -0
  133. package/dist/lib/utils/ktx-format-helper.d.ts +9 -1
  134. package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
  135. package/dist/lib/utils/ktx-format-helper.js +77 -109
  136. package/dist/lib/utils/ktx-format-helper.js.map +1 -0
  137. package/dist/lib/utils/texture-format-map.d.ts +10 -0
  138. package/dist/lib/utils/texture-format-map.d.ts.map +1 -0
  139. package/dist/lib/utils/texture-format-map.js +87 -0
  140. package/dist/lib/utils/texture-format-map.js.map +1 -0
  141. package/dist/lib/utils/version.js +2 -1
  142. package/dist/lib/utils/version.js.map +1 -0
  143. package/dist/libs/libs/README.md +9 -0
  144. package/dist/libs/libs/basis_encoder.js +21 -0
  145. package/dist/libs/libs/basis_encoder.wasm +0 -0
  146. package/dist/libs/libs/basis_transcoder.js +22 -0
  147. package/dist/libs/libs/basis_transcoder.wasm +0 -0
  148. package/dist/libs/libs/crunch.js +136 -0
  149. package/dist/npy-loader.d.ts +2 -2
  150. package/dist/npy-loader.js +1 -0
  151. package/dist/npy-loader.js.map +1 -0
  152. package/dist/npy-worker.d.ts +2 -0
  153. package/dist/npy-worker.d.ts.map +1 -0
  154. package/dist/npy-worker.js +5 -2
  155. package/dist/npy-worker.js.map +1 -0
  156. package/dist/radiance-hdr-loader.d.ts +25 -0
  157. package/dist/radiance-hdr-loader.d.ts.map +1 -0
  158. package/dist/radiance-hdr-loader.js +23 -0
  159. package/dist/radiance-hdr-loader.js.map +1 -0
  160. package/dist/texture-array-loader.d.ts +25 -0
  161. package/dist/texture-array-loader.d.ts.map +1 -0
  162. package/dist/texture-array-loader.js +24 -0
  163. package/dist/texture-array-loader.js.map +1 -0
  164. package/dist/texture-cube-array-loader.d.ts +25 -0
  165. package/dist/texture-cube-array-loader.d.ts.map +1 -0
  166. package/dist/texture-cube-array-loader.js +24 -0
  167. package/dist/texture-cube-array-loader.js.map +1 -0
  168. package/dist/texture-cube-loader.d.ts +25 -0
  169. package/dist/texture-cube-loader.d.ts.map +1 -0
  170. package/dist/texture-cube-loader.js +24 -0
  171. package/dist/texture-cube-loader.js.map +1 -0
  172. package/dist/texture-loader.d.ts +25 -0
  173. package/dist/texture-loader.d.ts.map +1 -0
  174. package/dist/texture-loader.js +24 -0
  175. package/dist/texture-loader.js.map +1 -0
  176. package/dist/workers/basis-worker-node.js +1 -0
  177. package/dist/workers/basis-worker-node.js.map +1 -0
  178. package/dist/workers/basis-worker.js +1 -0
  179. package/dist/workers/basis-worker.js.map +1 -0
  180. package/dist/workers/compressed-texture-worker.js +1 -1
  181. package/dist/workers/compressed-texture-worker.js.map +1 -0
  182. package/dist/workers/crunch-worker.d.ts +1 -3
  183. package/dist/workers/crunch-worker.d.ts.map +1 -1
  184. package/dist/workers/crunch-worker.js +1 -0
  185. package/dist/workers/crunch-worker.js.map +1 -0
  186. package/dist/workers/ktx2-basis-writer-worker-node.js +1 -0
  187. package/dist/workers/ktx2-basis-writer-worker-node.js.map +1 -0
  188. package/dist/workers/ktx2-basis-writer-worker.js +1 -0
  189. package/dist/workers/ktx2-basis-writer-worker.js.map +1 -0
  190. package/dist/workers/npy-worker.js +1 -0
  191. package/dist/workers/npy-worker.js.map +1 -0
  192. package/package.json +27 -6
  193. package/src/basis-loader.ts +19 -9
  194. package/src/basis-worker.ts +7 -0
  195. package/src/compressed-texture-loader.ts +3 -7
  196. package/src/compressed-texture-worker.ts +6 -0
  197. package/src/crunch-loader.ts +1 -5
  198. package/src/crunch-worker.ts +6 -0
  199. package/src/index.ts +21 -4
  200. package/src/ktx2-basis-writer-worker.ts +6 -0
  201. package/src/lib/composite-image/image-texture-cube.ts +49 -0
  202. package/src/lib/composite-image/parse-composite-image.ts +699 -0
  203. package/src/lib/encoders/encode-ktx.ts +1 -1
  204. package/src/lib/encoders/encode-ktx2-basis-texture.ts +4 -2
  205. package/src/lib/gl-extensions.ts +188 -81
  206. package/src/lib/gl-types.ts +136 -0
  207. package/src/lib/parsers/basis-module-loader.ts +5 -5
  208. package/src/lib/parsers/crunch-module-loader.ts +4 -4
  209. package/src/lib/parsers/parse-basis.ts +358 -66
  210. package/src/lib/parsers/parse-crunch.ts +11 -8
  211. package/src/lib/parsers/parse-dds.ts +11 -12
  212. package/src/lib/parsers/parse-hdr.ts +426 -0
  213. package/src/lib/parsers/parse-ktx.ts +13 -3
  214. package/src/lib/parsers/parse-pvr.ts +33 -75
  215. package/src/lib/texture-api/generate-url.ts +2 -12
  216. package/src/lib/texture-api/load-image-array.ts +15 -6
  217. package/src/lib/texture-api/load-image-cube.ts +20 -34
  218. package/src/lib/texture-api/load-image.ts +19 -8
  219. package/src/lib/texture-api/texture-api-types.ts +15 -0
  220. package/src/lib/utils/detect-supported-texture-formats.ts +210 -0
  221. package/src/lib/utils/extract-mipmap-images.ts +23 -4
  222. package/src/lib/utils/ktx-format-helper.ts +135 -111
  223. package/src/lib/utils/texture-format-map.ts +162 -0
  224. package/src/npy-worker.ts +6 -0
  225. package/src/radiance-hdr-loader.ts +36 -0
  226. package/src/texture-array-loader.ts +46 -0
  227. package/src/texture-cube-array-loader.ts +49 -0
  228. package/src/texture-cube-loader.ts +46 -0
  229. package/src/texture-loader.ts +49 -0
  230. package/src/workers/compressed-texture-worker.ts +0 -1
  231. package/dist/lib/utils/texture-formats.d.ts +0 -8
  232. package/dist/lib/utils/texture-formats.d.ts.map +0 -1
  233. package/dist/lib/utils/texture-formats.js +0 -50
  234. package/src/lib/utils/texture-formats.ts +0 -59
@@ -2,117 +2,132 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {GL_EXTENSIONS_CONSTANTS} from '../gl-extensions';
5
+ /* eslint-disable camelcase */
6
+ import type {TextureFormat} from '@loaders.gl/schema';
7
+ import type {GLTextureFormat} from '../gl-types';
8
+ import {
9
+ GL_COMPRESSED_R11_EAC,
10
+ GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
11
+ GL_COMPRESSED_RED_RGTC1_EXT,
12
+ GL_COMPRESSED_RG11_EAC,
13
+ GL_COMPRESSED_RGB8_ETC2,
14
+ GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
15
+ GL_COMPRESSED_RGBA8_ETC2_EAC,
16
+ GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
17
+ GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
18
+ GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
19
+ GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
20
+ GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
21
+ GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
22
+ GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
23
+ GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
24
+ GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
25
+ GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
26
+ GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
27
+ GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
28
+ GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
29
+ GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
30
+ GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
31
+ GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
32
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
33
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
34
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
35
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
36
+ GL_COMPRESSED_SIGNED_R11_EAC,
37
+ GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
38
+ GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
39
+ GL_COMPRESSED_SIGNED_RG11_EAC,
40
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
41
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
42
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
43
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
44
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
45
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
46
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
47
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
48
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
49
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
50
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
51
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
52
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
53
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
54
+ GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
55
+ GL_COMPRESSED_SRGB8_ETC2,
56
+ GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
57
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
58
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
59
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
60
+ GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
61
+ } from '../gl-extensions';
62
+ import {getTextureFormatFromWebGLFormat} from './texture-format-map';
6
63
 
7
- const VULKAN_TO_WEBGL_FORMAT_MAP: Record<number, number> = {
8
- 131: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
9
- 132: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_S3TC_DXT1_EXT,
10
- 133: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT1_EXT,
11
- 134: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
12
- 135: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
13
- 136: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
14
- 137: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
15
- 138: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
16
- 139: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_RGTC1_EXT,
17
- 140: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_RGTC1_EXT,
18
- 141: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_GREEN_RGTC2_EXT,
19
- 142: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
20
- 147: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_ETC2,
21
- 148: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ETC2,
22
- 149: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
23
- 150: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
24
- 151: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA8_ETC2_EAC,
25
- 152: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
26
- 153: GL_EXTENSIONS_CONSTANTS.COMPRESSED_R11_EAC,
27
- 154: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_R11_EAC,
28
- 155: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RG11_EAC,
29
- 156: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RG11_EAC,
30
- // @ts-ignore
31
- 157: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
32
- // @ts-ignore
33
- 158: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
34
- // @ts-ignore
35
- 159: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
36
- // @ts-ignore
37
- 160: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,
38
- // @ts-ignore
39
- 161: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
40
- // @ts-ignore
41
- 162: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
42
- // @ts-ignore
43
- 163: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
44
- // @ts-ignore
45
- 164: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
46
- // @ts-ignore
47
- 165: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
48
- // @ts-ignore
49
- 166: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
50
- // @ts-ignore
51
- 167: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
52
- // @ts-ignore
53
- 168: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
54
- // @ts-ignore
55
- 169: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
56
- // @ts-ignore
57
- 170: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
58
- // @ts-ignore
59
- 171: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
60
- // @ts-ignore
61
- 172: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
62
- // @ts-ignore
63
- 173: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
64
- // @ts-ignore
65
- 174: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
66
- // @ts-ignore
67
- 175: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
68
- // @ts-ignore
69
- 176: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
70
- // @ts-ignore
71
- 177: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
72
- // @ts-ignore
73
- 178: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
74
- // @ts-ignore
75
- 179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
76
- // @ts-ignore
77
- 180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
78
- // @ts-ignore
79
- 181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
80
- // @ts-ignore
81
- 182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
82
- // @ts-ignore
83
- 183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
84
- // @ts-ignore
85
- 184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
86
- 1000054000: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
87
- 1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
88
- // @ts-ignore
89
- 1000066000: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
90
- // @ts-ignore
91
- 1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
92
- // @ts-ignore
93
- 1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
94
- // @ts-ignore
95
- 1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
96
- // @ts-ignore
97
- 1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
98
- // @ts-ignore
99
- 1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
100
- // @ts-ignore
101
- 1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
102
- // @ts-ignore
103
- 1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
104
- // @ts-ignore
105
- 1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
106
- // @ts-ignore
107
- 1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
108
- // @ts-ignore
109
- 1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
110
- // @ts-ignore
111
- 1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
112
- // @ts-ignore
113
- 1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
114
- // @ts-ignore
115
- 1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
64
+ const VULKAN_TO_WEBGL_FORMAT_MAP: Record<number, GLTextureFormat> = {
65
+ 131: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
66
+ 132: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
67
+ 133: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
68
+ 134: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
69
+ 135: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
70
+ 136: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
71
+ 137: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
72
+ 138: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
73
+ 139: GL_COMPRESSED_RED_RGTC1_EXT,
74
+ 140: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
75
+ 141: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
76
+ 142: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
77
+ 147: GL_COMPRESSED_RGB8_ETC2,
78
+ 148: GL_COMPRESSED_SRGB8_ETC2,
79
+ 149: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
80
+ 150: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
81
+ 151: GL_COMPRESSED_RGBA8_ETC2_EAC,
82
+ 152: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
83
+ 153: GL_COMPRESSED_R11_EAC,
84
+ 154: GL_COMPRESSED_SIGNED_R11_EAC,
85
+ 155: GL_COMPRESSED_RG11_EAC,
86
+ 156: GL_COMPRESSED_SIGNED_RG11_EAC,
87
+ 157: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
88
+ 158: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
89
+ 159: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
90
+ 160: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
91
+ 161: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
92
+ 162: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
93
+ 163: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
94
+ 164: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
95
+ 165: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
96
+ 166: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
97
+ 167: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
98
+ 168: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
99
+ 169: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
100
+ 170: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
101
+ 171: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
102
+ 172: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
103
+ 173: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
104
+ 174: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
105
+ 175: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
106
+ 176: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
107
+ 177: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
108
+ 178: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
109
+ 179: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
110
+ 180: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
111
+ 181: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
112
+ 182: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
113
+ 183: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
114
+ 184: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
115
+ 1000054000: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
116
+ 1000054001: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
117
+ 1000066000: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
118
+ 1000066001: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
119
+ 1000066002: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
120
+ 1000066003: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
121
+ 1000066004: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
122
+ 1000066005: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
123
+ 1000066006: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
124
+ 1000066007: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
125
+ 1000066008: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
126
+ 1000066009: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
127
+ 1000066010: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
128
+ 1000066011: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
129
+ 1000066012: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
130
+ 1000066013: GL_COMPRESSED_RGBA_ASTC_12x12_KHR
116
131
  };
117
132
 
118
133
  /**
@@ -122,6 +137,15 @@ const VULKAN_TO_WEBGL_FORMAT_MAP: Record<number, number> = {
122
137
  * @param vkFormat
123
138
  * @returns WebGL / OpenGL constant
124
139
  */
125
- export function mapVkFormatToWebGL(vkFormat: number): number {
140
+ export function mapVkFormatToWebGL(vkFormat: number): GLTextureFormat | undefined {
126
141
  return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
127
142
  }
143
+
144
+ /**
145
+ * Returns the canonical loaders.gl texture format corresponding to a Vulkan `vkFormat` value.
146
+ * @param vkFormat - Vulkan format constant from the KTX container.
147
+ * @returns Canonical texture format string, if known.
148
+ */
149
+ export function mapVkFormatToTextureFormat(vkFormat: number): TextureFormat | undefined {
150
+ return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
151
+ }
@@ -0,0 +1,162 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /* eslint-disable camelcase */
6
+ import type {TextureFormat} from '@loaders.gl/schema';
7
+ import type {GLTextureFormat} from '../gl-types';
8
+ import {
9
+ GL_RGBA32F,
10
+ GL_COMPRESSED_R11_EAC,
11
+ GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
12
+ GL_COMPRESSED_RED_RGTC1_EXT,
13
+ GL_COMPRESSED_RG11_EAC,
14
+ GL_COMPRESSED_RGB8_ETC2,
15
+ GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
16
+ GL_COMPRESSED_RGB_ATC_WEBGL,
17
+ GL_COMPRESSED_RGB_ETC1_WEBGL,
18
+ GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
19
+ GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
20
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
21
+ GL_COMPRESSED_RGBA8_ETC2_EAC,
22
+ GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
23
+ GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
24
+ GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
25
+ GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
26
+ GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
27
+ GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
28
+ GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
29
+ GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
30
+ GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
31
+ GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
32
+ GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
33
+ GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
34
+ GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
35
+ GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
36
+ GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
37
+ GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
38
+ GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
39
+ GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
40
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
41
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
42
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
43
+ GL_COMPRESSED_SIGNED_R11_EAC,
44
+ GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
45
+ GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
46
+ GL_COMPRESSED_SIGNED_RG11_EAC,
47
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
48
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
49
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
50
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
51
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
52
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
53
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
54
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
55
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
56
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
57
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
58
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
59
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
60
+ GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
61
+ GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
62
+ GL_COMPRESSED_SRGB8_ETC2,
63
+ GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
64
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
65
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
66
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
67
+ GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
68
+ } from '../gl-extensions';
69
+
70
+ const WEBGL_TO_TEXTURE_FORMAT: Record<number, TextureFormat> = {
71
+ [GL_RGBA32F]: 'rgba32float',
72
+ [GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-webgl',
73
+ [GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-srgb-webgl',
74
+ [GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm',
75
+ [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm-srgb',
76
+ [GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm',
77
+ [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm-srgb',
78
+ [GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm',
79
+ [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm-srgb',
80
+ [GL_COMPRESSED_RED_RGTC1_EXT]: 'bc4-r-unorm',
81
+ [GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: 'bc4-r-snorm',
82
+ [GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-unorm',
83
+ [GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-snorm',
84
+ [GL_COMPRESSED_RGB8_ETC2]: 'etc2-rgb8unorm',
85
+ [GL_COMPRESSED_SRGB8_ETC2]: 'etc2-rgb8unorm-srgb',
86
+ [GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm',
87
+ [GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm-srgb',
88
+ [GL_COMPRESSED_RGBA8_ETC2_EAC]: 'etc2-rgba8unorm',
89
+ [GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: 'etc2-rgba8unorm-srgb',
90
+ [GL_COMPRESSED_R11_EAC]: 'eac-r11unorm',
91
+ [GL_COMPRESSED_SIGNED_R11_EAC]: 'eac-r11snorm',
92
+ [GL_COMPRESSED_RG11_EAC]: 'eac-rg11unorm',
93
+ [GL_COMPRESSED_SIGNED_RG11_EAC]: 'eac-rg11snorm',
94
+ [GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: 'astc-4x4-unorm',
95
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: 'astc-4x4-unorm-srgb',
96
+ [GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: 'astc-5x4-unorm',
97
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: 'astc-5x4-unorm-srgb',
98
+ [GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: 'astc-5x5-unorm',
99
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: 'astc-5x5-unorm-srgb',
100
+ [GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: 'astc-6x5-unorm',
101
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: 'astc-6x5-unorm-srgb',
102
+ [GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: 'astc-6x6-unorm',
103
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: 'astc-6x6-unorm-srgb',
104
+ [GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: 'astc-8x5-unorm',
105
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: 'astc-8x5-unorm-srgb',
106
+ [GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: 'astc-8x6-unorm',
107
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: 'astc-8x6-unorm-srgb',
108
+ [GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: 'astc-8x8-unorm',
109
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: 'astc-8x8-unorm-srgb',
110
+ [GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: 'astc-10x5-unorm',
111
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: 'astc-10x5-unorm-srgb',
112
+ [GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: 'astc-10x6-unorm',
113
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: 'astc-10x6-unorm-srgb',
114
+ [GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: 'astc-10x8-unorm',
115
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: 'astc-10x8-unorm-srgb',
116
+ [GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: 'astc-10x10-unorm',
117
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: 'astc-10x10-unorm-srgb',
118
+ [GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: 'astc-12x10-unorm',
119
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: 'astc-12x10-unorm-srgb',
120
+ [GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: 'astc-12x12-unorm',
121
+ [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: 'astc-12x12-unorm-srgb',
122
+ [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: 'pvrtc-rgb4unorm-webgl',
123
+ [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: 'pvrtc-rgba4unorm-webgl',
124
+ [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: 'pvrtc-rgb2unorm-webgl',
125
+ [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: 'pvrtc-rgba2unorm-webgl',
126
+ [GL_COMPRESSED_RGB_ETC1_WEBGL]: 'etc1-rgb-unorm-webgl',
127
+ [GL_COMPRESSED_RGB_ATC_WEBGL]: 'atc-rgb-unorm-webgl',
128
+ [GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: 'atc-rgba-unorm-webgl',
129
+ [GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: 'atc-rgbai-unorm-webgl'
130
+ };
131
+
132
+ const TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(
133
+ Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
134
+ textureFormat,
135
+ Number(format)
136
+ ])
137
+ ) as Partial<Record<TextureFormat, GLTextureFormat>>;
138
+
139
+ export function getTextureFormatFromWebGLFormat(
140
+ format?: GLTextureFormat
141
+ ): TextureFormat | undefined {
142
+ if (format === undefined) {
143
+ return undefined;
144
+ }
145
+
146
+ return WEBGL_TO_TEXTURE_FORMAT[format];
147
+ }
148
+
149
+ /**
150
+ * Returns the WebGL/OpenGL compressed texture constant for a canonical loaders.gl texture format.
151
+ * @param textureFormat - Canonical texture format string.
152
+ * @returns Matching WebGL/OpenGL constant, if known.
153
+ */
154
+ export function getWebGLFormatFromTextureFormat(
155
+ textureFormat?: TextureFormat
156
+ ): GLTextureFormat | undefined {
157
+ if (textureFormat === undefined) {
158
+ return undefined;
159
+ }
160
+
161
+ return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
162
+ }
@@ -0,0 +1,6 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // Classic-worker entrypoint that lazily loads the ESM worker implementation.
6
+ import(new URL('./workers/npy-worker.js', import.meta.url).toString());
@@ -0,0 +1,36 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderWithParser, StrictLoaderOptions} from '@loaders.gl/loader-utils';
6
+ import type {Texture} from '@loaders.gl/schema';
7
+ import {VERSION} from './lib/utils/version';
8
+ import type {RadianceHDRMetadata} from './lib/parsers/parse-hdr';
9
+ import {isHDR, parseHDR} from './lib/parsers/parse-hdr';
10
+
11
+ export type RadianceHDRLoaderOptions = StrictLoaderOptions & {
12
+ hdr?: {};
13
+ };
14
+
15
+ export const RadianceHDRLoader = {
16
+ dataType: null as unknown as Texture<RadianceHDRMetadata>,
17
+ batchType: null as never,
18
+
19
+ name: 'Radiance HDR',
20
+ id: 'hdr',
21
+ module: 'textures',
22
+ version: VERSION,
23
+ extensions: ['hdr'],
24
+ mimeTypes: ['image/vnd.radiance', 'image/x-hdr', 'application/octet-stream'],
25
+ binary: true,
26
+ tests: [isHDR],
27
+ options: {
28
+ hdr: {}
29
+ },
30
+ parseSync: parseHDR,
31
+ parse: async (arrayBuffer: ArrayBuffer) => parseHDR(arrayBuffer)
32
+ } as const satisfies LoaderWithParser<
33
+ Texture<RadianceHDRMetadata>,
34
+ never,
35
+ RadianceHDRLoaderOptions
36
+ >;
@@ -0,0 +1,46 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderContext, LoaderWithParser} from '@loaders.gl/loader-utils';
6
+ import type {Texture} from '@loaders.gl/schema';
7
+ import type {TextureLoaderOptions as TextureApiLoaderOptions} from './lib/texture-api/texture-api-types';
8
+ import {VERSION} from './lib/utils/version';
9
+ import {
10
+ parseCompositeImageManifest,
11
+ testCompositeImageManifestShape,
12
+ type ImageTextureArrayManifest
13
+ } from './lib/composite-image/parse-composite-image';
14
+
15
+ export type TextureArrayLoaderOptions = TextureApiLoaderOptions;
16
+ export type {ImageTextureArrayManifest as TextureArrayManifest};
17
+
18
+ export const TextureArrayLoader = {
19
+ dataType: null as unknown as Texture,
20
+ batchType: null as never,
21
+ id: 'texture-array',
22
+ name: 'Texture Array',
23
+ module: 'textures',
24
+ version: VERSION,
25
+ extensions: [],
26
+ mimeTypes: [],
27
+ text: true,
28
+ worker: false,
29
+ testText: (text: string) => testCompositeImageManifestShape(text, 'image-texture-array'),
30
+ options: {
31
+ image: {}
32
+ },
33
+ parse: async (
34
+ arrayBuffer: ArrayBuffer,
35
+ options?: TextureArrayLoaderOptions,
36
+ context?: LoaderContext
37
+ ) =>
38
+ await parseCompositeImageManifest(
39
+ new TextDecoder().decode(arrayBuffer),
40
+ 'image-texture-array',
41
+ options,
42
+ context
43
+ ),
44
+ parseText: async (text: string, options?: TextureArrayLoaderOptions, context?: LoaderContext) =>
45
+ await parseCompositeImageManifest(text, 'image-texture-array', options, context)
46
+ } as const satisfies LoaderWithParser<Texture, never, TextureArrayLoaderOptions>;
@@ -0,0 +1,49 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderContext, LoaderWithParser} from '@loaders.gl/loader-utils';
6
+ import type {Texture} from '@loaders.gl/schema';
7
+ import type {TextureLoaderOptions as TextureApiLoaderOptions} from './lib/texture-api/texture-api-types';
8
+ import {VERSION} from './lib/utils/version';
9
+ import {
10
+ parseCompositeImageManifest,
11
+ testCompositeImageManifestShape,
12
+ type ImageTextureCubeArrayManifest
13
+ } from './lib/composite-image/parse-composite-image';
14
+
15
+ export type TextureCubeArrayLoaderOptions = TextureApiLoaderOptions;
16
+ export type {ImageTextureCubeArrayManifest as TextureCubeArrayManifest};
17
+
18
+ export const TextureCubeArrayLoader = {
19
+ dataType: null as unknown as Texture,
20
+ batchType: null as never,
21
+ id: 'texture-cube-array',
22
+ name: 'Texture Cube Array',
23
+ module: 'textures',
24
+ version: VERSION,
25
+ extensions: [],
26
+ mimeTypes: [],
27
+ text: true,
28
+ worker: false,
29
+ testText: (text: string) => testCompositeImageManifestShape(text, 'image-texture-cube-array'),
30
+ options: {
31
+ image: {}
32
+ },
33
+ parse: async (
34
+ arrayBuffer: ArrayBuffer,
35
+ options?: TextureCubeArrayLoaderOptions,
36
+ context?: LoaderContext
37
+ ) =>
38
+ await parseCompositeImageManifest(
39
+ new TextDecoder().decode(arrayBuffer),
40
+ 'image-texture-cube-array',
41
+ options,
42
+ context
43
+ ),
44
+ parseText: async (
45
+ text: string,
46
+ options?: TextureCubeArrayLoaderOptions,
47
+ context?: LoaderContext
48
+ ) => await parseCompositeImageManifest(text, 'image-texture-cube-array', options, context)
49
+ } as const satisfies LoaderWithParser<Texture, never, TextureCubeArrayLoaderOptions>;
@@ -0,0 +1,46 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderContext, LoaderWithParser} from '@loaders.gl/loader-utils';
6
+ import type {Texture} from '@loaders.gl/schema';
7
+ import type {TextureLoaderOptions as TextureApiLoaderOptions} from './lib/texture-api/texture-api-types';
8
+ import {VERSION} from './lib/utils/version';
9
+ import {
10
+ parseCompositeImageManifest,
11
+ testCompositeImageManifestShape,
12
+ type ImageTextureCubeManifest
13
+ } from './lib/composite-image/parse-composite-image';
14
+
15
+ export type TextureCubeLoaderOptions = TextureApiLoaderOptions;
16
+ export type {ImageTextureCubeManifest as TextureCubeManifest};
17
+
18
+ export const TextureCubeLoader = {
19
+ dataType: null as unknown as Texture,
20
+ batchType: null as never,
21
+ id: 'texture-cube',
22
+ name: 'Texture Cube',
23
+ module: 'textures',
24
+ version: VERSION,
25
+ extensions: [],
26
+ mimeTypes: [],
27
+ text: true,
28
+ worker: false,
29
+ testText: (text: string) => testCompositeImageManifestShape(text, 'image-texture-cube'),
30
+ options: {
31
+ image: {}
32
+ },
33
+ parse: async (
34
+ arrayBuffer: ArrayBuffer,
35
+ options?: TextureCubeLoaderOptions,
36
+ context?: LoaderContext
37
+ ) =>
38
+ await parseCompositeImageManifest(
39
+ new TextDecoder().decode(arrayBuffer),
40
+ 'image-texture-cube',
41
+ options,
42
+ context
43
+ ),
44
+ parseText: async (text: string, options?: TextureCubeLoaderOptions, context?: LoaderContext) =>
45
+ await parseCompositeImageManifest(text, 'image-texture-cube', options, context)
46
+ } as const satisfies LoaderWithParser<Texture, never, TextureCubeLoaderOptions>;
@@ -0,0 +1,49 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderContext, LoaderWithParser} from '@loaders.gl/loader-utils';
6
+ import type {Texture} from '@loaders.gl/schema';
7
+ import type {TextureLoaderOptions as TextureApiLoaderOptions} from './lib/texture-api/texture-api-types';
8
+ import {VERSION} from './lib/utils/version';
9
+ import {
10
+ parseCompositeImageManifest,
11
+ testCompositeImageManifestShape,
12
+ type ImageTextureManifest
13
+ } from './lib/composite-image/parse-composite-image';
14
+
15
+ export type TextureManifestLoaderOptions = TextureApiLoaderOptions;
16
+ export type {ImageTextureManifest as TextureManifest};
17
+
18
+ export const TextureLoader = {
19
+ dataType: null as unknown as Texture,
20
+ batchType: null as never,
21
+ id: 'texture',
22
+ name: 'Texture',
23
+ module: 'textures',
24
+ version: VERSION,
25
+ extensions: [],
26
+ mimeTypes: [],
27
+ text: true,
28
+ worker: false,
29
+ testText: (text: string) => testCompositeImageManifestShape(text, 'image-texture'),
30
+ options: {
31
+ image: {}
32
+ },
33
+ parse: async (
34
+ arrayBuffer: ArrayBuffer,
35
+ options?: TextureManifestLoaderOptions,
36
+ context?: LoaderContext
37
+ ) =>
38
+ await parseCompositeImageManifest(
39
+ new TextDecoder().decode(arrayBuffer),
40
+ 'image-texture',
41
+ options,
42
+ context
43
+ ),
44
+ parseText: async (
45
+ text: string,
46
+ options?: TextureManifestLoaderOptions,
47
+ context?: LoaderContext
48
+ ) => await parseCompositeImageManifest(text, 'image-texture', options, context)
49
+ } as const satisfies LoaderWithParser<Texture, never, TextureManifestLoaderOptions>;
@@ -5,5 +5,4 @@
5
5
  import {createLoaderWorker} from '@loaders.gl/loader-utils';
6
6
  import {CompressedTextureLoader} from '../compressed-texture-loader';
7
7
 
8
- // @ts-expect-error
9
8
  createLoaderWorker(CompressedTextureLoader);