Skip to content

Commit baffa23

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
docs: start on migration docs
1 parent ce80683 commit baffa23

File tree

1 file changed

+25
-56
lines changed

1 file changed

+25
-56
lines changed
Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,39 @@
11
---
22
id: migrate
3-
title: Migrate to Angular Three (WIP)
4-
sidebar_label: Migrate to Angular Three (WIP)
3+
title: Migrate to V2
4+
sidebar_label: Migrate to V2
55
---
66

7-
## Packages
7+
Angular Three v2 is utilizing [Angular Signals](https://angular.io/guide/signals) under the hood so there are some fundamental changes
8+
as to how things work
89

9-
NGT is now distributed via `angular-three` (and auxiliary packages like `angular-three-soba` or `angular-three-cannon`) instead of `@angular-three/*`
10+
### `NgtStore`
1011

11-
```shell
12-
npx ng add angular-three
13-
npx ng add angular-three-soba
14-
npx ng add angular-three-cannon
15-
...
16-
```
17-
18-
## Canvas
19-
20-
The Scene Graph now has to be in a separate component instead of inline as Content Child to the `NgtCanvas`.
21-
22-
```html title="app.component.html"
23-
<!-- before -->
24-
<ngt-canvas>
25-
<ng-template>
26-
<ngt-mesh></ngt-mesh>
27-
</ng-template>
28-
</ngt-canvas>
29-
```
30-
31-
```html title="app.component.html"
32-
<!-- after -->
33-
<ngt-canvas [sceneGraph]="Scene" />
34-
```
12+
`NgtStore` utilizes Signal APIs that returns reactive properties as `Signal<Type>` instead of `Observable<Type>`. Check out [Store](../api/store) for more information
3513

36-
where `Scene` is a reference to the component with our Scene graph.
14+
```ts
15+
export class Scene {
16+
readonly #store = inject(NgtStore);
3717

38-
```ts title="app.component.ts"
39-
@Component({
40-
standalone: true,
41-
template: ` <ngt-mesh></ngt-mesh> `,
42-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
43-
})
44-
export class SceneComponent {}
18+
// before
19+
readonly camera$ = this.#store.select('camera'); // Observable<NgtCamera>
20+
readonly glDom$ = this.#store.select('gl', 'domElement'); // Observable<HTMLElement>
21+
readonly orbitControlsArgs$ = combineLatest([this.camera$, this.glDom$]); // Observable<[NgtCamera, HTMLElement]>
4522

46-
@Component({
47-
standalone: true,
48-
templateUrl: 'app.component.html',
49-
imports: [NgtCanvas],
50-
})
51-
export class AppComponent {
52-
readonly Scene = SceneComponent;
23+
// after
24+
readonly #camera = this.#store.select('camera'); // Signal<NgtCamera>
25+
readonly #glDom = this.#store.select('gl', 'domElement'); // Signal<HTMLElement>
26+
readonly orbitControlsArgs = computed(() => [this.#camera(), this.#glDom()]); // Signal<[NgtCamera, HTMLElement]>
5327
}
5428
```
5529

56-
:::info
30+
### `NgtPush`
5731

58-
Check out [First Scene](../getting-started/first-scene) for better explanation
32+
With Signals, we do not need `NgtPush` pipe anymore so this pipe is removed
5933

60-
:::
61-
62-
## Store
63-
64-
`angular-three` has migrated to [RxAngular](https://www.rx-angular.io/) instead of [NgRx](https://ngrx.io) for our internal states.
65-
66-
:::info
67-
68-
Check out [Store](../api/store) for more info
69-
70-
:::
34+
```html
35+
<!-- before -->
36+
<ngt-primitive *args="[model$ | push]" />
37+
<!-- after -->
38+
<ngt-primitive *args="[model()]" />
39+
```

0 commit comments

Comments
 (0)