Sfoglia il codice sorgente

Merge pull request #7998 from Mugen87/dev

WebGLState: Added clearDepth and clearStencil
Mr.doob 9 anni fa
parent
commit
f8f77ccfd6
1 ha cambiato i file con 32 aggiunte e 4 eliminazioni
  1. 32 4
      src/renderers/webgl/WebGLState.js

+ 32 - 4
src/renderers/webgl/WebGLState.js

@@ -52,14 +52,17 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 	var currentBoundTextures = {};
 
 	var currentClearColor = new THREE.Vector4();
+	var currentClearDepth = null;
+	var currentClearStencil = null;
+
 	var currentScissor = new THREE.Vector4();
 	var currentViewport = new THREE.Vector4();
 
 	this.init = function () {
 
 		this.clearColor( 0, 0, 0, 1 );
-		gl.clearDepth( 1 );
-		gl.clearStencil( 0 );
+		this.clearDepth( 1 );
+		this.clearStencil( 0 );
 
 		this.enable( gl.DEPTH_TEST );
 		gl.depthFunc( gl.LEQUAL );
@@ -585,7 +588,7 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 	};
 
-	//
+	// clear values
 
 	this.clearColor = function ( r, g, b, a ) {
 
@@ -600,6 +603,30 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 	};
 
+	this.clearDepth = function ( depth ) {
+
+		if ( currentClearDepth !== depth ) {
+
+			gl.clearDepth( depth );
+			currentClearDepth = depth;
+
+		}
+
+	};
+
+	this.clearStencil = function ( stencil ) {
+
+		if ( currentClearStencil !== stencil ) {
+
+			gl.clearStencil( stencil );
+			currentClearStencil = stencil;
+
+		}
+
+	};
+
+	//
+
 	this.scissor = function ( scissor ) {
 
 		if ( currentScissor.equals( scissor ) === false ) {
@@ -643,8 +670,9 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 
 		currentBlending = null;
 
-		currentDepthWrite = null;
 		currentColorWrite = null;
+		currentDepthWrite = null;
+		currentStencilWrite = null;
 
 		currentFlipSided = null;