@vfx-js/effects 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (631) hide show
  1. package/README.md +4 -0
  2. package/THIRD_PARTY_NOTICES.md +61 -0
  3. package/lib/cjs/_bloom-common.d.ts +31 -0
  4. package/lib/cjs/_bloom-common.js +101 -0
  5. package/lib/cjs/_bloom-common.js.map +1 -0
  6. package/lib/cjs/_bubble-fill.d.ts +126 -0
  7. package/lib/cjs/_bubble-fill.js +1044 -0
  8. package/lib/cjs/_bubble-fill.js.map +1 -0
  9. package/lib/cjs/_bubble-kernel-source.d.ts +2 -0
  10. package/lib/cjs/_bubble-kernel-source.js +8 -0
  11. package/lib/cjs/_bubble-kernel-source.js.map +1 -0
  12. package/lib/cjs/_holo/data/kernels.d.ts +4 -0
  13. package/lib/cjs/_holo/data/kernels.js +10 -0
  14. package/lib/cjs/_holo/data/kernels.js.map +1 -0
  15. package/lib/cjs/_holo/data/looks.d.ts +2 -0
  16. package/lib/cjs/_holo/data/looks.js +595 -0
  17. package/lib/cjs/_holo/data/looks.js.map +1 -0
  18. package/lib/cjs/_holo/data/ltc.d.ts +2 -0
  19. package/lib/cjs/_holo/data/ltc.js +11 -0
  20. package/lib/cjs/_holo/data/ltc.js.map +1 -0
  21. package/lib/cjs/_holo/data/material-presets.d.ts +3 -0
  22. package/lib/cjs/_holo/data/material-presets.js +75 -0
  23. package/lib/cjs/_holo/data/material-presets.js.map +1 -0
  24. package/lib/cjs/_holo/data/not-ported.d.ts +5 -0
  25. package/lib/cjs/_holo/data/not-ported.js +190 -0
  26. package/lib/cjs/_holo/data/not-ported.js.map +1 -0
  27. package/lib/cjs/_holo/data/params.d.ts +4 -0
  28. package/lib/cjs/_holo/data/params.js +1641 -0
  29. package/lib/cjs/_holo/data/params.js.map +1 -0
  30. package/lib/cjs/_holo/data/starting-points.d.ts +199 -0
  31. package/lib/cjs/_holo/data/starting-points.js +193 -0
  32. package/lib/cjs/_holo/data/starting-points.js.map +1 -0
  33. package/lib/cjs/_holo/data/studio-presets.d.ts +2 -0
  34. package/lib/cjs/_holo/data/studio-presets.js +177 -0
  35. package/lib/cjs/_holo/data/studio-presets.js.map +1 -0
  36. package/lib/cjs/_holo/emboss-assets.d.ts +55 -0
  37. package/lib/cjs/_holo/emboss-assets.js +155 -0
  38. package/lib/cjs/_holo/emboss-assets.js.map +1 -0
  39. package/lib/cjs/_holo/glare.d.ts +15 -0
  40. package/lib/cjs/_holo/glare.js +125 -0
  41. package/lib/cjs/_holo/glare.js.map +1 -0
  42. package/lib/cjs/_holo/glsl/coat.d.ts +2 -0
  43. package/lib/cjs/_holo/glsl/coat.js +32 -0
  44. package/lib/cjs/_holo/glsl/coat.js.map +1 -0
  45. package/lib/cjs/_holo/glsl/common.d.ts +2 -0
  46. package/lib/cjs/_holo/glsl/common.js +141 -0
  47. package/lib/cjs/_holo/glsl/common.js.map +1 -0
  48. package/lib/cjs/_holo/glsl/emboss.d.ts +2 -0
  49. package/lib/cjs/_holo/glsl/emboss.js +246 -0
  50. package/lib/cjs/_holo/glsl/emboss.js.map +1 -0
  51. package/lib/cjs/_holo/glsl/env.d.ts +2 -0
  52. package/lib/cjs/_holo/glsl/env.js +52 -0
  53. package/lib/cjs/_holo/glsl/env.js.map +1 -0
  54. package/lib/cjs/_holo/glsl/glare-down.d.ts +2 -0
  55. package/lib/cjs/_holo/glsl/glare-down.js +65 -0
  56. package/lib/cjs/_holo/glsl/glare-down.js.map +1 -0
  57. package/lib/cjs/_holo/glsl/glare-up.d.ts +2 -0
  58. package/lib/cjs/_holo/glsl/glare-up.js +18 -0
  59. package/lib/cjs/_holo/glsl/glare-up.js.map +1 -0
  60. package/lib/cjs/_holo/glsl/glitter.d.ts +2 -0
  61. package/lib/cjs/_holo/glsl/glitter.js +325 -0
  62. package/lib/cjs/_holo/glsl/glitter.js.map +1 -0
  63. package/lib/cjs/_holo/glsl/grating.d.ts +2 -0
  64. package/lib/cjs/_holo/glsl/grating.js +240 -0
  65. package/lib/cjs/_holo/glsl/grating.js.map +1 -0
  66. package/lib/cjs/_holo/glsl/holo-emboss.d.ts +2 -0
  67. package/lib/cjs/_holo/glsl/holo-emboss.js +296 -0
  68. package/lib/cjs/_holo/glsl/holo-emboss.js.map +1 -0
  69. package/lib/cjs/_holo/glsl/holo-nebula.d.ts +2 -0
  70. package/lib/cjs/_holo/glsl/holo-nebula.js +186 -0
  71. package/lib/cjs/_holo/glsl/holo-nebula.js.map +1 -0
  72. package/lib/cjs/_holo/glsl/holo-prism.d.ts +2 -0
  73. package/lib/cjs/_holo/glsl/holo-prism.js +183 -0
  74. package/lib/cjs/_holo/glsl/holo-prism.js.map +1 -0
  75. package/lib/cjs/_holo/glsl/holo-shatter.d.ts +2 -0
  76. package/lib/cjs/_holo/glsl/holo-shatter.js +328 -0
  77. package/lib/cjs/_holo/glsl/holo-shatter.js.map +1 -0
  78. package/lib/cjs/_holo/glsl/holo-sparkle.d.ts +2 -0
  79. package/lib/cjs/_holo/glsl/holo-sparkle.js +235 -0
  80. package/lib/cjs/_holo/glsl/holo-sparkle.js.map +1 -0
  81. package/lib/cjs/_holo/glsl/holo-vortex.d.ts +2 -0
  82. package/lib/cjs/_holo/glsl/holo-vortex.js +201 -0
  83. package/lib/cjs/_holo/glsl/holo-vortex.js.map +1 -0
  84. package/lib/cjs/_holo/glsl/ibl.d.ts +2 -0
  85. package/lib/cjs/_holo/glsl/ibl.js +79 -0
  86. package/lib/cjs/_holo/glsl/ibl.js.map +1 -0
  87. package/lib/cjs/_holo/glsl/lights.d.ts +2 -0
  88. package/lib/cjs/_holo/glsl/lights.js +125 -0
  89. package/lib/cjs/_holo/glsl/lights.js.map +1 -0
  90. package/lib/cjs/_holo/glsl/ltc.d.ts +2 -0
  91. package/lib/cjs/_holo/glsl/ltc.js +66 -0
  92. package/lib/cjs/_holo/glsl/ltc.js.map +1 -0
  93. package/lib/cjs/_holo/glsl/output.d.ts +2 -0
  94. package/lib/cjs/_holo/glsl/output.js +113 -0
  95. package/lib/cjs/_holo/glsl/output.js.map +1 -0
  96. package/lib/cjs/_holo/glsl/paper.d.ts +2 -0
  97. package/lib/cjs/_holo/glsl/paper.js +165 -0
  98. package/lib/cjs/_holo/glsl/paper.js.map +1 -0
  99. package/lib/cjs/_holo/glsl/relief.d.ts +2 -0
  100. package/lib/cjs/_holo/glsl/relief.js +103 -0
  101. package/lib/cjs/_holo/glsl/relief.js.map +1 -0
  102. package/lib/cjs/_holo/glsl/sparkle.d.ts +2 -0
  103. package/lib/cjs/_holo/glsl/sparkle.js +279 -0
  104. package/lib/cjs/_holo/glsl/sparkle.js.map +1 -0
  105. package/lib/cjs/_holo/glsl/spectral.d.ts +2 -0
  106. package/lib/cjs/_holo/glsl/spectral.js +60 -0
  107. package/lib/cjs/_holo/glsl/spectral.js.map +1 -0
  108. package/lib/cjs/_holo/glsl/wear.d.ts +2 -0
  109. package/lib/cjs/_holo/glsl/wear.js +107 -0
  110. package/lib/cjs/_holo/glsl/wear.js.map +1 -0
  111. package/lib/cjs/_holo/ltc.d.ts +9 -0
  112. package/lib/cjs/_holo/ltc.js +56 -0
  113. package/lib/cjs/_holo/ltc.js.map +1 -0
  114. package/lib/cjs/_holo/materials/build.d.ts +32 -0
  115. package/lib/cjs/_holo/materials/build.js +36 -0
  116. package/lib/cjs/_holo/materials/build.js.map +1 -0
  117. package/lib/cjs/_holo/materials/emboss.d.ts +22 -0
  118. package/lib/cjs/_holo/materials/emboss.js +205 -0
  119. package/lib/cjs/_holo/materials/emboss.js.map +1 -0
  120. package/lib/cjs/_holo/materials/nebula.d.ts +4 -0
  121. package/lib/cjs/_holo/materials/nebula.js +105 -0
  122. package/lib/cjs/_holo/materials/nebula.js.map +1 -0
  123. package/lib/cjs/_holo/materials/prism.d.ts +2 -0
  124. package/lib/cjs/_holo/materials/prism.js +69 -0
  125. package/lib/cjs/_holo/materials/prism.js.map +1 -0
  126. package/lib/cjs/_holo/materials/registry.d.ts +11 -0
  127. package/lib/cjs/_holo/materials/registry.js +88 -0
  128. package/lib/cjs/_holo/materials/registry.js.map +1 -0
  129. package/lib/cjs/_holo/materials/shatter.d.ts +2 -0
  130. package/lib/cjs/_holo/materials/shatter.js +80 -0
  131. package/lib/cjs/_holo/materials/shatter.js.map +1 -0
  132. package/lib/cjs/_holo/materials/sparkle.d.ts +2 -0
  133. package/lib/cjs/_holo/materials/sparkle.js +108 -0
  134. package/lib/cjs/_holo/materials/sparkle.js.map +1 -0
  135. package/lib/cjs/_holo/materials/vortex.d.ts +2 -0
  136. package/lib/cjs/_holo/materials/vortex.js +85 -0
  137. package/lib/cjs/_holo/materials/vortex.js.map +1 -0
  138. package/lib/cjs/_holo/physics/emboss.d.ts +39 -0
  139. package/lib/cjs/_holo/physics/emboss.js +95 -0
  140. package/lib/cjs/_holo/physics/emboss.js.map +1 -0
  141. package/lib/cjs/_holo/physics/geometry.d.ts +109 -0
  142. package/lib/cjs/_holo/physics/geometry.js +252 -0
  143. package/lib/cjs/_holo/physics/geometry.js.map +1 -0
  144. package/lib/cjs/_holo/physics/grating.d.ts +86 -0
  145. package/lib/cjs/_holo/physics/grating.js +328 -0
  146. package/lib/cjs/_holo/physics/grating.js.map +1 -0
  147. package/lib/cjs/_holo/physics/sparkle.d.ts +143 -0
  148. package/lib/cjs/_holo/physics/sparkle.js +388 -0
  149. package/lib/cjs/_holo/physics/sparkle.js.map +1 -0
  150. package/lib/cjs/_holo/scene/env.d.ts +17 -0
  151. package/lib/cjs/_holo/scene/env.js +151 -0
  152. package/lib/cjs/_holo/scene/env.js.map +1 -0
  153. package/lib/cjs/_holo/scene/lights.d.ts +13 -0
  154. package/lib/cjs/_holo/scene/lights.js +211 -0
  155. package/lib/cjs/_holo/scene/lights.js.map +1 -0
  156. package/lib/cjs/_holo/scene/logo.d.ts +87 -0
  157. package/lib/cjs/_holo/scene/logo.js +655 -0
  158. package/lib/cjs/_holo/scene/logo.js.map +1 -0
  159. package/lib/cjs/_holo/scene/paper-maps.d.ts +26 -0
  160. package/lib/cjs/_holo/scene/paper-maps.js +391 -0
  161. package/lib/cjs/_holo/scene/paper-maps.js.map +1 -0
  162. package/lib/cjs/_holo/scene/pose.d.ts +31 -0
  163. package/lib/cjs/_holo/scene/pose.js +77 -0
  164. package/lib/cjs/_holo/scene/pose.js.map +1 -0
  165. package/lib/cjs/_holo/scene/relief.d.ts +24 -0
  166. package/lib/cjs/_holo/scene/relief.js +148 -0
  167. package/lib/cjs/_holo/scene/relief.js.map +1 -0
  168. package/lib/cjs/_holo/settings-types.d.ts +20 -0
  169. package/lib/cjs/_holo/settings-types.js +3 -0
  170. package/lib/cjs/_holo/settings-types.js.map +1 -0
  171. package/lib/cjs/_holo/settings.d.ts +83 -0
  172. package/lib/cjs/_holo/settings.js +375 -0
  173. package/lib/cjs/_holo/settings.js.map +1 -0
  174. package/lib/cjs/_holo/shader.d.ts +23 -0
  175. package/lib/cjs/_holo/shader.js +219 -0
  176. package/lib/cjs/_holo/shader.js.map +1 -0
  177. package/lib/cjs/_holo/spectral/atlas.d.ts +36 -0
  178. package/lib/cjs/_holo/spectral/atlas.js +114 -0
  179. package/lib/cjs/_holo/spectral/atlas.js.map +1 -0
  180. package/lib/cjs/_holo/spectral/cmf.d.ts +67 -0
  181. package/lib/cjs/_holo/spectral/cmf.js +244 -0
  182. package/lib/cjs/_holo/spectral/cmf.js.map +1 -0
  183. package/lib/cjs/_holo/spectral/float24.d.ts +8 -0
  184. package/lib/cjs/_holo/spectral/float24.js +70 -0
  185. package/lib/cjs/_holo/spectral/float24.js.map +1 -0
  186. package/lib/cjs/_holo/spectral/spd.d.ts +22 -0
  187. package/lib/cjs/_holo/spectral/spd.js +139 -0
  188. package/lib/cjs/_holo/spectral/spd.js.map +1 -0
  189. package/lib/cjs/_holo/spectral/tables.d.ts +62 -0
  190. package/lib/cjs/_holo/spectral/tables.js +386 -0
  191. package/lib/cjs/_holo/spectral/tables.js.map +1 -0
  192. package/lib/cjs/_holo/tier.d.ts +4 -0
  193. package/lib/cjs/_holo/tier.js +110 -0
  194. package/lib/cjs/_holo/tier.js.map +1 -0
  195. package/lib/cjs/_holo/types.d.ts +148 -0
  196. package/lib/cjs/_holo/types.js +14 -0
  197. package/lib/cjs/_holo/types.js.map +1 -0
  198. package/lib/cjs/_kernel-worker.d.ts +22 -0
  199. package/lib/cjs/_kernel-worker.js +174 -0
  200. package/lib/cjs/_kernel-worker.js.map +1 -0
  201. package/lib/cjs/_orbit-camera.d.ts +175 -0
  202. package/lib/cjs/_orbit-camera.js +366 -0
  203. package/lib/cjs/_orbit-camera.js.map +1 -0
  204. package/lib/cjs/_pad.d.ts +2 -0
  205. package/lib/cjs/_pad.js +11 -0
  206. package/lib/cjs/_pad.js.map +1 -1
  207. package/lib/cjs/_scene3d.d.ts +101 -0
  208. package/lib/cjs/_scene3d.js +794 -0
  209. package/lib/cjs/_scene3d.js.map +1 -0
  210. package/lib/cjs/_shape-kernel-source.d.ts +2 -0
  211. package/lib/cjs/_shape-kernel-source.js +8 -0
  212. package/lib/cjs/_shape-kernel-source.js.map +1 -0
  213. package/lib/cjs/_shape-worker.d.ts +8 -0
  214. package/lib/cjs/_shape-worker.js +27 -0
  215. package/lib/cjs/_shape-worker.js.map +1 -0
  216. package/lib/cjs/_silhouette.d.ts +88 -0
  217. package/lib/cjs/_silhouette.js +441 -0
  218. package/lib/cjs/_silhouette.js.map +1 -0
  219. package/lib/cjs/_simplex3.d.ts +2 -0
  220. package/lib/cjs/_simplex3.js +160 -0
  221. package/lib/cjs/_simplex3.js.map +1 -0
  222. package/lib/cjs/_source.d.ts +80 -0
  223. package/lib/cjs/_source.js +192 -0
  224. package/lib/cjs/_source.js.map +1 -0
  225. package/lib/cjs/_sphere-foam.d.ts +34 -0
  226. package/lib/cjs/_sphere-foam.js +135 -0
  227. package/lib/cjs/_sphere-foam.js.map +1 -0
  228. package/lib/cjs/_thin-film.d.ts +26 -0
  229. package/lib/cjs/_thin-film.js +146 -0
  230. package/lib/cjs/_thin-film.js.map +1 -0
  231. package/lib/cjs/ascii.js +63 -73
  232. package/lib/cjs/ascii.js.map +1 -1
  233. package/lib/cjs/bad-jpeg.js +7 -5
  234. package/lib/cjs/bad-jpeg.js.map +1 -1
  235. package/lib/cjs/bloom.js +59 -135
  236. package/lib/cjs/bloom.js.map +1 -1
  237. package/lib/cjs/bubble.d.ts +284 -0
  238. package/lib/cjs/bubble.js +1820 -0
  239. package/lib/cjs/bubble.js.map +1 -0
  240. package/lib/cjs/chromatic.js +1 -0
  241. package/lib/cjs/chromatic.js.map +1 -1
  242. package/lib/cjs/colored-edges.js +1 -0
  243. package/lib/cjs/colored-edges.js.map +1 -1
  244. package/lib/cjs/datamosh.js +173 -183
  245. package/lib/cjs/datamosh.js.map +1 -1
  246. package/lib/cjs/dither.js +6 -3
  247. package/lib/cjs/dither.js.map +1 -1
  248. package/lib/cjs/duotone.js +4 -2
  249. package/lib/cjs/duotone.js.map +1 -1
  250. package/lib/cjs/fluid.js +62 -74
  251. package/lib/cjs/fluid.js.map +1 -1
  252. package/lib/cjs/glass.d.ts +254 -0
  253. package/lib/cjs/glass.js +981 -0
  254. package/lib/cjs/glass.js.map +1 -0
  255. package/lib/cjs/glitch.js +1 -0
  256. package/lib/cjs/glitch.js.map +1 -1
  257. package/lib/cjs/gradient-map.js +4 -1
  258. package/lib/cjs/gradient-map.js.map +1 -1
  259. package/lib/cjs/halftone.js +3 -0
  260. package/lib/cjs/halftone.js.map +1 -1
  261. package/lib/cjs/holo-static.d.ts +3 -0
  262. package/lib/cjs/holo-static.js +29 -0
  263. package/lib/cjs/holo-static.js.map +1 -0
  264. package/lib/cjs/holo.d.ts +401 -0
  265. package/lib/cjs/holo.js +1613 -0
  266. package/lib/cjs/holo.js.map +1 -0
  267. package/lib/cjs/hue-shift.js +1 -0
  268. package/lib/cjs/hue-shift.js.map +1 -1
  269. package/lib/cjs/index.d.ts +18 -9
  270. package/lib/cjs/index.js +12 -1
  271. package/lib/cjs/index.js.map +1 -1
  272. package/lib/cjs/jpeg-glitch.js +275 -276
  273. package/lib/cjs/jpeg-glitch.js.map +1 -1
  274. package/lib/cjs/light-streak.js +34 -47
  275. package/lib/cjs/light-streak.js.map +1 -1
  276. package/lib/cjs/matrix.d.ts +1 -1
  277. package/lib/cjs/matrix.js +48 -59
  278. package/lib/cjs/matrix.js.map +1 -1
  279. package/lib/cjs/package.json +20 -4
  280. package/lib/cjs/particle-explode.js +122 -128
  281. package/lib/cjs/particle-explode.js.map +1 -1
  282. package/lib/cjs/particle.js +253 -258
  283. package/lib/cjs/particle.js.map +1 -1
  284. package/lib/cjs/pattern-refraction.js +1 -0
  285. package/lib/cjs/pattern-refraction.js.map +1 -1
  286. package/lib/cjs/pixel-stretch.js +1 -0
  287. package/lib/cjs/pixel-stretch.js.map +1 -1
  288. package/lib/cjs/pixelate.js +1 -0
  289. package/lib/cjs/pixelate.js.map +1 -1
  290. package/lib/cjs/pixelsort.js +102 -121
  291. package/lib/cjs/pixelsort.js.map +1 -1
  292. package/lib/cjs/rainbow.js +1 -0
  293. package/lib/cjs/rainbow.js.map +1 -1
  294. package/lib/cjs/rgb-glitch.js +1 -0
  295. package/lib/cjs/rgb-glitch.js.map +1 -1
  296. package/lib/cjs/rgb-shift.js +1 -0
  297. package/lib/cjs/rgb-shift.js.map +1 -1
  298. package/lib/cjs/scanline.js +1 -0
  299. package/lib/cjs/scanline.js.map +1 -1
  300. package/lib/cjs/sinewave.js +1 -0
  301. package/lib/cjs/sinewave.js.map +1 -1
  302. package/lib/cjs/slice-shift.js +1 -0
  303. package/lib/cjs/slice-shift.js.map +1 -1
  304. package/lib/cjs/swirl-particle.d.ts +257 -0
  305. package/lib/cjs/swirl-particle.js +2346 -0
  306. package/lib/cjs/swirl-particle.js.map +1 -0
  307. package/lib/cjs/tile-pixelate.js +4 -1
  308. package/lib/cjs/tile-pixelate.js.map +1 -1
  309. package/lib/cjs/tritone.js +5 -2
  310. package/lib/cjs/tritone.js.map +1 -1
  311. package/lib/cjs/vignette.js +1 -0
  312. package/lib/cjs/vignette.js.map +1 -1
  313. package/lib/cjs/voronoi.js +6 -76
  314. package/lib/cjs/voronoi.js.map +1 -1
  315. package/lib/cjs/warp.js +1 -0
  316. package/lib/cjs/warp.js.map +1 -1
  317. package/lib/esm/_bloom-common.d.ts +31 -0
  318. package/lib/esm/_bloom-common.js +95 -0
  319. package/lib/esm/_bloom-common.js.map +1 -0
  320. package/lib/esm/_bubble-fill.d.ts +126 -0
  321. package/lib/esm/_bubble-fill.js +1039 -0
  322. package/lib/esm/_bubble-fill.js.map +1 -0
  323. package/lib/esm/_bubble-kernel-source.d.ts +2 -0
  324. package/lib/esm/_bubble-kernel-source.js +5 -0
  325. package/lib/esm/_bubble-kernel-source.js.map +1 -0
  326. package/lib/esm/_holo/data/kernels.d.ts +4 -0
  327. package/lib/esm/_holo/data/kernels.js +7 -0
  328. package/lib/esm/_holo/data/kernels.js.map +1 -0
  329. package/lib/esm/_holo/data/looks.d.ts +2 -0
  330. package/lib/esm/_holo/data/looks.js +592 -0
  331. package/lib/esm/_holo/data/looks.js.map +1 -0
  332. package/lib/esm/_holo/data/ltc.d.ts +2 -0
  333. package/lib/esm/_holo/data/ltc.js +8 -0
  334. package/lib/esm/_holo/data/ltc.js.map +1 -0
  335. package/lib/esm/_holo/data/material-presets.d.ts +3 -0
  336. package/lib/esm/_holo/data/material-presets.js +72 -0
  337. package/lib/esm/_holo/data/material-presets.js.map +1 -0
  338. package/lib/esm/_holo/data/not-ported.d.ts +5 -0
  339. package/lib/esm/_holo/data/not-ported.js +187 -0
  340. package/lib/esm/_holo/data/not-ported.js.map +1 -0
  341. package/lib/esm/_holo/data/params.d.ts +4 -0
  342. package/lib/esm/_holo/data/params.js +1638 -0
  343. package/lib/esm/_holo/data/params.js.map +1 -0
  344. package/lib/esm/_holo/data/starting-points.d.ts +199 -0
  345. package/lib/esm/_holo/data/starting-points.js +190 -0
  346. package/lib/esm/_holo/data/starting-points.js.map +1 -0
  347. package/lib/esm/_holo/data/studio-presets.d.ts +2 -0
  348. package/lib/esm/_holo/data/studio-presets.js +174 -0
  349. package/lib/esm/_holo/data/studio-presets.js.map +1 -0
  350. package/lib/esm/_holo/emboss-assets.d.ts +55 -0
  351. package/lib/esm/_holo/emboss-assets.js +150 -0
  352. package/lib/esm/_holo/emboss-assets.js.map +1 -0
  353. package/lib/esm/_holo/glare.d.ts +15 -0
  354. package/lib/esm/_holo/glare.js +117 -0
  355. package/lib/esm/_holo/glare.js.map +1 -0
  356. package/lib/esm/_holo/glsl/coat.d.ts +2 -0
  357. package/lib/esm/_holo/glsl/coat.js +30 -0
  358. package/lib/esm/_holo/glsl/coat.js.map +1 -0
  359. package/lib/esm/_holo/glsl/common.d.ts +2 -0
  360. package/lib/esm/_holo/glsl/common.js +139 -0
  361. package/lib/esm/_holo/glsl/common.js.map +1 -0
  362. package/lib/esm/_holo/glsl/emboss.d.ts +2 -0
  363. package/lib/esm/_holo/glsl/emboss.js +244 -0
  364. package/lib/esm/_holo/glsl/emboss.js.map +1 -0
  365. package/lib/esm/_holo/glsl/env.d.ts +2 -0
  366. package/lib/esm/_holo/glsl/env.js +50 -0
  367. package/lib/esm/_holo/glsl/env.js.map +1 -0
  368. package/lib/esm/_holo/glsl/glare-down.d.ts +2 -0
  369. package/lib/esm/_holo/glsl/glare-down.js +63 -0
  370. package/lib/esm/_holo/glsl/glare-down.js.map +1 -0
  371. package/lib/esm/_holo/glsl/glare-up.d.ts +2 -0
  372. package/lib/esm/_holo/glsl/glare-up.js +16 -0
  373. package/lib/esm/_holo/glsl/glare-up.js.map +1 -0
  374. package/lib/esm/_holo/glsl/glitter.d.ts +2 -0
  375. package/lib/esm/_holo/glsl/glitter.js +323 -0
  376. package/lib/esm/_holo/glsl/glitter.js.map +1 -0
  377. package/lib/esm/_holo/glsl/grating.d.ts +2 -0
  378. package/lib/esm/_holo/glsl/grating.js +238 -0
  379. package/lib/esm/_holo/glsl/grating.js.map +1 -0
  380. package/lib/esm/_holo/glsl/holo-emboss.d.ts +2 -0
  381. package/lib/esm/_holo/glsl/holo-emboss.js +294 -0
  382. package/lib/esm/_holo/glsl/holo-emboss.js.map +1 -0
  383. package/lib/esm/_holo/glsl/holo-nebula.d.ts +2 -0
  384. package/lib/esm/_holo/glsl/holo-nebula.js +184 -0
  385. package/lib/esm/_holo/glsl/holo-nebula.js.map +1 -0
  386. package/lib/esm/_holo/glsl/holo-prism.d.ts +2 -0
  387. package/lib/esm/_holo/glsl/holo-prism.js +181 -0
  388. package/lib/esm/_holo/glsl/holo-prism.js.map +1 -0
  389. package/lib/esm/_holo/glsl/holo-shatter.d.ts +2 -0
  390. package/lib/esm/_holo/glsl/holo-shatter.js +326 -0
  391. package/lib/esm/_holo/glsl/holo-shatter.js.map +1 -0
  392. package/lib/esm/_holo/glsl/holo-sparkle.d.ts +2 -0
  393. package/lib/esm/_holo/glsl/holo-sparkle.js +233 -0
  394. package/lib/esm/_holo/glsl/holo-sparkle.js.map +1 -0
  395. package/lib/esm/_holo/glsl/holo-vortex.d.ts +2 -0
  396. package/lib/esm/_holo/glsl/holo-vortex.js +199 -0
  397. package/lib/esm/_holo/glsl/holo-vortex.js.map +1 -0
  398. package/lib/esm/_holo/glsl/ibl.d.ts +2 -0
  399. package/lib/esm/_holo/glsl/ibl.js +77 -0
  400. package/lib/esm/_holo/glsl/ibl.js.map +1 -0
  401. package/lib/esm/_holo/glsl/lights.d.ts +2 -0
  402. package/lib/esm/_holo/glsl/lights.js +123 -0
  403. package/lib/esm/_holo/glsl/lights.js.map +1 -0
  404. package/lib/esm/_holo/glsl/ltc.d.ts +2 -0
  405. package/lib/esm/_holo/glsl/ltc.js +64 -0
  406. package/lib/esm/_holo/glsl/ltc.js.map +1 -0
  407. package/lib/esm/_holo/glsl/output.d.ts +2 -0
  408. package/lib/esm/_holo/glsl/output.js +111 -0
  409. package/lib/esm/_holo/glsl/output.js.map +1 -0
  410. package/lib/esm/_holo/glsl/paper.d.ts +2 -0
  411. package/lib/esm/_holo/glsl/paper.js +163 -0
  412. package/lib/esm/_holo/glsl/paper.js.map +1 -0
  413. package/lib/esm/_holo/glsl/relief.d.ts +2 -0
  414. package/lib/esm/_holo/glsl/relief.js +101 -0
  415. package/lib/esm/_holo/glsl/relief.js.map +1 -0
  416. package/lib/esm/_holo/glsl/sparkle.d.ts +2 -0
  417. package/lib/esm/_holo/glsl/sparkle.js +277 -0
  418. package/lib/esm/_holo/glsl/sparkle.js.map +1 -0
  419. package/lib/esm/_holo/glsl/spectral.d.ts +2 -0
  420. package/lib/esm/_holo/glsl/spectral.js +58 -0
  421. package/lib/esm/_holo/glsl/spectral.js.map +1 -0
  422. package/lib/esm/_holo/glsl/wear.d.ts +2 -0
  423. package/lib/esm/_holo/glsl/wear.js +105 -0
  424. package/lib/esm/_holo/glsl/wear.js.map +1 -0
  425. package/lib/esm/_holo/ltc.d.ts +9 -0
  426. package/lib/esm/_holo/ltc.js +52 -0
  427. package/lib/esm/_holo/ltc.js.map +1 -0
  428. package/lib/esm/_holo/materials/build.d.ts +32 -0
  429. package/lib/esm/_holo/materials/build.js +30 -0
  430. package/lib/esm/_holo/materials/build.js.map +1 -0
  431. package/lib/esm/_holo/materials/emboss.d.ts +22 -0
  432. package/lib/esm/_holo/materials/emboss.js +198 -0
  433. package/lib/esm/_holo/materials/emboss.js.map +1 -0
  434. package/lib/esm/_holo/materials/nebula.d.ts +4 -0
  435. package/lib/esm/_holo/materials/nebula.js +98 -0
  436. package/lib/esm/_holo/materials/nebula.js.map +1 -0
  437. package/lib/esm/_holo/materials/prism.d.ts +2 -0
  438. package/lib/esm/_holo/materials/prism.js +63 -0
  439. package/lib/esm/_holo/materials/prism.js.map +1 -0
  440. package/lib/esm/_holo/materials/registry.d.ts +11 -0
  441. package/lib/esm/_holo/materials/registry.js +48 -0
  442. package/lib/esm/_holo/materials/registry.js.map +1 -0
  443. package/lib/esm/_holo/materials/shatter.d.ts +2 -0
  444. package/lib/esm/_holo/materials/shatter.js +74 -0
  445. package/lib/esm/_holo/materials/shatter.js.map +1 -0
  446. package/lib/esm/_holo/materials/sparkle.d.ts +2 -0
  447. package/lib/esm/_holo/materials/sparkle.js +102 -0
  448. package/lib/esm/_holo/materials/sparkle.js.map +1 -0
  449. package/lib/esm/_holo/materials/vortex.d.ts +2 -0
  450. package/lib/esm/_holo/materials/vortex.js +79 -0
  451. package/lib/esm/_holo/materials/vortex.js.map +1 -0
  452. package/lib/esm/_holo/physics/emboss.d.ts +39 -0
  453. package/lib/esm/_holo/physics/emboss.js +89 -0
  454. package/lib/esm/_holo/physics/emboss.js.map +1 -0
  455. package/lib/esm/_holo/physics/geometry.d.ts +109 -0
  456. package/lib/esm/_holo/physics/geometry.js +228 -0
  457. package/lib/esm/_holo/physics/geometry.js.map +1 -0
  458. package/lib/esm/_holo/physics/grating.d.ts +86 -0
  459. package/lib/esm/_holo/physics/grating.js +313 -0
  460. package/lib/esm/_holo/physics/grating.js.map +1 -0
  461. package/lib/esm/_holo/physics/sparkle.d.ts +143 -0
  462. package/lib/esm/_holo/physics/sparkle.js +360 -0
  463. package/lib/esm/_holo/physics/sparkle.js.map +1 -0
  464. package/lib/esm/_holo/scene/env.d.ts +17 -0
  465. package/lib/esm/_holo/scene/env.js +141 -0
  466. package/lib/esm/_holo/scene/env.js.map +1 -0
  467. package/lib/esm/_holo/scene/lights.d.ts +13 -0
  468. package/lib/esm/_holo/scene/lights.js +204 -0
  469. package/lib/esm/_holo/scene/lights.js.map +1 -0
  470. package/lib/esm/_holo/scene/logo.d.ts +87 -0
  471. package/lib/esm/_holo/scene/logo.js +645 -0
  472. package/lib/esm/_holo/scene/logo.js.map +1 -0
  473. package/lib/esm/_holo/scene/paper-maps.d.ts +26 -0
  474. package/lib/esm/_holo/scene/paper-maps.js +387 -0
  475. package/lib/esm/_holo/scene/paper-maps.js.map +1 -0
  476. package/lib/esm/_holo/scene/pose.d.ts +31 -0
  477. package/lib/esm/_holo/scene/pose.js +71 -0
  478. package/lib/esm/_holo/scene/pose.js.map +1 -0
  479. package/lib/esm/_holo/scene/relief.d.ts +24 -0
  480. package/lib/esm/_holo/scene/relief.js +142 -0
  481. package/lib/esm/_holo/scene/relief.js.map +1 -0
  482. package/lib/esm/_holo/settings-types.d.ts +20 -0
  483. package/lib/esm/_holo/settings-types.js +2 -0
  484. package/lib/esm/_holo/settings-types.js.map +1 -0
  485. package/lib/esm/_holo/settings.d.ts +83 -0
  486. package/lib/esm/_holo/settings.js +358 -0
  487. package/lib/esm/_holo/settings.js.map +1 -0
  488. package/lib/esm/_holo/shader.d.ts +23 -0
  489. package/lib/esm/_holo/shader.js +211 -0
  490. package/lib/esm/_holo/shader.js.map +1 -0
  491. package/lib/esm/_holo/spectral/atlas.d.ts +36 -0
  492. package/lib/esm/_holo/spectral/atlas.js +110 -0
  493. package/lib/esm/_holo/spectral/atlas.js.map +1 -0
  494. package/lib/esm/_holo/spectral/cmf.d.ts +67 -0
  495. package/lib/esm/_holo/spectral/cmf.js +230 -0
  496. package/lib/esm/_holo/spectral/cmf.js.map +1 -0
  497. package/lib/esm/_holo/spectral/float24.d.ts +8 -0
  498. package/lib/esm/_holo/spectral/float24.js +64 -0
  499. package/lib/esm/_holo/spectral/float24.js.map +1 -0
  500. package/lib/esm/_holo/spectral/spd.d.ts +22 -0
  501. package/lib/esm/_holo/spectral/spd.js +130 -0
  502. package/lib/esm/_holo/spectral/spd.js.map +1 -0
  503. package/lib/esm/_holo/spectral/tables.d.ts +62 -0
  504. package/lib/esm/_holo/spectral/tables.js +372 -0
  505. package/lib/esm/_holo/spectral/tables.js.map +1 -0
  506. package/lib/esm/_holo/tier.d.ts +4 -0
  507. package/lib/esm/_holo/tier.js +106 -0
  508. package/lib/esm/_holo/tier.js.map +1 -0
  509. package/lib/esm/_holo/types.d.ts +148 -0
  510. package/lib/esm/_holo/types.js +11 -0
  511. package/lib/esm/_holo/types.js.map +1 -0
  512. package/lib/esm/_kernel-worker.d.ts +22 -0
  513. package/lib/esm/_kernel-worker.js +169 -0
  514. package/lib/esm/_kernel-worker.js.map +1 -0
  515. package/lib/esm/_orbit-camera.d.ts +175 -0
  516. package/lib/esm/_orbit-camera.js +360 -0
  517. package/lib/esm/_orbit-camera.js.map +1 -0
  518. package/lib/esm/_pad.d.ts +2 -0
  519. package/lib/esm/_pad.js +10 -0
  520. package/lib/esm/_pad.js.map +1 -1
  521. package/lib/esm/_scene3d.d.ts +101 -0
  522. package/lib/esm/_scene3d.js +783 -0
  523. package/lib/esm/_scene3d.js.map +1 -0
  524. package/lib/esm/_shape-kernel-source.d.ts +2 -0
  525. package/lib/esm/_shape-kernel-source.js +5 -0
  526. package/lib/esm/_shape-kernel-source.js.map +1 -0
  527. package/lib/esm/_shape-worker.d.ts +8 -0
  528. package/lib/esm/_shape-worker.js +23 -0
  529. package/lib/esm/_shape-worker.js.map +1 -0
  530. package/lib/esm/_silhouette.d.ts +88 -0
  531. package/lib/esm/_silhouette.js +436 -0
  532. package/lib/esm/_silhouette.js.map +1 -0
  533. package/lib/esm/_simplex3.d.ts +2 -0
  534. package/lib/esm/_simplex3.js +157 -0
  535. package/lib/esm/_simplex3.js.map +1 -0
  536. package/lib/esm/_source.d.ts +80 -0
  537. package/lib/esm/_source.js +187 -0
  538. package/lib/esm/_source.js.map +1 -0
  539. package/lib/esm/_sphere-foam.d.ts +34 -0
  540. package/lib/esm/_sphere-foam.js +131 -0
  541. package/lib/esm/_sphere-foam.js.map +1 -0
  542. package/lib/esm/_thin-film.d.ts +26 -0
  543. package/lib/esm/_thin-film.js +140 -0
  544. package/lib/esm/_thin-film.js.map +1 -0
  545. package/lib/esm/ascii.js +63 -73
  546. package/lib/esm/ascii.js.map +1 -1
  547. package/lib/esm/bad-jpeg.js +7 -5
  548. package/lib/esm/bad-jpeg.js.map +1 -1
  549. package/lib/esm/bloom.js +59 -135
  550. package/lib/esm/bloom.js.map +1 -1
  551. package/lib/esm/bubble.d.ts +284 -0
  552. package/lib/esm/bubble.js +1816 -0
  553. package/lib/esm/bubble.js.map +1 -0
  554. package/lib/esm/chromatic.js +1 -0
  555. package/lib/esm/chromatic.js.map +1 -1
  556. package/lib/esm/colored-edges.js +1 -0
  557. package/lib/esm/colored-edges.js.map +1 -1
  558. package/lib/esm/datamosh.js +172 -182
  559. package/lib/esm/datamosh.js.map +1 -1
  560. package/lib/esm/dither.js +6 -3
  561. package/lib/esm/dither.js.map +1 -1
  562. package/lib/esm/duotone.js +4 -2
  563. package/lib/esm/duotone.js.map +1 -1
  564. package/lib/esm/fluid.js +62 -74
  565. package/lib/esm/fluid.js.map +1 -1
  566. package/lib/esm/glass.d.ts +254 -0
  567. package/lib/esm/glass.js +977 -0
  568. package/lib/esm/glass.js.map +1 -0
  569. package/lib/esm/glitch.js +1 -0
  570. package/lib/esm/glitch.js.map +1 -1
  571. package/lib/esm/gradient-map.js +4 -1
  572. package/lib/esm/gradient-map.js.map +1 -1
  573. package/lib/esm/halftone.js +3 -0
  574. package/lib/esm/halftone.js.map +1 -1
  575. package/lib/esm/holo-static.d.ts +3 -0
  576. package/lib/esm/holo-static.js +13 -0
  577. package/lib/esm/holo-static.js.map +1 -0
  578. package/lib/esm/holo.d.ts +401 -0
  579. package/lib/esm/holo.js +1606 -0
  580. package/lib/esm/holo.js.map +1 -0
  581. package/lib/esm/hue-shift.js +1 -0
  582. package/lib/esm/hue-shift.js.map +1 -1
  583. package/lib/esm/index.d.ts +18 -9
  584. package/lib/esm/index.js +7 -2
  585. package/lib/esm/index.js.map +1 -1
  586. package/lib/esm/jpeg-glitch.js +274 -275
  587. package/lib/esm/jpeg-glitch.js.map +1 -1
  588. package/lib/esm/light-streak.js +34 -47
  589. package/lib/esm/light-streak.js.map +1 -1
  590. package/lib/esm/matrix.d.ts +1 -1
  591. package/lib/esm/matrix.js +48 -59
  592. package/lib/esm/matrix.js.map +1 -1
  593. package/lib/esm/package.json +20 -4
  594. package/lib/esm/particle-explode.js +122 -128
  595. package/lib/esm/particle-explode.js.map +1 -1
  596. package/lib/esm/particle.js +253 -258
  597. package/lib/esm/particle.js.map +1 -1
  598. package/lib/esm/pattern-refraction.js +1 -0
  599. package/lib/esm/pattern-refraction.js.map +1 -1
  600. package/lib/esm/pixel-stretch.js +1 -0
  601. package/lib/esm/pixel-stretch.js.map +1 -1
  602. package/lib/esm/pixelate.js +1 -0
  603. package/lib/esm/pixelate.js.map +1 -1
  604. package/lib/esm/pixelsort.js +102 -121
  605. package/lib/esm/pixelsort.js.map +1 -1
  606. package/lib/esm/rainbow.js +1 -0
  607. package/lib/esm/rainbow.js.map +1 -1
  608. package/lib/esm/rgb-glitch.js +1 -0
  609. package/lib/esm/rgb-glitch.js.map +1 -1
  610. package/lib/esm/rgb-shift.js +1 -0
  611. package/lib/esm/rgb-shift.js.map +1 -1
  612. package/lib/esm/scanline.js +1 -0
  613. package/lib/esm/scanline.js.map +1 -1
  614. package/lib/esm/sinewave.js +1 -0
  615. package/lib/esm/sinewave.js.map +1 -1
  616. package/lib/esm/slice-shift.js +1 -0
  617. package/lib/esm/slice-shift.js.map +1 -1
  618. package/lib/esm/swirl-particle.d.ts +257 -0
  619. package/lib/esm/swirl-particle.js +2342 -0
  620. package/lib/esm/swirl-particle.js.map +1 -0
  621. package/lib/esm/tile-pixelate.js +4 -1
  622. package/lib/esm/tile-pixelate.js.map +1 -1
  623. package/lib/esm/tritone.js +5 -2
  624. package/lib/esm/tritone.js.map +1 -1
  625. package/lib/esm/vignette.js +1 -0
  626. package/lib/esm/vignette.js.map +1 -1
  627. package/lib/esm/voronoi.js +6 -76
  628. package/lib/esm/voronoi.js.map +1 -1
  629. package/lib/esm/warp.js +1 -0
  630. package/lib/esm/warp.js.map +1 -1
  631. package/package.json +38 -10
