@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,18 +1,6 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- 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");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- 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");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- 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;
13
1
  import { captureContent } from "./_capture.js";
14
2
  // Passthrough of the live source to the canvas (used until the first
15
- // glitch result is ready). Premultiplied for the canvas blend.
3
+ // glitch result is ready). `src` is already premultiplied.
16
4
  const FRAG_PASSTHROUGH = `#version 300 es
17
5
  precision highp float;
18
6
  in vec2 uvSrc;
@@ -25,8 +13,7 @@ void main() {
25
13
  outColor = vec4(0.0);
26
14
  return;
27
15
  }
28
- vec4 c = texture(src, uvSrc);
29
- outColor = vec4(c.rgb * c.a, c.a);
16
+ outColor = texture(src, uvSrc);
30
17
  }
31
18
  `;
32
19
  // Draw the decoded glitch canvas (element-sized, upright) to the canvas.
@@ -173,109 +160,132 @@ function glitchBytes(bytes, headerLength, iterations, rng) {
173
160
  * render loop. The source passes through until the first result lands.
174
161
  */
175
162
  export class JPEGGlitchEffect {
163
+ params;
164
+ enabled = true;
165
+ #supported = false;
166
+ #readRT = null;
167
+ #outTex = null;
168
+ // Raw GL handles for the on-demand display-texture upload.
169
+ #gl = null;
170
+ // Display texture we upload `outCanvas` into only when a new glitch
171
+ // lands, instead of re-uploading the canvas every frame.
172
+ #outGLTex = null;
173
+ #uploadPending = false;
174
+ #restoreUnsub = null;
175
+ #srcCanvas = null;
176
+ #srcCtx = null;
177
+ // Holds the (optionally rotated) image that actually gets encoded; its
178
+ // size is set per-glitch since a quarter turn swaps width and height.
179
+ #encCanvas = null;
180
+ #encCtx = null;
181
+ #outCanvas = null;
182
+ #outCtx = null;
183
+ #imageData = null;
184
+ #w = 0;
185
+ #h = 0;
186
+ // Source native size last seen — a change (e.g. an image finishing
187
+ // loading) re-arms a static glitch so it doesn't latch a blank frame.
188
+ #srcW = 0;
189
+ #srcH = 0;
190
+ // Re-glitch when a static frame's inputs change (params / resize).
191
+ #dirty = true;
192
+ // An encode/decode round trip is in flight; gate new glitches on it.
193
+ #busy = false;
194
+ // Last glitch start time (seconds), for the `speed` throttle.
195
+ #lastGlitchTime = -1e9;
196
+ // Bumped on resize so a stale in-flight result is discarded.
197
+ #generation = 0;
198
+ // Drives the animated seed walk when `speed > 0`.
199
+ #glitchCount = 0;
200
+ #hasResult = false;
201
+ // Number of decoded glitch results produced. Increments once per
202
+ // completed encode/decode round trip — sample it to measure the real
203
+ // output rate, which is capped by codec latency below high `speed`.
204
+ #producedFrames = 0;
176
205
  /** Count of decoded glitch results produced so far. */
177
206
  get producedFrames() {
178
- return __classPrivateFieldGet(this, _JPEGGlitchEffect_producedFrames, "f");
207
+ return this.#producedFrames;
179
208
  }
180
209
  constructor(initial = {}) {
181
- _JPEGGlitchEffect_instances.add(this);
182
- this.enabled = true;
183
- _JPEGGlitchEffect_supported.set(this, false);
184
- _JPEGGlitchEffect_readRT.set(this, null);
185
- _JPEGGlitchEffect_outTex.set(this, null);
186
- // Raw GL handles for the on-demand display-texture upload.
187
- _JPEGGlitchEffect_gl.set(this, null);
188
- // Display texture we upload `outCanvas` into only when a new glitch
189
- // lands, instead of re-uploading the canvas every frame.
190
- _JPEGGlitchEffect_outGLTex.set(this, null);
191
- _JPEGGlitchEffect_uploadPending.set(this, false);
192
- _JPEGGlitchEffect_restoreUnsub.set(this, null);
193
- _JPEGGlitchEffect_srcCanvas.set(this, null);
194
- _JPEGGlitchEffect_srcCtx.set(this, null);
195
- // Holds the (optionally rotated) image that actually gets encoded; its
196
- // size is set per-glitch since a quarter turn swaps width and height.
197
- _JPEGGlitchEffect_encCanvas.set(this, null);
198
- _JPEGGlitchEffect_encCtx.set(this, null);
199
- _JPEGGlitchEffect_outCanvas.set(this, null);
200
- _JPEGGlitchEffect_outCtx.set(this, null);
201
- _JPEGGlitchEffect_raw.set(this, new Uint8Array(0));
202
- _JPEGGlitchEffect_imageData.set(this, null);
203
- _JPEGGlitchEffect_w.set(this, 0);
204
- _JPEGGlitchEffect_h.set(this, 0);
205
- // Source native size last seen — a change (e.g. an image finishing
206
- // loading) re-arms a static glitch so it doesn't latch a blank frame.
207
- _JPEGGlitchEffect_srcW.set(this, 0);
208
- _JPEGGlitchEffect_srcH.set(this, 0);
209
- // Re-glitch when a static frame's inputs change (params / resize).
210
- _JPEGGlitchEffect_dirty.set(this, true);
211
- // An encode/decode round trip is in flight; gate new glitches on it.
212
- _JPEGGlitchEffect_busy.set(this, false);
213
- // Last glitch start time (seconds), for the `speed` throttle.
214
- _JPEGGlitchEffect_lastGlitchTime.set(this, -1e9);
215
- // Bumped on resize so a stale in-flight result is discarded.
216
- _JPEGGlitchEffect_generation.set(this, 0);
217
- // Drives the animated seed walk when `speed > 0`.
218
- _JPEGGlitchEffect_glitchCount.set(this, 0);
219
- _JPEGGlitchEffect_hasResult.set(this, false);
220
- // Number of decoded glitch results produced. Increments once per
221
- // completed encode/decode round trip — sample it to measure the real
222
- // output rate, which is capped by codec latency below high `speed`.
223
- _JPEGGlitchEffect_producedFrames.set(this, 0);
224
210
  this.params = { ...DEFAULT_PARAMS, ...initial };
225
211
  }
226
212
  setParams(updates) {
227
213
  Object.assign(this.params, updates);
228
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
214
+ this.#dirty = true;
229
215
  }
230
216
  init(ctx) {
231
- __classPrivateFieldSet(this, _JPEGGlitchEffect_supported, typeof createImageBitmap === "function" &&
232
- (typeof OffscreenCanvas !== "undefined" ||
233
- typeof document !== "undefined"), "f");
234
- if (!__classPrivateFieldGet(this, _JPEGGlitchEffect_supported, "f")) {
217
+ this.#supported =
218
+ typeof createImageBitmap === "function" &&
219
+ (typeof OffscreenCanvas !== "undefined" ||
220
+ typeof document !== "undefined");
221
+ if (!this.#supported) {
235
222
  return;
236
223
  }
237
224
  // The element's time base restarts at 0 on each (re-)attach.
238
- __classPrivateFieldSet(this, _JPEGGlitchEffect_lastGlitchTime, -1e9, "f");
239
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
240
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCanvas, createCanvas(1, 1), "f");
241
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f")), "f");
242
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCanvas, createCanvas(1, 1), "f");
243
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_encCanvas, "f")), "f");
244
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCanvas, createCanvas(1, 1), "f");
245
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCtx, get2d(__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")), "f");
225
+ this.#lastGlitchTime = -1e9;
226
+ this.#dirty = true;
227
+ this.#srcCanvas = createCanvas(1, 1);
228
+ this.#srcCtx = get2d(this.#srcCanvas);
229
+ this.#encCanvas = createCanvas(1, 1);
230
+ this.#encCtx = get2d(this.#encCanvas);
231
+ this.#outCanvas = createCanvas(1, 1);
232
+ this.#outCtx = get2d(this.#outCanvas);
246
233
  // Sized to the processing resolution in #resize; start at 1×1.
247
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, ctx.createRenderTarget({ size: [1, 1] }), "f");
248
- __classPrivateFieldSet(this, _JPEGGlitchEffect_gl, ctx.gl, "f");
249
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_createOutTexture).call(this, ctx);
234
+ this.#readRT = ctx.createRenderTarget({ size: [1, 1] });
235
+ this.#gl = ctx.gl;
236
+ this.#createOutTexture(ctx);
250
237
  // The display texture dies on context loss; rebuild it.
