1
1
import {
2
+ deprecation ,
2
3
Filter ,
3
4
FilterSystem ,
4
5
GlProgram ,
5
6
GpuProgram ,
6
7
PointData ,
7
8
RenderSurface ,
8
9
Texture ,
9
- UniformGroup ,
10
10
} from 'pixi.js' ;
11
11
import { vertex , wgslVertex } from '../defaults' ;
12
12
import fragment from './shockwave.frag' ;
@@ -44,6 +44,11 @@ export interface ShockwaveFilterOptions
44
44
* @default -1
45
45
*/
46
46
radius ?: number ;
47
+ /**
48
+ * Sets the elapsed time of the shockwave.
49
+ * @default 0
50
+ */
51
+ time ?: number ;
47
52
}
48
53
49
54
/**
@@ -83,8 +88,35 @@ export class ShockwaveFilter extends Filter
83
88
/**
84
89
* @param options
85
90
*/
86
- constructor ( options ?: ShockwaveFilterOptions )
91
+ constructor ( options ?: ShockwaveFilterOptions ) ;
92
+ /**
93
+ * @deprecated since 6.0.0
94
+ *
95
+ * @param {PIXI.PointData|number[] } [center=[0.5, 0.5]] - See `center` property.
96
+ * @param {object } [options] - The optional parameters of shockwave filter.
97
+ * @param {number } [options.amplitude=0.5] - See `amplitude`` property.
98
+ * @param {number } [options.wavelength=1.0] - See `wavelength` property.
99
+ * @param {number } [options.speed=500.0] - See `speed` property.
100
+ * @param {number } [options.brightness=8] - See `brightness` property.
101
+ * @param {number } [options.radius=4] - See `radius` property.
102
+ * @param {number } [time=0] - See `time` property.
103
+ */
104
+ constructor ( center ?: PointData | number [ ] , options ?: Omit < ShockwaveFilterOptions , 'time' | 'center' > , time ?: number ) ;
105
+ // eslint-disable-next-line max-len
106
+ constructor ( ...args : [ ShockwaveFilterOptions ?] | [ ( PointData | number [ ] ) ?, Omit < ShockwaveFilterOptions , 'time' | 'center' > ?, number ?] )
87
107
{
108
+ let options = args [ 0 ] ?? { } ;
109
+
110
+ if ( Array . isArray ( options ) || ( 'x' in options && 'y' in options ) )
111
+ {
112
+ // eslint-disable-next-line max-len
113
+ deprecation ( '6.0.0' , 'ShockwaveFilter constructor params are now options object. See params: { center, speed, amplitude, wavelength, brightness, radius, time }' ) ;
114
+
115
+ options = { center : options , ...args [ 1 ] } as ShockwaveFilterOptions ;
116
+
117
+ if ( args [ 2 ] !== undefined ) options . time = args [ 2 ] ;
118
+ }
119
+
88
120
options = { ...ShockwaveFilter . DEFAULT_OPTIONS , ...options } ;
89
121
90
122
const gpuProgram = GpuProgram . from ( {
@@ -108,12 +140,12 @@ export class ShockwaveFilter extends Filter
108
140
gpuProgram,
109
141
glProgram,
110
142
resources : {
111
- shockwaveUniforms : new UniformGroup ( {
112
- uTime : { value : 0 , type : 'f32' } ,
143
+ shockwaveUniforms : {
144
+ uTime : { value : options . time , type : 'f32' } ,
113
145
uCenter : { value : options . center , type : 'vec2<f32>' } ,
114
146
uSpeed : { value : options . speed , type : 'f32' } ,
115
147
uWave : { value : new Float32Array ( 4 ) , type : 'vec4<f32>' } ,
116
- } )
148
+ } ,
117
149
} ,
118
150
} ) ;
119
151
@@ -143,7 +175,15 @@ export class ShockwaveFilter extends Filter
143
175
* @default [0,0]
144
176
*/
145
177
get center ( ) : PointData { return this . uniforms . uCenter ; }
146
- set center ( value : PointData ) { this . uniforms . uCenter = value ; }
178
+ set center ( value : PointData | number [ ] )
179
+ {
180
+ if ( Array . isArray ( value ) )
181
+ {
182
+ value = { x : value [ 0 ] , y : value [ 1 ] } ;
183
+ }
184
+
185
+ this . uniforms . uCenter = value ;
186
+ }
147
187
148
188
/**
149
189
* Sets the center of the effect in normalized screen coords on the `x` axis
0 commit comments