@@ -3,10 +3,8 @@ import {
33 ChangeDetectionStrategy ,
44 Component ,
55 ElementRef ,
6- Injector ,
76 computed ,
87 effect ,
9- inject ,
108 input ,
119 viewChild ,
1210} from '@angular/core' ;
@@ -66,7 +64,6 @@ function isConvolution(effect: Effect) {
6664export class NgtpEffectComposer {
6765 options = input ( defaultOptions , { transform : mergeInputs ( defaultOptions ) } ) ;
6866
69- private injector = inject ( Injector ) ;
7067 private store = injectStore ( ) ;
7168
7269 private depthBuffer = pick ( this . options , 'depthBuffer' ) ;
@@ -157,7 +154,7 @@ export class NgtpEffectComposer {
157154 } ) ;
158155
159156 effect ( ( ) => {
160- const [ { composer } , width , height ] = [ this . composerData ( ) , this . store . size . width ( ) , this . store . size . height ( ) ] ;
157+ const [ composer , width , height ] = [ this . effectComposer ( ) , this . store . size . width ( ) , this . store . size . height ( ) ] ;
161158 if ( composer ) {
162159 composer . setSize ( width , height ) ;
163160 }
@@ -213,29 +210,23 @@ export class NgtpEffectComposer {
213210 } ) ;
214211 } ) ;
215212
216- effect ( ( onCleanup ) => {
217- const priority = this . priority ( ) ;
218-
219- const sub = injectBeforeRender (
220- ( { delta } ) => {
221- const [ { composer } , { enabled, autoClear, stencilBuffer } , gl ] = [
222- this . composerData ( ) ,
223- this . options ( ) ,
224- this . store . snapshot . gl ,
225- ] ;
226-
227- if ( enabled ) {
228- const currentAutoClear = gl . autoClear ;
229- gl . autoClear = autoClear ;
230- if ( stencilBuffer && ! autoClear ) gl . clearStencil ( ) ;
231- composer . render ( delta ) ;
232- gl . autoClear = currentAutoClear ;
233- }
234- } ,
235- { injector : this . injector , priority } ,
236- ) ;
237-
238- onCleanup ( ( ) => sub ( ) ) ;
239- } ) ;
213+ injectBeforeRender (
214+ ( { delta } ) => {
215+ const [ composer , { enabled, autoClear, stencilBuffer } , gl ] = [
216+ this . effectComposer ( ) ,
217+ this . options ( ) ,
218+ this . store . snapshot . gl ,
219+ ] ;
220+
221+ if ( enabled ) {
222+ const currentAutoClear = gl . autoClear ;
223+ gl . autoClear = autoClear ;
224+ if ( stencilBuffer && ! autoClear ) gl . clearStencil ( ) ;
225+ composer . render ( delta ) ;
226+ gl . autoClear = currentAutoClear ;
227+ }
228+ } ,
229+ { priority : this . priority } ,
230+ ) ;
240231 }
241232}
0 commit comments