浏览代码

WebGLRenderer: Added clearColor, clearDepth and clearStencil. See discussion in ef7ead99873d1a6059a21cb419484ce0ff8c1b89.

Mr.doob 11 年之前
父节点
当前提交
accc1ce358
共有 2 个文件被更改,包括 23 次插入4 次删除
  1. 5 4
      examples/webgl_sprites.html
  2. 18 0
      src/renderers/WebGLRenderer.js

+ 5 - 4
examples/webgl_sprites.html

@@ -142,11 +142,11 @@
 				var widthHalf = material.map.image.width / 2;
 				var widthHalf = material.map.image.width / 2;
 				var heightHalf = material.map.image.height / 2;
 				var heightHalf = material.map.image.height / 2;
 
 
-				spriteTL.position.set( widthHalf, window.innerHeight - heightHalf, 1 ); // top left
-				spriteTR.position.set( window.innerWidth - widthHalf, window.innerHeight - heightHalf, 2 ); // top right
+				spriteTL.position.set( widthHalf, window.innerHeight - heightHalf, 0 ); // top left
+				spriteTR.position.set( window.innerWidth - widthHalf, window.innerHeight - heightHalf, 0 ); // top right
 				spriteBL.position.set( widthHalf, heightHalf, 0 ); // bottom left
 				spriteBL.position.set( widthHalf, heightHalf, 0 ); // bottom left
-				spriteBR.position.set( window.innerWidth - widthHalf, heightHalf, 3 ); // bottom right
-				spriteC.position.set( window.innerWidth * 0.5, window.innerHeight * 0.5, 4 ); // center
+				spriteBR.position.set( window.innerWidth - widthHalf, heightHalf, 0 ); // bottom right
+				spriteC.position.set( window.innerWidth * 0.5, window.innerHeight * 0.5, 0 ); // center
 
 
 			};
 			};
 
 
@@ -209,6 +209,7 @@
 
 
 				renderer.clear();
 				renderer.clear();
 				renderer.render( scene, camera );
 				renderer.render( scene, camera );
+				renderer.clearDepth();
 				renderer.render( sceneOrtho, cameraOrtho );
 				renderer.render( sceneOrtho, cameraOrtho );
 
 
 			}
 			}

+ 18 - 0
src/renderers/WebGLRenderer.js

@@ -374,6 +374,24 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.clearColor = function () {
+
+		_gl.clear( _gl.COLOR_BUFFER_BIT );
+
+	};
+
+	this.clearDepth = function () {
+
+		_gl.clear( _gl.DEPTH_BUFFER_BIT );
+
+	};
+
+	this.clearStencil = function () {
+
+		_gl.clear( _gl.STENCIL_BUFFER_BIT );
+
+	};
+
 	this.clearTarget = function ( renderTarget, color, depth, stencil ) {
 	this.clearTarget = function ( renderTarget, color, depth, stencil ) {
 
 
 		this.setRenderTarget( renderTarget );
 		this.setRenderTarget( renderTarget );