1
- import { Filter , GlProgram , GpuProgram , Point , UniformGroup } from 'pixi.js' ;
1
+ import { Filter , GlProgram , GpuProgram , Point } from 'pixi.js' ;
2
2
import { vertex , wgslVertex } from '../defaults' ;
3
3
import fragment from './pixelate.frag' ;
4
4
import source from './pixelate.wgsl' ;
@@ -15,21 +15,12 @@ type Size = number | number[] | Point;
15
15
*/
16
16
export class PixelateFilter extends Filter
17
17
{
18
- /** Default values for options. */
19
- public static readonly DEFAULT_SIZE : Size = 10 ;
20
-
21
18
/**
22
19
* @param {Point|Array<number>|number } [size=10] - Either the width/height of the size of the pixels, or square size
23
20
*/
24
- constructor ( size : Size )
21
+ constructor ( size : Size = 10 )
25
22
{
26
- size = size ?? PixelateFilter . DEFAULT_SIZE ;
27
-
28
- const pixelateUniforms = new UniformGroup ( {
29
- uSize : { value : new Float32Array ( 2 ) , type : 'vec2<f32>' } ,
30
- } ) ;
31
-
32
- const gpuProgram = new GpuProgram ( {
23
+ const gpuProgram = GpuProgram . from ( {
33
24
vertex : {
34
25
source : wgslVertex ,
35
26
entryPoint : 'mainVertex' ,
@@ -40,7 +31,7 @@ export class PixelateFilter extends Filter
40
31
} ,
41
32
} ) ;
42
33
43
- const glProgram = new GlProgram ( {
34
+ const glProgram = GlProgram . from ( {
44
35
vertex,
45
36
fragment,
46
37
name : 'pixelate-filter' ,
@@ -50,7 +41,9 @@ export class PixelateFilter extends Filter
50
41
gpuProgram,
51
42
glProgram,
52
43
resources : {
53
- pixelateUniforms,
44
+ pixelateUniforms : {
45
+ uSize : { value : new Float32Array ( 2 ) , type : 'vec2<f32>' } ,
46
+ } ,
54
47
} ,
55
48
} ) ;
56
49
0 commit comments