@woosh/meep-engine 3.79.0 → 3.80.1

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 (309) hide show
  1. package/CHANGELOG.md +62 -3
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
  5. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
  6. package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
  7. package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
  8. package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
  9. package/src/format/image/webp/vp8/vp8_decode.js +756 -0
  10. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
  11. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
  12. package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
  13. package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
  14. package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
  15. package/src/format/image/webp/vp8/vp8_predict.js +290 -0
  16. package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
  17. package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
  18. package/src/format/image/webp/vp8/vp8_tables.js +350 -0
  19. package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
  20. package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
  21. package/src/format/image/webp/vp8/vp8_transform.js +114 -0
  22. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
  23. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
  24. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
  25. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
  26. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
  27. package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
  28. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
  29. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
  30. package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
  31. package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
  32. package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
  33. package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
  34. package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
  35. package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
  36. package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
  37. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
  38. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
  39. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
  40. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
  41. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
  42. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
  43. package/src/format/image/webp/webp_decode.d.ts +23 -0
  44. package/src/format/image/webp/webp_decode.d.ts.map +1 -0
  45. package/src/format/image/webp/webp_decode.js +179 -0
  46. package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
  47. package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
  48. package/src/format/image/webp/webp_decode_alpha.js +84 -0
  49. package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
  50. package/src/format/texture/astc/astc_block.d.ts.map +1 -0
  51. package/src/format/texture/{basis → astc}/astc_block.js +284 -164
  52. package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
  53. package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
  54. package/src/format/texture/astc/astc_decode_block.js +1119 -0
  55. package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
  56. package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
  57. package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
  58. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
  59. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
  60. package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
  61. package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
  62. package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
  63. package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
  64. package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
  65. package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
  66. package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
  67. package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
  68. package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
  69. package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
  70. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
  71. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
  72. package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
  73. package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
  74. package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
  75. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
  76. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
  77. package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
  78. package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
  79. package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
  80. package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
  81. package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
  82. package/src/format/texture/bc/bc1_decode_block.js +22 -0
  83. package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
  84. package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
  85. package/src/format/texture/bc/bc1_decode_colors.js +100 -0
  86. package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
  87. package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
  88. package/src/format/texture/bc/bc2_decode_block.js +28 -0
  89. package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
  90. package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
  91. package/src/format/texture/bc/bc3_decode_block.js +23 -0
  92. package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
  93. package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
  94. package/src/format/texture/bc/bc4_decode_channel.js +138 -0
  95. package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
  96. package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
  97. package/src/format/texture/bc/bc4_encode_block.js +324 -0
  98. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
  99. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
  100. package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
  101. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
  102. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
  103. package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
  104. package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
  105. package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
  106. package/src/format/texture/bc/bc5_encode_block.js +34 -0
  107. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
  108. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
  109. package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
  110. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
  111. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
  112. package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
  113. package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
  114. package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
  115. package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
  116. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
  117. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
  118. package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
  119. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
  120. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
  121. package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
  122. package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
  123. package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
  124. package/src/format/texture/bc/bc7_decode_block.js +232 -0
  125. package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
  126. package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
  127. package/src/format/texture/bc/bc7_encode_block.js +423 -0
  128. package/src/format/texture/bc/bc7_tables.d.ts +126 -0
  129. package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
  130. package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
  131. package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
  132. package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
  133. package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
  134. package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
  135. package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
  136. package/src/format/texture/etc/eac_decode_channel.js +142 -0
  137. package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
  138. package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
  139. package/src/format/texture/etc/eac_modifiers.js +31 -0
  140. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
  141. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
  142. package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
  143. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
  144. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
  145. package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
  146. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
  147. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
  148. package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
  149. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
  150. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
  151. package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
  152. package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
  153. package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
  154. package/src/format/texture/etc/etc2_decode_color.js +370 -0
  155. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
  156. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
  157. package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
  158. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
  159. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
  160. package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
  161. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
  162. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
  163. package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
  164. package/src/format/texture/fit/fit_line.d.ts +23 -0
  165. package/src/format/texture/fit/fit_line.d.ts.map +1 -0
  166. package/src/format/texture/fit/fit_line.js +123 -0
  167. package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
  168. package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
  169. package/src/format/texture/fit/fit_line_refine.js +69 -0
  170. package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
  171. package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
  172. package/src/format/texture/fit/fit_line_solve.js +71 -0
  173. package/src/format/texture/texel_decode_image.d.ts +44 -0
  174. package/src/format/texture/texel_decode_image.d.ts.map +1 -0
  175. package/src/format/texture/texel_decode_image.js +251 -0
  176. package/src/format/texture/texel_encode_image.d.ts +77 -0
  177. package/src/format/texture/texel_encode_image.d.ts.map +1 -0
  178. package/src/format/texture/texel_encode_image.js +187 -0
  179. package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
  180. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  181. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  182. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +1 -0
  183. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -1
  184. package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +102 -28
  185. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
  186. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
  187. package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
  188. package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
  189. package/src/shade/renderer/loader/mtf/mtf_write.js +7 -31
  190. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
  191. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
  192. package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
  193. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
  194. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
  195. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
  196. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
  197. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  198. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
  199. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
  200. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
  201. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
  202. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
  203. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  204. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
  205. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  206. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
  207. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
  208. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
  209. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
  210. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
  211. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  212. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
  213. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
  214. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
  215. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
  216. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
  217. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
  218. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
  219. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
  220. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
  221. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
  222. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
  223. package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
  224. package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
  225. package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
  226. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
  227. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
  228. package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
  229. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
  230. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
  231. package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
  232. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
  233. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
  234. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
  235. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
  236. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
  237. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
  238. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
  239. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
  240. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
  241. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
  242. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
  243. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
  244. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
  245. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
  246. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
  247. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
  248. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
  249. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
  250. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
  251. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
  252. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
  253. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
  254. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
  255. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
  256. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
  257. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
  258. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
  259. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
  260. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
  261. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
  262. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
  263. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
  264. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
  265. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
  266. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
  267. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
  268. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
  269. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
  270. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
  271. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
  272. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
  273. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
  274. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
  275. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
  276. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
  277. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
  278. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
  279. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
  280. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
  281. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
  282. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
  283. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
  284. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
  285. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
  286. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
  287. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
  288. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
  289. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
  290. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
  291. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
  292. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
  293. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
  294. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
  295. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
  296. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
  297. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
  298. package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
  299. package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
  300. package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
  301. package/src/format/texture/basis/astc_block.d.ts.map +0 -1
  302. package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
  303. package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
  304. package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
  305. package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
  306. package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
  307. package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
  308. /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
  309. /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * EAC's modifier table: sixteen rows of eight, a block's table index picking the row and a texel's three-bit index
