Преглед изворни кода

Fix logic in DepthBuffer's setFunc which prevented NeverDepth from being set (#24628)

Co-authored-by: Noeri Huisman <[email protected]>
Noeri Huisman пре 2 година
родитељ
комит
50f1db16c1
1 измењених фајлова са 27 додато и 35 уклоњено
  1. 27 35
      src/renderers/webgl/WebGLState.js

+ 27 - 35
src/renderers/webgl/WebGLState.js

@@ -103,59 +103,51 @@ function WebGLState( gl, extensions, capabilities ) {
 
 				if ( currentDepthFunc !== depthFunc ) {
 
-					if ( depthFunc ) {
+					switch ( depthFunc ) {
 
-						switch ( depthFunc ) {
+						case NeverDepth:
 
-							case NeverDepth:
-
-								gl.depthFunc( gl.NEVER );
-								break;
-
-							case AlwaysDepth:
-
-								gl.depthFunc( gl.ALWAYS );
-								break;
-
-							case LessDepth:
+							gl.depthFunc( gl.NEVER );
+							break;
 
-								gl.depthFunc( gl.LESS );
-								break;
+						case AlwaysDepth:
 
-							case LessEqualDepth:
+							gl.depthFunc( gl.ALWAYS );
+							break;
 
-								gl.depthFunc( gl.LEQUAL );
-								break;
+						case LessDepth:
 
-							case EqualDepth:
+							gl.depthFunc( gl.LESS );
+							break;
 
-								gl.depthFunc( gl.EQUAL );
-								break;
+						case LessEqualDepth:
 
-							case GreaterEqualDepth:
+							gl.depthFunc( gl.LEQUAL );
+							break;
 
-								gl.depthFunc( gl.GEQUAL );
-								break;
+						case EqualDepth:
 
-							case GreaterDepth:
+							gl.depthFunc( gl.EQUAL );
+							break;
 
-								gl.depthFunc( gl.GREATER );
-								break;
+						case GreaterEqualDepth:
 
-							case NotEqualDepth:
+							gl.depthFunc( gl.GEQUAL );
+							break;
 
-								gl.depthFunc( gl.NOTEQUAL );
-								break;
+						case GreaterDepth:
 
-							default:
+							gl.depthFunc( gl.GREATER );
+							break;
 
-								gl.depthFunc( gl.LEQUAL );
+						case NotEqualDepth:
 
-						}
+							gl.depthFunc( gl.NOTEQUAL );
+							break;
 
-					} else {
+						default:
 
-						gl.depthFunc( gl.LEQUAL );
+							gl.depthFunc( gl.LEQUAL );
 
 					}