Skip to content

docs: fix syntax errors in first scene #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ import { Mesh } from 'three';
})
export class SceneGraph {

meshRef = viewChild.required<ElementRef<Mesh>('mesh');
meshRef = viewChild.required<ElementRef<Mesh>>('mesh');

constructor() {

Expand All @@ -250,7 +250,7 @@ Using Angular means we can make components out of our template. Let's do that fo
<Tabs>
<TabItem label="src/app/cube.component.ts">
```angular-ts
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from '@angular/core';
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild } from '@angular/core';
import { injectBeforeRender } from 'angular-three';
import { Mesh } from 'three';

Expand All @@ -261,7 +261,8 @@ Using Angular means we can make components out of our template. Let's do that fo
<ngt-mesh #mesh>
<ngt-box-geometry />
</ngt-mesh>
`
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class Cube {
meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
Expand Down Expand Up @@ -310,8 +311,8 @@ We will add 2 states `hovered` and `clicked` to the cube component:
- When the cube is clicked, we'll change its scale

```diff lang="angular-ts" title="src/app/cube.component.ts"
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from '@angular/core';
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild, signal } from '@angular/core';
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild } from '@angular/core';
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild, signal } from '@angular/core';
import { injectBeforeRender } from 'angular-three';
import { Mesh } from 'three';

Expand All @@ -330,6 +331,7 @@ import { Mesh } from 'three';
+ <ngt-mesh-basic-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
</ngt-mesh>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class Cube {
meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
Expand Down Expand Up @@ -361,8 +363,8 @@ However, we need to render the cube in different positions so we can see them bo
Let's do that by adding a `position` input to the Cube component

```diff lang="angular-ts" title="src/app/cube.component.ts"
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild, signal } from '@angular/core';
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild, signal, input } from '@angular/core';
- import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild, signal } from '@angular/core';
+ import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild, signal, input } from '@angular/core';

- import { injectBeforeRender } from 'angular-three';
+ import { injectBeforeRender, NgtVector3 } from 'angular-three';
Expand All @@ -384,6 +386,7 @@ import { Mesh } from 'three';
<ngt-mesh-basic-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
</ngt-mesh>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class Cube {
+ position = input<NgtVector3>([0, 0, 0]);
Expand Down Expand Up @@ -420,7 +423,7 @@ import { Cube } from './cube.component';
+ <app-cube [position]="[1.5, 0, 0]" />
+ <app-cube [position]="[-1.5, 0, 0]" />
`,
imports: [Cube]
imports: [Cube],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down Expand Up @@ -463,7 +466,7 @@ export class SceneGraph {
Next, we will want to change the `Material` of the cube to `MeshStandardMaterial` so that it can be lit by the lights.

```diff lang="angular-ts" title="src/app/cube.component.ts"
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild, signal, input } from '@angular/core';
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild, signal, input } from '@angular/core';
import { injectBeforeRender, NgtVector3 } from 'angular-three';
import { Mesh } from 'three';

Expand All @@ -484,6 +487,7 @@ import { Mesh } from 'three';
+ <ngt-mesh-standard-material [color]="hovered() ? 'darkred' : 'mediumpurple'" />
</ngt-mesh>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class Cube {
position = input<NgtVector3>([0, 0, 0]);
Expand Down