Skip to content

Commit

Permalink
Make Background disposable
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Mar 2, 2024
1 parent f6c1bf5 commit 1979f2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/passes/ClearPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class ClearPass extends Pass {
this.backgroundScene = new Scene();
this.backgroundScene.add(this.background);

this.disposables.add(this.background);

}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/utils/Background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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.
Expand Down Expand Up @@ -189,4 +190,11 @@ export class Background extends Group {

}

dispose(): void {

this.skyBox.material.dispose();
this.background.material.dispose();

}

}

0 comments on commit 1979f2e

Please sign in to comment.