@@ -1,21 +1,9 @@
1
1
  "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
- if (kind === "m") throw new TypeError("Private method is not writable");
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
- };
13
- var _JPEGGlitchEffect_instances, _JPEGGlitchEffect_supported, _JPEGGlitchEffect_readRT, _JPEGGlitchEffect_outTex, _JPEGGlitchEffect_gl, _JPEGGlitchEffect_outGLTex, _JPEGGlitchEffect_uploadPending, _JPEGGlitchEffect_restoreUnsub, _JPEGGlitchEffect_srcCanvas, _JPEGGlitchEffect_srcCtx, _JPEGGlitchEffect_encCanvas, _JPEGGlitchEffect_encCtx, _JPEGGlitchEffect_outCanvas, _JPEGGlitchEffect_outCtx, _JPEGGlitchEffect_raw, _JPEGGlitchEffect_imageData, _JPEGGlitchEffect_w, _JPEGGlitchEffect_h, _JPEGGlitchEffect_srcW, _JPEGGlitchEffect_srcH, _JPEGGlitchEffect_dirty, _JPEGGlitchEffect_busy, _JPEGGlitchEffect_lastGlitchTime, _JPEGGlitchEffect_generation, _JPEGGlitchEffect_glitchCount, _JPEGGlitchEffect_hasResult, _JPEGGlitchEffect_producedFrames, _JPEGGlitchEffect_createOutTexture, _JPEGGlitchEffect_passthrough, _JPEGGlitchEffect_shouldGlitch, _JPEGGlitchEffect_resize, _JPEGGlitchEffect_startGlitch, _JPEGGlitchEffect_uploadOutCanvas, _JPEGGlitchEffect_runGlitch;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.JPEGGlitchEffect = void 0;
16
4
  const _capture_js_1 = require("./_capture.js");
