@@ -226,7 +226,7 @@ import { Mesh } from 'three';
226
226
})
227
227
export class SceneGraph {
228
228
229
- meshRef = viewChild.required<ElementRef<Mesh>('mesh');
229
+ meshRef = viewChild.required<ElementRef<Mesh>> ('mesh');
230
230
231
231
constructor() {
232
232
@@ -250,7 +250,7 @@ Using Angular means we can make components out of our template. Let's do that fo
250
250
<Tabs >
251
251
<TabItem label = " src/app/cube.component.ts" >
252
252
``` angular-ts
253
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from '@angular/core';
253
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild } from '@angular/core';
254
254
import { injectBeforeRender } from 'angular-three';
255
255
import { Mesh } from 'three';
256
256
@@ -261,7 +261,8 @@ Using Angular means we can make components out of our template. Let's do that fo
261
261
<ngt-mesh #mesh>
262
262
<ngt-box-geometry />
263
263
</ngt-mesh>
264
- `
264
+ `,
265
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
265
266
})
266
267
export class Cube {
267
268
meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
@@ -310,8 +311,8 @@ We will add 2 states `hovered` and `clicked` to the cube component:
310
311
- When the cube is clicked, we'll change its scale
311
312
312
313
``` diff lang="angular-ts" title="src/app/cube.component.ts"
313
- - import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from '@angular/core';
314
- + import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild , signal } from '@angular/core';
314
+ - import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild } from '@angular/core';
315
+ + import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild , signal } from '@angular/core';
315
316
import { injectBeforeRender } from 'angular-three';
316
317
import { Mesh } from 'three';
317
318
@@ -330,6 +331,7 @@ import { Mesh } from 'three';
330
331
+ <ngt-mesh-basic-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
331
332
</ngt-mesh>
332
333
`,
334
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
333
335
})
334
336
export class Cube {
335
337
meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
@@ -361,8 +363,8 @@ However, we need to render the cube in different positions so we can see them bo
361
363
Let's do that by adding a ` position ` input to the Cube component
362
364
363
365
``` diff lang="angular-ts" title="src/app/cube.component.ts"
364
- - import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild , signal } from '@angular/core';
365
- + import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild , signal, input } from '@angular/core';
366
+ - import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild , signal } from '@angular/core';
367
+ + import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild , signal, input } from '@angular/core';
366
368
367
369
- import { injectBeforeRender } from 'angular-three';
368
370
+ import { injectBeforeRender, NgtVector3 } from 'angular-three';
@@ -384,6 +386,7 @@ import { Mesh } from 'three';
384
386
<ngt-mesh-basic-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
385
387
</ngt-mesh>
386
388
`,
389
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
387
390
})
388
391
export class Cube {
389
392
+ position = input<NgtVector3>([0, 0, 0]);
@@ -420,7 +423,7 @@ import { Cube } from './cube.component';
420
423
+ <app-cube [position]="[1.5, 0, 0]" />
421
424
+ <app-cube [position]="[-1.5, 0, 0]" />
422
425
`,
423
- imports: [Cube]
426
+ imports: [Cube],
424
427
schemas: [CUSTOM_ELEMENTS_SCHEMA],
425
428
changeDetection: ChangeDetectionStrategy.OnPush,
426
429
})
@@ -463,7 +466,7 @@ export class SceneGraph {
463
466
Next, we will want to change the ` Material ` of the cube to ` MeshStandardMaterial ` so that it can be lit by the lights.
464
467
465
468
``` diff lang="angular-ts" title="src/app/cube.component.ts"
466
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild , signal, input } from '@angular/core';
469
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild , signal, input } from '@angular/core';
467
470
import { injectBeforeRender, NgtVector3 } from 'angular-three';
468
471
import { Mesh } from 'three';
469
472
@@ -484,6 +487,7 @@ import { Mesh } from 'three';
484
487
+ <ngt-mesh-standard-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
485
488
</ngt-mesh>
486
489
`,
490
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
487
491
})
488
492
export class Cube {
489
493
position = input<NgtVector3>([0, 0, 0]);
0 commit comments