251
- __classPrivateFieldSet(this, _JPEGGlitchEffect_restoreUnsub, ctx.onContextRestored(() => {
252
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_createOutTexture).call(this, ctx);
238
+ this.#restoreUnsub = ctx.onContextRestored(() => {
239
+ this.#createOutTexture(ctx);
253
240
  // Re-push the last decoded frame, if any.
254
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, __classPrivateFieldGet(this, _JPEGGlitchEffect_hasResult, "f"), "f");
255
- }), "f");
241
+ this.#uploadPending = this.#hasResult;
242
+ });
243
+ }
244
+ // Create (or recreate) the display texture and wrap it for sampling.
245
+ // We own the GL handle and upload into it manually, so context-loss
246
+ // rebuilds are our responsibility.
247
+ #createOutTexture(ctx) {
248
+ const gl = ctx.gl;
249
+ const tex = gl.createTexture();
250
+ if (!tex) {
251
+ return;
252
+ }
253
+ gl.bindTexture(gl.TEXTURE_2D, tex);
254
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
255
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
256
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
257
+ // Nearest mag so low resolutionScale upscales crisp, not blurry.
258
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
259
+ // 1×1 placeholder so the sampler is valid before the first upload.
260
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
261
+ gl.bindTexture(gl.TEXTURE_2D, null);
262
+ this.#outGLTex = tex;
263
+ this.#outTex = ctx.wrapTexture(tex, {
264
+ size: [this.#w || 1, this.#h || 1],
265
+ });
256
266
  }
