11import { NgTemplateOutlet } from '@angular/common' ;
22import {
3- afterNextRender ,
43 ChangeDetectionStrategy ,
54 Component ,
65 computed ,
@@ -92,17 +91,19 @@ export class ManagePortalScene {
9291 return [ quad , blend ] as const ;
9392 } ) ;
9493
94+ effect ( ( ) => {
95+ portalScene ( ) . matrixAutoUpdate = false ;
96+ } ) ;
97+
9598 effect ( ( ) => {
9699 const [ events , setEvents ] = [ this . events ( ) , portalSetEvents ( ) ] ;
97100 if ( ! events ) return ;
98101 setEvents ( { enabled : events } ) ;
99102 } ) ;
100103
101- afterNextRender ( ( ) => {
102- portalScene ( ) . matrixAutoUpdate = false ;
103- } ) ;
104-
105104 effect ( ( onCleanup ) => {
105+ const priority = this . priority ( ) ;
106+
106107 // we start the before render in effect because we need the priority input to be resolved
107108 const sub = injectBeforeRender (
108109 ( { gl, camera } ) => {
@@ -115,9 +116,8 @@ export class ManagePortalScene {
115116 if ( ! parent ) return ;
116117
117118 const materialBlend = 'blend' in material && typeof material . blend === 'number' ? material . blend : 0 ;
118- const [ worldUnits , priority , rootScene , scene , [ quad , blend ] ] = [
119+ const [ worldUnits , rootScene , scene , [ quad , blend ] ] = [
119120 this . worldUnits ( ) ,
120- this . priority ( ) ,
121121 this . rootScene ( ) ,
122122 portalScene ( ) ,
123123 fullScreenQuad ( ) ,
@@ -150,7 +150,7 @@ export class ManagePortalScene {
150150 }
151151 }
152152 } ,
153- { injector, priority : this . priority ( ) } ,
153+ { injector, priority } ,
154154 ) ;
155155 onCleanup ( ( ) => sub ( ) ) ;
156156 } ) ;
@@ -285,19 +285,22 @@ export class NgtsMeshPortalMaterial {
285285 constructor ( ) {
286286 extend ( { MeshPortalMaterial } ) ;
287287
288- afterNextRender ( ( ) => {
289- const material = this . materialRef ( ) . nativeElement ;
288+ effect (
289+ ( ) => {
290+ const material = this . materialRef ( ) . nativeElement ;
290291
291- const localState = getLocalState ( material ) ;
292- if ( ! localState ) return ;
292+ const localState = getLocalState ( material ) ;
293+ if ( ! localState ) return ;
293294
294- const materialParent = localState . parent ( ) ;
295- if ( ! materialParent || ! ( materialParent instanceof Mesh ) ) return ;
295+ const materialParent = localState . parent ( ) ;
296+ if ( ! materialParent || ! ( materialParent instanceof Mesh ) ) return ;
296297
297- // Since the ref above is not tied to a mesh directly (we're inside a material),
298- // it has to be tied to the parent mesh here
299- this . parent . set ( materialParent ) ;
300- } ) ;
298+ // Since the ref above is not tied to a mesh directly (we're inside a material),
299+ // it has to be tied to the parent mesh here
300+ this . parent . set ( materialParent ) ;
301+ } ,
302+ { allowSignalWrites : true } ,
303+ ) ;
301304
302305 effect ( ( ) => {
303306 const events = this . events ( ) ;
0 commit comments