Browse Source

EffectComposer: Add dispose(). (#24712)

Michael Herzog 2 years ago
parent
commit
9b0df262d8

+ 5 - 0
docs/examples/en/postprocessing/EffectComposer.html

@@ -89,6 +89,11 @@
 			Adds the given pass to the pass chain.
 		</p>
 
+		<h3>[method:undefined dispose]()</h3>
+		<p>
+			Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
+		</p>
+
 		<h3>[method:undefined insertPass]( [param:Pass pass], [param:Integer index] )</h3>
 
 		<p>

+ 5 - 0
docs/examples/zh/postprocessing/EffectComposer.html

@@ -88,6 +88,11 @@
 			将传入的过程添加到过程链。
 		</p>
 
+		<h3>[method:undefined dispose]()</h3>
+		<p>
+			Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
+		</p>
+
 		<h3>[method:undefined insertPass]( [param:Pass pass], [param:Integer index] )</h3>
 
 		<p>

+ 9 - 0
examples/jsm/postprocessing/EffectComposer.js

@@ -232,6 +232,15 @@ class EffectComposer {
 
 	}
 
+	dispose() {
+
+		this.renderTarget1.dispose();
+		this.renderTarget2.dispose();
+
+		this.copyPass.dispose();
+
+	}
+
 }
 
 

+ 2 - 0
examples/jsm/postprocessing/Pass.js

@@ -31,6 +31,8 @@ class Pass {
 
 	}
 
+	dispose() {}
+
 }
 
 // Helper for passes that need to fill the viewport with a single quad.

+ 7 - 0
examples/jsm/postprocessing/ShaderPass.js

@@ -63,6 +63,13 @@ class ShaderPass extends Pass {
 
 	}
 
+	dispose() {
+
+		this.fsQuad.dispose();
+		this.material.dispose();
+
+	}
+
 }
 
 export { ShaderPass };