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' ;
2
11
import { Meta } from '@storybook/angular' ;
3
12
import { NgtAnyRecord , NgtArgs } from 'angular-three' ;
4
13
import { NgtsGrid } from 'angular-three-soba/abstractions' ;
@@ -40,6 +49,14 @@ class Suzi {
40
49
41
50
rotation = input ( [ 0 , 0 , 0 ] ) ;
42
51
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
+ }
43
60
}
44
61
45
62
@Component ( {
@@ -63,22 +80,24 @@ class Shadows {}
63
80
template : `
64
81
<ngt-group [position]="[0, -0.5, 0]">
65
82
<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)" />
67
84
</ngts-center>
68
85
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>
75
93
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
+ }
82
101
83
102
<grid-shadows />
84
103
@@ -108,6 +127,7 @@ class Shadows {}
108
127
} )
109
128
class DefaultGridStory {
110
129
Math = Math ;
130
+ loaded = signal ( false ) ;
111
131
}
112
132
113
133
export default {
0 commit comments