Skip to content

Commit bc7507d

Browse files
committed
docs: clean up extend(THREE)
1 parent 651cfe2 commit bc7507d

File tree

11 files changed

+26
-40
lines changed

11 files changed

+26
-40
lines changed

apps/examples/src/app/cannon/cannon.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './cannon.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh">

apps/examples/src/app/misc/misc.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './misc.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh">

apps/examples/src/app/misc/webgpu-renderer/scene.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, viewChild } from '@angular/core';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
CUSTOM_ELEMENTS_SCHEMA,
5+
DestroyRef,
6+
ElementRef,
7+
inject,
8+
viewChild,
9+
} from '@angular/core';
210
import { beforeRender, extend, NgtAfterAttach, NgtArgs } from 'angular-three';
311
import { NgtsOrbitControls } from 'angular-three-soba/controls';
412
import * as THREE from 'three/webgpu';
@@ -71,7 +79,7 @@ export class SceneGraph {
7179
private scale = new THREE.Vector3();
7280

7381
constructor() {
74-
extend(THREE);
82+
const remove = extend(THREE);
7583

7684
beforeRender(() => {
7785
const group = this.groupRef().nativeElement;
@@ -84,6 +92,10 @@ export class SceneGraph {
8492
);
8593
}
8694
});
95+
96+
inject(DestroyRef).onDestroy(() => {
97+
remove();
98+
});
8799
}
88100

89101
protected onAttached(event: NgtAfterAttach<THREE.Mesh>) {

apps/examples/src/app/misc/webgpu-tsl/scene.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import {
44
Component,
55
computed,
66
CUSTOM_ELEMENTS_SCHEMA,
7+
DestroyRef,
78
effect,
89
ElementRef,
10+
inject,
911
signal,
1012
viewChild,
1113
} from '@angular/core';
@@ -151,7 +153,7 @@ export class SceneGraph {
151153
protected startAngle = computed(() => THREE.MathUtils.DEG2RAD * this.startAngleDegrees());
152154

153155
constructor() {
154-
extend({ MeshPhysicalNodeMaterial, DirectionalLight });
156+
const remove = extend({ MeshPhysicalNodeMaterial, DirectionalLight });
155157

156158
beforeRender(({ delta }) => {
157159
if (!this.rotate()) return;
@@ -180,5 +182,9 @@ export class SceneGraph {
180182
scene.backgroundBlurriness = blurriness;
181183
});
182184
});
185+
186+
inject(DestroyRef).onDestroy(() => {
187+
remove();
188+
});
183189
}
184190
}

apps/examples/src/app/postprocessing/postprocessing.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './postprocessing.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh">

apps/examples/src/app/rapier/rapier.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './rapier.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh bg-gradient-to-r from-violet-500 to-fuchsia-500">

apps/examples/src/app/routed-rocks/routed-rocks.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
2-
import { extend, NgtRoutedScene } from 'angular-three';
2+
import { NgtRoutedScene } from 'angular-three';
33
import { NgtCanvas } from 'angular-three/dom';
4-
import * as THREE from 'three';
54
import { RockStore } from './store';
65

7-
extend(THREE);
8-
96
@Component({
107
template: `
118
<ngt-canvas [camera]="{ position: [8.978, 1.426, 2.766] }" shadows>

apps/examples/src/app/routed/routed.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive } from '@angular/router';
3-
import { extend } from 'angular-three';
43
import { NgtCanvas } from 'angular-three/dom';
5-
import * as THREE from 'three';
64
import { RoutedScene } from './routed-scene';
75

8-
extend(THREE);
9-
106
@Component({
117
template: `
128
<div class="h-svh">

apps/examples/src/app/soba/shoe-configuration/scene.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ export class ColorPicker {
6666
>
6767
@if (gltf.value(); as gltf) {
6868
<ng-template #m let-ctx="ctx">
69-
@let geometry = gltf.meshes[ctx[0]].geometry;
70-
@let material = gltf.materials[ctx[1]];
71-
<ngt-mesh receiveShadow castShadow [geometry]="geometry" [material]="material">
72-
<ngt-value [rawValue]="$any(state.items)[ctx[1]]()" attach="material.color" />
73-
</ngt-mesh>
69+
@let geo = gltf.meshes[ctx[0]].geometry;
70+
@let mat = gltf.materials[ctx[1]];
71+
@let color = $any(state.items)[ctx[1]]();
72+
<ngt-mesh receiveShadow castShadow [geometry]="geo" [material]="mat" [material.color]="color" />
7473
</ng-template>
7574
7675
<ng-container [ngTemplateOutlet]="m" [ngTemplateOutletContext]="{ ctx: ['shoe', 'laces'] }" />

apps/examples/src/app/soba/soba.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './soba.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh">

apps/examples/src/app/theatre/theatre.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { extend } from 'angular-three';
4-
import * as THREE from 'three';
53
import routes from './theatre.routes';
64

7-
extend(THREE);
8-
95
@Component({
106
template: `
117
<div class="h-svh">

0 commit comments

Comments
 (0)