@woosh/meep-engine 3.60.6 → 3.60.7

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 (326) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BitSet.d.ts.map +1 -1
  4. package/src/core/binary/BitSet.js +2 -1
  5. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.d.ts +2 -2
  6. package/src/core/binary/operations/ceil_log2.d.ts.map +1 -0
  7. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.js +18 -18
  8. package/src/core/binary/zstd/ZstdReverseBitReader.d.ts.map +1 -1
  9. package/src/core/binary/zstd/ZstdReverseBitReader.js +225 -223
  10. package/src/core/binary/zstd/zstd_fse.d.ts.map +1 -1
  11. package/src/core/binary/zstd/zstd_fse.js +267 -265
  12. package/src/core/binary/zstd/zstd_huffman.d.ts.map +1 -1
  13. package/src/core/binary/zstd/zstd_huffman.js +246 -244
  14. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  15. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +8 -2
  16. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.d.ts.map +1 -1
  17. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.js +8 -7
  18. package/src/core/collection/PairUint32Map.d.ts.map +1 -1
  19. package/src/core/collection/PairUint32Map.js +2 -2
  20. package/src/core/collection/Uint32Map.d.ts.map +1 -1
  21. package/src/core/collection/Uint32Map.js +2 -4
  22. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -1
  23. package/src/core/collection/heap/FibonacciHeap.js +2 -1
  24. package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -1
  25. package/src/core/geom/2d/r-tree/StaticR2Tree.js +8 -2
  26. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.d.ts.map +1 -1
  27. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.js +2 -3
  28. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  29. package/src/engine/graphics/texture/atlas/TextureAtlas.js +13 -14
  30. package/src/engine/graphics/texture/atlas/sprite_atlas_border.d.ts.map +1 -1
  31. package/src/engine/graphics/texture/atlas/sprite_atlas_border.js +70 -69
  32. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.d.ts.map +1 -1
  33. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.js +2 -1
  34. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  35. package/src/engine/graphics3/GPUParticleEmitterSystem.js +2 -1
  36. package/src/engine/graphics3/decal/GPUDecalRenderer.d.ts.map +1 -1
  37. package/src/engine/graphics3/decal/GPUDecalRenderer.js +2 -1
  38. package/src/engine/graphics3/decal/chunk_decal_record.d.ts +14 -0
  39. package/src/engine/graphics3/decal/chunk_decal_record.d.ts.map +1 -0
  40. package/src/engine/graphics3/decal/chunk_decal_record.js +44 -0
  41. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts.map +1 -1
  42. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +2 -15
  43. package/src/engine/graphics3/decal/shader_cull_decals_frustum.d.ts.map +1 -1
  44. package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +3 -16
  45. package/src/engine/graphics3/decal/shader_decal_composite.d.ts.map +1 -1
  46. package/src/engine/graphics3/decal/shader_decal_composite.js +3 -23
  47. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.d.ts.map +1 -1
  48. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.js +2 -1
  49. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  50. package/src/engine/physics/queries/shape_cast.js +2 -2
  51. package/src/format/image/avif/av1/decode/decode_palette.js +442 -442
  52. package/src/format/image/avif/av1/entropy/SymbolWriter.d.ts.map +1 -1
  53. package/src/format/image/avif/av1/entropy/SymbolWriter.js +2 -1
  54. package/src/generation/foliage/material/foliage_tile.d.ts.map +1 -1
  55. package/src/generation/foliage/material/foliage_tile.js +2 -1
  56. package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
  57. package/src/shade/device/mock/SoftwareGPUDevice.js +6 -13
  58. package/src/shade/playground/caldera/main.js +3 -2
  59. package/src/shade/playground/probe_clipmap/README.md +2 -1
  60. package/src/shade/playground/probe_clipmap/index.html +7 -2
  61. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  62. package/src/shade/playground/probe_clipmap/main.js +17 -7
  63. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.d.ts.map +1 -1
  64. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.js +7 -13
  65. package/src/shade/playground/vgeo_scene/main.js +2 -1
  66. package/src/shade/playground/vsm/VSMDebugOverlay.d.ts.map +1 -1
  67. package/src/shade/playground/vsm/VSMDebugOverlay.js +3 -1
  68. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  69. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  70. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  71. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  72. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.d.ts.map +1 -1
  73. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.js +5 -4
  74. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.d.ts.map +1 -1
  75. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.js +168 -166
  76. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.d.ts.map +1 -1
  77. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.js +221 -219
  78. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  79. package/src/shade/renderer/fow/shader_fog_of_war.d.ts.map +1 -1
  80. package/src/shade/renderer/fow/shader_fog_of_war.js +8 -19
  81. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  82. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +6 -6
  83. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.d.ts.map +1 -1
  84. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.js +2 -1
  85. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  86. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +2 -1
  87. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.d.ts.map +1 -1
  88. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.js +2 -1
  89. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.d.ts.map +1 -1
  90. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.js +10 -31
  91. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.d.ts.map +1 -1
  92. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.js +9 -15
  93. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts +2 -1
  94. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts.map +1 -1
  95. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.js +6 -5
  96. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.d.ts.map +1 -1
  97. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.js +2 -1
  98. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +15 -3
  99. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +168 -18
  101. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +98 -57
  102. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  103. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +168 -77
  104. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +4 -2
  105. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  106. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +27 -12
  107. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
  108. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +12 -7
  109. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  110. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +8 -2
  111. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -1
  112. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +5 -2
  113. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +1 -1
  114. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -1
  115. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +5 -3
  116. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +1 -1
  117. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts.map +1 -1
  118. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.js +1 -1
  119. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.d.ts.map +1 -1
  120. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.js +4 -2
  121. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.d.ts.map +1 -1
  122. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.js +1 -1
  123. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.d.ts.map +1 -1
  124. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.js +1 -1
  125. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.d.ts.map +1 -1
  126. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.js +3 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_cards.js +2 -2
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +114 -41
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +424 -207
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +34 -25
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +41 -31
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts +7 -5
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts.map +1 -1
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.js +7 -5
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts +47 -0
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts.map +1 -0
  139. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.js +84 -0
  140. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +48 -0
  141. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -0
  142. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +101 -0
  143. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +58 -4
  144. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  145. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +127 -30
  146. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts +18 -7
  147. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts.map +1 -1
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.js +39 -13
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts +29 -8
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts.map +1 -1
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +112 -56
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts +19 -0
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts.map +1 -0
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.js +35 -0
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +9 -3
  157. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +3 -3
  158. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +5 -5
  159. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +8 -12
  160. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  161. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +23 -56
  162. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts +0 -3
  163. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts.map +1 -1
  164. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +11 -15
  165. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts +26 -0
  166. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts.map +1 -0
  167. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.js +173 -0
  168. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts +32 -0
  169. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts.map +1 -0
  170. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.js +166 -0
  171. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +3 -4
  172. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  173. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +3 -4
  174. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts.map +1 -1
  175. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.js +3 -1
  176. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +6 -12
  177. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  178. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +15 -65
  179. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts.map +1 -1
  180. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.js +7 -2
  181. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +4 -4
  182. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  183. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +24 -17
  184. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts +7 -5
  185. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts.map +1 -1
  186. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.js +18 -10
  187. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts +2 -2
  188. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts.map +1 -1
  189. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.js +9 -5
  190. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts +3 -0
  191. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
  192. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +9 -6
  193. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts +1 -1
  194. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts.map +1 -1
  195. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.js +16 -16
  196. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts +36 -0
  197. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts.map +1 -0
  198. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.js +233 -0
  199. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  200. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +7 -5
  201. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
  202. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +5 -3
  203. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  204. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +10 -4
  205. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts +2 -1
  206. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts.map +1 -1
  207. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.js +12 -6
  208. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +1 -2
  209. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
  210. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +5 -6
  211. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +14 -18
  212. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts.map +1 -1
  213. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +25 -35
  214. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts +13 -0
  215. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts.map +1 -0
  216. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.js +12 -0
  217. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts +27 -2
  218. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts.map +1 -1
  219. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.js +62 -6
  220. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.d.ts.map +1 -1
  221. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.js +10 -19
  222. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.d.ts.map +1 -1
  223. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.js +6 -3
  224. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -1
  225. package/src/shade/renderer/hiz/hzb_pick_alignment.js +149 -148
  226. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.d.ts.map +1 -1
  227. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.js +4 -2
  228. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.d.ts.map +1 -1
  229. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.js +6 -5
  230. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.d.ts.map +1 -1
  231. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.js +3 -1
  232. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.d.ts.map +1 -1
  233. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.js +3 -1
  234. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.d.ts.map +1 -1
  235. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.js +3 -1
  236. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +0 -5
  237. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -1
  238. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +0 -7
  239. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +15 -2
  240. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -1
  241. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +51 -16
  242. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -1
  243. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +3 -2
  244. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  245. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts +17 -0
  246. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts.map +1 -0
  247. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.js +81 -0
  248. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.d.ts.map +1 -1
  249. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.js +5 -48
  250. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.d.ts.map +1 -1
  251. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.js +4 -44
  252. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.d.ts.map +1 -1
  253. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.js +4 -1
  254. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
  255. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +8 -7
  256. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  257. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.d.ts.map +1 -1
  258. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.js +5 -7
  259. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts +17 -0
  260. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts.map +1 -0
  261. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.js +56 -0
  262. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.d.ts.map +1 -1
  263. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.js +2 -22
  264. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.d.ts.map +1 -1
  265. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.js +2 -13
  266. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  267. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +10 -13
  268. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.d.ts.map +1 -1
  269. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.js +39 -38
  270. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.d.ts.map +1 -1
  271. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js +7 -12
  272. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts +8 -6
  273. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts.map +1 -1
  274. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.js +10 -7
  275. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts +16 -0
  276. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts.map +1 -0
  277. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.js +35 -0
  278. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts +5 -2
  279. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts.map +1 -1
  280. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.js +27 -18
  281. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.d.ts.map +1 -1
  282. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.js +5 -15
  283. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.d.ts.map +1 -1
  284. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.js +5 -19
  285. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.d.ts.map +1 -1
  286. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.js +3 -22
  287. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.d.ts.map +1 -1
  288. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.js +2 -1
  289. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.d.ts.map +1 -1
  290. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.js +154 -152
  291. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -1
  292. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +2 -1
  293. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +3 -1
  294. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -1
  295. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +4 -3
  296. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +7 -1
  297. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -1
  298. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +54 -47
  299. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -1
  300. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +371 -370
  301. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  302. package/src/shade/renderer/water/GPUWaterRenderer.js +2 -1
  303. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  304. package/src/shade/renderer/water/surface/lod/shader_water_lod.d.ts.map +1 -1
  305. package/src/shade/renderer/water/surface/lod/shader_water_lod.js +12 -14
  306. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  307. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +2 -9
  308. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  309. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +2 -1
  310. package/src/shade/renderer/wind/WIND_FIELD.d.ts +3 -1
  311. package/src/shade/renderer/wind/WIND_FIELD.d.ts.map +1 -1
  312. package/src/shade/renderer/wind/WIND_FIELD.js +4 -3
  313. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts +8 -2
  314. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts.map +1 -1
  315. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.js +11 -4
  316. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -2
  317. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  318. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +13 -4
  319. package/src/shade/util/texture_mip_extent.d.ts.map +1 -1
  320. package/src/shade/util/texture_mip_extent.js +88 -87
  321. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  322. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +9 -7
  323. package/src/format/image/avif/av1/util/ceil_log2.d.ts.map +0 -1
  324. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts +0 -1
  325. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts.map +0 -1
  326. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.js +0 -0
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Advanced 3D game engine",
7
7
  "type": "module",
