diff --git a/src/passes/ClearPass.ts b/src/passes/ClearPass.ts index 91312173f..1504560d7 100644 --- a/src/passes/ClearPass.ts +++ b/src/passes/ClearPass.ts @@ -70,6 +70,8 @@ export class ClearPass extends Pass { this.backgroundScene = new Scene(); this.backgroundScene.add(this.background); + this.disposables.add(this.background); + } /** diff --git a/src/utils/Background.ts b/src/utils/Background.ts index b9732b222..6a073a4f6 100644 --- a/src/utils/Background.ts +++ b/src/utils/Background.ts @@ -16,6 +16,7 @@ import { WebGLRenderer } from "three"; +import { Disposable } from "../core/Disposable.js"; import { BackgroundMaterial } from "../materials/BackgroundMaterial.js"; import { SkyBoxMaterial } from "../materials/SkyBoxMaterial.js"; import { ClearValues } from "./ClearValues.js"; @@ -31,7 +32,7 @@ const matrix4 = /* @__PURE__ */ new Matrix4(); * @internal */ -export class Background extends Group { +export class Background extends Group implements Disposable { /** * A sky box. @@ -189,4 +190,11 @@ export class Background extends Group { } + dispose(): void { + + this.skyBox.material.dispose(); + this.background.material.dispose(); + + } + }