257
267
  // update() runs even while disabled (the chain only skips render); drop
258
268
  // the cached glitch so re-enabling starts clean instead of flashing it.
259
269
  update() {
260
270
  if (this.enabled === false) {
261
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
271
+ this.#hasResult = false;
262
272
  }
263
273
  }
264
274
  render(ctx) {
265
- if (this.params.bypass || !__classPrivateFieldGet(this, _JPEGGlitchEffect_supported, "f") || !__classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")) {
275
+ if (this.params.bypass || !this.#supported || !this.#readRT) {
266
276
  // Drop any stale decoded frame so re-enabling starts clean rather
267
277
  // than flashing the last glitch.
268
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
269
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_passthrough).call(this, ctx);
278
+ this.#hasResult = false;
279
+ this.#passthrough(ctx);
270
280
  return;
271
281
  }
272
282
  // Re-arm a static glitch when the source first loads / changes size.
273
283
  const srcW = ctx.src.width;
274
284
  const srcH = ctx.src.height;
275
- if (srcW !== __classPrivateFieldGet(this, _JPEGGlitchEffect_srcW, "f") || srcH !== __classPrivateFieldGet(this, _JPEGGlitchEffect_srcH, "f")) {
276
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcW, srcW, "f");
277
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcH, srcH, "f");
278
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
285
+ if (srcW !== this.#srcW || srcH !== this.#srcH) {
286
+ this.#srcW = srcW;
287
+ this.#srcH = srcH;
288
+ this.#dirty = true;
279
289
  }
280
290
  // Process at a fraction of the element resolution. The decoded
281
291
  // output is sampled by uvContent so it scales back up to fit.
@@ -284,215 +294,204 @@ export class JPEGGlitchEffect {
284
294
  const w = Math.max(1, Math.round(ew * scale));
285
295
  const h = Math.max(1, Math.round(eh * scale));
286
296
  if (ew >= 2 && eh >= 2 && srcW > 0 && srcH > 0) {
287
- if (w !== __classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f") || h !== __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f")) {
288
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_resize).call(this, ctx, w, h);
297
+ if (w !== this.#w || h !== this.#h) {
298
+ this.#resize(ctx, w, h);
289
299
  }
290
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_shouldGlitch).call(this, ctx)) {
291
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_startGlitch).call(this, ctx);
300
+ if (this.#shouldGlitch(ctx)) {
301
+ this.#startGlitch(ctx);
292
302
  }