8
8
  "author": "Alexander Goldring",
9
- "version": "3.60.6",
9
+ "version": "3.60.7",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -1 +1 @@
1
- {"version":3,"file":"BitSet.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BitSet.js"],"names":[],"mappings":"AAgEA;;;;;;;;;;;;;;GAcG;AACH;IA0qBI;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAQlB;IA5qBD;;;OAGG;IACH,+BAFW,MAAM,EAkChB;IA3CD;;;;OAIG;IACH,iBAAa;IAST;;;;;OAKG;IACH,mBAA4C;IAE5C;;;;OAIG;IACH,sBAA0D;IAE1D;;;;;;OAMG;IACH,2BAAkF;IAElF;;;OAGG;IACH,gBAFU,MAAM,CAE2B;IAG/C;;;;OAIG;IACH,iBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAOhB;IACD;;;;;;OAMG;IACH,uBAJW,MAAM,GAEJ,IAAI,CAUhB;IAED;;;;OAIG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAsCC;IAED;;;;;;OAMG;IACH,iCAeC;IAED;;;OAGG;IACH,uBAMC;IAED;;;;;OAKG;IACH,oBAyBC;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAwClB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAuDlB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,MAAM,CAuElB;IAED;;;;;OAKG;IACH,eAJW,MAAM,SACN,OAAO,GACL,IAAI,CAiDhB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,QAWhB;IAED;;;;OAIG;IACH,wBAHW,MAAM,aACN,MAAM,QAShB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,OAAO,CAkBnB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAQhB;IAED;;OAEG;IACH,cAkBC;IAED;;;;OAIG;IACH,eAFa,MAAM,CAsBlB;IAED;;;OAGG;IACH,YAFW,MAAM,QA0ChB;CAcJ"}
1
+ {"version":3,"file":"BitSet.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BitSet.js"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;GAcG;AACH;IA0qBI;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAQlB;IA5qBD;;;OAGG;IACH,+BAFW,MAAM,EAkChB;IA3CD;;;;OAIG;IACH,iBAAa;IAST;;;;;OAKG;IACH,mBAA4C;IAE5C;;;;OAIG;IACH,sBAA0D;IAE1D;;;;;;OAMG;IACH,2BAAkF;IAElF;;;OAGG;IACH,gBAFU,MAAM,CAE2B;IAG/C;;;;OAIG;IACH,iBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAOhB;IACD;;;;;;OAMG;IACH,uBAJW,MAAM,GAEJ,IAAI,CAUhB;IAED;;;;OAIG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAsCC;IAED;;;;;;OAMG;IACH,iCAeC;IAED;;;OAGG;IACH,uBAMC;IAED;;;;;OAKG;IACH,oBAyBC;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAwClB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAuDlB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,MAAM,CAuElB;IAED;;;;;OAKG;IACH,eAJW,MAAM,SACN,OAAO,GACL,IAAI,CAiDhB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,QAWhB;IAED;;;;OAIG;IACH,wBAHW,MAAM,aACN,MAAM,QAShB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,OAAO,CAkBnB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAQhB;IAED;;OAEG;IACH,cAkBC;IAED;;;;OAIG;IACH,eAFa,MAAM,CAsBlB;IAED;;;OAGG;IACH,YAFW,MAAM,QA0ChB;CAcJ"}
@@ -4,6 +4,7 @@ import { min2 } from "../math/min2.js";
4
4
  import { align_32 } from "./align_32.js";
5
5
  import { ctz32 } from "./ctz32.js";
6
6
  import { bitCount } from "./operations/bitCount.js";
7
+ import { msb_32 } from "./msb_32.js";
7
8
 
8
9
  /**
9
10
  * Used for overallocating space when bit set needs to grow
@@ -324,7 +325,7 @@ export class BitSet {
324
325
 
325
326
  if (word !== 0) {
326
327
  // index of the highest set bit within the word
327
- return word_index * 32 + (31 - Math.clz32(word >>> 0));
328
+ return word_index * 32 + msb_32(word);
328
329
  }
329
330
 
330
331
  word_index--;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * `CeilLog2( x )` from the AV1 specification: the number of bits needed to code a value in the
3
- * range `0 .. x - 1`. Defined to be `0` for `x < 2`.
2
+ * `ceil(log2(x))` in integers: the number of bits needed to code a value in the range `0 .. x - 1`.
3
+ * Defined to be `0` for `x < 2`. The AV1 specification's `CeilLog2( x )`.
4
4
  *
5
5
  * @param {number} x 32-bit unsigned integer, `>= 0`
6
6
  * @returns {number}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceil_log2.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/operations/ceil_log2.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,6BAPW,MAAM,GACJ,MAAM,CAYlB"}
@@ -1,18 +1,18 @@
1
- /**
2
- * `CeilLog2( x )` from the AV1 specification: the number of bits needed to code a value in the
3
- * range `0 .. x - 1`. Defined to be `0` for `x < 2`.
4
- *
5
- * @param {number} x 32-bit unsigned integer, `>= 0`
6
- * @returns {number}
7
- * @see AV1 spec 4.7 "Mathematical functions"
8
- *
9
- * @author Alex Goldring
10
- * @copyright Company Named Limited (c) 2026
11
- */
12
- export function ceil_log2(x) {
13
- if (x < 2) {
14
- return 0;
15
- }
16
-
17
- return 32 - Math.clz32(x - 1);
18
- }
1
+ /**
2
+ * `ceil(log2(x))` in integers: the number of bits needed to code a value in the range `0 .. x - 1`.
3
+ * Defined to be `0` for `x < 2`. The AV1 specification's `CeilLog2( x )`.
4
+ *
5
+ * @param {number} x 32-bit unsigned integer, `>= 0`
6
+ * @returns {number}
7
+ * @see AV1 spec 4.7 "Mathematical functions"
8
+ *
9
+ * @author Alex Goldring
10
+ * @copyright Company Named Limited (c) 2026
11
+ */
12
+ export function ceil_log2(x) {
13
+ if (x < 2) {
14
+ return 0;
15
+ }
16
+
17
+ return 32 - Math.clz32(x - 1);
18
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ZstdReverseBitReader.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/zstd/ZstdReverseBitReader.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;GAiBG;AACH;IA0BI;;;;;;;;;OASG;IACH,WAPW,UAAU,eACV,MAAM,eACN,MAAM,GACJ,oBAAoB,CAgChC;IAED;;;;OAIG;IACH,wBAEC;IAED;;;;;;;OAOG;IACH,4BAEC;IAED;;;;;;;;;;OAUG;IACH,YAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;OAIG;IACH,eAFW,MAAM,QAIhB;IAED;;;;;;;;OAQG;IACH,YAHW,MAAM,GACJ,MAAM,CA+ClB;;CAuBJ"}
1
+ {"version":3,"file":"ZstdReverseBitReader.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/zstd/ZstdReverseBitReader.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;GAiBG;AACH;IA0BI;;;;;;;;;OASG;IACH,WAPW,UAAU,eACV,MAAM,eACN,MAAM,GACJ,oBAAoB,CAgChC;IAED;;;;OAIG;IACH,wBAEC;IAED;;;;;;;OAOG;IACH,4BAEC;IAED;;;;;;;;;;OAUG;IACH,YAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;OAIG;IACH,eAFW,MAAM,QAIhB;IAED;;;;;;;;OAQG;IACH,YAHW,MAAM,GACJ,MAAM,CA+ClB;;CAuBJ"}
@@ -1,223 +1,225 @@
1
- /**
2
- * Most bits one {@link ZstdReverseBitReader#read} can take in a single extraction.
3
- *
4
- * A read is served by a four-byte window shifted by up to seven bits, so twenty-five bits are
5
- * reachable; twenty-four keeps the shift inside the range where JavaScript's bitwise operators are
6
- * exact. Wider reads are split.
7
- *
8
- * @readonly
9
- * @type {number}
10
- */
11
- const MAX_SINGLE_READ = 24;
12
-
13
- /**
14
- * A backward bit cursor, which is how every entropy-coded stream in Zstandard is read.
15
- *
16
- * **Backward is not the same as reversed.** The encoder writes bits forward and the decoder consumes
17
- * them from the end, but the bits themselves keep their order — so the first bit a decoder sees is
18
- * the *last* one written, and a value of several bits comes out with the first-read bit as its most
19
- * significant. Finite State Entropy requires this: its state carries from symbol to symbol, so
20
- * decoding has to run opposite to encoding.
21
- *
22
- * **The stream says where it ends by where its padding stops.** The encoder writes a single set bit
23
- * after the last useful one and zero-fills the rest of the byte, so the highest set bit of the final
24
- * byte is a marker rather than data, and a final byte of zero is malformed. Finding that bit is how
25
- * the reader knows which bit to start on.
26
- *
27
- * @see RFC 8878, sections 4.1 and 4.2.2
28
- * @author Alex Goldring
29
- * @copyright Company Named Limited (c) 2026
30
- */
31
- export class ZstdReverseBitReader {
32
- /**
33
- * Bytes being read. Not owned.
34
- * @type {Uint8Array}
35
- */
36
- #data = null;
37
-
38
- /**
39
- * Index into {@link #data} of the first readable byte.
40
- * @type {number}
41
- */
42
- #start = 0;
43
-
44
- /**
45
- * Index into {@link #data} one past the last readable byte.
46
- * @type {number}
47
- */
48
- #end = 0;
49
-
50
- /**
51
- * Index of the next bit to read, counted in bits from {@link #start} and *decreasing* as the
52
- * stream is consumed. Negative once the stream is spent.
53
- * @type {number}
54
- */
55
- #bit = 0;
56
-
57
- /**
58
- * Point the reader at a range and skip its padding.
59
- *
60
- * @param {Uint8Array} data
61
- * @param {number} byte_offset
62
- * @param {number} byte_length
63
- * @returns {ZstdReverseBitReader} this
64
- * @throws {Error} for an empty range, or one whose last byte is zero and so carries no padding
65
- * marker
66
- */
67
- init(data, byte_offset, byte_length) {
68
- if (byte_length <= 0) {
69
- throw new Error("zstd: an entropy-coded stream cannot be empty");
70
- }
71
-
72
- const last = data[byte_offset + byte_length - 1];
73
-
74
- if (last === 0) {
75
- throw new Error(
76
- "zstd: an entropy-coded stream ends in a zero byte, which cannot happen — the"
77
- + " encoder writes a set bit after the last useful one, so the final byte always has"
78
- + " one"
79
- );
80
- }
81
-
82
- this.#data = data;
83
- this.#start = byte_offset;
84
- this.#end = byte_offset + byte_length;
85
-
86
- /*
87
- The highest set bit of the last byte is the padding marker. Everything above it is zero fill
88
- and the marker itself is not data, so reading starts just below it.
89
- */
90
- const highest = 31 - Math.clz32(last);
91
-
92
- this.#bit = byte_length * 8 - (8 - highest) - 1;
93
-
94
- return this;
95
- }
96
-
97
- /**
98
- * Bits left, including the one about to be read.
99
- *
100
- * @returns {number}
101
- */
102
- get remaining() {
103
- return this.#bit + 1;
104
- }
105
-
106
- /**
107
- * Whether the stream has been consumed exactly.
108
- *
109
- * A well-formed stream ends here; one that stops short or overruns is corrupt, which is a check
110
- * the callers make rather than this reader, since only they know how many symbols were due.
111
- *
112
- * @returns {boolean}
113
- */
114
- get is_exhausted() {
115
- return this.#bit === -1;
116
- }
117
-
118
- /**
119
- * Read `count` bits, the first read becoming the most significant.
120
- *
121
- * **Past the start of the stream reads zeros.** That is the format's rule rather than leniency:
122
- * a Finite State Entropy decoder is expected to keep going when the bits run out, and the
123
- * specification says outright that the missing bits are taken as zero. Whether the stream ended
124
- * where it should is a question the caller answers from {@link is_exhausted}.
125
- *
126
- * @param {number} count `0` to `32`
127
- * @returns {number}
128
- */
129
- read(count) {
130
- const value = this.peek(count);
131
-
132
- this.#bit -= count;
133
-
134
- return value;
135
- }
136
-
137
- /**
138
- * Drop `count` bits without reading them.
139
- *
140
- * @param {number} count
141
- */
142
- consume(count) {
143
- this.#bit -= count;
144
- }
145
-
146
- /**
147
- * Look at the next `count` bits without consuming them.
148
- *
149
- * Huffman decoding needs this: the table is indexed by the widest code, so a lookup reads more
150
- * bits than the code turned out to use and gives the rest back.
151
- *
152
- * @param {number} count `0` to `32`
153
- * @returns {number}
154
- */
155
- peek(count) {
156
- if (count === 0) {
157
- return 0;
158
- }
159
-
160
- if (count > MAX_SINGLE_READ) {
161
- // split, keeping the first-read half the more significant one
162
- const high = count - MAX_SINGLE_READ;
163
-
164
- const upper = this.peek(high);
165
-
166
- this.#bit -= high;
167
-
168
- const lower = this.peek(MAX_SINGLE_READ);
169
-
170
- this.#bit += high;
171
-
172
- return upper * (2 ** MAX_SINGLE_READ) + lower;
173
- }
174
-
175
- const low_bit = this.#bit - count + 1;
176
-
177
- if (low_bit + count <= 0) {
178
- // entirely past the start
179
- return 0;
180
- }
181
-
182
- let byte = this.#start + (low_bit >> 3);
183
-
184
- let shift = low_bit & 7;
185
-
186
- if (low_bit < 0) {
187
- /*
188
- Straddling the start. The bits below it are zero by the rule above, so the window is
189
- taken from the first real byte and shifted up to put them there.
190
- */
191
- byte = this.#start;
192
- shift = 0;
193
-
194
- const value = this.#window(byte) << -low_bit;
195
-
196
- return value & ((1 << count) - 1);
197
- }
198
-
199
- return (this.#window(byte) >>> shift) & ((1 << count) - 1);
200
- }
201
-
202
- /**
203
- * Four bytes from `byte` as a little-endian value, zero past the end of the range.
204
- *
205
- * @param {number} byte
206
- * @returns {number}
207
- */
208
- #window(byte) {
209
- let value = 0;
210
-
211
- for (let i = 0; i < 4; i++) {
212
- const at = byte + i;
213
-
214
- if (at >= this.#end || at < this.#start) {
215
- continue;
216
- }
217
-
218
- value |= this.#data[at] << (i * 8);
219
- }
220
-
221
- return value >>> 0;
222
- }
223
- }
1
+ import { msb_32 } from "../msb_32.js";
2
+
3
+ /**
4
+ * Most bits one {@link ZstdReverseBitReader#read} can take in a single extraction.
5
+ *
6
+ * A read is served by a four-byte window shifted by up to seven bits, so twenty-five bits are
7
+ * reachable; twenty-four keeps the shift inside the range where JavaScript's bitwise operators are
8
+ * exact. Wider reads are split.
9
+ *
10
+ * @readonly
11
+ * @type {number}
12
+ */
13
+ const MAX_SINGLE_READ = 24;
14
+
15
+ /**
16
+ * A backward bit cursor, which is how every entropy-coded stream in Zstandard is read.
17
+ *
18
+ * **Backward is not the same as reversed.** The encoder writes bits forward and the decoder consumes
19
+ * them from the end, but the bits themselves keep their order — so the first bit a decoder sees is
20
+ * the *last* one written, and a value of several bits comes out with the first-read bit as its most
21
+ * significant. Finite State Entropy requires this: its state carries from symbol to symbol, so
22
+ * decoding has to run opposite to encoding.
23
+ *
24
+ * **The stream says where it ends by where its padding stops.** The encoder writes a single set bit
25
+ * after the last useful one and zero-fills the rest of the byte, so the highest set bit of the final
26
+ * byte is a marker rather than data, and a final byte of zero is malformed. Finding that bit is how
27
+ * the reader knows which bit to start on.
28
+ *
29
+ * @see RFC 8878, sections 4.1 and 4.2.2
30
+ * @author Alex Goldring
31
+ * @copyright Company Named Limited (c) 2026
32
+ */
33
+ export class ZstdReverseBitReader {
34
+ /**
35
+ * Bytes being read. Not owned.
36
+ * @type {Uint8Array}
37
+ */
38
+ #data = null;
39
+
40
+ /**
41
+ * Index into {@link #data} of the first readable byte.
42
+ * @type {number}
43
+ */
44
+ #start = 0;
45
+
46
+ /**
47
+ * Index into {@link #data} one past the last readable byte.
48
+ * @type {number}
49
+ */
50
+ #end = 0;
51
+
52
+ /**
53
+ * Index of the next bit to read, counted in bits from {@link #start} and *decreasing* as the
54
+ * stream is consumed. Negative once the stream is spent.
55
+ * @type {number}
56
+ */
57
+ #bit = 0;
58
+
59
+ /**
60
+ * Point the reader at a range and skip its padding.
61
+ *
62
+ * @param {Uint8Array} data
63
+ * @param {number} byte_offset
64
+ * @param {number} byte_length
65
+ * @returns {ZstdReverseBitReader} this
66
+ * @throws {Error} for an empty range, or one whose last byte is zero and so carries no padding
67
+ * marker
68
+ */
69
+ init(data, byte_offset, byte_length) {
70
+ if (byte_length <= 0) {
71
+ throw new Error("zstd: an entropy-coded stream cannot be empty");
72
+ }
73
+
74
+ const last = data[byte_offset + byte_length - 1];
75
+
76
+ if (last === 0) {
77
+ throw new Error(
78
+ "zstd: an entropy-coded stream ends in a zero byte, which cannot happen — the"
79
+ + " encoder writes a set bit after the last useful one, so the final byte always has"
80
+ + " one"
81
+ );
82
+ }
83
+
84
+ this.#data = data;
85
+ this.#start = byte_offset;
86
+ this.#end = byte_offset + byte_length;
87
+
88
+ /*
89
+ The highest set bit of the last byte is the padding marker. Everything above it is zero fill
90
+ and the marker itself is not data, so reading starts just below it.
91
+ */
92
+ const highest = msb_32(last);
93
+
94
+ this.#bit = byte_length * 8 - (8 - highest) - 1;
95
+
96
+ return this;
97
+ }
98
+
99
+ /**
100
+ * Bits left, including the one about to be read.
101
+ *
102
+ * @returns {number}
103
+ */
104
+ get remaining() {
105
+ return this.#bit + 1;
106
+ }
107
+
108
+ /**
109
+ * Whether the stream has been consumed exactly.
110
+ *
111
+ * A well-formed stream ends here; one that stops short or overruns is corrupt, which is a check
112
+ * the callers make rather than this reader, since only they know how many symbols were due.
113
+ *
114
+ * @returns {boolean}
115
+ */
116
+ get is_exhausted() {
117
+ return this.#bit === -1;
118
+ }
119
+
120
+ /**
121
+ * Read `count` bits, the first read becoming the most significant.
122
+ *
123
+ * **Past the start of the stream reads zeros.** That is the format's rule rather than leniency:
124
+ * a Finite State Entropy decoder is expected to keep going when the bits run out, and the
125
+ * specification says outright that the missing bits are taken as zero. Whether the stream ended
126
+ * where it should is a question the caller answers from {@link is_exhausted}.
127
+ *
128
+ * @param {number} count `0` to `32`
129
+ * @returns {number}
130
+ */
131
+ read(count) {
132
+ const value = this.peek(count);
133
+
134
+ this.#bit -= count;
135
+
136
+ return value;
137
+ }
138
+
139
+ /**
140
+ * Drop `count` bits without reading them.
141
+ *
142
+ * @param {number} count
143
+ */
144
+ consume(count) {
145
+ this.#bit -= count;
146
+ }
147
+
148
+ /**
149
+ * Look at the next `count` bits without consuming them.
150
+ *
151
+ * Huffman decoding needs this: the table is indexed by the widest code, so a lookup reads more
152
+ * bits than the code turned out to use and gives the rest back.
153
+ *
154
+ * @param {number} count `0` to `32`
155
+ * @returns {number}
156
+ */
157
+ peek(count) {
158
+ if (count === 0) {
159
+ return 0;
160
+ }
161
+
162
+ if (count > MAX_SINGLE_READ) {
163
+ // split, keeping the first-read half the more significant one
164
+ const high = count - MAX_SINGLE_READ;
165
+
166
+ const upper = this.peek(high);
167
+
168
+ this.#bit -= high;
169
+
170
+ const lower = this.peek(MAX_SINGLE_READ);
171
+
172
+ this.#bit += high;
173
+
174
+ return upper * (2 ** MAX_SINGLE_READ) + lower;
175
+ }
176
+
177
+ const low_bit = this.#bit - count + 1;
178
+
179
+ if (low_bit + count <= 0) {
180
+ // entirely past the start
181
+ return 0;
182
+ }
183
+
184
+ let byte = this.#start + (low_bit >> 3);
185
+
186
+ let shift = low_bit & 7;
187
+
188
+ if (low_bit < 0) {
189
+ /*
190
+ Straddling the start. The bits below it are zero by the rule above, so the window is
191
+ taken from the first real byte and shifted up to put them there.
192
+ */
193
+ byte = this.#start;
194
+ shift = 0;
195
+
196
+ const value = this.#window(byte) << -low_bit;
197
+
198
+ return value & ((1 << count) - 1);
199
+ }
200
+
201
+ return (this.#window(byte) >>> shift) & ((1 << count) - 1);
202
+ }
203
+
204
+ /**
205
+ * Four bytes from `byte` as a little-endian value, zero past the end of the range.
206
+ *
207
+ * @param {number} byte
208
+ * @returns {number}
209
+ */
210
+ #window(byte) {
211
+ let value = 0;
212
+
213
+ for (let i = 0; i < 4; i++) {
214
+ const at = byte + i;
215
+
216
+ if (at >= this.#end || at < this.#start) {
217
+ continue;
218
+ }
219
+
220
+ value |= this.#data[at] << (i * 8);
221
+ }
222
+
223
+ return value >>> 0;
224
+ }
225
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"zstd_fse.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/zstd/zstd_fse.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,6CATW,UAAU,GAAC,MAAM,EAAE,gBACnB,MAAM,gBACN,MAAM,GACJ,YAAY,CAgFxB;AAED;;;;;;;;;;;;;GAaG;AACH,0CARW,UAAU,UACV,MAAM,OACN,MAAM,cACN,MAAM,oBACN,MAAM,GACJ;IAAC,KAAK,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CAkItD;AAED;;;;;GAKG;AACH,0CAHW,MAAM,GACJ,YAAY,CASxB;;;;;;;;;;;;kBAjQa,MAAM;;;;YAEN,UAAU;;;;UACV,UAAU;;;;cACV,WAAW"}
1
+ {"version":3,"file":"zstd_fse.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/zstd/zstd_fse.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,6CATW,UAAU,GAAC,MAAM,EAAE,gBACnB,MAAM,gBACN,MAAM,GACJ,YAAY,CAgFxB;AAED;;;;;;;;;;;;;GAaG;AACH,0CARW,UAAU,UACV,MAAM,OACN,MAAM,cACN,MAAM,oBACN,MAAM,GACJ;IAAC,KAAK,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CAkItD;AAED;;;;;GAKG;AACH,0CAHW,MAAM,GACJ,YAAY,CASxB;;;;;;;;;;;;kBAjQa,MAAM;;;;YAEN,UAAU;;;;UACV,UAAU;;;;cACV,WAAW"}