From 41500fe4d8a637811f097e6487db9c5f597ca36f Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 14 Jun 2016 18:27:59 -0700 Subject: [PATCH] WebGLRenderer: We need to clear depth even if we draw background. Maybe we can just clear depth... --- src/renderers/WebGLRenderer.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 0363ac2bf6..ddd88cfc6f 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1160,14 +1160,25 @@ THREE.WebGLRenderer = function ( parameters ) { // - var needsClear = this.autoClear || forceClear; var background = scene.background; if ( background === null ) { 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 ); @@ -1179,28 +1190,12 @@ THREE.WebGLRenderer = function ( parameters ) { _this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null ); - needsClear = false; - } else if ( background instanceof THREE.Texture ) { backgroundPlaneMesh.material.map = background; _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 ); - } // -- GitLab