293
303
  }
294
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_hasResult, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outTex, "f")) {
304
+ if (this.#hasResult && this.#outTex) {
295
305
  // Upload the decoded canvas to the GPU only when it changed.
296
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_uploadPending, "f")) {
297
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_uploadOutCanvas).call(this, ctx);
306
+ if (this.#uploadPending) {
307
+ this.#uploadOutCanvas(ctx);
298
308
  }
299
309
  ctx.draw({
300
310
  frag: FRAG_OUTPUT,
301
- uniforms: { tex: __classPrivateFieldGet(this, _JPEGGlitchEffect_outTex, "f") },
311
+ uniforms: { tex: this.#outTex },
302
312
  target: ctx.target,
303
313
  });
304
314
  }
305
315
  else {
306
- __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_passthrough).call(this, ctx);
316
+ this.#passthrough(ctx);
307
317
  }
308
318
  }
309
- dispose() {
310
- var _a;
311
- __classPrivateFieldGet(this, _JPEGGlitchEffect_restoreUnsub, "f")?.call(this);
312
- __classPrivateFieldSet(this, _JPEGGlitchEffect_restoreUnsub, null, "f");
313
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_gl, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f")) {
314
- __classPrivateFieldGet(this, _JPEGGlitchEffect_gl, "f").deleteTexture(__classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f"));
315
- }
316
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outGLTex, null, "f");
317
- __classPrivateFieldSet(this, _JPEGGlitchEffect_gl, null, "f");
318
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
319
- __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")?.dispose();
320
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, null, "f");
321
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outTex, null, "f");
322
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCanvas, null, "f");
323
- __classPrivateFieldSet(this, _JPEGGlitchEffect_srcCtx, null, "f");
324
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCanvas, null, "f");
325
- __classPrivateFieldSet(this, _JPEGGlitchEffect_encCtx, null, "f");
326
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCanvas, null, "f");
327
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outCtx, null, "f");
328
- __classPrivateFieldSet(this, _JPEGGlitchEffect_imageData, null, "f");
329
- __classPrivateFieldSet(this, _JPEGGlitchEffect_raw, new Uint8Array(0), "f");
330
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
331
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
332
- // Forget the processed size so a re-init reallocates the readback RT
333
- // (which dispose just freed) instead of mistaking it for current.
334
- __classPrivateFieldSet(this, _JPEGGlitchEffect_w, 0, "f");
335
- __classPrivateFieldSet(this, _JPEGGlitchEffect_h, 0, "f");
336
- // Invalidate any in-flight round trip.
337
- __classPrivateFieldSet(this, _JPEGGlitchEffect_generation, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"), _a++, _a), "f");
338
- }
339
- }
340
- _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) {
341
- const gl = ctx.gl;
342
- const tex = gl.createTexture();
343
- if (!tex) {
344
- return;
345
- }
346
- gl.bindTexture(gl.TEXTURE_2D, tex);
347
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
348
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
349
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
350
- // Nearest mag so low resolutionScale upscales crisp, not blurry.
351
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
352
- // 1×1 placeholder so the sampler is valid before the first upload.
353
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
354
- gl.bindTexture(gl.TEXTURE_2D, null);
355
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outGLTex, tex, "f");
356
- __classPrivateFieldSet(this, _JPEGGlitchEffect_outTex, ctx.wrapTexture(tex, {
357
- size: [__classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f") || 1, __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f") || 1],
358
- }), "f");
359
- }, _JPEGGlitchEffect_passthrough = function _JPEGGlitchEffect_passthrough(ctx) {
360
- ctx.draw({
361
- frag: FRAG_PASSTHROUGH,
362
- uniforms: { src: ctx.src },
363
- target: ctx.target,
364
- });
365
- }, _JPEGGlitchEffect_shouldGlitch = function _JPEGGlitchEffect_shouldGlitch(ctx) {
366
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_busy, "f")) {
367
- return false;
368
- }
369
- const speed = this.params.speed;
370
- if (speed > 0) {
371
- return ctx.time - __classPrivateFieldGet(this, _JPEGGlitchEffect_lastGlitchTime, "f") >= 1 / speed;
319
+ #passthrough(ctx) {
320
+ ctx.draw({
321
+ frag: FRAG_PASSTHROUGH,
322
+ uniforms: { src: ctx.src },
323
+ target: ctx.target,
324
+ });
372
325
  }
