浏览代码

Merge pull request #20818 from gkjohnson/pmrem-fix

WebGLRenderer: Add "target" argument to "getClearColor"
Mr.doob 4 年之前
父节点
当前提交
1ae1df9ab9

+ 1 - 1
docs/api/en/renderers/WebGLRenderer.html

@@ -335,7 +335,7 @@
 		<h3>[method:Float getClearAlpha]()</h3>
 		<h3>[method:Float getClearAlpha]()</h3>
 		<p>Returns a [page:Float float] with the current clear alpha. Ranges from 0 to 1.</p>
 		<p>Returns a [page:Float float] with the current clear alpha. Ranges from 0 to 1.</p>
 
 
-		<h3>[method:Color getClearColor]()</h3>
+		<h3>[method:Color getClearColor]( [param:Color target] )</h3>
 		<p>Returns a [page:Color THREE.Color] instance with the current clear color.</p>
 		<p>Returns a [page:Color THREE.Color] instance with the current clear color.</p>
 
 
 		<h3>[method:WebGLRenderingContext getContext]()</h3>
 		<h3>[method:WebGLRenderingContext getContext]()</h3>

+ 1 - 1
docs/api/zh/renderers/WebGLRenderer.html

@@ -322,7 +322,7 @@
 		<h3>[method:Float getClearAlpha]()</h3>
 		<h3>[method:Float getClearAlpha]()</h3>
 		<p>返回一个表示当前alpha值的[page:Float float],范围0到1</p>
 		<p>返回一个表示当前alpha值的[page:Float float],范围0到1</p>
 
 
-		<h3>[method:Color getClearColor]()</h3>
+		<h3>[method:Color getClearColor]( [param:Color target] )</h3>
 		<p>返回一个表示当前颜色值的[page:Color THREE.Color]实例</p>
 		<p>返回一个表示当前颜色值的[page:Color THREE.Color]实例</p>
 
 
 		<h3>[method:WebGLRenderingContext getContext]()</h3>
 		<h3>[method:WebGLRenderingContext getContext]()</h3>

+ 3 - 3
examples/js/postprocessing/BokehPass.js

@@ -64,7 +64,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
 
 
 	this.fsQuad = new THREE.Pass.FullScreenQuad( this.materialBokeh );
 	this.fsQuad = new THREE.Pass.FullScreenQuad( this.materialBokeh );
 
 
-	this.oldClearColor = new THREE.Color();
+	this._oldClearColor = new THREE.Color();
 
 
 };
 };
 
 
@@ -78,7 +78,7 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
 
 
 		this.scene.overrideMaterial = this.materialDepth;
 		this.scene.overrideMaterial = this.materialDepth;
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -109,7 +109,7 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
 		}
 		}
 
 
 		this.scene.overrideMaterial = null;
 		this.scene.overrideMaterial = null;
-		renderer.setClearColor( this.oldClearColor );
+		renderer.setClearColor( this._oldClearColor );
 		renderer.setClearAlpha( oldClearAlpha );
 		renderer.setClearAlpha( oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 

+ 4 - 3
examples/js/postprocessing/ClearPass.js

@@ -6,6 +6,7 @@ THREE.ClearPass = function ( clearColor, clearAlpha ) {
 
 
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+	this._oldClearColor = new THREE.Color();
 
 
 };
 };
 
 
@@ -15,11 +16,11 @@ THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
 
 
 	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var oldClearColor, oldClearAlpha;
+		var oldClearAlpha;
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			oldClearColor = renderer.getClearColor().getHex();
+			renderer.getClearColor( this._oldClearColor );
 			oldClearAlpha = renderer.getClearAlpha();
 			oldClearAlpha = renderer.getClearAlpha();
 
 
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
@@ -31,7 +32,7 @@ THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			renderer.setClearColor( oldClearColor, oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 		}
 		}
 
 

+ 3 - 3
examples/js/postprocessing/OutlinePass.js

@@ -96,7 +96,7 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
 	this.enabled = true;
 	this.enabled = true;
 	this.needsSwap = false;
 	this.needsSwap = false;
 
 
