@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.
- package/README.md +4 -0
- package/THIRD_PARTY_NOTICES.md +61 -0
- package/lib/cjs/_bloom-common.d.ts +31 -0
- package/lib/cjs/_bloom-common.js +101 -0
- package/lib/cjs/_bloom-common.js.map +1 -0
- package/lib/cjs/_bubble-fill.d.ts +126 -0
- package/lib/cjs/_bubble-fill.js +1044 -0
- package/lib/cjs/_bubble-fill.js.map +1 -0
- package/lib/cjs/_bubble-kernel-source.d.ts +2 -0
- package/lib/cjs/_bubble-kernel-source.js +8 -0
- package/lib/cjs/_bubble-kernel-source.js.map +1 -0
- package/lib/cjs/_holo/data/kernels.d.ts +4 -0
- package/lib/cjs/_holo/data/kernels.js +10 -0
- package/lib/cjs/_holo/data/kernels.js.map +1 -0
- package/lib/cjs/_holo/data/looks.d.ts +2 -0
- package/lib/cjs/_holo/data/looks.js +595 -0
- package/lib/cjs/_holo/data/looks.js.map +1 -0
- package/lib/cjs/_holo/data/ltc.d.ts +2 -0
- package/lib/cjs/_holo/data/ltc.js +11 -0
- package/lib/cjs/_holo/data/ltc.js.map +1 -0
- package/lib/cjs/_holo/data/material-presets.d.ts +3 -0
- package/lib/cjs/_holo/data/material-presets.js +75 -0
- package/lib/cjs/_holo/data/material-presets.js.map +1 -0
- package/lib/cjs/_holo/data/not-ported.d.ts +5 -0
- package/lib/cjs/_holo/data/not-ported.js +190 -0
- package/lib/cjs/_holo/data/not-ported.js.map +1 -0
- package/lib/cjs/_holo/data/params.d.ts +4 -0
- package/lib/cjs/_holo/data/params.js +1641 -0
- package/lib/cjs/_holo/data/params.js.map +1 -0
- package/lib/cjs/_holo/data/starting-points.d.ts +199 -0
- package/lib/cjs/_holo/data/starting-points.js +193 -0
- package/lib/cjs/_holo/data/starting-points.js.map +1 -0
- package/lib/cjs/_holo/data/studio-presets.d.ts +2 -0
- package/lib/cjs/_holo/data/studio-presets.js +177 -0
- package/lib/cjs/_holo/data/studio-presets.js.map +1 -0
- package/lib/cjs/_holo/emboss-assets.d.ts +55 -0
- package/lib/cjs/_holo/emboss-assets.js +155 -0
- package/lib/cjs/_holo/emboss-assets.js.map +1 -0
- package/lib/cjs/_holo/glare.d.ts +15 -0
- package/lib/cjs/_holo/glare.js +125 -0
- package/lib/cjs/_holo/glare.js.map +1 -0
- package/lib/cjs/_holo/glsl/coat.d.ts +2 -0
- package/lib/cjs/_holo/glsl/coat.js +32 -0
- package/lib/cjs/_holo/glsl/coat.js.map +1 -0
- package/lib/cjs/_holo/glsl/common.d.ts +2 -0
- package/lib/cjs/_holo/glsl/common.js +141 -0
- package/lib/cjs/_holo/glsl/common.js.map +1 -0
- package/lib/cjs/_holo/glsl/emboss.d.ts +2 -0
- package/lib/cjs/_holo/glsl/emboss.js +246 -0
- package/lib/cjs/_holo/glsl/emboss.js.map +1 -0
- package/lib/cjs/_holo/glsl/env.d.ts +2 -0
- package/lib/cjs/_holo/glsl/env.js +52 -0
- package/lib/cjs/_holo/glsl/env.js.map +1 -0
- package/lib/cjs/_holo/glsl/glare-down.d.ts +2 -0
- package/lib/cjs/_holo/glsl/glare-down.js +65 -0
- package/lib/cjs/_holo/glsl/glare-down.js.map +1 -0
- package/lib/cjs/_holo/glsl/glare-up.d.ts +2 -0
- package/lib/cjs/_holo/glsl/glare-up.js +18 -0
- package/lib/cjs/_holo/glsl/glare-up.js.map +1 -0
- package/lib/cjs/_holo/glsl/glitter.d.ts +2 -0
- package/lib/cjs/_holo/glsl/glitter.js +325 -0
- package/lib/cjs/_holo/glsl/glitter.js.map +1 -0
- package/lib/cjs/_holo/glsl/grating.d.ts +2 -0
- package/lib/cjs/_holo/glsl/grating.js +240 -0
- package/lib/cjs/_holo/glsl/grating.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-emboss.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-emboss.js +296 -0
- package/lib/cjs/_holo/glsl/holo-emboss.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-nebula.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-nebula.js +186 -0
- package/lib/cjs/_holo/glsl/holo-nebula.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-prism.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-prism.js +183 -0
- package/lib/cjs/_holo/glsl/holo-prism.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-shatter.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-shatter.js +328 -0
- package/lib/cjs/_holo/glsl/holo-shatter.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-sparkle.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-sparkle.js +235 -0
- package/lib/cjs/_holo/glsl/holo-sparkle.js.map +1 -0
- package/lib/cjs/_holo/glsl/holo-vortex.d.ts +2 -0
- package/lib/cjs/_holo/glsl/holo-vortex.js +201 -0
- package/lib/cjs/_holo/glsl/holo-vortex.js.map +1 -0
- package/lib/cjs/_holo/glsl/ibl.d.ts +2 -0
- package/lib/cjs/_holo/glsl/ibl.js +79 -0
- package/lib/cjs/_holo/glsl/ibl.js.map +1 -0
- package/lib/cjs/_holo/glsl/lights.d.ts +2 -0
- package/lib/cjs/_holo/glsl/lights.js +125 -0
- package/lib/cjs/_holo/glsl/lights.js.map +1 -0
- package/lib/cjs/_holo/glsl/ltc.d.ts +2 -0
- package/lib/cjs/_holo/glsl/ltc.js +66 -0
- package/lib/cjs/_holo/glsl/ltc.js.map +1 -0
- package/lib/cjs/_holo/glsl/output.d.ts +2 -0
- package/lib/cjs/_holo/glsl/output.js +113 -0
- package/lib/cjs/_holo/glsl/output.js.map +1 -0
- package/lib/cjs/_holo/glsl/paper.d.ts +2 -0
- package/lib/cjs/_holo/glsl/paper.js +165 -0
- package/lib/cjs/_holo/glsl/paper.js.map +1 -0
- package/lib/cjs/_holo/glsl/relief.d.ts +2 -0
- package/lib/cjs/_holo/glsl/relief.js +103 -0
- package/lib/cjs/_holo/glsl/relief.js.map +1 -0
- package/lib/cjs/_holo/glsl/sparkle.d.ts +2 -0
- package/lib/cjs/_holo/glsl/sparkle.js +279 -0
- package/lib/cjs/_holo/glsl/sparkle.js.map +1 -0
- package/lib/cjs/_holo/glsl/spectral.d.ts +2 -0
- package/lib/cjs/_holo/glsl/spectral.js +60 -0
- package/lib/cjs/_holo/glsl/spectral.js.map +1 -0
- package/lib/cjs/_holo/glsl/wear.d.ts +2 -0
- package/lib/cjs/_holo/glsl/wear.js +107 -0
- package/lib/cjs/_holo/glsl/wear.js.map +1 -0
- package/lib/cjs/_holo/ltc.d.ts +9 -0
- package/lib/cjs/_holo/ltc.js +56 -0
- package/lib/cjs/_holo/ltc.js.map +1 -0
- package/lib/cjs/_holo/materials/build.d.ts +32 -0
- package/lib/cjs/_holo/materials/build.js +36 -0
- package/lib/cjs/_holo/materials/build.js.map +1 -0
- package/lib/cjs/_holo/materials/emboss.d.ts +22 -0
- package/lib/cjs/_holo/materials/emboss.js +205 -0
- package/lib/cjs/_holo/materials/emboss.js.map +1 -0
- package/lib/cjs/_holo/materials/nebula.d.ts +4 -0
- package/lib/cjs/_holo/materials/nebula.js +105 -0
- package/lib/cjs/_holo/materials/nebula.js.map +1 -0
- package/lib/cjs/_holo/materials/prism.d.ts +2 -0
- package/lib/cjs/_holo/materials/prism.js +69 -0
- package/lib/cjs/_holo/materials/prism.js.map +1 -0
- package/lib/cjs/_holo/materials/registry.d.ts +11 -0
- package/lib/cjs/_holo/materials/registry.js +88 -0
- package/lib/cjs/_holo/materials/registry.js.map +1 -0
- package/lib/cjs/_holo/materials/shatter.d.ts +2 -0
- package/lib/cjs/_holo/materials/shatter.js +80 -0
- package/lib/cjs/_holo/materials/shatter.js.map +1 -0
- package/lib/cjs/_holo/materials/sparkle.d.ts +2 -0
- package/lib/cjs/_holo/materials/sparkle.js +108 -0
- package/lib/cjs/_holo/materials/sparkle.js.map +1 -0
- package/lib/cjs/_holo/materials/vortex.d.ts +2 -0
- package/lib/cjs/_holo/materials/vortex.js +85 -0
- package/lib/cjs/_holo/materials/vortex.js.map +1 -0
- package/lib/cjs/_holo/physics/emboss.d.ts +39 -0
- package/lib/cjs/_holo/physics/emboss.js +95 -0
- package/lib/cjs/_holo/physics/emboss.js.map +1 -0
- package/lib/cjs/_holo/physics/geometry.d.ts +109 -0
- package/lib/cjs/_holo/physics/geometry.js +252 -0
- package/lib/cjs/_holo/physics/geometry.js.map +1 -0
- package/lib/cjs/_holo/physics/grating.d.ts +86 -0
- package/lib/cjs/_holo/physics/grating.js +328 -0
- package/lib/cjs/_holo/physics/grating.js.map +1 -0
- package/lib/cjs/_holo/physics/sparkle.d.ts +143 -0
- package/lib/cjs/_holo/physics/sparkle.js +388 -0
- package/lib/cjs/_holo/physics/sparkle.js.map +1 -0
- package/lib/cjs/_holo/scene/env.d.ts +17 -0
- package/lib/cjs/_holo/scene/env.js +151 -0
- package/lib/cjs/_holo/scene/env.js.map +1 -0
- package/lib/cjs/_holo/scene/lights.d.ts +13 -0
- package/lib/cjs/_holo/scene/lights.js +211 -0
- package/lib/cjs/_holo/scene/lights.js.map +1 -0
- package/lib/cjs/_holo/scene/logo.d.ts +87 -0
- package/lib/cjs/_holo/scene/logo.js +655 -0
- package/lib/cjs/_holo/scene/logo.js.map +1 -0
- package/lib/cjs/_holo/scene/paper-maps.d.ts +26 -0
- package/lib/cjs/_holo/scene/paper-maps.js +391 -0
- package/lib/cjs/_holo/scene/paper-maps.js.map +1 -0
- package/lib/cjs/_holo/scene/pose.d.ts +31 -0
- package/lib/cjs/_holo/scene/pose.js +77 -0
- package/lib/cjs/_holo/scene/pose.js.map +1 -0
- package/lib/cjs/_holo/scene/relief.d.ts +24 -0
- package/lib/cjs/_holo/scene/relief.js +148 -0
- package/lib/cjs/_holo/scene/relief.js.map +1 -0
- package/lib/cjs/_holo/settings-types.d.ts +20 -0
- package/lib/cjs/_holo/settings-types.js +3 -0
- package/lib/cjs/_holo/settings-types.js.map +1 -0
- package/lib/cjs/_holo/settings.d.ts +83 -0
- package/lib/cjs/_holo/settings.js +375 -0
- package/lib/cjs/_holo/settings.js.map +1 -0
- package/lib/cjs/_holo/shader.d.ts +23 -0
- package/lib/cjs/_holo/shader.js +219 -0
- package/lib/cjs/_holo/shader.js.map +1 -0
- package/lib/cjs/_holo/spectral/atlas.d.ts +36 -0
- package/lib/cjs/_holo/spectral/atlas.js +114 -0
- package/lib/cjs/_holo/spectral/atlas.js.map +1 -0
- package/lib/cjs/_holo/spectral/cmf.d.ts +67 -0
- package/lib/cjs/_holo/spectral/cmf.js +244 -0
- package/lib/cjs/_holo/spectral/cmf.js.map +1 -0
- package/lib/cjs/_holo/spectral/float24.d.ts +8 -0
- package/lib/cjs/_holo/spectral/float24.js +70 -0
- package/lib/cjs/_holo/spectral/float24.js.map +1 -0
- package/lib/cjs/_holo/spectral/spd.d.ts +22 -0
- package/lib/cjs/_holo/spectral/spd.js +139 -0
- package/lib/cjs/_holo/spectral/spd.js.map +1 -0
- package/lib/cjs/_holo/spectral/tables.d.ts +62 -0
- package/lib/cjs/_holo/spectral/tables.js +386 -0
- package/lib/cjs/_holo/spectral/tables.js.map +1 -0
- package/lib/cjs/_holo/tier.d.ts +4 -0
- package/lib/cjs/_holo/tier.js +110 -0
- package/lib/cjs/_holo/tier.js.map +1 -0
- package/lib/cjs/_holo/types.d.ts +148 -0
- package/lib/cjs/_holo/types.js +14 -0
- package/lib/cjs/_holo/types.js.map +1 -0
- package/lib/cjs/_kernel-worker.d.ts +22 -0
- package/lib/cjs/_kernel-worker.js +174 -0
- package/lib/cjs/_kernel-worker.js.map +1 -0
- package/lib/cjs/_orbit-camera.d.ts +175 -0
- package/lib/cjs/_orbit-camera.js +366 -0
- package/lib/cjs/_orbit-camera.js.map +1 -0
- package/lib/cjs/_pad.d.ts +2 -0
- package/lib/cjs/_pad.js +11 -0
- package/lib/cjs/_pad.js.map +1 -1
- package/lib/cjs/_scene3d.d.ts +101 -0
- package/lib/cjs/_scene3d.js +794 -0
- package/lib/cjs/_scene3d.js.map +1 -0
- package/lib/cjs/_shape-kernel-source.d.ts +2 -0
- package/lib/cjs/_shape-kernel-source.js +8 -0
- package/lib/cjs/_shape-kernel-source.js.map +1 -0
- package/lib/cjs/_shape-worker.d.ts +8 -0
- package/lib/cjs/_shape-worker.js +27 -0
- package/lib/cjs/_shape-worker.js.map +1 -0
- package/lib/cjs/_silhouette.d.ts +88 -0
- package/lib/cjs/_silhouette.js +441 -0
- package/lib/cjs/_silhouette.js.map +1 -0
- package/lib/cjs/_simplex3.d.ts +2 -0
- package/lib/cjs/_simplex3.js +160 -0
- package/lib/cjs/_simplex3.js.map +1 -0
- package/lib/cjs/_source.d.ts +80 -0
- package/lib/cjs/_source.js +192 -0
- package/lib/cjs/_source.js.map +1 -0
- package/lib/cjs/_sphere-foam.d.ts +34 -0
- package/lib/cjs/_sphere-foam.js +135 -0
- package/lib/cjs/_sphere-foam.js.map +1 -0
- package/lib/cjs/_thin-film.d.ts +26 -0
- package/lib/cjs/_thin-film.js +146 -0
- package/lib/cjs/_thin-film.js.map +1 -0
- package/lib/cjs/ascii.js +63 -73
- package/lib/cjs/ascii.js.map +1 -1
- package/lib/cjs/bad-jpeg.js +7 -5
- package/lib/cjs/bad-jpeg.js.map +1 -1
- package/lib/cjs/bloom.js +59 -135
- package/lib/cjs/bloom.js.map +1 -1
- package/lib/cjs/bubble.d.ts +284 -0
- package/lib/cjs/bubble.js +1820 -0
- package/lib/cjs/bubble.js.map +1 -0
- package/lib/cjs/chromatic.js +1 -0
- package/lib/cjs/chromatic.js.map +1 -1
- package/lib/cjs/colored-edges.js +1 -0
- package/lib/cjs/colored-edges.js.map +1 -1
- package/lib/cjs/datamosh.js +173 -183
- package/lib/cjs/datamosh.js.map +1 -1
- package/lib/cjs/dither.js +6 -3
- package/lib/cjs/dither.js.map +1 -1
- package/lib/cjs/duotone.js +4 -2
- package/lib/cjs/duotone.js.map +1 -1
- package/lib/cjs/fluid.js +62 -74
- package/lib/cjs/fluid.js.map +1 -1
- package/lib/cjs/glass.d.ts +254 -0
- package/lib/cjs/glass.js +981 -0
- package/lib/cjs/glass.js.map +1 -0
- package/lib/cjs/glitch.js +1 -0
- package/lib/cjs/glitch.js.map +1 -1
- package/lib/cjs/gradient-map.js +4 -1
- package/lib/cjs/gradient-map.js.map +1 -1
- package/lib/cjs/halftone.js +3 -0
- package/lib/cjs/halftone.js.map +1 -1
- package/lib/cjs/holo-static.d.ts +3 -0
- package/lib/cjs/holo-static.js +29 -0
- package/lib/cjs/holo-static.js.map +1 -0
- package/lib/cjs/holo.d.ts +401 -0
- package/lib/cjs/holo.js +1613 -0
- package/lib/cjs/holo.js.map +1 -0
- package/lib/cjs/hue-shift.js +1 -0
- package/lib/cjs/hue-shift.js.map +1 -1
- package/lib/cjs/index.d.ts +18 -9
- package/lib/cjs/index.js +12 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/jpeg-glitch.js +275 -276
- package/lib/cjs/jpeg-glitch.js.map +1 -1
- package/lib/cjs/light-streak.js +34 -47
- package/lib/cjs/light-streak.js.map +1 -1
- package/lib/cjs/matrix.d.ts +1 -1
- package/lib/cjs/matrix.js +48 -59
- package/lib/cjs/matrix.js.map +1 -1
- package/lib/cjs/package.json +20 -4
- package/lib/cjs/particle-explode.js +122 -128
- package/lib/cjs/particle-explode.js.map +1 -1
- package/lib/cjs/particle.js +253 -258
- package/lib/cjs/particle.js.map +1 -1
- package/lib/cjs/pattern-refraction.js +1 -0
- package/lib/cjs/pattern-refraction.js.map +1 -1
- package/lib/cjs/pixel-stretch.js +1 -0
- package/lib/cjs/pixel-stretch.js.map +1 -1
- package/lib/cjs/pixelate.js +1 -0
- package/lib/cjs/pixelate.js.map +1 -1
- package/lib/cjs/pixelsort.js +102 -121
- package/lib/cjs/pixelsort.js.map +1 -1
- package/lib/cjs/rainbow.js +1 -0
- package/lib/cjs/rainbow.js.map +1 -1
- package/lib/cjs/rgb-glitch.js +1 -0
- package/lib/cjs/rgb-glitch.js.map +1 -1
- package/lib/cjs/rgb-shift.js +1 -0
- package/lib/cjs/rgb-shift.js.map +1 -1
- package/lib/cjs/scanline.js +1 -0
- package/lib/cjs/scanline.js.map +1 -1
- package/lib/cjs/sinewave.js +1 -0
- package/lib/cjs/sinewave.js.map +1 -1
- package/lib/cjs/slice-shift.js +1 -0
- package/lib/cjs/slice-shift.js.map +1 -1
- package/lib/cjs/swirl-particle.d.ts +257 -0
- package/lib/cjs/swirl-particle.js +2346 -0
- package/lib/cjs/swirl-particle.js.map +1 -0
- package/lib/cjs/tile-pixelate.js +4 -1
- package/lib/cjs/tile-pixelate.js.map +1 -1
- package/lib/cjs/tritone.js +5 -2
- package/lib/cjs/tritone.js.map +1 -1
- package/lib/cjs/vignette.js +1 -0
- package/lib/cjs/vignette.js.map +1 -1
- package/lib/cjs/voronoi.js +6 -76
- package/lib/cjs/voronoi.js.map +1 -1
- package/lib/cjs/warp.js +1 -0
- package/lib/cjs/warp.js.map +1 -1
- package/lib/esm/_bloom-common.d.ts +31 -0
- package/lib/esm/_bloom-common.js +95 -0
- package/lib/esm/_bloom-common.js.map +1 -0
- package/lib/esm/_bubble-fill.d.ts +126 -0
- package/lib/esm/_bubble-fill.js +1039 -0
- package/lib/esm/_bubble-fill.js.map +1 -0
- package/lib/esm/_bubble-kernel-source.d.ts +2 -0
- package/lib/esm/_bubble-kernel-source.js +5 -0
- package/lib/esm/_bubble-kernel-source.js.map +1 -0
- package/lib/esm/_holo/data/kernels.d.ts +4 -0
- package/lib/esm/_holo/data/kernels.js +7 -0
- package/lib/esm/_holo/data/kernels.js.map +1 -0
- package/lib/esm/_holo/data/looks.d.ts +2 -0
- package/lib/esm/_holo/data/looks.js +592 -0
- package/lib/esm/_holo/data/looks.js.map +1 -0
- package/lib/esm/_holo/data/ltc.d.ts +2 -0
- package/lib/esm/_holo/data/ltc.js +8 -0
- package/lib/esm/_holo/data/ltc.js.map +1 -0
- package/lib/esm/_holo/data/material-presets.d.ts +3 -0
- package/lib/esm/_holo/data/material-presets.js +72 -0
- package/lib/esm/_holo/data/material-presets.js.map +1 -0
- package/lib/esm/_holo/data/not-ported.d.ts +5 -0
- package/lib/esm/_holo/data/not-ported.js +187 -0
- package/lib/esm/_holo/data/not-ported.js.map +1 -0
- package/lib/esm/_holo/data/params.d.ts +4 -0
- package/lib/esm/_holo/data/params.js +1638 -0
- package/lib/esm/_holo/data/params.js.map +1 -0
- package/lib/esm/_holo/data/starting-points.d.ts +199 -0
- package/lib/esm/_holo/data/starting-points.js +190 -0
- package/lib/esm/_holo/data/starting-points.js.map +1 -0
- package/lib/esm/_holo/data/studio-presets.d.ts +2 -0
- package/lib/esm/_holo/data/studio-presets.js +174 -0
- package/lib/esm/_holo/data/studio-presets.js.map +1 -0
- package/lib/esm/_holo/emboss-assets.d.ts +55 -0
- package/lib/esm/_holo/emboss-assets.js +150 -0
- package/lib/esm/_holo/emboss-assets.js.map +1 -0
- package/lib/esm/_holo/glare.d.ts +15 -0
- package/lib/esm/_holo/glare.js +117 -0
- package/lib/esm/_holo/glare.js.map +1 -0
- package/lib/esm/_holo/glsl/coat.d.ts +2 -0
- package/lib/esm/_holo/glsl/coat.js +30 -0
- package/lib/esm/_holo/glsl/coat.js.map +1 -0
- package/lib/esm/_holo/glsl/common.d.ts +2 -0
- package/lib/esm/_holo/glsl/common.js +139 -0
- package/lib/esm/_holo/glsl/common.js.map +1 -0
- package/lib/esm/_holo/glsl/emboss.d.ts +2 -0
- package/lib/esm/_holo/glsl/emboss.js +244 -0
- package/lib/esm/_holo/glsl/emboss.js.map +1 -0
- package/lib/esm/_holo/glsl/env.d.ts +2 -0
- package/lib/esm/_holo/glsl/env.js +50 -0
- package/lib/esm/_holo/glsl/env.js.map +1 -0
- package/lib/esm/_holo/glsl/glare-down.d.ts +2 -0
- package/lib/esm/_holo/glsl/glare-down.js +63 -0
- package/lib/esm/_holo/glsl/glare-down.js.map +1 -0
- package/lib/esm/_holo/glsl/glare-up.d.ts +2 -0
- package/lib/esm/_holo/glsl/glare-up.js +16 -0
- package/lib/esm/_holo/glsl/glare-up.js.map +1 -0
- package/lib/esm/_holo/glsl/glitter.d.ts +2 -0
- package/lib/esm/_holo/glsl/glitter.js +323 -0
- package/lib/esm/_holo/glsl/glitter.js.map +1 -0
- package/lib/esm/_holo/glsl/grating.d.ts +2 -0
- package/lib/esm/_holo/glsl/grating.js +238 -0
- package/lib/esm/_holo/glsl/grating.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-emboss.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-emboss.js +294 -0
- package/lib/esm/_holo/glsl/holo-emboss.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-nebula.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-nebula.js +184 -0
- package/lib/esm/_holo/glsl/holo-nebula.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-prism.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-prism.js +181 -0
- package/lib/esm/_holo/glsl/holo-prism.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-shatter.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-shatter.js +326 -0
- package/lib/esm/_holo/glsl/holo-shatter.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-sparkle.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-sparkle.js +233 -0
- package/lib/esm/_holo/glsl/holo-sparkle.js.map +1 -0
- package/lib/esm/_holo/glsl/holo-vortex.d.ts +2 -0
- package/lib/esm/_holo/glsl/holo-vortex.js +199 -0
- package/lib/esm/_holo/glsl/holo-vortex.js.map +1 -0
- package/lib/esm/_holo/glsl/ibl.d.ts +2 -0
- package/lib/esm/_holo/glsl/ibl.js +77 -0
- package/lib/esm/_holo/glsl/ibl.js.map +1 -0
- package/lib/esm/_holo/glsl/lights.d.ts +2 -0
- package/lib/esm/_holo/glsl/lights.js +123 -0
- package/lib/esm/_holo/glsl/lights.js.map +1 -0
- package/lib/esm/_holo/glsl/ltc.d.ts +2 -0
- package/lib/esm/_holo/glsl/ltc.js +64 -0
- package/lib/esm/_holo/glsl/ltc.js.map +1 -0
- package/lib/esm/_holo/glsl/output.d.ts +2 -0
- package/lib/esm/_holo/glsl/output.js +111 -0
- package/lib/esm/_holo/glsl/output.js.map +1 -0
- package/lib/esm/_holo/glsl/paper.d.ts +2 -0
- package/lib/esm/_holo/glsl/paper.js +163 -0
- package/lib/esm/_holo/glsl/paper.js.map +1 -0
- package/lib/esm/_holo/glsl/relief.d.ts +2 -0
- package/lib/esm/_holo/glsl/relief.js +101 -0
- package/lib/esm/_holo/glsl/relief.js.map +1 -0
- package/lib/esm/_holo/glsl/sparkle.d.ts +2 -0
- package/lib/esm/_holo/glsl/sparkle.js +277 -0
- package/lib/esm/_holo/glsl/sparkle.js.map +1 -0
- package/lib/esm/_holo/glsl/spectral.d.ts +2 -0
- package/lib/esm/_holo/glsl/spectral.js +58 -0
- package/lib/esm/_holo/glsl/spectral.js.map +1 -0
- package/lib/esm/_holo/glsl/wear.d.ts +2 -0
- package/lib/esm/_holo/glsl/wear.js +105 -0
- package/lib/esm/_holo/glsl/wear.js.map +1 -0
- package/lib/esm/_holo/ltc.d.ts +9 -0
- package/lib/esm/_holo/ltc.js +52 -0
- package/lib/esm/_holo/ltc.js.map +1 -0
- package/lib/esm/_holo/materials/build.d.ts +32 -0
- package/lib/esm/_holo/materials/build.js +30 -0
- package/lib/esm/_holo/materials/build.js.map +1 -0
- package/lib/esm/_holo/materials/emboss.d.ts +22 -0
- package/lib/esm/_holo/materials/emboss.js +198 -0
- package/lib/esm/_holo/materials/emboss.js.map +1 -0
- package/lib/esm/_holo/materials/nebula.d.ts +4 -0
- package/lib/esm/_holo/materials/nebula.js +98 -0
- package/lib/esm/_holo/materials/nebula.js.map +1 -0
- package/lib/esm/_holo/materials/prism.d.ts +2 -0
- package/lib/esm/_holo/materials/prism.js +63 -0
- package/lib/esm/_holo/materials/prism.js.map +1 -0
- package/lib/esm/_holo/materials/registry.d.ts +11 -0
- package/lib/esm/_holo/materials/registry.js +48 -0
- package/lib/esm/_holo/materials/registry.js.map +1 -0
- package/lib/esm/_holo/materials/shatter.d.ts +2 -0
- package/lib/esm/_holo/materials/shatter.js +74 -0
- package/lib/esm/_holo/materials/shatter.js.map +1 -0
- package/lib/esm/_holo/materials/sparkle.d.ts +2 -0
- package/lib/esm/_holo/materials/sparkle.js +102 -0
- package/lib/esm/_holo/materials/sparkle.js.map +1 -0
- package/lib/esm/_holo/materials/vortex.d.ts +2 -0
- package/lib/esm/_holo/materials/vortex.js +79 -0
- package/lib/esm/_holo/materials/vortex.js.map +1 -0
- package/lib/esm/_holo/physics/emboss.d.ts +39 -0
- package/lib/esm/_holo/physics/emboss.js +89 -0
- package/lib/esm/_holo/physics/emboss.js.map +1 -0
- package/lib/esm/_holo/physics/geometry.d.ts +109 -0
- package/lib/esm/_holo/physics/geometry.js +228 -0
- package/lib/esm/_holo/physics/geometry.js.map +1 -0
- package/lib/esm/_holo/physics/grating.d.ts +86 -0
- package/lib/esm/_holo/physics/grating.js +313 -0
- package/lib/esm/_holo/physics/grating.js.map +1 -0
- package/lib/esm/_holo/physics/sparkle.d.ts +143 -0
- package/lib/esm/_holo/physics/sparkle.js +360 -0
- package/lib/esm/_holo/physics/sparkle.js.map +1 -0
- package/lib/esm/_holo/scene/env.d.ts +17 -0
- package/lib/esm/_holo/scene/env.js +141 -0
- package/lib/esm/_holo/scene/env.js.map +1 -0
- package/lib/esm/_holo/scene/lights.d.ts +13 -0
- package/lib/esm/_holo/scene/lights.js +204 -0
- package/lib/esm/_holo/scene/lights.js.map +1 -0
- package/lib/esm/_holo/scene/logo.d.ts +87 -0
- package/lib/esm/_holo/scene/logo.js +645 -0
- package/lib/esm/_holo/scene/logo.js.map +1 -0
- package/lib/esm/_holo/scene/paper-maps.d.ts +26 -0
- package/lib/esm/_holo/scene/paper-maps.js +387 -0
- package/lib/esm/_holo/scene/paper-maps.js.map +1 -0
- package/lib/esm/_holo/scene/pose.d.ts +31 -0
- package/lib/esm/_holo/scene/pose.js +71 -0
- package/lib/esm/_holo/scene/pose.js.map +1 -0
- package/lib/esm/_holo/scene/relief.d.ts +24 -0
- package/lib/esm/_holo/scene/relief.js +142 -0
- package/lib/esm/_holo/scene/relief.js.map +1 -0
- package/lib/esm/_holo/settings-types.d.ts +20 -0
- package/lib/esm/_holo/settings-types.js +2 -0
- package/lib/esm/_holo/settings-types.js.map +1 -0
- package/lib/esm/_holo/settings.d.ts +83 -0
- package/lib/esm/_holo/settings.js +358 -0
- package/lib/esm/_holo/settings.js.map +1 -0
- package/lib/esm/_holo/shader.d.ts +23 -0
- package/lib/esm/_holo/shader.js +211 -0
- package/lib/esm/_holo/shader.js.map +1 -0
- package/lib/esm/_holo/spectral/atlas.d.ts +36 -0
- package/lib/esm/_holo/spectral/atlas.js +110 -0
- package/lib/esm/_holo/spectral/atlas.js.map +1 -0
- package/lib/esm/_holo/spectral/cmf.d.ts +67 -0
- package/lib/esm/_holo/spectral/cmf.js +230 -0
- package/lib/esm/_holo/spectral/cmf.js.map +1 -0
- package/lib/esm/_holo/spectral/float24.d.ts +8 -0
- package/lib/esm/_holo/spectral/float24.js +64 -0
- package/lib/esm/_holo/spectral/float24.js.map +1 -0
- package/lib/esm/_holo/spectral/spd.d.ts +22 -0
- package/lib/esm/_holo/spectral/spd.js +130 -0
- package/lib/esm/_holo/spectral/spd.js.map +1 -0
- package/lib/esm/_holo/spectral/tables.d.ts +62 -0
- package/lib/esm/_holo/spectral/tables.js +372 -0
- package/lib/esm/_holo/spectral/tables.js.map +1 -0
- package/lib/esm/_holo/tier.d.ts +4 -0
- package/lib/esm/_holo/tier.js +106 -0
- package/lib/esm/_holo/tier.js.map +1 -0
- package/lib/esm/_holo/types.d.ts +148 -0
- package/lib/esm/_holo/types.js +11 -0
- package/lib/esm/_holo/types.js.map +1 -0
- package/lib/esm/_kernel-worker.d.ts +22 -0
- package/lib/esm/_kernel-worker.js +169 -0
- package/lib/esm/_kernel-worker.js.map +1 -0
- package/lib/esm/_orbit-camera.d.ts +175 -0
- package/lib/esm/_orbit-camera.js +360 -0
- package/lib/esm/_orbit-camera.js.map +1 -0
- package/lib/esm/_pad.d.ts +2 -0
- package/lib/esm/_pad.js +10 -0
- package/lib/esm/_pad.js.map +1 -1
- package/lib/esm/_scene3d.d.ts +101 -0
- package/lib/esm/_scene3d.js +783 -0
- package/lib/esm/_scene3d.js.map +1 -0
- package/lib/esm/_shape-kernel-source.d.ts +2 -0
- package/lib/esm/_shape-kernel-source.js +5 -0
- package/lib/esm/_shape-kernel-source.js.map +1 -0
- package/lib/esm/_shape-worker.d.ts +8 -0
- package/lib/esm/_shape-worker.js +23 -0
- package/lib/esm/_shape-worker.js.map +1 -0
- package/lib/esm/_silhouette.d.ts +88 -0
- package/lib/esm/_silhouette.js +436 -0
- package/lib/esm/_silhouette.js.map +1 -0
- package/lib/esm/_simplex3.d.ts +2 -0
- package/lib/esm/_simplex3.js +157 -0
- package/lib/esm/_simplex3.js.map +1 -0
- package/lib/esm/_source.d.ts +80 -0
- package/lib/esm/_source.js +187 -0
- package/lib/esm/_source.js.map +1 -0
- package/lib/esm/_sphere-foam.d.ts +34 -0
- package/lib/esm/_sphere-foam.js +131 -0
- package/lib/esm/_sphere-foam.js.map +1 -0
- package/lib/esm/_thin-film.d.ts +26 -0
- package/lib/esm/_thin-film.js +140 -0
- package/lib/esm/_thin-film.js.map +1 -0
- package/lib/esm/ascii.js +63 -73
- package/lib/esm/ascii.js.map +1 -1
- package/lib/esm/bad-jpeg.js +7 -5
- package/lib/esm/bad-jpeg.js.map +1 -1
- package/lib/esm/bloom.js +59 -135
- package/lib/esm/bloom.js.map +1 -1
- package/lib/esm/bubble.d.ts +284 -0
- package/lib/esm/bubble.js +1816 -0
- package/lib/esm/bubble.js.map +1 -0
- package/lib/esm/chromatic.js +1 -0
- package/lib/esm/chromatic.js.map +1 -1
- package/lib/esm/colored-edges.js +1 -0
- package/lib/esm/colored-edges.js.map +1 -1
- package/lib/esm/datamosh.js +172 -182
- package/lib/esm/datamosh.js.map +1 -1
- package/lib/esm/dither.js +6 -3
- package/lib/esm/dither.js.map +1 -1
- package/lib/esm/duotone.js +4 -2
- package/lib/esm/duotone.js.map +1 -1
- package/lib/esm/fluid.js +62 -74
- package/lib/esm/fluid.js.map +1 -1
- package/lib/esm/glass.d.ts +254 -0
- package/lib/esm/glass.js +977 -0
- package/lib/esm/glass.js.map +1 -0
- package/lib/esm/glitch.js +1 -0
- package/lib/esm/glitch.js.map +1 -1
- package/lib/esm/gradient-map.js +4 -1
- package/lib/esm/gradient-map.js.map +1 -1
- package/lib/esm/halftone.js +3 -0
- package/lib/esm/halftone.js.map +1 -1
- package/lib/esm/holo-static.d.ts +3 -0
- package/lib/esm/holo-static.js +13 -0
- package/lib/esm/holo-static.js.map +1 -0
- package/lib/esm/holo.d.ts +401 -0
- package/lib/esm/holo.js +1606 -0
- package/lib/esm/holo.js.map +1 -0
- package/lib/esm/hue-shift.js +1 -0
- package/lib/esm/hue-shift.js.map +1 -1
- package/lib/esm/index.d.ts +18 -9
- package/lib/esm/index.js +7 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/jpeg-glitch.js +274 -275
- package/lib/esm/jpeg-glitch.js.map +1 -1
- package/lib/esm/light-streak.js +34 -47
- package/lib/esm/light-streak.js.map +1 -1
- package/lib/esm/matrix.d.ts +1 -1
- package/lib/esm/matrix.js +48 -59
- package/lib/esm/matrix.js.map +1 -1
- package/lib/esm/package.json +20 -4
- package/lib/esm/particle-explode.js +122 -128
- package/lib/esm/particle-explode.js.map +1 -1
- package/lib/esm/particle.js +253 -258
- package/lib/esm/particle.js.map +1 -1
- package/lib/esm/pattern-refraction.js +1 -0
- package/lib/esm/pattern-refraction.js.map +1 -1
- package/lib/esm/pixel-stretch.js +1 -0
- package/lib/esm/pixel-stretch.js.map +1 -1
- package/lib/esm/pixelate.js +1 -0
- package/lib/esm/pixelate.js.map +1 -1
- package/lib/esm/pixelsort.js +102 -121
- package/lib/esm/pixelsort.js.map +1 -1
- package/lib/esm/rainbow.js +1 -0
- package/lib/esm/rainbow.js.map +1 -1
- package/lib/esm/rgb-glitch.js +1 -0
- package/lib/esm/rgb-glitch.js.map +1 -1
- package/lib/esm/rgb-shift.js +1 -0
- package/lib/esm/rgb-shift.js.map +1 -1
- package/lib/esm/scanline.js +1 -0
- package/lib/esm/scanline.js.map +1 -1
- package/lib/esm/sinewave.js +1 -0
- package/lib/esm/sinewave.js.map +1 -1
- package/lib/esm/slice-shift.js +1 -0
- package/lib/esm/slice-shift.js.map +1 -1
- package/lib/esm/swirl-particle.d.ts +257 -0
- package/lib/esm/swirl-particle.js +2342 -0
- package/lib/esm/swirl-particle.js.map +1 -0
- package/lib/esm/tile-pixelate.js +4 -1
- package/lib/esm/tile-pixelate.js.map +1 -1
- package/lib/esm/tritone.js +5 -2
- package/lib/esm/tritone.js.map +1 -1
- package/lib/esm/vignette.js +1 -0
- package/lib/esm/vignette.js.map +1 -1
- package/lib/esm/voronoi.js +6 -76
- package/lib/esm/voronoi.js.map +1 -1
- package/lib/esm/warp.js +1 -0
- package/lib/esm/warp.js.map +1 -1
- package/package.json +38 -10
package/lib/esm/jpeg-glitch.js
CHANGED
|
@@ -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).
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
214
|
+
this.#dirty = true;
|
|
229
215
|
}
|
|
230
216
|
init(ctx) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
typeof
|
|
234
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
252
|
-
|
|
238
|
+
this.#restoreUnsub = ctx.onContextRestored(() => {
|
|
239
|
+
this.#createOutTexture(ctx);
|
|
253
240
|
// Re-push the last decoded frame, if any.
|
|
254
|
-
|
|
255
|
-
})
|
|
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
|
-
|
|
271
|
+
this.#hasResult = false;
|
|
262
272
|
}
|
|
263
273
|
}
|
|
264
274
|
render(ctx) {
|
|
265
|
-
if (this.params.bypass || !
|
|
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
|
-
|
|
269
|
-
|
|
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 !==
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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 !==
|
|
288
|
-
|
|
297
|
+
if (w !== this.#w || h !== this.#h) {
|
|
298
|
+
this.#resize(ctx, w, h);
|
|
289
299
|
}
|
|
290
|
-
if (
|
|
291
|
-
|
|
300
|
+
if (this.#shouldGlitch(ctx)) {
|
|
301
|
+
this.#startGlitch(ctx);
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
|
-
if (
|
|
304
|
+
if (this.#hasResult && this.#outTex) {
|
|
295
305
|
// Upload the decoded canvas to the GPU only when it changed.
|
|
296
|
-
if (
|
|
297
|
-
|
|
306
|
+
if (this.#uploadPending) {
|
|
307
|
+
this.#uploadOutCanvas(ctx);
|
|
298
308
|
}
|
|
299
309
|
ctx.draw({
|
|
300
310
|
frag: FRAG_OUTPUT,
|
|
301
|
-
uniforms: { tex:
|
|
311
|
+
uniforms: { tex: this.#outTex },
|
|
302
312
|
target: ctx.target,
|
|
303
313
|
});
|
|
304
314
|
}
|
|
305
315
|
else {
|
|
306
|
-
|
|
316
|
+
this.#passthrough(ctx);
|
|
307
317
|
}
|
|
308
318
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
-
|
|
432
|
-
|
|
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
|
-
//
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
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
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|