3
+ * the entry. The same table serves the eight-bit alpha of ETC2 RGBA8 and the eleven-bit R11 and RG11 formats.
4
+ *
5
+ * Row 13 is the only one holding a zero, which is what lets a block hold one value exactly.
6
+ *
7
+ * @readonly
8
+ * @type {Int32Array}
9
+ * @see OpenGL ES 3.0, table C.10; Khronos Data Format Specification 1.3, table 22.6
10
+ *
11
+ * @author Alex Goldring
12
+ * @copyright Company Named Limited (c) 2026
13
+ */
14
+ export const EAC_MODIFIERS = new Int32Array([
15
+ -3, -6, -9, -15, 2, 5, 8, 14,
16
+ -3, -7, -10, -13, 2, 6, 9, 12,
17
+ -2, -5, -8, -13, 1, 4, 7, 12,
18
+ -2, -4, -6, -13, 1, 3, 5, 12,
19
+ -3, -6, -8, -12, 2, 5, 7, 11,
20
+ -3, -7, -9, -11, 2, 6, 8, 10,
21
+ -4, -7, -8, -11, 3, 6, 7, 10,
22
+ -3, -5, -8, -11, 2, 4, 7, 10,
23
+ -2, -6, -8, -10, 1, 5, 7, 9,
24
+ -2, -5, -8, -10, 1, 4, 7, 9,
25
+ -2, -4, -8, -10, 1, 3, 7, 9,
26
+ -2, -5, -7, -10, 1, 4, 6, 9,
27
+ -3, -4, -7, -10, 2, 3, 6, 9,
28
+ -1, -2, -3, -10, 0, 1, 2, 9,
29
+ -4, -6, -8, -9, 3, 5, 7, 8,
30
+ -3, -5, -7, -9, 2, 4, 6, 8,
31
+ ]);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Decode one `eac-r11snorm` block to sixteen texels.
3
+ *
4
+ * The specification's eleven-bit signed value: the base codeword a two's-complement byte with -128
5
+ * read as -127, then `clamp(base × 8 + modifier × multiplier × 8)` to `[-1023, 1023]` with a
6
+ * multiplier of 0 standing for 1/8, where 1023 represents 1.0. The specification defines no
7
+ * conversion to fewer than eleven bits, so red is the nearest eight-bit snorm,
8
+ * `round(value × 127 / 1023)`; green and blue are 0 and alpha 127 (1.0), as a one-channel format
9
+ * samples.
10
+ *
11
+ * @param {Uint8Array} source
12
+ * @param {number} offset byte offset of the eight-byte block in `source`
13
+ * @param {Int8Array} out receives sixteen texels in raster order, RGBA
14
+ *
15
+ * @see Khronos Data Format Specification 1.3, section 22.7
16
+ * @see OpenGL ES 3.0 Specification, section C.1.7
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function eac_r11_snorm_decode_block(source: Uint8Array, offset: number, out: Int8Array): void;
21
+ //# sourceMappingURL=eac_r11_snorm_decode_block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_r11_snorm_decode_block.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_r11_snorm_decode_block.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,mDATW,UAAU,UACV,MAAM,OACN,SAAS,QAenB"}
@@ -0,0 +1,30 @@
1
+ import { eac_decode_channel_snorm11 } from "./eac_decode_channel.js";
2
+
3
+ /**
4
+ * Decode one `eac-r11snorm` block to sixteen texels.
5
+ *
6
+ * The specification's eleven-bit signed value: the base codeword a two's-complement byte with -128
7
+ * read as -127, then `clamp(base × 8 + modifier × multiplier × 8)` to `[-1023, 1023]` with a
8
+ * multiplier of 0 standing for 1/8, where 1023 represents 1.0. The specification defines no
9
+ * conversion to fewer than eleven bits, so red is the nearest eight-bit snorm,
10
+ * `round(value × 127 / 1023)`; green and blue are 0 and alpha 127 (1.0), as a one-channel format
11
+ * samples.
12
+ *
13
+ * @param {Uint8Array} source
14
+ * @param {number} offset byte offset of the eight-byte block in `source`
15
+ * @param {Int8Array} out receives sixteen texels in raster order, RGBA
16
+ *
17
+ * @see Khronos Data Format Specification 1.3, section 22.7
18
+ * @see OpenGL ES 3.0 Specification, section C.1.7
19
+ * @author Alex Goldring
20
+ * @copyright Company Named Limited (c) 2026
21
+ */
22
+ export function eac_r11_snorm_decode_block(source, offset, out) {
23
+ eac_decode_channel_snorm11(source, offset, out, 0);
24
+
25
+ for (let texel = 0; texel < 16; texel++) {
26
+ out[texel * 4 + 1] = 0;
27
+ out[texel * 4 + 2] = 0;
28
+ out[texel * 4 + 3] = 127;
29
+ }
30
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Decode one `eac-r11unorm` block to sixteen texels.
3
+ *
4
+ * The specification's eleven-bit unsigned value, `clamp(base × 8 + 4 + modifier × multiplier × 8)`
5
+ * to `[0, 2047]` with a multiplier of 0 standing for 1/8, where 2047 represents 1.0. The
6
+ * specification defines no conversion to fewer than eleven bits, so red is the nearest eight-bit
7
+ * unorm, `round(value × 255 / 2047)`; green and blue are 0 and alpha 255, as a one-channel format
8
+ * samples.
9
+ *
10
+ * @param {Uint8Array} source
11
+ * @param {number} offset byte offset of the eight-byte block in `source`
12
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA
13
+ *
14
+ * @see Khronos Data Format Specification 1.3, section 22.5
15
+ * @see OpenGL ES 3.0 Specification, section C.1.5
16
+ * @author Alex Goldring
17
+ * @copyright Company Named Limited (c) 2026
18
+ */
19
+ export function eac_r11_unorm_decode_block(source: Uint8Array, offset: number, out: Uint8Array): void;
20
+ //# sourceMappingURL=eac_r11_unorm_decode_block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_r11_unorm_decode_block.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_r11_unorm_decode_block.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,mDATW,UAAU,UACV,MAAM,OACN,UAAU,QAepB"}
@@ -0,0 +1,29 @@
1
+ import { eac_decode_channel_unorm11 } from "./eac_decode_channel.js";
2
+
3
+ /**
4
+ * Decode one `eac-r11unorm` block to sixteen texels.
5
+ *
6
+ * The specification's eleven-bit unsigned value, `clamp(base × 8 + 4 + modifier × multiplier × 8)`
7
+ * to `[0, 2047]` with a multiplier of 0 standing for 1/8, where 2047 represents 1.0. The
8
+ * specification defines no conversion to fewer than eleven bits, so red is the nearest eight-bit
9
+ * unorm, `round(value × 255 / 2047)`; green and blue are 0 and alpha 255, as a one-channel format
10
+ * samples.
11
+ *
12
+ * @param {Uint8Array} source
13
+ * @param {number} offset byte offset of the eight-byte block in `source`
14
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA
15
+ *
16
+ * @see Khronos Data Format Specification 1.3, section 22.5
17
+ * @see OpenGL ES 3.0 Specification, section C.1.5
18
+ * @author Alex Goldring
19
+ * @copyright Company Named Limited (c) 2026
20
+ */
21
+ export function eac_r11_unorm_decode_block(source, offset, out) {
22
+ eac_decode_channel_unorm11(source, offset, out, 0);
23
+
24
+ for (let texel = 0; texel < 16; texel++) {
25
+ out[texel * 4 + 1] = 0;
26
+ out[texel * 4 + 2] = 0;
27
+ out[texel * 4 + 3] = 255;
28
+ }
29
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Decode one `eac-rg11snorm` block to sixteen texels.
3
+ *
4
+ * The block is sixteen bytes: an EAC block holding red, then one holding green, each decoded exactly
5
+ * as `eac-r11snorm` — the specification's eleven-bit signed value, written as the nearest eight-bit
6
+ * snorm `round(value × 127 / 1023)`, since the specification defines no conversion to fewer than
7
+ * eleven bits. Blue is 0 and alpha 127 (1.0), as a two-channel format samples.
8
+ *
9
+ * @param {Uint8Array} source
10
+ * @param {number} offset byte offset of the sixteen-byte block in `source`
11
+ * @param {Int8Array} out receives sixteen texels in raster order, RGBA
12
+ *
13
+ * @see Khronos Data Format Specification 1.3, section 22.8
14
+ * @see OpenGL ES 3.0 Specification, section C.1.8
15
+ * @author Alex Goldring
16
+ * @copyright Company Named Limited (c) 2026
17
+ */
18
+ export function eac_rg11_snorm_decode_block(source: Uint8Array, offset: number, out: Int8Array): void;
19
+ //# sourceMappingURL=eac_rg11_snorm_decode_block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_rg11_snorm_decode_block.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_rg11_snorm_decode_block.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,oDATW,UAAU,UACV,MAAM,OACN,SAAS,QAenB"}
@@ -0,0 +1,28 @@
1
+ import { eac_decode_channel_snorm11 } from "./eac_decode_channel.js";
2
+
3
+ /**
4
+ * Decode one `eac-rg11snorm` block to sixteen texels.
5
+ *
6
+ * The block is sixteen bytes: an EAC block holding red, then one holding green, each decoded exactly
7
+ * as `eac-r11snorm` — the specification's eleven-bit signed value, written as the nearest eight-bit
8
+ * snorm `round(value × 127 / 1023)`, since the specification defines no conversion to fewer than
9
+ * eleven bits. Blue is 0 and alpha 127 (1.0), as a two-channel format samples.
10
+ *
11
+ * @param {Uint8Array} source
12
+ * @param {number} offset byte offset of the sixteen-byte block in `source`
13
+ * @param {Int8Array} out receives sixteen texels in raster order, RGBA
14
+ *
15
+ * @see Khronos Data Format Specification 1.3, section 22.8
16
+ * @see OpenGL ES 3.0 Specification, section C.1.8
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function eac_rg11_snorm_decode_block(source, offset, out) {
21
+ eac_decode_channel_snorm11(source, offset, out, 0);
22
+ eac_decode_channel_snorm11(source, offset + 8, out, 1);
23
+
24
+ for (let texel = 0; texel < 16; texel++) {
25
+ out[texel * 4 + 2] = 0;
26
+ out[texel * 4 + 3] = 127;
27
+ }
28
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Decode one `eac-rg11unorm` block to sixteen texels.
3
+ *
4
+ * The block is sixteen bytes: an EAC block holding red, then one holding green, each decoded exactly
5
+ * as `eac-r11unorm` — the specification's eleven-bit unsigned value, written as the nearest eight-bit
6
+ * unorm `round(value × 255 / 2047)`, since the specification defines no conversion to fewer than
7
+ * eleven bits. Blue is 0 and alpha 255, as a two-channel format samples.
8
+ *
9
+ * @param {Uint8Array} source
10
+ * @param {number} offset byte offset of the sixteen-byte block in `source`
11
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA
12
+ *
13
+ * @see Khronos Data Format Specification 1.3, section 22.6
14
+ * @see OpenGL ES 3.0 Specification, section C.1.6
15
+ * @author Alex Goldring
16
+ * @copyright Company Named Limited (c) 2026
17
+ */
18
+ export function eac_rg11_unorm_decode_block(source: Uint8Array, offset: number, out: Uint8Array): void;
19
+ //# sourceMappingURL=eac_rg11_unorm_decode_block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_rg11_unorm_decode_block.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_rg11_unorm_decode_block.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,oDATW,UAAU,UACV,MAAM,OACN,UAAU,QAepB"}
@@ -0,0 +1,28 @@
1
+ import { eac_decode_channel_unorm11 } from "./eac_decode_channel.js";
2
+
3
+ /**
4
+ * Decode one `eac-rg11unorm` block to sixteen texels.
5
+ *
6
+ * The block is sixteen bytes: an EAC block holding red, then one holding green, each decoded exactly
7
+ * as `eac-r11unorm` — the specification's eleven-bit unsigned value, written as the nearest eight-bit
8
+ * unorm `round(value × 255 / 2047)`, since the specification defines no conversion to fewer than
9
+ * eleven bits. Blue is 0 and alpha 255, as a two-channel format samples.
10
+ *
11
+ * @param {Uint8Array} source
12
+ * @param {number} offset byte offset of the sixteen-byte block in `source`
13
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA
14
+ *
15
+ * @see Khronos Data Format Specification 1.3, section 22.6
16
+ * @see OpenGL ES 3.0 Specification, section C.1.6
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function eac_rg11_unorm_decode_block(source, offset, out) {
21
+ eac_decode_channel_unorm11(source, offset, out, 0);
22
+ eac_decode_channel_unorm11(source, offset + 8, out, 1);
23
+
24
+ for (let texel = 0; texel < 16; texel++) {
25
+ out[texel * 4 + 2] = 0;
26
+ out[texel * 4 + 3] = 255;
27
+ }
28
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Decode one 64-bit ETC2 colour block: the RGB8 block, the colour half of an RGBA8 block, or the
3
+ * punch-through RGB8A1 block.
4
+ *
5
+ * The block is the big-endian integer of its eight bytes. Its mode follows the specification:
6
+ * without punch-through, a clear D bit (bit 33) is the individual mode; otherwise the differential
7
+ * fields are read — 5-bit R, G, B and 3-bit two's-complement dR, dG, dB — and R + dR outside
8
+ * `[0, 31]` is the T mode, else G + dG outside it the H mode, else B + dB outside it the planar
9
+ * mode, else the differential mode. With punch-through there is no individual mode, bit 33 is the
10
+ * opaque bit, and a clear opaque bit makes pixel index 2 transparent black (0, 0, 0, 0) in the
11
+ * differential, T and H modes and empties the differential tables' small modifiers; the planar mode
12
+ * ignores it. Every bit pattern decodes; nothing is checked or refused.
13
+ *
14
+ * @param {Uint8Array} source
15
+ * @param {number} offset byte offset of the block in `source`
16
+ * @param {boolean} punchthrough whether to read the block as RGB8A1 rather than RGB8
17
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA, alpha 255 where opaque
18
+ *
19
+ * @see Khronos Data Format Specification 1.3, sections 22.1 and 22.9
20
+ * @see OpenGL ES 3.0 Specification, sections C.1.1 and C.1.9
21
+ * @author Alex Goldring
22
+ * @copyright Company Named Limited (c) 2026
23
+ */
24
+ export function etc2_decode_color(source: Uint8Array, offset: number, punchthrough: boolean, out: Uint8Array): void;
25
+ //# sourceMappingURL=etc2_decode_color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etc2_decode_color.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/etc2_decode_color.js"],"names":[],"mappings":"AA+SA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,0CAVW,UAAU,UACV,MAAM,gBACN,OAAO,OACP,UAAU,QAkDpB"}
@@ -0,0 +1,370 @@
1
+ /**
2
+ * The small modifier `a` of each intensity table, by table codeword. A pixel index of 0, 1, 2, 3
3
+ * selects `+a, +b, -a, -b`.
4
+ *
5
+ * @readonly
6
+ * @type {Int32Array}
7
+ */
8
+ const MODIFIER_SMALL = new Int32Array([2, 5, 9, 13, 18, 24, 33, 47]);
9
+
10
+ /**
11
+ * The large modifier `b` of each intensity table, by table codeword.
12
+ *
13
+ * @readonly
14
+ * @type {Int32Array}
15
+ */
16
+ const MODIFIER_LARGE = new Int32Array([8, 17, 29, 42, 60, 80, 106, 183]);
17
+
18
+ /**
19
+ * The distance table of the T and H modes, by distance index.
20
+ *
21
+ * @readonly
22
+ * @type {Int32Array}
23
+ */
24
+ const DISTANCE = new Int32Array([3, 6, 11, 16, 23, 32, 41, 64]);
25
+
26
+ /**
27
+ * Scratch: the RGBA colour each pixel index selects. Individual and differential blocks use two
28
+ * runs of four (one per subblock), T and H blocks the first four.
29
+ *
30
+ * @type {Int32Array}
31
+ */
32
+ const palette = new Int32Array(32);
33
+
34
+ /**
35
+ * @param {number} value
36
+ * @returns {number} `value` clamped to `[0, 255]`
37
+ */
38
+ function clamp255(value) {
39
+ return value < 0 ? 0 : value > 255 ? 255 : value;
40
+ }
41
+
42
+ /**
43
+ * @param {number} value four bits
44
+ * @returns {number} eight bits, the four replicated
45
+ */
46
+ function extend4(value) {
47
+ return (value << 4) | value;
48
+ }
49
+
50
+ /**
51
+ * @param {number} value five bits
52
+ * @returns {number} eight bits, the top three replicated below
53
+ */
54
+ function extend5(value) {
55
+ return (value << 3) | (value >> 2);
56
+ }
57
+
58
+ /**
59
+ * @param {number} value six bits
60
+ * @returns {number} eight bits, the top two replicated below
61
+ */
62
+ function extend6(value) {
63
+ return (value << 2) | (value >> 4);
64
+ }
65
+
66
+ /**
67
+ * @param {number} value seven bits
68
+ * @returns {number} eight bits, the top bit replicated below
69
+ */
70
+ function extend7(value) {
71
+ return (value << 1) | (value >> 6);
72
+ }
73
+
74
+ /**
75
+ * @param {number} value three bits
76
+ * @returns {number} as a two's-complement number, `-4..3`
77
+ */
78
+ function signed3(value) {
79
+ return ((value & 7) << 29) >> 29;
80
+ }
81
+
82
+ /**
83
+ * Set one palette entry to a colour, each channel clamped, and opaque.
84
+ *
85
+ * @param {number} entry
86
+ * @param {number} r
87
+ * @param {number} g
88
+ * @param {number} b
89
+ */
90
+ function set_entry(entry, r, g, b) {
91
+ const at = entry * 4;
92
+
93
+ palette[at] = clamp255(r);
94
+ palette[at + 1] = clamp255(g);
95
+ palette[at + 2] = clamp255(b);
96
+ palette[at + 3] = 255;
97
+ }
98
+
99
+ /**
100
+ * Set one palette entry to transparent black.
101
+ *
102
+ * @param {number} entry
103
+ */
104
+ function set_transparent(entry) {
105
+ const at = entry * 4;
106
+
107
+ palette[at] = 0;
108
+ palette[at + 1] = 0;
109
+ palette[at + 2] = 0;
110
+ palette[at + 3] = 0;
111
+ }
112
+
113
+ /**
114
+ * The four colours of one subblock of an individual or differential block: its base colour plus
115
+ * the modifier each pixel index selects from its table.
116
+ *
117
+ * @param {number} subblock 0 or 1
118
+ * @param {number} r eight-bit base colour
119
+ * @param {number} g
120
+ * @param {number} b
121
+ * @param {number} table codeword, `0..7`
122
+ * @param {boolean} opaque false for a punch-through block with its opaque bit clear, whose table
123
+ * keeps only the large modifiers and whose index 2 is transparent black
124
+ */
125
+ function subblock_palette(subblock, r, g, b, table, opaque) {
126
+ const large = MODIFIER_LARGE[table];
127
+ const entry = subblock * 4;
128
+
129
+ set_entry(entry + 1, r + large, g + large, b + large);
130
+ set_entry(entry + 3, r - large, g - large, b - large);
131
+
132
+ if (opaque) {
133
+ const small = MODIFIER_SMALL[table];
134
+
135
+ set_entry(entry, r + small, g + small, b + small);
136
+ set_entry(entry + 2, r - small, g - small, b - small);
137
+ } else {
138
+ set_entry(entry, r, g, b);
139
+ set_transparent(entry + 2);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * The two-bit pixel index of a texel. The specification letters the texels a..p down each column;
145
+ * letter `k` keeps its index's most significant bit at bit `16 + k` of the block's low word and its
146
+ * least significant bit at bit `k`.
147
+ *
148
+ * @param {number} lo bits 31..0 of the block
149
+ * @param {number} letter `4x + y`
150
+ * @returns {number} `0..3`
151
+ */
152
+ function pixel_index(lo, letter) {
153
+ return (((lo >>> (16 + letter)) & 1) << 1) | ((lo >>> letter) & 1);
154
+ }
155
+
156
+ /**
157
+ * Write the sixteen texels of a two-subblock block from {@link palette}.
158
+ *
159
+ * @param {number} lo bits 31..0 of the block
160
+ * @param {number} flip 0: subblocks side by side (two columns each), 1: stacked (two rows each)
161
+ * @param {Uint8Array} out
162
+ */
163
+ function write_subblocks(lo, flip, out) {
164
+ for (let y = 0; y < 4; y++) {
165
+ for (let x = 0; x < 4; x++) {
166
+ const subblock = flip === 0 ? (x >> 1) : (y >> 1);
167
+
168
+ const from = (subblock * 4 + pixel_index(lo, x * 4 + y)) * 4;
169
+ const to = (y * 4 + x) * 4;
170
+
171
+ out[to] = palette[from];
172
+ out[to + 1] = palette[from + 1];
173
+ out[to + 2] = palette[from + 2];
174
+ out[to + 3] = palette[from + 3];
175
+ }
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Write the sixteen texels of a T or H block, each texel's index selecting a paint colour from the
181
+ * first four entries of {@link palette}.
182
+ *
183
+ * @param {number} lo bits 31..0 of the block
184
+ * @param {Uint8Array} out
185
+ */
186
+ function write_paint(lo, out) {
187
+ for (let y = 0; y < 4; y++) {
188
+ for (let x = 0; x < 4; x++) {
189
+ const from = pixel_index(lo, x * 4 + y) * 4;
190
+ const to = (y * 4 + x) * 4;
191
+
192
+ out[to] = palette[from];
193
+ out[to + 1] = palette[from + 1];
194
+ out[to + 2] = palette[from + 2];
195
+ out[to + 3] = palette[from + 3];
196
+ }
197
+ }
198
+ }
199
+
200
+ /**
201
+ * The T mode: base colour 1 (red split around a free bit), base colour 2, and a distance; paint
202
+ * colours are base 1, base 2 plus the distance, base 2, base 2 minus the distance.
203
+ *
204
+ * @param {number} hi bits 63..32 of the block
205
+ * @param {number} lo bits 31..0
206
+ * @param {boolean} opaque false makes paint colour 2 transparent black
207
+ * @param {Uint8Array} out
208
+ */
209
+ function decode_t(hi, lo, opaque, out) {
210
+ const r1 = extend4((((hi >>> 27) & 3) << 2) | ((hi >>> 24) & 3));
211
+ const g1 = extend4((hi >>> 20) & 15);
212
+ const b1 = extend4((hi >>> 16) & 15);
213
+
214
+ const r2 = extend4((hi >>> 12) & 15);
215
+ const g2 = extend4((hi >>> 8) & 15);
216
+ const b2 = extend4((hi >>> 4) & 15);
217
+
218
+ const d = DISTANCE[(((hi >>> 2) & 3) << 1) | (hi & 1)];
219
+
220
+ set_entry(0, r1, g1, b1);
221
+ set_entry(1, r2 + d, g2 + d, b2 + d);
222
+ set_entry(3, r2 - d, g2 - d, b2 - d);
223
+
224
+ if (opaque) {
225
+ set_entry(2, r2, g2, b2);
226
+ } else {
227
+ set_transparent(2);
228
+ }
229
+
230
+ write_paint(lo, out);
231
+ }
232
+
233
+ /**
234
+ * The H mode: two base colours (green and blue of the first split around free bits) and a distance
235
+ * whose index takes its two high bits from the block and its low bit from whether base colour 1 is
236
+ * at least base colour 2, each colour valued `R << 16 | G << 8 | B`; paint colours are each base
237
+ * plus and minus the distance.
238
+ *
239
+ * @param {number} hi bits 63..32 of the block
240
+ * @param {number} lo bits 31..0
241
+ * @param {boolean} opaque false makes paint colour 2 transparent black
242
+ * @param {Uint8Array} out
243
+ */
244
+ function decode_h(hi, lo, opaque, out) {
245
+ const r1 = extend4((hi >>> 27) & 15);
246
+ const g1 = extend4((((hi >>> 24) & 7) << 1) | ((hi >>> 20) & 1));
247
+ const b1 = extend4((((hi >>> 19) & 1) << 3) | ((hi >>> 15) & 7));
248
+
249
+ const r2 = extend4((hi >>> 11) & 15);
250
+ const g2 = extend4((hi >>> 7) & 15);
251
+ const b2 = extend4((hi >>> 3) & 15);
252
+
253
+ const order = ((r1 << 16) | (g1 << 8) | b1) >= ((r2 << 16) | (g2 << 8) | b2) ? 1 : 0;
254
+
255
+ const d = DISTANCE[(((hi >>> 2) & 1) << 2) | ((hi & 1) << 1) | order];
256
+
257
+ set_entry(0, r1 + d, g1 + d, b1 + d);
258
+ set_entry(1, r1 - d, g1 - d, b1 - d);
259
+ set_entry(3, r2 - d, g2 - d, b2 - d);
260
+
261
+ if (opaque) {
262
+ set_entry(2, r2 + d, g2 + d, b2 + d);
263
+ } else {
264
+ set_transparent(2);
265
+ }
266
+
267
+ write_paint(lo, out);
268
+ }
269
+
270
+ /**
271
+ * The planar mode: three colours O, H and V in RGB 6:7:6, and each texel
272
+ * `clamp255((x (H - O) + y (V - O) + 4 O + 2) >> 2)` per channel — the plane through them rounded to
273
+ * the nearest integer, a tie going up. Always opaque.
274
+ *
275
+ * @param {number} hi bits 63..32 of the block
276
+ * @param {number} lo bits 31..0
277
+ * @param {Uint8Array} out
278
+ */
279
+ function decode_planar(hi, lo, out) {
280
+ const ro = extend6((hi >>> 25) & 63);
281
+ const go = extend7((((hi >>> 24) & 1) << 6) | ((hi >>> 17) & 63));
282
+ const bo = extend6((((hi >>> 16) & 1) << 5) | (((hi >>> 11) & 3) << 3) | ((hi >>> 7) & 7));
283
+
284
+ const rh = extend6((((hi >>> 2) & 31) << 1) | (hi & 1));
285
+ const gh = extend7((lo >>> 25) & 127);
286
+ const bh = extend6((lo >>> 19) & 63);
287
+
288
+ const rv = extend6((lo >>> 13) & 63);
289
+ const gv = extend7((lo >>> 6) & 127);
290
+ const bv = extend6(lo & 63);
291
+
292
+ for (let y = 0; y < 4; y++) {
293
+ for (let x = 0; x < 4; x++) {
294
+ const to = (y * 4 + x) * 4;
295
+
296
+ out[to] = clamp255((x * (rh - ro) + y * (rv - ro) + 4 * ro + 2) >> 2);
297
+ out[to + 1] = clamp255((x * (gh - go) + y * (gv - go) + 4 * go + 2) >> 2);
298
+ out[to + 2] = clamp255((x * (bh - bo) + y * (bv - bo) + 4 * bo + 2) >> 2);
299
+ out[to + 3] = 255;
300
+ }
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Decode one 64-bit ETC2 colour block: the RGB8 block, the colour half of an RGBA8 block, or the
306
+ * punch-through RGB8A1 block.
307
+ *
308
+ * The block is the big-endian integer of its eight bytes. Its mode follows the specification:
309
+ * without punch-through, a clear D bit (bit 33) is the individual mode; otherwise the differential
310
+ * fields are read — 5-bit R, G, B and 3-bit two's-complement dR, dG, dB — and R + dR outside
311
+ * `[0, 31]` is the T mode, else G + dG outside it the H mode, else B + dB outside it the planar
312
+ * mode, else the differential mode. With punch-through there is no individual mode, bit 33 is the
313
+ * opaque bit, and a clear opaque bit makes pixel index 2 transparent black (0, 0, 0, 0) in the
314
+ * differential, T and H modes and empties the differential tables' small modifiers; the planar mode
315
+ * ignores it. Every bit pattern decodes; nothing is checked or refused.
316
+ *
317
+ * @param {Uint8Array} source
318
+ * @param {number} offset byte offset of the block in `source`
319
+ * @param {boolean} punchthrough whether to read the block as RGB8A1 rather than RGB8
320
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA, alpha 255 where opaque
321
+ *
322
+ * @see Khronos Data Format Specification 1.3, sections 22.1 and 22.9
323
+ * @see OpenGL ES 3.0 Specification, sections C.1.1 and C.1.9
324
+ * @author Alex Goldring
325
+ * @copyright Company Named Limited (c) 2026
326
+ */
327
+ export function etc2_decode_color(source, offset, punchthrough, out) {
328
+ const hi = ((source[offset] << 24) | (source[offset + 1] << 16) | (source[offset + 2] << 8) | source[offset + 3]) >>> 0;
329
+ const lo = ((source[offset + 4] << 24) | (source[offset + 5] << 16) | (source[offset + 6] << 8) | source[offset + 7]) >>> 0;
330
+
331
+ const bit33 = (hi >>> 1) & 1;
332
+ const flip = hi & 1;
333
+
334
+ if (!punchthrough && bit33 === 0) {
335
+ // individual: two 4-bit base colours, R1 R2 G1 G2 B1 B2 from bit 63 down
336
+ subblock_palette(
337
+ 0, extend4((hi >>> 28) & 15), extend4((hi >>> 20) & 15), extend4((hi >>> 12) & 15), (hi >>> 5) & 7, true
338
+ );
339
+ subblock_palette(
340
+ 1, extend4((hi >>> 24) & 15), extend4((hi >>> 16) & 15), extend4((hi >>> 8) & 15), (hi >>> 2) & 7, true
341
+ );
342
+
343
+ write_subblocks(lo, flip, out);
344
+
345
+ return;
346
+ }
347
+
348
+ const opaque = !punchthrough || bit33 === 1;
349
+
350
+ const r = (hi >>> 27) & 31;
351
+ const g = (hi >>> 19) & 31;
352
+ const b = (hi >>> 11) & 31;
353
+
354
+ const r2 = r + signed3(hi >>> 24);
355
+ const g2 = g + signed3(hi >>> 16);
356
+ const b2 = b + signed3(hi >>> 8);
357
+
358
+ if (r2 < 0 || r2 > 31) {
359
+ decode_t(hi, lo, opaque, out);
360
+ } else if (g2 < 0 || g2 > 31) {
361
+ decode_h(hi, lo, opaque, out);
362
+ } else if (b2 < 0 || b2 > 31) {
363
+ decode_planar(hi, lo, out);
364
+ } else {
365
+ subblock_palette(0, extend5(r), extend5(g), extend5(b), (hi >>> 5) & 7, opaque);
366
+ subblock_palette(1, extend5(r2), extend5(g2), extend5(b2), (hi >>> 2) & 7, opaque);
367
+
368
+ write_subblocks(lo, flip, out);
369
+ }
370
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Decode one `etc2-rgb8unorm` (or `-srgb`) block to sixteen texels.
3
+ *
4
+ * Every mode the specification defines: ETC1's individual and differential modes, and ETC2's T, H
5
+ * and planar modes, selected as the specification selects them. Alpha is 255. The `-srgb` variant
6
+ * is the same blocks and decodes to the same bytes.
7
+ *
8
+ * @param {Uint8Array} source
9
+ * @param {number} offset byte offset of the eight-byte block in `source`
10
+ * @param {Uint8Array} out receives sixteen texels in raster order, RGBA
11
+ *
12
+ * @see Khronos Data Format Specification 1.3, section 22.1
13
+ * @see OpenGL ES 3.0 Specification, section C.1.1
14
+ * @author Alex Goldring
15
+ * @copyright Company Named Limited (c) 2026
16
+ */
17
+ export function etc2_rgb8_decode_block(source: Uint8Array, offset: number, out: Uint8Array): void;
18
+ //# sourceMappingURL=etc2_rgb8_decode_block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etc2_rgb8_decode_block.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/etc2_rgb8_decode_block.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,+CATW,UAAU,UACV,MAAM,OACN,UAAU,QASpB"}