17
5
  // Passthrough of the live source to the canvas (used until the first
18
- // glitch result is ready). Premultiplied for the canvas blend.
6
+ // glitch result is ready). `src` is already premultiplied.
19
7
  const FRAG_PASSTHROUGH = `#version 300 es
20
8
  precision highp float;
21
9
  in vec2 uvSrc;
@@ -28,8 +16,7 @@ void main() {
28
16
  outColor = vec4(0.0);
29
17
  return;
30
18
  }
31
- vec4 c = texture(src, uvSrc);
32
- outColor = vec4(c.rgb * c.a, c.a);
19
+ outColor = texture(src, uvSrc);
33
20
  }
34
21
  `;
35
22
  // Draw the decoded glitch canvas (element-sized, upright) to the canvas.
@@ -176,109 +163,132 @@ function glitchBytes(bytes, headerLength, iterations, rng) {
176
163
  * render loop. The source passes through until the first result lands.
177
164
  */
178
165
  class JPEGGlitchEffect {
166
+ params;
167
+ enabled = true;
168
+ #supported = false;
169
+ #readRT = null;
170
+ #outTex = null;
171
+ // Raw GL handles for the on-demand display-texture upload.
172
+ #gl = null;
173
+ // Display texture we upload `outCanvas` into only when a new glitch
174
+ // lands, instead of re-uploading the canvas every frame.
175
+ #outGLTex = null;
176
+ #uploadPending = false;
177
+ #restoreUnsub = null;
178
+ #srcCanvas = null;
179
+ #srcCtx = null;
180
+ // Holds the (optionally rotated) image that actually gets encoded; its
181
+ // size is set per-glitch since a quarter turn swaps width and height.
182
+ #encCanvas = null;
183
+ #encCtx = null;
184
+ #outCanvas = null;
185
+ #outCtx = null;
186
+ #imageData = null;
187
+ #w = 0;
188
+ #h = 0;
189
+ // Source native size last seen — a change (e.g. an image finishing
190
+ // loading) re-arms a static glitch so it doesn't latch a blank frame.
191
+ #srcW = 0;
192
+ #srcH = 0;
193
+ // Re-glitch when a static frame's inputs change (params / resize).
194
+ #dirty = true;
195
+ // An encode/decode round trip is in flight; gate new glitches on it.
196
+ #busy = false;
197
+ // Last glitch start time (seconds), for the `speed` throttle.
198
+ #lastGlitchTime = -1e9;
199
+ // Bumped on resize so a stale in-flight result is discarded.
200
+ #generation = 0;
201
+ // Drives the animated seed walk when `speed > 0`.
202
+ #glitchCount = 0;
203
+ #hasResult = false;
204
+ // Number of decoded glitch results produced. Increments once per
205
+ // completed encode/decode round trip — sample it to measure the real
206
+ // output rate, which is capped by codec latency below high `speed`.
207
+ #producedFrames = 0;
179
208
  /** Count of decoded glitch results produced so far. */
180
209
  get producedFrames() {
181
- return __classPrivateFieldGet(this, _JPEGGlitchEffect_producedFrames, "f");
210
+ return this.#producedFrames;
182
211
  }
183
212
  constructor(initial = {}) {
184
- _JPEGGlitchEffect_instances.add(this);
185
- this.enabled = true;
186
- _JPEGGlitchEffect_supported.set(this, false);
187
- _JPEGGlitchEffect_readRT.set(this, null);
188
- _JPEGGlitchEffect_outTex.set(this, null);
189
- // Raw GL handles for the on-demand display-texture upload.
190
- _JPEGGlitchEffect_gl.set(this, null);
191
- // Display texture we upload `outCanvas` into only when a new glitch
192
- // lands, instead of re-uploading the canvas every frame.
193
- _JPEGGlitchEffect_outGLTex.set(this, null);
194
- _JPEGGlitchEffect_uploadPending.set(this, false);
195
- _JPEGGlitchEffect_restoreUnsub.set(this, null);
196
- _JPEGGlitchEffect_srcCanvas.set(this, null);
197
- _JPEGGlitchEffect_srcCtx.set(this, null);
198
- // Holds the (optionally rotated) image that actually gets encoded; its
199
- // size is set per-glitch since a quarter turn swaps width and height.
200
- _JPEGGlitchEffect_encCanvas.set(this, null);
201
- _JPEGGlitchEffect_encCtx.set(this, null);
202
- _JPEGGlitchEffect_outCanvas.set(this, null);
203
- _JPEGGlitchEffect_outCtx.set(this, null);
204
- _JPEGGlitchEffect_raw.set(this, new Uint8Array(0));
205
- _JPEGGlitchEffect_imageData.set(this, null);
206
- _JPEGGlitchEffect_w.set(this, 0);
207
- _JPEGGlitchEffect_h.set(this, 0);
208
- // Source native size last seen — a change (e.g. an image finishing
209
- // loading) re-arms a static glitch so it doesn't latch a blank frame.
210
- _JPEGGlitchEffect_srcW.set(this, 0);
211
- _JPEGGlitchEffect_srcH.set(this, 0);
212
- // Re-glitch when a static frame's inputs change (params / resize).
213
- _JPEGGlitchEffect_dirty.set(this, true);
214
- // An encode/decode round trip is in flight; gate new glitches on it.
215
- _JPEGGlitchEffect_busy.set(this, false);
216
- // Last glitch start time (seconds), for the `speed` throttle.
217
- _JPEGGlitchEffect_lastGlitchTime.set(this, -1e9);
218
- // Bumped on resize so a stale in-flight result is discarded.
219
- _JPEGGlitchEffect_generation.set(this, 0);
220
- // Drives the animated seed walk when `speed > 0`.
221
- _JPEGGlitchEffect_glitchCount.set(this, 0);
222
- _JPEGGlitchEffect_hasResult.set(this, false);
223
- // Number of decoded glitch results produced. Increments once per
224
- // completed encode/decode round trip — sample it to measure the real
225
- // output rate, which is capped by codec latency below high `speed`.
226
- _JPEGGlitchEffect_producedFrames.set(this, 0);
227
213
  this.params = { ...DEFAULT_PARAMS, ...initial };
228
214
  }
229
215
  setParams(updates) {
230
216
  Object.assign(this.params, updates);
231
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
217
+ this.#dirty = true;
232
218
  }
233
219
  init(ctx) {
234
- __classPrivateFieldSet(this, _JPEGGlitchEffect_supported, typeof createImageBitmap === "function" &&
235
- (typeof OffscreenCanvas !== "undefined" ||
236
- typeof document !== "undefined"), "f");
237
- if (!__classPrivateFieldGet(this, _JPEGGlitchEffect_supported, "f")) {
220
+ this.#supported =
221
+ typeof createImageBitmap === "function" &&
222
+ (typeof OffscreenCanvas !== "undefined" ||
223
+ typeof document !== "undefined");
224
+ if (!this.#supported) {
238
225
  return;
239
226
  }
240
227
  // The element's time base restarts at 0 on each (re-)attach.
241
- __classPrivateFieldSet(this, _JPEGGlitchEffect_lastGlitchTime, -1e9, "f");
242
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
243
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCanvas, createCanvas(1, 1), "f");
244
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f")), "f");
245
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCanvas, createCanvas(1, 1), "f");
246
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_encCanvas, "f")), "f");
247
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCanvas, createCanvas(1, 1), "f");
248
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")), "f");
228
+ this.#lastGlitchTime = -1e9;
229
+ this.#dirty = true;
230
+ this.#srcCanvas = createCanvas(1, 1);
231
+ this.#srcCtx = get2d(this.#srcCanvas);
232
+ this.#encCanvas = createCanvas(1, 1);
233
+ this.#encCtx = get2d(this.#encCanvas);
234
+ this.#outCanvas = createCanvas(1, 1);
235
+ this.#outCtx = get2d(this.#outCanvas);
249
236
  // Sized to the processing resolution in #resize; start at 1×1.
