Skip to content

Commit 1104e27

Browse files
committed
docs: remove GUI on destroy (animation spinning)
1 parent 4553199 commit 1104e27

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

apps/demo/src/app/animation-skinning-ik/animation-skinning-ik.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgIf } from '@angular/common';
2-
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, inject, ViewChild } from '@angular/core';
2+
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, inject, OnDestroy, ViewChild } from '@angular/core';
33
import { extend, injectBeforeRender, injectNgtLoader, NgtArgs, NgtCanvas, NgtPush, NgtStore } from 'angular-three';
44
import { map } from 'rxjs';
55
import * as THREE from 'three';
@@ -49,7 +49,7 @@ extend({ TransformControls, CCDIKHelper });
4949
imports: [NgtArgs, NgIf, DemoOrbitControls, NgtPush],
5050
schemas: [CUSTOM_ELEMENTS_SCHEMA],
5151
})
52-
export class Scene {
52+
export class Scene implements OnDestroy {
5353
private readonly config = { followSphere: false, turnHead: true, ikSolver: true };
5454
private readonly gui = new GUI();
5555

@@ -143,6 +143,10 @@ export class Scene {
143143
this.gui.add(this.solver, 'update').name('IK Manual update()');
144144
this.gui.open();
145145
}
146+
147+
ngOnDestroy() {
148+
this.gui.domElement.remove();
149+
}
146150
}
147151

148152
@Component({

apps/demo/src/app/camera/camera.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ export class Scene implements AfterViewInit, OnInit {
166166
@Component({
167167
standalone: true,
168168
template: `
169+
<div class="block h-full w-full bg-black">
170+
<ngt-canvas
171+
[sceneGraph]="SceneGraph"
172+
[gl]="{ alpha: false }"
173+
[camera]="{ fov: 50, near: 1, far: 10000, position: [0, 0, 2500] }"
174+
(created)="onCreated($event)"
175+
/>
176+
</div>
169177
<div class="absolute text-center text-white w-full top-0 left-0 text-xl">
170178
<a href="https://threejs.org" target="_blank" rel="noopener" class="underline"> three.js </a> -
171179
<a href="https://angular-threejs.netlify.app" target="_blank" rel="noopener" class="underline">
@@ -175,14 +183,6 @@ export class Scene implements AfterViewInit, OnInit {
175183
<br />
176184
<b class="text-green-300">O</b> orthographic <b class="text-green-300">P</b> perspective
177185
</div>
178-
<div class="block h-full w-full bg-black">
179-
<ngt-canvas
180-
[sceneGraph]="SceneGraph"
181-
[gl]="{ alpha: false }"
182-
[camera]="{ fov: 50, near: 1, far: 10000, position: [0, 0, 2500] }"
183-
(created)="onCreated($event)"
184-
/>
185-
</div>
186186
`,
187187
imports: [NgtCanvas],
188188
})

0 commit comments

Comments
 (0)