-	this.oldClearColor = new THREE.Color();
+	this._oldClearColor = new THREE.Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.fsQuad = new THREE.Pass.FullScreenQuad( null );
 	this.fsQuad = new THREE.Pass.FullScreenQuad( null );
@@ -276,7 +276,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 
 		if ( this.selectedObjects.length > 0 ) {
 		if ( this.selectedObjects.length > 0 ) {
 
 
-			this.oldClearColor.copy( renderer.getClearColor() );
+			renderer.getClearColor( this._oldClearColor );
 			this.oldClearAlpha = renderer.getClearAlpha();
 			this.oldClearAlpha = renderer.getClearAlpha();
 			var oldAutoClear = renderer.autoClear;
 			var oldAutoClear = renderer.autoClear;
 
 
@@ -391,7 +391,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 			renderer.setRenderTarget( readBuffer );
 			renderer.setRenderTarget( readBuffer );
 			this.fsQuad.render( renderer );
 			this.fsQuad.render( renderer );
 
 
-			renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}

+ 4 - 3
examples/js/postprocessing/RenderPass.js

@@ -13,6 +13,7 @@ THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clear
 	this.clear = true;
 	this.clear = true;
 	this.clearDepth = false;
 	this.clearDepth = false;
 	this.needsSwap = false;
 	this.needsSwap = false;
+	this._oldClearColor = new THREE.Color();
 
 
 };
 };
 
 
@@ -25,7 +26,7 @@ THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var oldClearColor, oldClearAlpha, oldOverrideMaterial;
+		var oldClearAlpha, oldOverrideMaterial;
 
 
 		if ( this.overrideMaterial !== undefined ) {
 		if ( this.overrideMaterial !== undefined ) {
 
 
@@ -37,7 +38,7 @@ THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			oldClearColor = renderer.getClearColor().getHex();
+			renderer.getClearColor( this._oldClearColor );
 			oldClearAlpha = renderer.getClearAlpha();
 			oldClearAlpha = renderer.getClearAlpha();
 
 
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
@@ -58,7 +59,7 @@ THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			renderer.setClearColor( oldClearColor, oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 		}
 		}
 
 

+ 5 - 5
examples/js/postprocessing/SAOPass.js

@@ -16,7 +16,7 @@ THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution )
 	this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
 	this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
 
 
 	this.originalClearColor = new THREE.Color();
 	this.originalClearColor = new THREE.Color();
-	this.oldClearColor = new THREE.Color();
+	this._oldClearColor = new THREE.Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.params = {
 	this.params = {
@@ -192,7 +192,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 
 
 		}
 		}
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -303,7 +303,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 		// Rendering SAOPass result on top of previous pass
 		// Rendering SAOPass result on top of previous pass
 		this.renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer );
 		this.renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer );
 
 
-		renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
 	},
 	},
@@ -311,7 +311,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 
@@ -339,7 +339,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 
 
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 

+ 3 - 2
examples/js/postprocessing/SSAARenderPass.js

@@ -21,6 +21,7 @@ THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
 	// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
 	// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+	this._oldClearColor = new THREE.Color();
 
 
 	if ( THREE.CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on THREE.CopyShader' );
 	if ( THREE.CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on THREE.CopyShader' );
 
 
@@ -77,7 +78,7 @@ THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.protot
 		var autoClear = renderer.autoClear;
 		var autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var oldClearColor = renderer.getClearColor().getHex();
+		renderer.getClearColor( this._oldClearColor );
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldClearAlpha = renderer.getClearAlpha();
 
 
 		var baseSampleWeight = 1.0 / jitterOffsets.length;
 		var baseSampleWeight = 1.0 / jitterOffsets.length;
@@ -134,7 +135,7 @@ THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.protot
 		if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
 		if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
 
 
 		renderer.autoClear = autoClear;
 		renderer.autoClear = autoClear;
-		renderer.setClearColor( oldClearColor, oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 	}
 	}
 
 

+ 2 - 2
examples/js/postprocessing/SSAOPass.js

@@ -252,7 +252,7 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 
@@ -280,7 +280,7 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
 
 
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 

+ 3 - 3
examples/js/postprocessing/UnrealBloomPass.js

@@ -131,7 +131,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
 	this.enabled = true;
 	this.enabled = true;
 	this.needsSwap = false;
 	this.needsSwap = false;
 
 
-	this.oldClearColor = new THREE.Color();
+	this._oldClearColor = new THREE.Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.basic = new THREE.MeshBasicMaterial();
 	this.basic = new THREE.MeshBasicMaterial();
@@ -185,7 +185,7 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
 
 
 	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -273,7 +273,7 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
 
 
 		// Restore renderer settings
 		// Restore renderer settings
 
 
-		renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
 	},
 	},