250
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, ctx.createRenderTarget({ size: [1, 1] }), "f");
251
- __classPrivateFieldSet(this, _JPEGGlitchEffect_gl, ctx.gl, "f");
252
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_createOutTexture).call(this, ctx);
237
+ this.#readRT = ctx.createRenderTarget({ size: [1, 1] });
238
+ this.#gl = ctx.gl;
239
+ this.#createOutTexture(ctx);
253
240
  // The display texture dies on context loss; rebuild it.
254
- __classPrivateFieldSet(this, _JPEGGlitchEffect_restoreUnsub, ctx.onContextRestored(() => {
255
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_createOutTexture).call(this, ctx);
241
+ this.#restoreUnsub = ctx.onContextRestored(() => {
242
+ this.#createOutTexture(ctx);
256
243
  // Re-push the last decoded frame, if any.
257
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, __classPrivateFieldGet(this, _JPEGGlitchEffect_hasResult, "f"), "f");
258
- }), "f");
244
+ this.#uploadPending = this.#hasResult;
245
+ });
246
+ }
247
+ // Create (or recreate) the display texture and wrap it for sampling.
248
+ // We own the GL handle and upload into it manually, so context-loss
249
+ // rebuilds are our responsibility.
250
+ #createOutTexture(ctx) {
251
+ const gl = ctx.gl;
252
+ const tex = gl.createTexture();
253
+ if (!tex) {
254
+ return;
255
+ }
256
+ gl.bindTexture(gl.TEXTURE_2D, tex);
257
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
258
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
259
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
260
+ // Nearest mag so low resolutionScale upscales crisp, not blurry.
261
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
262
+ // 1×1 placeholder so the sampler is valid before the first upload.
263
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
264
+ gl.bindTexture(gl.TEXTURE_2D, null);
265
+ this.#outGLTex = tex;
266
+ this.#outTex = ctx.wrapTexture(tex, {
267
+ size: [this.#w || 1, this.#h || 1],
268
+ });
259
269
  }
