Skip to content

Commit 41500fe

Browse files
committed
WebGLRenderer: We need to clear depth even if we draw background. Maybe we can just clear depth...
1 parent e4324dc commit 41500fe

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/renderers/WebGLRenderer.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,14 +1160,25 @@ THREE.WebGLRenderer = function ( parameters ) {
11601160

11611161
//
11621162

1163-
var needsClear = this.autoClear || forceClear;
11641163
var background = scene.background;
11651164

11661165
if ( background === null ) {
11671166

11681167
glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
11691168

1170-
} else if ( background instanceof THREE.CubeTexture ) {
1169+
} else if ( background instanceof THREE.Color ) {
1170+
1171+
glClearColor( background.r, background.g, background.b, 1 );
1172+
1173+
}
1174+
1175+
if ( this.autoClear || forceClear ) {
1176+
1177+
this.clear( this.autoClearColor, this.autoClearDepth, this.autoClearStencil );
1178+
1179+
}
1180+
1181+
if ( background instanceof THREE.CubeTexture ) {
11711182

11721183
backgroundCamera2.projectionMatrix.copy( camera.projectionMatrix );
11731184

@@ -1179,28 +1190,12 @@ THREE.WebGLRenderer = function ( parameters ) {
11791190

11801191
_this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
11811192

1182-
needsClear = false;
1183-
11841193
} else if ( background instanceof THREE.Texture ) {
11851194

11861195
backgroundPlaneMesh.material.map = background;
11871196

11881197
_this.renderBufferDirect( backgroundCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
11891198

1190-
needsClear = false;
1191-
1192-
} else if ( background instanceof THREE.Color ) {
1193-
1194-
glClearColor( background.r, background.g, background.b, 1 );
1195-
1196-
needsClear = true;
1197-
1198-
}
1199-
1200-
if ( needsClear ) {
1201-
1202-
this.clear( this.autoClearColor, this.autoClearDepth, this.autoClearStencil );
1203-
12041199
}
12051200

12061201
//

0 commit comments

Comments
 (0)