+ 3 - 3
examples/jsm/postprocessing/BokehPass.js

@@ -77,7 +77,7 @@ var BokehPass = function ( scene, camera, params ) {
 
 
 	this.fsQuad = new Pass.FullScreenQuad( this.materialBokeh );
 	this.fsQuad = new Pass.FullScreenQuad( this.materialBokeh );
 
 
-	this.oldClearColor = new Color();
+	this._oldClearColor = new Color();
 
 
 };
 };
 
 
@@ -91,7 +91,7 @@ BokehPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.scene.overrideMaterial = this.materialDepth;
 		this.scene.overrideMaterial = this.materialDepth;
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -122,7 +122,7 @@ BokehPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		}
 		}
 
 
 		this.scene.overrideMaterial = null;
 		this.scene.overrideMaterial = null;
-		renderer.setClearColor( this.oldClearColor );
+		renderer.setClearColor( this._oldClearColor );
 		renderer.setClearAlpha( oldClearAlpha );
 		renderer.setClearAlpha( oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 

+ 7 - 3
examples/jsm/postprocessing/ClearPass.js

@@ -1,3 +1,6 @@
+import {
+	Color
+} from "../../../build/three.module.js";
 import { Pass } from "../postprocessing/Pass.js";
 import { Pass } from "../postprocessing/Pass.js";
 
 
 var ClearPass = function ( clearColor, clearAlpha ) {
 var ClearPass = function ( clearColor, clearAlpha ) {
@@ -8,6 +11,7 @@ var ClearPass = function ( clearColor, clearAlpha ) {
 
 
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+	this._oldClearColor = new Color();
 
 
 };
 };
 
 
@@ -17,11 +21,11 @@ ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var oldClearColor, oldClearAlpha;
+		var oldClearAlpha;
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			oldClearColor = renderer.getClearColor().getHex();
+			renderer.getClearColor( this._oldClearColor );
 			oldClearAlpha = renderer.getClearAlpha();
 			oldClearAlpha = renderer.getClearAlpha();
 
 
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
@@ -33,7 +37,7 @@ ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			renderer.setClearColor( oldClearColor, oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 		}
 		}
 
 

+ 3 - 3
examples/jsm/postprocessing/OutlinePass.js

@@ -116,7 +116,7 @@ var OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
 	this.enabled = true;
 	this.enabled = true;
 	this.needsSwap = false;
 	this.needsSwap = false;
 
 
-	this.oldClearColor = new Color();
+	this._oldClearColor = new Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.fsQuad = new Pass.FullScreenQuad( null );
 	this.fsQuad = new Pass.FullScreenQuad( null );
@@ -296,7 +296,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		if ( this.selectedObjects.length > 0 ) {
 		if ( this.selectedObjects.length > 0 ) {
 
 
-			this.oldClearColor.copy( renderer.getClearColor() );
+			renderer.getClearColor( this._oldClearColor );
 			this.oldClearAlpha = renderer.getClearAlpha();
 			this.oldClearAlpha = renderer.getClearAlpha();
 			var oldAutoClear = renderer.autoClear;
 			var oldAutoClear = renderer.autoClear;
 
 
@@ -411,7 +411,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			renderer.setRenderTarget( readBuffer );
 			renderer.setRenderTarget( readBuffer );
 			this.fsQuad.render( renderer );
 			this.fsQuad.render( renderer );
 
 
-			renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}

+ 7 - 3
examples/jsm/postprocessing/RenderPass.js

@@ -1,3 +1,6 @@
+import {
+	Color
+} from "../../../build/three.module.js";
 import { Pass } from "../postprocessing/Pass.js";
 import { Pass } from "../postprocessing/Pass.js";
 
 
 var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
 var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
@@ -15,6 +18,7 @@ var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAl
 	this.clear = true;
 	this.clear = true;
 	this.clearDepth = false;
 	this.clearDepth = false;
 	this.needsSwap = false;
 	this.needsSwap = false;
+	this._oldClearColor = new Color();
 
 
 };
 };
 
 