260
270
  // update() runs even while disabled (the chain only skips render); drop
261
271
  // the cached glitch so re-enabling starts clean instead of flashing it.
262
272
  update() {
263
273
  if (this.enabled === false) {
264
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
274
+ this.#hasResult = false;
265
275
  }
266
276
  }
267
277
  render(ctx) {
268
- if (this.params.bypass || !__classPrivateFieldGet(this, _JPEGGlitchEffect_supported, "f") || !__classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")) {
278
+ if (this.params.bypass || !this.#supported || !this.#readRT) {
269
279
  // Drop any stale decoded frame so re-enabling starts clean rather
270
280
  // than flashing the last glitch.
271
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
272
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_passthrough).call(this, ctx);
281
+ this.#hasResult = false;
282
+ this.#passthrough(ctx);
273
283
  return;
274
284
  }
275
285
  // Re-arm a static glitch when the source first loads / changes size.
276
286
  const srcW = ctx.src.width;
277
287
  const srcH = ctx.src.height;
278
- if (srcW !== __classPrivateFieldGet(this, _JPEGGlitchEffect_srcW, "f") || srcH !== __classPrivateFieldGet(this, _JPEGGlitchEffect_srcH, "f")) {
279
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcW, srcW, "f");
280
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcH, srcH, "f");
281
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
288
+ if (srcW !== this.#srcW || srcH !== this.#srcH) {
289
+ this.#srcW = srcW;
290
+ this.#srcH = srcH;
291
+ this.#dirty = true;
282
292
  }
