Skip to content

Commit

Permalink
Chore: PixelateFilter backward-compatibility (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Baz Utsahajit <[email protected]>
  • Loading branch information
bbazukun123 and bbazukun123 authored Feb 14, 2024
1 parent 3d4f7c3 commit 2216543
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/pixelate/PixelateFilter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filter, GlProgram, GpuProgram, Point, UniformGroup } from 'pixi.js';
import { Filter, GlProgram, GpuProgram, Point } from 'pixi.js';
import { vertex, wgslVertex } from '../defaults';
import fragment from './pixelate.frag';
import source from './pixelate.wgsl';
Expand All @@ -15,20 +15,11 @@ type Size = number | number[] | Point;
*/
export class PixelateFilter extends Filter
{
/** Default values for options. */
public static readonly DEFAULT_SIZE: Size = 10;

/**
* @param {Point|Array<number>|number} [size=10] - Either the width/height of the size of the pixels, or square size
*/
constructor(size: Size)
constructor(size: Size = 10)
{
size = size ?? PixelateFilter.DEFAULT_SIZE;

const pixelateUniforms = new UniformGroup({
uSize: { value: new Float32Array(2), type: 'vec2<f32>' },
});

const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
Expand All @@ -50,7 +41,9 @@ export class PixelateFilter extends Filter
gpuProgram,
glProgram,
resources: {
pixelateUniforms,
pixelateUniforms: {
uSize: { value: new Float32Array(2), type: 'vec2<f32>' },
},
},
});

Expand Down

0 comments on commit 2216543

Please sign in to comment.