fix: close final viewer integration gaps (#5)

This commit is contained in:
2026-07-29 10:14:09 +09:00
parent cadbd5fb60
commit 8ae7c45e9a
9 changed files with 196 additions and 28 deletions
@@ -29,6 +29,7 @@ export class ThreeDViewer {
private readonly onError;
private readonly fps = createFpsMeter();
private readonly adaptive;
private disposed = false;
private raf = 0;
private current: THREE.Object3D | null = null;
private outline: THREE.Group | null = null;
@@ -323,6 +324,7 @@ export class ThreeDViewer {
};
private animate = (now: number = performance.now()): void => {
if (this.disposed) return;
this.raf = requestAnimationFrame(this.animate);
this.fps.sample(now);
this.adaptive.update(this.fps.fps());
@@ -331,14 +333,20 @@ export class ThreeDViewer {
};
dispose(): void {
if (this.disposed) return;
this.disposed = true;
cancelAnimationFrame(this.raf);
this.raf = 0;
window.removeEventListener('resize', this.onResize);
this.controls.dispose();
this.clearOutline();
if (this.current) this.disposeObject(this.current);
this.current = null;
this.fps.el.remove();
this.renderer.dispose();
this.renderer.forceContextLoss();
this.renderer.domElement.remove();
this.scene.clear();
}
/** Orbit the camera to azimuth (radians) around the model — used by tools/prerender.mjs. */