@@ -27,7 +31,7 @@ RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var oldClearColor, oldClearAlpha, oldOverrideMaterial;
+		var oldClearAlpha, oldOverrideMaterial;
 
 
 		if ( this.overrideMaterial !== undefined ) {
 		if ( this.overrideMaterial !== undefined ) {
 
 
@@ -39,7 +43,7 @@ RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			oldClearColor = renderer.getClearColor().getHex();
+			renderer.getClearColor( this._oldClearColor );
 			oldClearAlpha = renderer.getClearAlpha();
 			oldClearAlpha = renderer.getClearAlpha();
 
 
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
 			renderer.setClearColor( this.clearColor, this.clearAlpha );
@@ -60,7 +64,7 @@ RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
-			renderer.setClearColor( oldClearColor, oldClearAlpha );
+			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 		}
 		}
 
 

+ 5 - 5
examples/jsm/postprocessing/SAOPass.js

@@ -44,7 +44,7 @@ var SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) {
 	this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
 	this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
 
 
 	this.originalClearColor = new Color();
 	this.originalClearColor = new Color();
-	this.oldClearColor = new Color();
+	this._oldClearColor = new Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.params = {
 	this.params = {
@@ -220,7 +220,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -331,7 +331,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		// Rendering SAOPass result on top of previous pass
 		// Rendering SAOPass result on top of previous pass
 		this.renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer );
 		this.renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer );
 
 
-		renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
 	},
 	},
@@ -339,7 +339,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 
@@ -367,7 +367,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 

+ 4 - 2
examples/jsm/postprocessing/SSAARenderPass.js

@@ -1,5 +1,6 @@
 import {
 import {
 	AdditiveBlending,
 	AdditiveBlending,
+	Color,
 	LinearFilter,
 	LinearFilter,
 	RGBAFormat,
 	RGBAFormat,
 	ShaderMaterial,
 	ShaderMaterial,
@@ -32,6 +33,7 @@ var SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
 	// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
 	// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
 	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+	this._oldClearColor = new Color();
 
 
 	if ( CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on CopyShader' );
 	if ( CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on CopyShader' );
 
 
@@ -88,7 +90,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		var autoClear = renderer.autoClear;
 		var autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var oldClearColor = renderer.getClearColor().getHex();
+		renderer.getClearColor( this._oldClearColor );
 		var oldClearAlpha = renderer.getClearAlpha();
 		var oldClearAlpha = renderer.getClearAlpha();
 
 
 		var baseSampleWeight = 1.0 / jitterOffsets.length;
 		var baseSampleWeight = 1.0 / jitterOffsets.length;
@@ -145,7 +147,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
 		if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
 
 
 		renderer.autoClear = autoClear;
 		renderer.autoClear = autoClear;
-		renderer.setClearColor( oldClearColor, oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 	}
 	}
 
 

+ 2 - 2
examples/jsm/postprocessing/SSAOPass.js

@@ -282,7 +282,7 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 
@@ -310,7 +310,7 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
-		this.originalClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this.originalClearColor );
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalClearAlpha = renderer.getClearAlpha();
 		var originalAutoClear = renderer.autoClear;
 		var originalAutoClear = renderer.autoClear;
 
 

+ 3 - 3
examples/jsm/postprocessing/UnrealBloomPass.js

@@ -147,7 +147,7 @@ var UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
 	this.enabled = true;
 	this.enabled = true;
 	this.needsSwap = false;
 	this.needsSwap = false;
 
 
-	this.oldClearColor = new Color();
+	this._oldClearColor = new Color();
 	this.oldClearAlpha = 1;
 	this.oldClearAlpha = 1;
 
 
 	this.basic = new MeshBasicMaterial();
 	this.basic = new MeshBasicMaterial();
@@ -201,7 +201,7 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
-		this.oldClearColor.copy( renderer.getClearColor() );
+		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
 		var oldAutoClear = renderer.autoClear;
 		var oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -289,7 +289,7 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		// Restore renderer settings
 		// Restore renderer settings
 
 
-		renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
+		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
 	},
 	},