373
- return __classPrivateFieldGet(this, _JPEGGlitchEffect_dirty, "f");
374
- }, _JPEGGlitchEffect_resize = function _JPEGGlitchEffect_resize(ctx, w, h) {
375
- var _a;
376
- __classPrivateFieldSet(this, _JPEGGlitchEffect_w, w, "f");
377
- __classPrivateFieldSet(this, _JPEGGlitchEffect_h, h, "f");
378
- __classPrivateFieldSet(this, _JPEGGlitchEffect_raw, new Uint8Array(w * h * 4), "f");
379
- __classPrivateFieldSet(this, _JPEGGlitchEffect_imageData, new ImageData(w, h), "f");
380
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f")) {
381
- __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f").width = w;
382
- __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f").height = h;
383
- }
384
- if (__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")) {
385
- __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f").width = w;
386
- __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f").height = h;
387
- }
388
- // The readback RT is sized to the processing resolution, so recreate
389
- // it (explicit-size RTs don't auto-track the element).
390
- __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")?.dispose();
391
- __classPrivateFieldSet(this, _JPEGGlitchEffect_readRT, ctx.createRenderTarget({ size: [w, h] }), "f");
392
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, false, "f");
393
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, true, "f");
394
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
395
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
396
- __classPrivateFieldSet(this, _JPEGGlitchEffect_generation, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"), _a++, _a), "f");
397
- }, _JPEGGlitchEffect_startGlitch = function _JPEGGlitchEffect_startGlitch(ctx) {
398
- var _a;
399
- const w = __classPrivateFieldGet(this, _JPEGGlitchEffect_w, "f");
400
- const h = __classPrivateFieldGet(this, _JPEGGlitchEffect_h, "f");
401
- const srcCanvas = __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCanvas, "f");
402
- const srcCtx = __classPrivateFieldGet(this, _JPEGGlitchEffect_srcCtx, "f");
403
- const encCanvas = __classPrivateFieldGet(this, _JPEGGlitchEffect_encCanvas, "f");
404
- const encCtx = __classPrivateFieldGet(this, _JPEGGlitchEffect_encCtx, "f");
405
- const imageData = __classPrivateFieldGet(this, _JPEGGlitchEffect_imageData, "f");
406
- if (!srcCanvas ||
407
- !srcCtx ||
408
- !encCanvas ||
409
- !encCtx ||
410
- !imageData ||
411
- !__classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f")) {
412
- return;
326
+ #shouldGlitch(ctx) {
327
+ if (this.#busy) {
328
+ return false;
329
+ }
330
+ const speed = this.params.speed;
331
+ if (speed > 0) {
332
+ return ctx.time - this.#lastGlitchTime >= 1 / speed;
333
+ }
334
+ return this.#dirty;
413
335
  }
