Browse Source

Merge pull request #7810 from Aldrien-/WebGLState_conflicts

Fix #7758 - WebGLState conflicts
Mr.doob 9 years ago
parent
commit
69325c28fc
1 changed files with 10 additions and 12 deletions
  1. 10 12
      src/renderers/webgl/WebGLState.js

+ 10 - 12
src/renderers/webgl/WebGLState.js

@@ -176,15 +176,20 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 	this.setBlending = function ( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha ) {
 
-		if ( blending !== currentBlending ) {
+		if ( blending === THREE.NoBlending ) {
 
-			if ( blending === THREE.NoBlending ) {
+			this.disable( gl.BLEND );
 
-				this.disable( gl.BLEND );
+		} else {
 
-			} else if ( blending === THREE.AdditiveBlending ) {
+			this.enable( gl.BLEND );
+
+		}
+
+		if ( blending !== currentBlending ) {
+
+			if ( blending === THREE.AdditiveBlending ) {
 
-				this.enable( gl.BLEND );
 				gl.blendEquation( gl.FUNC_ADD );
 				gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
 
@@ -192,7 +197,6 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 				// TODO: Find blendFuncSeparate() combination
 
-				this.enable( gl.BLEND );
 				gl.blendEquation( gl.FUNC_ADD );
 				gl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );
 
@@ -200,17 +204,11 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 				// TODO: Find blendFuncSeparate() combination
 
-				this.enable( gl.BLEND );
 				gl.blendEquation( gl.FUNC_ADD );
 				gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
 
-			} else if ( blending === THREE.CustomBlending ) {
-
-				this.enable( gl.BLEND );
-
 			} else {
 
-				this.enable( gl.BLEND );
 				gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
 				gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );