1- import { ChangeDetectionStrategy , Component , CUSTOM_ELEMENTS_SCHEMA , input , Signal } from '@angular/core' ;
1+ import {
2+ ChangeDetectionStrategy ,
3+ Component ,
4+ CUSTOM_ELEMENTS_SCHEMA ,
5+ effect ,
6+ input ,
7+ output ,
8+ signal ,
9+ Signal ,
10+ } from '@angular/core' ;
211import { Meta } from '@storybook/angular' ;
312import { NgtAnyRecord , NgtArgs } from 'angular-three' ;
413import { NgtsGrid } from 'angular-three-soba/abstractions' ;
@@ -40,6 +49,14 @@ class Suzi {
4049
4150 rotation = input ( [ 0 , 0 , 0 ] ) ;
4251 scale = input ( 1 ) ;
52+ loaded = output < void > ( ) ;
53+
54+ constructor ( ) {
55+ effect ( ( ) => {
56+ const gltf = this . gltf ( ) ;
57+ if ( gltf ) this . loaded . emit ( ) ;
58+ } ) ;
59+ }
4360}
4461
4562@Component ( {
@@ -63,22 +80,24 @@ class Shadows {}
6380 template : `
6481 <ngt-group [position]="[0, -0.5, 0]">
6582 <ngts-center [options]="{ top: true }">
66- <grid-suzi [rotation]="[-0.63, 0, 0]" [scale]="2" />
83+ <grid-suzi [rotation]="[-0.63, 0, 0]" [scale]="2" (loaded)="loaded.set(true)" />
6784 </ngts-center>
6885
69- <ngts-center [options]="{ top: true, position: [-2, 0, 2] }">
70- <ngt-mesh [castShadow]="true">
71- <ngt-sphere-geometry *args="[0.5, 64, 64]" />
72- <ngt-mesh-standard-material color="#9d4b4b" />
73- </ngt-mesh>
74- </ngts-center>
86+ @if (loaded()) {
87+ <ngts-center [options]="{ top: true, position: [-2, 0, 2] }">
88+ <ngt-mesh [castShadow]="true">
89+ <ngt-sphere-geometry *args="[0.5, 64, 64]" />
90+ <ngt-mesh-standard-material color="#9d4b4b" />
91+ </ngt-mesh>
92+ </ngts-center>
7593
76- <ngts-center [options]="{ top: true, position: [2.5, 0, 1] }">
77- <ngt-mesh [castShadow]="true" [rotation]="[0, Math.PI / 4, 0]">
78- <ngt-box-geometry *args="[0.7, 0.7, 0.7]" />
79- <ngt-mesh-standard-material color="#9d4b4b" />
80- </ngt-mesh>
81- </ngts-center>
94+ <ngts-center [options]="{ top: true, position: [2.5, 0, 1] }">
95+ <ngt-mesh [castShadow]="true" [rotation]="[0, Math.PI / 4, 0]">
96+ <ngt-box-geometry *args="[0.7, 0.7, 0.7]" />
97+ <ngt-mesh-standard-material color="#9d4b4b" />
98+ </ngt-mesh>
99+ </ngts-center>
100+ }
82101
83102 <grid-shadows />
84103
@@ -108,6 +127,7 @@ class Shadows {}
108127} )
109128class DefaultGridStory {
110129 Math = Math ;
130+ loaded = signal ( false ) ;
111131}
112132
113133export default {
0 commit comments