7
7
computed ,
8
8
createEnvironmentInjector ,
9
9
DestroyRef ,
10
+ effect ,
10
11
ElementRef ,
11
12
EnvironmentInjector ,
12
13
inject ,
@@ -21,7 +22,6 @@ import {
21
22
ViewContainerRef ,
22
23
} from '@angular/core' ;
23
24
import { outputFromObservable } from '@angular/core/rxjs-interop' ;
24
- import { injectAutoEffect } from 'ngxtension/auto-effect' ;
25
25
import { NgxResize , provideResizeOptions , ResizeOptions , ResizeResult } from 'ngxtension/resize' ;
26
26
import { Raycaster , Scene , Vector3 } from 'three' ;
27
27
import { createPointerEvents } from './dom/events' ;
@@ -58,7 +58,6 @@ import { is } from './utils/is';
58
58
export class NgtCanvas {
59
59
private store = injectStore ( ) ;
60
60
private initRoot = injectCanvasRootInitializer ( ) ;
61
- private autoEffect = injectAutoEffect ( ) ;
62
61
63
62
private host = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
64
63
private zone = inject ( NgZone ) ;
@@ -112,7 +111,12 @@ export class NgtCanvas {
112
111
afterNextRender ( ( ) => {
113
112
this . zone . runOutsideAngular ( ( ) => {
114
113
this . configurator = this . initRoot ( this . glCanvas ( ) . nativeElement ) ;
115
- this . noZoneResizeEffect ( ) ;
114
+ effect (
115
+ ( ) => {
116
+ this . noZoneResizeEffect ( ) ;
117
+ } ,
118
+ { injector : this . injector } ,
119
+ ) ;
116
120
} ) ;
117
121
} ) ;
118
122
@@ -124,39 +128,37 @@ export class NgtCanvas {
124
128
}
125
129
126
130
private noZoneResizeEffect ( ) {
127
- this . autoEffect ( ( ) => {
128
- const resizeResult = this . resizeResult ( ) ;
129
- if ( resizeResult . width > 0 && resizeResult . height > 0 ) {
130
- if ( ! this . configurator ) this . configurator = this . initRoot ( this . glCanvas ( ) . nativeElement ) ;
131
- this . configurator . configure ( {
132
- gl : this . gl ( ) ,
133
- shadows : this . shadows ( ) ,
134
- legacy : this . legacy ( ) ,
135
- linear : this . linear ( ) ,
136
- flat : this . flat ( ) ,
137
- orthographic : this . orthographic ( ) ,
138
- frameloop : this . frameloop ( ) ,
139
- performance : this . performance ( ) ,
140
- dpr : this . dpr ( ) ,
141
- raycaster : this . raycaster ( ) ,
142
- scene : this . scene ( ) ,
143
- camera : this . camera ( ) ,
144
- events : this . events ( ) ,
145
- eventSource : this . eventSource ( ) ,
146
- eventPrefix : this . eventPrefix ( ) ,
147
- lookAt : this . lookAt ( ) ,
148
- size : resizeResult ,
149
- } ) ;
150
-
151
- untracked ( ( ) => {
152
- if ( this . glRef ) {
153
- this . glRef . changeDetectorRef . detectChanges ( ) ;
154
- } else {
155
- this . noZoneRender ( ) ;
156
- }
157
- } ) ;
158
- }
159
- } ) ;
131
+ const resizeResult = this . resizeResult ( ) ;
132
+ if ( resizeResult . width > 0 && resizeResult . height > 0 ) {
133
+ if ( ! this . configurator ) this . configurator = this . initRoot ( this . glCanvas ( ) . nativeElement ) ;
134
+ this . configurator . configure ( {
135
+ gl : this . gl ( ) ,
136
+ shadows : this . shadows ( ) ,
137
+ legacy : this . legacy ( ) ,
138
+ linear : this . linear ( ) ,
139
+ flat : this . flat ( ) ,
140
+ orthographic : this . orthographic ( ) ,
141
+ frameloop : this . frameloop ( ) ,
142
+ performance : this . performance ( ) ,
143
+ dpr : this . dpr ( ) ,
144
+ raycaster : this . raycaster ( ) ,
145
+ scene : this . scene ( ) ,
146
+ camera : this . camera ( ) ,
147
+ events : this . events ( ) ,
148
+ eventSource : this . eventSource ( ) ,
149
+ eventPrefix : this . eventPrefix ( ) ,
150
+ lookAt : this . lookAt ( ) ,
151
+ size : resizeResult ,
152
+ } ) ;
153
+
154
+ untracked ( ( ) => {
155
+ if ( this . glRef ) {
156
+ this . glRef . changeDetectorRef . detectChanges ( ) ;
157
+ } else {
158
+ this . noZoneRender ( ) ;
159
+ }
160
+ } ) ;
161
+ }
160
162
}
161
163
162
164
private noZoneRender ( ) {
0 commit comments