Browse Source

update js examples

Garrett Johnson 4 years ago
parent
commit
e3b7148455

+ 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 );
 
 
 		}
 		}
 
 

+ 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 );
 
 
 		}
 		}
 
 

+ 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 );
 
 
 	}
 	}