283
293
  // Process at a fraction of the element resolution. The decoded
284
294
  // output is sampled by uvContent so it scales back up to fit.
@@ -287,216 +297,205 @@ class JPEGGlitchEffect {
287
297
  const w = Math.max(1, Math.round(ew * scale));
288
298
  const h = Math.max(1, Math.round(eh * scale));
289
299
  if (ew >= 2 && eh >= 2 && srcW > 0 && srcH > 0) {
290
- if (w !== __classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f") || h !== __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f")) {
291
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_resize).call(this, ctx, w, h);
300
+ if (w !== this.#w || h !== this.#h) {
301
+ this.#resize(ctx, w, h);
292
302
  }
293
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_shouldGlitch).call(this, ctx)) {
294
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_startGlitch).call(this, ctx);
303
+ if (this.#shouldGlitch(ctx)) {
304
+ this.#startGlitch(ctx);
295
305
  }
296
306
  }
297
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_hasResult, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outTex, "f")) {
307
+ if (this.#hasResult && this.#outTex) {
298
308
  // Upload the decoded canvas to the GPU only when it changed.
299
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_uploadPending, "f")) {
300
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_uploadOutCanvas).call(this, ctx);
309
+ if (this.#uploadPending) {
310
+ this.#uploadOutCanvas(ctx);
301
311
  }