414
- // Read the element capture back to the CPU. The draw leaves the
415
- // readback RT's framebuffer bound, so readPixels reads from it.
416
- captureContent(ctx, __classPrivateFieldGet(this, _JPEGGlitchEffect_readRT, "f"));
417
- const gl = ctx.gl;
418
- gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, __classPrivateFieldGet(this, _JPEGGlitchEffect_raw, "f"));
419
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
420
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, true, "f");
421
- __classPrivateFieldSet(this, _JPEGGlitchEffect_dirty, false, "f");
422
- __classPrivateFieldSet(this, _JPEGGlitchEffect_lastGlitchTime, ctx.time, "f");
423
- // GL framebuffers are bottom-up; flip rows so the canvas is upright.
424
- // Force opaque alpha — JPEG has no alpha channel.
425
- const data = imageData.data;
426
- const rowBytes = w * 4;
427
- for (let y = 0; y < h; y++) {
428
- const srcRow = (h - 1 - y) * rowBytes;
429
- data.set(__classPrivateFieldGet(this, _JPEGGlitchEffect_raw, "f").subarray(srcRow, srcRow + rowBytes), y * rowBytes);
336
+ #resize(ctx, w, h) {
337
+ this.#w = w;
338
+ this.#h = h;
339
+ this.#imageData = new ImageData(w, h);
340
+ if (this.#srcCanvas) {
341
+ this.#srcCanvas.width = w;
342
+ this.#srcCanvas.height = h;
343
+ }
344
+ if (this.#outCanvas) {
345
+ this.#outCanvas.width = w;
346
+ this.#outCanvas.height = h;
347
+ }
348
+ // The readback RT is sized to the processing resolution, so recreate
349
+ // it (explicit-size RTs don't auto-track the element).
350
+ this.#readRT?.dispose();
351
+ this.#readRT = ctx.createRenderTarget({ size: [w, h] });
352
+ this.#hasResult = false;
353
+ this.#dirty = true;
354
+ this.#busy = false;
355
+ this.#uploadPending = false;
356
+ this.#generation++;
430
357
  }
431
- for (let i = 3; i < data.length; i += 4) {
432
- data[i] = 255;
358
+ #startGlitch(ctx) {
359
+ const readRT = this.#readRT;
360
+ if (!readRT) {
361
+ return;
362
+ }
363
+ captureContent(ctx, readRT);
364
+ this.#busy = true;
365
+ this.#dirty = false;
366
+ this.#lastGlitchTime = ctx.time;
367
+ // Static glitch (speed 0) stays on variant 0 so it's reproducible;
368
+ // animated glitch advances the variant each round.
369
+ const variant = this.params.speed > 0 ? this.#glitchCount : 0;
370
+ this.#glitchCount++;
371
+ // Read the capture back to the CPU without stalling the GPU. Rows
372
+ // come top-down, ready for ImageData.
373
+ const generation = this.#generation;
374
+ ctx.readPixels(readRT, { flipY: true }).then((raw) => {
375
+ if (generation === this.#generation) {
376
+ this.#glitchPixels(raw, variant, generation);
377
+ }
378
+ }, () => {
379
+ // Disposed or context lost: nothing to glitch.
380
+ if (generation === this.#generation) {
381
+ this.#busy = false;
382
+ }
383
+ });
433
384
  }
