@@ -71,6 +71,7 @@ export default class DemoApplication extends PIXI.Application
71
71
height : this . initHeight ,
72
72
autoStart : false ,
73
73
preference,
74
+ useBackBuffer : true ,
74
75
} ) ;
75
76
}
76
77
@@ -96,7 +97,6 @@ export default class DemoApplication extends PIXI.Application
96
97
// Setup the container
97
98
this . pond = new PIXI . Container ( ) ;
98
99
this . pond . filterArea = this . filterArea ;
99
- this . pond . filters = this . pondFilters ;
100
100
this . stage . addChild ( this . pond ) ;
101
101
102
102
// Setup the background image
@@ -208,8 +208,6 @@ export default class DemoApplication extends PIXI.Application
208
208
209
209
this . events . emit ( 'animate' , delta , animateTimer ) ;
210
210
211
- this . pond . filters = this . pondFilters ;
212
-
213
211
if ( ! this . animating )
214
212
{
215
213
return ;
@@ -224,7 +222,6 @@ export default class DemoApplication extends PIXI.Application
224
222
const fish = this . fishes [ i ] ;
225
223
226
224
fish . direction += fish . turnSpeed * 0.01 ;
227
- fish . filters = this . fishFilters ;
228
225
fish . x += Math . sin ( fish . direction ) * fish . speed ;
229
226
fish . y += Math . cos ( fish . direction ) * fish . speed ;
230
227
@@ -302,28 +299,45 @@ export default class DemoApplication extends PIXI.Application
302
299
// https://github.com/orgs/pixijs/projects/2/views/4?pane=issue&itemId=48582986
303
300
const toggleFilter = ( enabled ) =>
304
301
{
305
- if ( enabled )
302
+ if ( options . fishOnly )
306
303
{
307
- if ( options . fishOnly )
304
+ const fishFilters = [ ...this . fishFilters ] ;
305
+
306
+ if ( enabled )
308
307
{
309
- this . fishFilters . push ( filter ) ;
308
+ fishFilters . push ( filter ) ;
310
309
}
311
310
else
312
311
{
313
- this . pondFilters . push ( filter ) ;
314
- }
315
- }
316
- else if ( options . fishOnly )
317
- {
318
- const index = this . fishFilters . indexOf ( filter ) ;
312
+ const index = fishFilters . indexOf ( filter ) ;
319
313
320
- if ( index !== - 1 ) this . fishFilters . splice ( index , 1 ) ;
314
+ if ( index !== - 1 ) fishFilters . splice ( index , 1 ) ;
315
+ }
316
+ this . fishFilters = fishFilters ;
317
+ this . fishes . forEach ( ( fish ) =>
318
+ {
319
+ fish . filters = fishFilters ;
320
+ } ) ;
321
321
}
322
322
else
323
323
{
324
- const index = this . pondFilters . indexOf ( filter ) ;
324
+ const pondFilters = [ ...this . pondFilters ] ;
325
+
326
+ if ( enabled )
327
+ {
328
+ pondFilters . push ( filter ) ;
329
+ }
330
+ else
331
+ {
332
+ const index = pondFilters . indexOf ( filter ) ;
333
+
334
+ if ( index !== - 1 ) pondFilters . splice ( index , 1 ) ;
335
+ }
325
336
326
- if ( index !== - 1 ) this . pondFilters . splice ( index , 1 ) ;
337
+ this . pondFilters = pondFilters ;
338
+ // TODO: seems like a bug, requiring invalidation
339
+ this . pond . filters = [ ] ;
340
+ this . pond . filters = pondFilters ;
327
341
}
328
342
} ;
329
343
0 commit comments