提交 f507558b 编写于 作者: B Ben Adams

Add depth function to materials

Fixes #6266
上级 67849f94
......@@ -115,6 +115,17 @@ THREE.DstColorFactor = 208;
THREE.OneMinusDstColorFactor = 209;
THREE.SrcAlphaSaturateFactor = 210;
// depth modes
THREE.NeverDepth = 0;
THREE.AlwaysDepth = 1;
THREE.LessDepth = 2;
THREE.LessEqualDepth = 3;
THREE.EqualDepth = 4;
THREE.GreaterEqualDepth = 5;
THREE.GreaterDepth = 6;
THREE.NotEqualDepth = 7;
// TEXTURE CONSTANTS
......
......@@ -26,6 +26,7 @@ THREE.Material = function () {
this.blendDstAlpha = null;
this.blendEquationAlpha = null;
this.depthFunc = THREE.LessEqualDepth;
this.depthTest = true;
this.depthWrite = true;
......@@ -152,6 +153,7 @@ THREE.Material.prototype = {
material.blendDstAlpha = this.blendDstAlpha;
material.blendEquationAlpha = this.blendEquationAlpha;
material.depthFunc = this.depthFunc;
material.depthTest = this.depthTest;
material.depthWrite = this.depthWrite;
......
......@@ -2464,6 +2464,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
state.setDepthFunc( material.depthFunc );
state.setDepthTest( material.depthTest );
state.setDepthWrite( material.depthWrite );
state.setColorWrite( material.colorWrite );
......
......@@ -15,6 +15,7 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
var currentBlendSrcAlpha = null;
var currentBlendDstAlpha = null;
var currentDepthFunc = null;
var currentDepthTest = null;
var currentDepthWrite = null;
......@@ -150,6 +151,71 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
};
this.setDepthFunc = function ( depthFunc ) {
if ( currentDepthFunc !== depthFunc ) {
if ( depthFunc ) {
switch ( depthFunc ) {
case THREE.NeverDepth:
gl.depthFunc( gl.NEVER );
break;
case THREE.AlwaysDepth:
gl.depthFunc( gl.ALWAYS );
break;
case THREE.LessDepth:
gl.depthFunc( gl.LESS );
break;
case THREE.LessEqualDepth:
gl.depthFunc( gl.LEQUAL );
break;
case THREE.EqualDepth:
gl.depthFunc( gl.EQUAL );
break;
case THREE.GreaterEqualDepth:
gl.depthFunc( gl.GEQUAL );
break;
case THREE.GreaterDepth:
gl.depthFunc( gl.GREATER );
break;
case THREE.NotEqualDepth:
gl.depthFunc( gl.NOTEQUAL );
break;
default:
gl.depthFunc( gl.LEQUAL );
}
} else {
gl.depthFunc( gl.LEQUAL );
}
currentDepthFunc = depthFunc;
}
};
this.setDepthTest = function ( depthTest ) {
if ( currentDepthTest !== depthTest ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册