434
- // Static glitch (speed 0) stays on variant 0 so it's reproducible;
435
- // animated glitch advances the variant each round.
436
- const variant = this.params.speed > 0 ? __classPrivateFieldGet(this, _JPEGGlitchEffect_glitchCount, "f") : 0;
437
- __classPrivateFieldSet(this, _JPEGGlitchEffect_glitchCount, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_glitchCount, "f"), _a++, _a), "f");
438
- const { quality, seed, iterations, randomFlip, vertical } = this.params;
439
- // One seeded sequence drives both the flip decision and the byte
440
- // corruption, so the whole glitch is reproducible from the seed.
441
- const rng = makeRng(seed, variant);
442
- const flip = randomFlip && rng() < 0.5;
443
- srcCtx.putImageData(imageData, 0, 0);
444
- // Rotate the source before corrupting: 180° (flip) balances the tear
445
- // direction, -90° (vertical, i.e. 270°) turns the tears sideways.
446
- // The angles compose; runGlitch rotates the decoded output back.
447
- const srcAngle = ((flip ? 180 : 0) + (vertical ? 270 : 0)) % 360;
448
- const swap = vertical; // a quarter turn swaps width and height
449
- const encW = swap ? h : w;
450
- const encH = swap ? w : h;
451
- encCanvas.width = encW;
452
- encCanvas.height = encH;
453
- drawRotated(encCtx, srcCanvas, w, h, srcAngle, encW, encH);
454
- void __classPrivateFieldGet(this, _JPEGGlitchEffect_instances, "m", _JPEGGlitchEffect_runGlitch).call(this, encCanvas, w, h, quality, iterations, srcAngle, rng, __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f"));
455
- }, _JPEGGlitchEffect_uploadOutCanvas = function _JPEGGlitchEffect_uploadOutCanvas(ctx) {
456
- const gl = ctx.gl;
457
- if (!__classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f") || !__classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f")) {
458
- return;
385
+ // Corrupt the read-back pixels through the JPEG codec (async).
386
+ #glitchPixels(raw, variant, generation) {
387
+ const w = this.#w;
388
+ const h = this.#h;
389
+ const srcCanvas = this.#srcCanvas;
390
+ const srcCtx = this.#srcCtx;
391
+ const encCanvas = this.#encCanvas;
392
+ const encCtx = this.#encCtx;
393
+ const imageData = this.#imageData;
394
+ if (!srcCanvas || !srcCtx || !encCanvas || !encCtx || !imageData) {
395
+ this.#busy = false;
396
+ return;
397
+ }
398
+ // Force opaque alpha — JPEG has no alpha channel.
399
+ const data = imageData.data;
400
+ data.set(raw);
401
+ for (let i = 3; i < data.length; i += 4) {
402
+ data[i] = 255;
403
+ }
404
+ const { quality, seed, iterations, randomFlip, vertical } = this.params;
405
+ // One seeded sequence drives both the flip decision and the byte
406
+ // corruption, so the whole glitch is reproducible from the seed.
407
+ const rng = makeRng(seed, variant);
408
+ const flip = randomFlip && rng() < 0.5;
409
+ srcCtx.putImageData(imageData, 0, 0);
410
+ // Rotate the source before corrupting: 180° (flip) balances the tear
411
+ // direction, -90° (vertical, i.e. 270°) turns the tears sideways.
412
+ // The angles compose; runGlitch rotates the decoded output back.
413
+ const srcAngle = ((flip ? 180 : 0) + (vertical ? 270 : 0)) % 360;
414
+ const swap = vertical; // a quarter turn swaps width and height
415
+ const encW = swap ? h : w;
416
+ const encH = swap ? w : h;
417
+ encCanvas.width = encW;
418
+ encCanvas.height = encH;
419
+ drawRotated(encCtx, srcCanvas, w, h, srcAngle, encW, encH);
420
+ void this.#runGlitch(encCanvas, w, h, quality, iterations, srcAngle, rng, generation);
459
421
  }