+ 4 - 2
src/extras/PMREMGenerator.js

@@ -22,6 +22,7 @@ import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
 import { RawShaderMaterial } from '../materials/RawShaderMaterial.js';
 import { RawShaderMaterial } from '../materials/RawShaderMaterial.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Vector3 } from '../math/Vector3.js';
+import { Color } from '../math/Color.js';
 import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget.js';
 import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget.js';
 
 
 const LOD_MIN = 4;
 const LOD_MIN = 4;
@@ -52,6 +53,7 @@ const ENCODINGS = {
 
 
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
+const _clearColor = /*@__PURE__*/ new Color();
 let _oldTarget = null;
 let _oldTarget = null;
 
 
 // Golden Ratio
 // Golden Ratio
@@ -257,7 +259,7 @@ class PMREMGenerator {
 
 
 		const outputEncoding = renderer.outputEncoding;
 		const outputEncoding = renderer.outputEncoding;
 		const toneMapping = renderer.toneMapping;
 		const toneMapping = renderer.toneMapping;
-		const clearColor = renderer.getClearColor();
+		renderer.getClearColor( _clearColor );
 		const clearAlpha = renderer.getClearAlpha();
 		const clearAlpha = renderer.getClearAlpha();
 
 
 		renderer.toneMapping = NoToneMapping;
 		renderer.toneMapping = NoToneMapping;
@@ -306,7 +308,7 @@ class PMREMGenerator {
 
 
 		renderer.toneMapping = toneMapping;
 		renderer.toneMapping = toneMapping;
 		renderer.outputEncoding = outputEncoding;
 		renderer.outputEncoding = outputEncoding;
-		renderer.setClearColor( clearColor, clearAlpha );
+		renderer.setClearColor( _clearColor, clearAlpha );
 
 
 	}
 	}
 
 

+ 1 - 1
src/renderers/WebGLRenderer.d.ts

@@ -290,7 +290,7 @@ export class WebGLRenderer implements Renderer {
 	/**
 	/**
 	 * Returns a THREE.Color instance with the current clear color.
 	 * Returns a THREE.Color instance with the current clear color.
 	 */
 	 */
-	getClearColor(): Color;
+	getClearColor( target: Color ): Color;
 
 
 	/**
 	/**
 	 * Sets the clear color, using color for the color and alpha for the opacity.
 	 * Sets the clear color, using color for the color and alpha for the opacity.

+ 11 - 2
src/renderers/WebGLRenderer.js

@@ -13,6 +13,7 @@ import { Matrix4 } from '../math/Matrix4.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Vector4 } from '../math/Vector4.js';
 import { Vector4 } from '../math/Vector4.js';
+import { Color } from '../math/Color.js';
 import { WebGLAnimation } from './webgl/WebGLAnimation.js';
 import { WebGLAnimation } from './webgl/WebGLAnimation.js';
 import { WebGLAttributes } from './webgl/WebGLAttributes.js';
 import { WebGLAttributes } from './webgl/WebGLAttributes.js';
 import { WebGLBackground } from './webgl/WebGLBackground.js';
 import { WebGLBackground } from './webgl/WebGLBackground.js';
@@ -532,9 +533,17 @@ function WebGLRenderer( parameters ) {
 
 
 	// Clearing
 	// Clearing
 
 
-	this.getClearColor = function () {
+	this.getClearColor = function ( target ) {
 
 
-		return background.getClearColor();
+		if ( target === undefined ) {
+
+			console.warn( 'WebGLRenderer: .getClearColor() now requires a Color as an argument' );
+
+			target = new Color();
+
+		}
+
+		return target.copy( background.getClearColor() );
 
 
 	};
 	};