Browse Source

WebGLRenderer: We need to clear depth even if we draw background. Maybe we can just clear depth...

Mr.doob 9 years ago
parent
commit
41500fe4d8
1 changed files with 13 additions and 18 deletions
  1. 13 18
      src/renderers/WebGLRenderer.js

+ 13 - 18
src/renderers/WebGLRenderer.js

@@ -1160,14 +1160,25 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		//
 		//
 
 
-		var needsClear = this.autoClear || forceClear;
 		var background = scene.background;
 		var background = scene.background;
 
 
 		if ( background === null ) {
 		if ( background === null ) {
 
 
 			glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
 			glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
 
 
-		} else if ( background instanceof THREE.CubeTexture ) {
+		} else if ( background instanceof THREE.Color ) {
+
+			glClearColor( background.r, background.g, background.b, 1 );
+
+		}
+
+		if ( this.autoClear || forceClear ) {
+
+			this.clear( this.autoClearColor, this.autoClearDepth, this.autoClearStencil );
+
+		}
+
+		if ( background instanceof THREE.CubeTexture ) {
 
 
 			backgroundCamera2.projectionMatrix.copy( camera.projectionMatrix );
 			backgroundCamera2.projectionMatrix.copy( camera.projectionMatrix );
 
 
@@ -1179,28 +1190,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			_this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
 			_this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
 
 
-			needsClear = false;
-
 		} else if ( background instanceof THREE.Texture ) {
 		} else if ( background instanceof THREE.Texture ) {
 
 
 			backgroundPlaneMesh.material.map = background;
 			backgroundPlaneMesh.material.map = background;
 
 
 			_this.renderBufferDirect( backgroundCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
 			_this.renderBufferDirect( backgroundCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
 
 
-			needsClear = false;
-
-		} else if ( background instanceof THREE.Color ) {
-
-			glClearColor( background.r, background.g, background.b, 1 );
-
-			needsClear = true;
-
-		}
-
-		if ( needsClear ) {
-
-			this.clear( this.autoClearColor, this.autoClearDepth, this.autoClearStencil );
-
 		}
 		}
 
 
 		//
 		//