Skip to content

Commit da4a798

Browse files
committed
fix: run cdr after load assets
1 parent ce2b986 commit da4a798

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libs/angular-three/src/lib/loader.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ChangeDetectorRef, inject } from '@angular/core';
12
import {
23
catchError,
34
forkJoin,
@@ -52,6 +53,7 @@ function injectLoader<TReturnType, TUrl extends string | string[] | Record<strin
5253
onProgress?: (event: ProgressEvent) => void
5354
): Observable<NgtLoaderResults<TUrl, NgtBranchingReturn<TReturnType, GLTF, GLTF & NgtObjectMap>>> {
5455
const urls$ = isObservable(input) ? input : of(input);
56+
const cdr = inject(ChangeDetectorRef);
5557

5658
return urls$.pipe(
5759
map((inputs) => {
@@ -92,6 +94,9 @@ function injectLoader<TReturnType, TUrl extends string | string[] | Record<strin
9294
result[key as keyof typeof result] = results[keys.indexOf(key)];
9395
return result;
9496
}, {} as { [key in keyof TUrl]: NgtBranchingReturn<TReturnType, GLTF, GLTF & NgtObjectMap> });
97+
}),
98+
tap(() => {
99+
requestAnimationFrame(() => cdr.detectChanges());
95100
})
96101
);
97102
})

0 commit comments

Comments
 (0)