302
312
  ctx.draw({
303
313
  frag: FRAG_OUTPUT,
304
- uniforms: { tex: __classPrivateFieldGet(this, _JPEGGlitchEffect_outTex, "f") },
314
+ uniforms: { tex: this.#outTex },
305
315
  target: ctx.target,
306
316
  });
307
317
  }
308
318
  else {
309
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_passthrough).call(this, ctx);
319
+ this.#passthrough(ctx);
310
320
  }
311
321
  }
312
- dispose() {
313
- var _a;
314
- __classPrivateFieldGet(this, _JPEGGlitchEffect_restoreUnsub, "f")?.call(this);
315
- __classPrivateFieldSet(this, _JPEGGlitchEffect_restoreUnsub, null, "f");
316
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_gl, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f")) {
317
- __classPrivateFieldGet(this, _JPEGGlitchEffect_gl, "f").deleteTexture(__classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f"));
318
- }
319
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outGLTex, null, "f");
320
- __classPrivateFieldSet(this, _JPEGGlitchEffect_gl, null, "f");
321
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
322
- __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")?.dispose();
323
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, null, "f");
324
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outTex, null, "f");
325
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCanvas, null, "f");
326
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCtx, null, "f");
327
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCanvas, null, "f");
328
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCtx, null, "f");
329
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCanvas, null, "f");
330
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCtx, null, "f");
331
- __classPrivateFieldSet(this, _JPEGGlitchEffect_imageData, null, "f");
332
- __classPrivateFieldSet(this, _JPEGGlitchEffect_raw, new Uint8Array(0), "f");
333
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
334
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
335
- // Forget the processed size so a re-init reallocates the readback RT
336
- // (which dispose just freed) instead of mistaking it for current.
337
- __classPrivateFieldSet(this, _JPEGGlitchEffect_w, 0, "f");
338
- __classPrivateFieldSet(this, _JPEGGlitchEffect_h, 0, "f");
339
- // Invalidate any in-flight round trip.
340
- __classPrivateFieldSet(this, _JPEGGlitchEffect_generation, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"), _a++, _a), "f");
322
+ #passthrough(ctx) {
323
+ ctx.draw({
324
+ frag: FRAG_PASSTHROUGH,
325
+ uniforms: { src: ctx.src },
326
+ target: ctx.target,
327
+ });
341
328
  }
342
- }
343
- exports.JPEGGlitchEffect = JPEGGlitchEffect;
344
- _JPEGGlitchEffect_supported = new WeakMap(), _JPEGGlitchEffect_readRT = new WeakMap(), _JPEGGlitchEffect_outTex = new WeakMap(), _JPEGGlitchEffect_gl = new WeakMap(), _JPEGGlitchEffect_outGLTex = new WeakMap(), _JPEGGlitchEffect_uploadPending = new WeakMap(), _JPEGGlitchEffect_restoreUnsub = new WeakMap(), _JPEGGlitchEffect_srcCanvas = new WeakMap(), _JPEGGlitchEffect_srcCtx = new WeakMap(), _JPEGGlitchEffect_encCanvas = new WeakMap(), _JPEGGlitchEffect_encCtx = new WeakMap(), _JPEGGlitchEffect_outCanvas = new WeakMap(), _JPEGGlitchEffect_outCtx = new WeakMap(), _JPEGGlitchEffect_raw = new WeakMap(), _JPEGGlitchEffect_imageData = new WeakMap(), _JPEGGlitchEffect_w = new WeakMap(), _JPEGGlitchEffect_h = new WeakMap(), _JPEGGlitchEffect_srcW = new WeakMap(), _JPEGGlitchEffect_srcH = new WeakMap(), _JPEGGlitchEffect_dirty = new WeakMap(), _JPEGGlitchEffect_busy = new WeakMap(), _JPEGGlitchEffect_lastGlitchTime = new WeakMap(), _JPEGGlitchEffect_generation = new WeakMap(), _JPEGGlitchEffect_glitchCount = new WeakMap(), _JPEGGlitchEffect_hasResult = new WeakMap(), _JPEGGlitchEffect_producedFrames = new WeakMap(), _JPEGGlitchEffect_instances = new WeakSet(), _JPEGGlitchEffect_createOutTexture = function _JPEGGlitchEffect_createOutTexture(ctx) {
345
- const gl = ctx.gl;
346
- const tex = gl.createTexture();
347
- if (!tex) {
348
- return;
349
- }
350
- gl.bindTexture(gl.TEXTURE_2D, tex);
351
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
352
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
353
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
354
- // Nearest mag so low resolutionScale upscales crisp, not blurry.
355
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
356
- // 1×1 placeholder so the sampler is valid before the first upload.
357
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
358
- gl.bindTexture(gl.TEXTURE_2D, null);
359
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outGLTex, tex, "f");
360
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outTex, ctx.wrapTexture(tex, {
361
- size: [__classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f") || 1, __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f") || 1],
362
- }), "f");
363
- }, _JPEGGlitchEffect_passthrough = function _JPEGGlitchEffect_passthrough(ctx) {
364
- ctx.draw({
365
- frag: FRAG_PASSTHROUGH,
366
- uniforms: { src: ctx.src },
367
- target: ctx.target,
368
- });
369
- }, _JPEGGlitchEffect_shouldGlitch = function _JPEGGlitchEffect_shouldGlitch(ctx) {
370
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_busy, "f")) {
371
- return false;
372
- }
373
- const speed = this.params.speed;
374
- if (speed > 0) {
375
- return ctx.time - __classPrivateFieldGet(this, _JPEGGlitchEffect_lastGlitchTime, "f") >= 1 / speed;
376
- }
377
- return __classPrivateFieldGet(this, _JPEGGlitchEffect_dirty, "f");
378
- }, _JPEGGlitchEffect_resize = function _JPEGGlitchEffect_resize(ctx, w, h) {
379
- var _a;
380
- __classPrivateFieldSet(this, _JPEGGlitchEffect_w, w, "f");
381
- __classPrivateFieldSet(this, _JPEGGlitchEffect_h, h, "f");
382
- __classPrivateFieldSet(this, _JPEGGlitchEffect_raw, new Uint8Array(w * h * 4), "f");
383
- __classPrivateFieldSet(this, _JPEGGlitchEffect_imageData, new ImageData(w, h), "f");
384
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f")) {
385
- __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f").width = w;
386
- __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f").height = h;
387
- }
388
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")) {
389
- __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f").width = w;
390
- __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f").height = h;
391
- }
392
- // The readback RT is sized to the processing resolution, so recreate
393
- // it (explicit-size RTs don't auto-track the element).
394
- __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")?.dispose();
395
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, ctx.createRenderTarget({ size: [w, h] }), "f");
396
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
397
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
398
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
399
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
400
- __classPrivateFieldSet(this, _JPEGGlitchEffect_generation, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"), _a++, _a), "f");
401
- }, _JPEGGlitchEffect_startGlitch = function _JPEGGlitchEffect_startGlitch(ctx) {
402
- var _a;
403
- const w = __classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f");
404
- const h = __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f");
405
- const srcCanvas = __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f");
406
- const srcCtx = __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCtx, "f");
407
- const encCanvas = __classPrivateFieldGet(this, _JPEGGlitchEffect_encCanvas, "f");
408
- const encCtx = __classPrivateFieldGet(this, _JPEGGlitchEffect_encCtx, "f");
409
- const imageData = __classPrivateFieldGet(this, _JPEGGlitchEffect_imageData, "f");
410
- if (!srcCanvas ||
411
- !srcCtx ||
412
- !encCanvas ||
413
- !encCtx ||
414
- !imageData ||
415
- !__classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")) {
416
- return;
329
+ #shouldGlitch(ctx) {
330
+ if (this.#busy) {
331
+ return false;
332
+ }
333
+ const speed = this.params.speed;
334
+ if (speed > 0) {
335
+ return ctx.time - this.#lastGlitchTime >= 1 / speed;
336
+ }
337
+ return this.#dirty;
417
338
  }
418
- // Read the element capture back to the CPU. The draw leaves the
419
- // readback RT's framebuffer bound, so readPixels reads from it.
420
- (0, _capture_js_1.captureContent)(ctx, __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f"));
421
- const gl = ctx.gl;
422
- gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, __classPrivateFieldGet(this, _JPEGGlitchEffect_raw, "f"));
423
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
424
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, true, "f");
425
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, false, "f");
426
- __classPrivateFieldSet(this, _JPEGGlitchEffect_lastGlitchTime, ctx.time, "f");
427
- // GL framebuffers are bottom-up; flip rows so the canvas is upright.
428
- // Force opaque alpha — JPEG has no alpha channel.
429
- const data = imageData.data;
430
- const rowBytes = w * 4;
431
- for (let y = 0; y < h; y++) {
432
- const srcRow = (h - 1 - y) * rowBytes;
433
- data.set(__classPrivateFieldGet(this, _JPEGGlitchEffect_raw, "f").subarray(srcRow, srcRow + rowBytes), y * rowBytes);
339
+ #resize(ctx, w, h) {
340
+ this.#w = w;
341
+ this.#h = h;
342
+ this.#imageData = new ImageData(w, h);
343
+ if (this.#srcCanvas) {
344
+ this.#srcCanvas.width = w;
345
+ this.#srcCanvas.height = h;
346
+ }
347
+ if (this.#outCanvas) {
348
+ this.#outCanvas.width = w;
349
+ this.#outCanvas.height = h;
350
+ }
351
+ // The readback RT is sized to the processing resolution, so recreate
352
+ // it (explicit-size RTs don't auto-track the element).
353
+ this.#readRT?.dispose();
354
+ this.#readRT = ctx.createRenderTarget({ size: [w, h] });
355
+ this.#hasResult = false;
356
+ this.#dirty = true;
357
+ this.#busy = false;
358
+ this.#uploadPending = false;
359
+ this.#generation++;
434
360
  }