460
- gl.bindTexture(gl.TEXTURE_2D, __classPrivateFieldGet(this, _JPEGGlitchEffect_outGLTex, "f"));
461
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
462
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
463
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, __classPrivateFieldGet(this, _JPEGGlitchEffect_outCanvas, "f"));
464
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
465
- gl.bindTexture(gl.TEXTURE_2D, null);
466
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, false, "f");
467
- }, _JPEGGlitchEffect_runGlitch = async function _JPEGGlitchEffect_runGlitch(canvas, w, h, quality, iterations, srcAngle, rng, generation) {
468
- var _a;
469
- try {
470
- const blob = await canvasToJpegBlob(canvas, quality);
471
- const bytes = new Uint8Array(await blob.arrayBuffer());
472
- const header = jpegScanStart(bytes);
473
- glitchBytes(bytes, header, iterations, rng);
474
- const bmp = await createImageBitmap(new Blob([bytes], { type: "image/jpeg" }));
475
- // Discard if a resize happened while we were encoding/decoding.
476
- if (generation === __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f") && __classPrivateFieldGet(this, _JPEGGlitchEffect_outCtx, "f")) {
477
- // Rotate the decoded glitch back upright (inverse of the
478
- // source rotation) into the w×h output canvas.
479
- const outAngle = (360 - srcAngle) % 360;
480
- drawRotated(__classPrivateFieldGet(this, _JPEGGlitchEffect_outCtx, "f"), bmp, bmp.width, bmp.height, outAngle, w, h);
481
- __classPrivateFieldSet(this, _JPEGGlitchEffect_hasResult, true, "f");
482
- __classPrivateFieldSet(this, _JPEGGlitchEffect_producedFrames, (_a = __classPrivateFieldGet(this, _JPEGGlitchEffect_producedFrames, "f"), _a++, _a), "f");
483
- // New pixels — upload to the display texture on the next draw.
484
- __classPrivateFieldSet(this, _JPEGGlitchEffect_uploadPending, true, "f");
422
+ // Upload the decoded glitch canvas into our display texture. FLIP_Y
423
+ // matches the framework's canvas-as-image convention so FRAG_OUTPUT
424
+ // (which samples by uvContent) shows it upright.
425
+ #uploadOutCanvas(ctx) {
426
+ const gl = ctx.gl;
427
+ if (!this.#outGLTex || !this.#outCanvas) {
428
+ return;
485
429
  }
486
- bmp.close();
430
+ gl.bindTexture(gl.TEXTURE_2D, this.#outGLTex);
431
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
432
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
433
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.#outCanvas);
434
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
435
+ gl.bindTexture(gl.TEXTURE_2D, null);
436
+ this.#uploadPending = false;
487
437
  }
488
- catch {
489
- // Corrupted past the decoder's tolerance — keep the last good
490
- // frame and try again on the next tick.
438
+ async #runGlitch(canvas, w, h, quality, iterations, srcAngle, rng, generation) {
439
+ try {
440
+ const blob = await canvasToJpegBlob(canvas, quality);
441
+ const bytes = new Uint8Array(await blob.arrayBuffer());
442
+ const header = jpegScanStart(bytes);
443
+ glitchBytes(bytes, header, iterations, rng);
444
+ const bmp = await createImageBitmap(new Blob([bytes], { type: "image/jpeg" }));
445
+ // Discard if a resize happened while we were encoding/decoding.
446
+ if (generation === this.#generation && this.#outCtx) {
447
+ // Rotate the decoded glitch back upright (inverse of the
448
+ // source rotation) into the w×h output canvas.
449
+ const outAngle = (360 - srcAngle) % 360;
450
+ drawRotated(this.#outCtx, bmp, bmp.width, bmp.height, outAngle, w, h);
451
+ this.#hasResult = true;
452
+ this.#producedFrames++;
453
+ // New pixels — upload to the display texture on the next draw.
454
+ this.#uploadPending = true;
455
+ }
456
+ bmp.close();
457
+ }
458
+ catch {
459
+ // Corrupted past the decoder's tolerance — keep the last good
460
+ // frame and try again on the next tick.
461
+ }
462
+ finally {
463
+ if (generation === this.#generation) {
464
+ this.#busy = false;
465
+ }
466
+ }
491
467
  }
492
- finally {
493
- if (generation === __classPrivateFieldGet(this, _JPEGGlitchEffect_generation, "f")) {
494
- __classPrivateFieldSet(this, _JPEGGlitchEffect_busy, false, "f");
468
+ dispose() {
469
+ this.#restoreUnsub?.();
470
+ this.#restoreUnsub = null;
471
+ if (this.#gl && this.#outGLTex) {
472
+ this.#gl.deleteTexture(this.#outGLTex);
495
473
  }
474
+ this.#outGLTex = null;
475
+ this.#gl = null;
476
+ this.#uploadPending = false;
477
+ this.#readRT?.dispose();
478
+ this.#readRT = null;
479
+ this.#outTex = null;
480
+ this.#srcCanvas = null;
481
+ this.#srcCtx = null;
482
+ this.#encCanvas = null;
483
+ this.#encCtx = null;
484
+ this.#outCanvas = null;
485
+ this.#outCtx = null;
486
+ this.#imageData = null;
487
+ this.#hasResult = false;
488
+ this.#busy = false;
489
+ // Forget the processed size so a re-init reallocates the readback RT
490
+ // (which dispose just freed) instead of mistaking it for current.
491
+ this.#w = 0;
492
+ this.#h = 0;
493
+ // Invalidate any in-flight round trip.
494
+ this.#generation++;
496
495
  }
497
- };
496
+ }
498
497
  //# sourceMappingURL=jpeg-glitch.js.map