435
- for (let i = 3; i < data.length; i += 4) {
436
- data[i] = 255;
361
+ #startGlitch(ctx) {
362
+ const readRT = this.#readRT;
363
+ if (!readRT) {
364
+ return;
365
+ }
366
+ (0, _capture_js_1.captureContent)(ctx, readRT);
367
+ this.#busy = true;
368
+ this.#dirty = false;
369
+ this.#lastGlitchTime = ctx.time;
370
+ // Static glitch (speed 0) stays on variant 0 so it's reproducible;
371
+ // animated glitch advances the variant each round.
372
+ const variant = this.params.speed > 0 ? this.#glitchCount : 0;
373
+ this.#glitchCount++;
374
+ // Read the capture back to the CPU without stalling the GPU. Rows
375
+ // come top-down, ready for ImageData.
376
+ const generation = this.#generation;
377
+ ctx.readPixels(readRT, { flipY: true }).then((raw) => {
378
+ if (generation === this.#generation) {
379
+ this.#glitchPixels(raw, variant, generation);
380
+ }
381
+ }, () => {
382
+ // Disposed or context lost: nothing to glitch.
383
+ if (generation === this.#generation) {
384
+ this.#busy = false;
385
+ }
386
+ });
437
387
  }
438
- // Static glitch (speed 0) stays on variant 0 so it's reproducible;
439
- // animated glitch advances the variant each round.
440
- const variant = this.params.speed > 0 ? __classPrivateFieldGet(this, _JPEGGlitchEffect_glitchCount, "f") : 0;
441
- __classPrivateFieldSet(this, _JPEGGlitchEffect_glitchCount, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_glitchCount, "f"), _a++, _a), "f");
442
- const { quality, seed, iterations, randomFlip, vertical } = this.params;
443
- // One seeded sequence drives both the flip decision and the byte
444
- // corruption, so the whole glitch is reproducible from the seed.
445
- const rng = makeRng(seed, variant);
446
- const flip = randomFlip && rng() < 0.5;
447
- srcCtx.putImageData(imageData, 0, 0);
448
- // Rotate the source before corrupting: 180° (flip) balances the tear
449
- // direction, -90° (vertical, i.e. 270°) turns the tears sideways.
450
- // The angles compose; runGlitch rotates the decoded output back.
451
- const srcAngle = ((flip ? 180 : 0) + (vertical ? 270 : 0)) % 360;
452
- const swap = vertical; // a quarter turn swaps width and height
453
- const encW = swap ? h : w;
454
- const encH = swap ? w : h;
455
- encCanvas.width = encW;
456
- encCanvas.height = encH;
457
- drawRotated(encCtx, srcCanvas, w, h, srcAngle, encW, encH);
458
- void __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_runGlitch).call(this, encCanvas, w, h, quality, iterations, srcAngle, rng, __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"));
459
- }, _JPEGGlitchEffect_uploadOutCanvas = function _JPEGGlitchEffect_uploadOutCanvas(ctx) {
460
- const gl = ctx.gl;
461
- if (!__classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f") || !__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")) {
462
- return;
388
+ // Corrupt the read-back pixels through the JPEG codec (async).
389
+ #glitchPixels(raw, variant, generation) {
390
+ const w = this.#w;
391
+ const h = this.#h;
392
+ const srcCanvas = this.#srcCanvas;
393
+ const srcCtx = this.#srcCtx;
394
+ const encCanvas = this.#encCanvas;
395
+ const encCtx = this.#encCtx;
396
+ const imageData = this.#imageData;
397
+ if (!srcCanvas || !srcCtx || !encCanvas || !encCtx || !imageData) {
398
+ this.#busy = false;
399
+ return;
400
+ }
401
+ // Force opaque alpha — JPEG has no alpha channel.
402
+ const data = imageData.data;
403
+ data.set(raw);
404
+ for (let i = 3; i < data.length; i += 4) {
405
+ data[i] = 255;
406
+ }
407
+ const { quality, seed, iterations, randomFlip, vertical } = this.params;
408
+ // One seeded sequence drives both the flip decision and the byte
409
+ // corruption, so the whole glitch is reproducible from the seed.
410
+ const rng = makeRng(seed, variant);
411
+ const flip = randomFlip && rng() < 0.5;
412
+ srcCtx.putImageData(imageData, 0, 0);
413
+ // Rotate the source before corrupting: 180° (flip) balances the tear
414
+ // direction, -90° (vertical, i.e. 270°) turns the tears sideways.
415
+ // The angles compose; runGlitch rotates the decoded output back.
416
+ const srcAngle = ((flip ? 180 : 0) + (vertical ? 270 : 0)) % 360;
417
+ const swap = vertical; // a quarter turn swaps width and height
418
+ const encW = swap ? h : w;
419
+ const encH = swap ? w : h;
420
+ encCanvas.width = encW;
421
+ encCanvas.height = encH;
422
+ drawRotated(encCtx, srcCanvas, w, h, srcAngle, encW, encH);
423
+ void this.#runGlitch(encCanvas, w, h, quality, iterations, srcAngle, rng, generation);
463
424
  }
464
- gl.bindTexture(gl.TEXTURE_2D, __classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f"));
465
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
466
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
467
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f"));
468
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
469
- gl.bindTexture(gl.TEXTURE_2D, null);
470
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
471
- }, _JPEGGlitchEffect_runGlitch = async function _JPEGGlitchEffect_runGlitch(canvas, w, h, quality, iterations, srcAngle, rng, generation) {
472
- var _a;
473
- try {
474
- const blob = await canvasToJpegBlob(canvas, quality);
475
- const bytes = new Uint8Array(await blob.arrayBuffer());
476
- const header = jpegScanStart(bytes);
477
- glitchBytes(bytes, header, iterations, rng);
478
- const bmp = await createImageBitmap(new Blob([bytes], { type: "image/jpeg" }));
479
- // Discard if a resize happened while we were encoding/decoding.
480
- if (generation === __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outCtx, "f")) {
481
- // Rotate the decoded glitch back upright (inverse of the
482
- // source rotation) into the w×h output canvas.
483
- const outAngle = (360 - srcAngle) % 360;
484
- drawRotated(__classPrivateFieldGet(this, _JPEGGlitchEffect_outCtx, "f"), bmp, bmp.width, bmp.height, outAngle, w, h);
485
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, true, "f");
486
- __classPrivateFieldSet(this, _JPEGGlitchEffect_producedFrames, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_producedFrames, "f"), _a++, _a), "f");
487
- // New pixels — upload to the display texture on the next draw.
488
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, true, "f");
425
+ // Upload the decoded glitch canvas into our display texture. FLIP_Y
426
+ // matches the framework's canvas-as-image convention so FRAG_OUTPUT
427
+ // (which samples by uvContent) shows it upright.
428
+ #uploadOutCanvas(ctx) {
429
+ const gl = ctx.gl;
430
+ if (!this.#outGLTex || !this.#outCanvas) {
431
+ return;
489
432
  }
490
- bmp.close();
433
+ gl.bindTexture(gl.TEXTURE_2D, this.#outGLTex);
434
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
435
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
436
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.#outCanvas);
437
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
438
+ gl.bindTexture(gl.TEXTURE_2D, null);
439
+ this.#uploadPending = false;
491
440
  }
492
- catch {
493
- // Corrupted past the decoder's tolerance — keep the last good
494
- // frame and try again on the next tick.
441
+ async #runGlitch(canvas, w, h, quality, iterations, srcAngle, rng, generation) {
442
+ try {
443
+ const blob = await canvasToJpegBlob(canvas, quality);
444
+ const bytes = new Uint8Array(await blob.arrayBuffer());
445
+ const header = jpegScanStart(bytes);
446
+ glitchBytes(bytes, header, iterations, rng);
447
+ const bmp = await createImageBitmap(new Blob([bytes], { type: "image/jpeg" }));
448
+ // Discard if a resize happened while we were encoding/decoding.
449
+ if (generation === this.#generation && this.#outCtx) {
450
+ // Rotate the decoded glitch back upright (inverse of the
451
+ // source rotation) into the w×h output canvas.
452
+ const outAngle = (360 - srcAngle) % 360;
453
+ drawRotated(this.#outCtx, bmp, bmp.width, bmp.height, outAngle, w, h);
454
+ this.#hasResult = true;
455
+ this.#producedFrames++;
456
+ // New pixels — upload to the display texture on the next draw.
457
+ this.#uploadPending = true;
458
+ }
459
+ bmp.close();
460
+ }
461
+ catch {
462
+ // Corrupted past the decoder's tolerance — keep the last good
463
+ // frame and try again on the next tick.
464
+ }
465
+ finally {
466
+ if (generation === this.#generation) {
467
+ this.#busy = false;
468
+ }
469
+ }
495
470
  }
496
- finally {
497
- if (generation === __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f")) {
498
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
471
+ dispose() {
472
+ this.#restoreUnsub?.();
473
+ this.#restoreUnsub = null;
474
+ if (this.#gl && this.#outGLTex) {
475
+ this.#gl.deleteTexture(this.#outGLTex);
499
476
  }
477
+ this.#outGLTex = null;
478
+ this.#gl = null;
479
+ this.#uploadPending = false;
480
+ this.#readRT?.dispose();
481
+ this.#readRT = null;
482
+ this.#outTex = null;
483
+ this.#srcCanvas = null;
484
+ this.#srcCtx = null;
485
+ this.#encCanvas = null;
486
+ this.#encCtx = null;
487
+ this.#outCanvas = null;
488
+ this.#outCtx = null;
489
+ this.#imageData = null;
490
+ this.#hasResult = false;
491
+ this.#busy = false;
492
+ // Forget the processed size so a re-init reallocates the readback RT
493
+ // (which dispose just freed) instead of mistaking it for current.
494
+ this.#w = 0;
495
+ this.#h = 0;
496
+ // Invalidate any in-flight round trip.
497
+ this.#generation++;
500
498
  }
501
- };
499
+ }
500
+ exports.JPEGGlitchEffect = JPEGGlitchEffect;
502
501
  //# sourceMappingURL=jpeg-glitch.js.map