提交 0eb402d3 编写于 作者: M Mr.doob

WebGLRenderer: Moved doubleSided/flipSided code to WebGLState.

上级 c5ec18bf
...@@ -118,11 +118,6 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -118,11 +118,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_usedTextureUnits = 0, _usedTextureUnits = 0,
// GL state cache
_currentDoubleSided = - 1,
_currentFlipSided = - 1,
_viewportX = 0, _viewportX = 0,
_viewportY = 0, _viewportY = 0,
_viewportWidth = _canvas.width, _viewportWidth = _canvas.width,
...@@ -280,8 +275,6 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -280,8 +275,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_currentProgram = null; _currentProgram = null;
_currentCamera = null; _currentCamera = null;
_currentDoubleSided = - 1;
_currentFlipSided = - 1;
_currentGeometryProgram = ''; _currentGeometryProgram = '';
_currentMaterialId = - 1; _currentMaterialId = - 1;
...@@ -5442,40 +5435,8 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -5442,40 +5435,8 @@ THREE.WebGLRenderer = function ( parameters ) {
this.setMaterialFaces = function ( material ) { this.setMaterialFaces = function ( material ) {
var doubleSided = material.side === THREE.DoubleSide; state.setDoubleSided( material.side === THREE.DoubleSide );
var flipSided = material.side === THREE.BackSide; state.setFlipSided( material.side === THREE.BackSide );
if ( _currentDoubleSided !== doubleSided ) {
if ( doubleSided ) {
_gl.disable( _gl.CULL_FACE );
} else {
_gl.enable( _gl.CULL_FACE );
}
_currentDoubleSided = doubleSided;
}
if ( _currentFlipSided !== flipSided ) {
if ( flipSided ) {
_gl.frontFace( _gl.CW );
} else {
_gl.frontFace( _gl.CCW );
}
_currentFlipSided = flipSided;
}
}; };
......
...@@ -12,6 +12,18 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -12,6 +12,18 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
var currentBlendSrcAlpha = - 1; var currentBlendSrcAlpha = - 1;
var currentBlendDstAlpha = - 1; var currentBlendDstAlpha = - 1;
var currentDepthTest = - 1;
var currentDepthWrite = - 1;
var currentDoubleSided = - 1;
var currentFlipSided = - 1;
var currentLineWidth = null;
var currentPolygonOffset = null;
var currentPolygonOffsetFactor = null;
var currentPolygonOffsetUnits = null;
this.setBlending = function ( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha ) { this.setBlending = function ( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha ) {
if ( blending !== currentBlending ) { if ( blending !== currentBlending ) {
...@@ -95,8 +107,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -95,8 +107,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
}; };
var currentDepthTest = - 1;
this.setDepthTest = function ( depthTest ) { this.setDepthTest = function ( depthTest ) {
if ( currentDepthTest !== depthTest ) { if ( currentDepthTest !== depthTest ) {
...@@ -117,8 +127,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -117,8 +127,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
}; };
var currentDepthWrite = - 1;
this.setDepthWrite = function ( depthWrite ) { this.setDepthWrite = function ( depthWrite ) {
if ( currentDepthWrite !== depthWrite ) { if ( currentDepthWrite !== depthWrite ) {
...@@ -130,7 +138,45 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -130,7 +138,45 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
}; };
var currentLineWidth = null; this.setDoubleSided = function ( doubleSided ) {
if ( currentDoubleSided !== doubleSided ) {
if ( doubleSided ) {
gl.disable( gl.CULL_FACE );
} else {
gl.enable( gl.CULL_FACE );
}
currentDoubleSided = doubleSided;
}
};
this.setFlipSided = function ( flipSided ) {
if ( currentFlipSided !== flipSided ) {
if ( flipSided ) {
gl.frontFace( gl.CW );
} else {
gl.frontFace( gl.CCW );
}
currentFlipSided = flipSided;
}
};
this.setLineWidth = function ( width ) { this.setLineWidth = function ( width ) {
...@@ -144,10 +190,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -144,10 +190,6 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
}; };
var currentPolygonOffset = null;
var currentPolygonOffsetFactor = null;
var currentPolygonOffsetUnits = null;
this.setPolygonOffset = function ( polygonoffset, factor, units ) { this.setPolygonOffset = function ( polygonoffset, factor, units ) {
if ( currentPolygonOffset !== polygonoffset ) { if ( currentPolygonOffset !== polygonoffset ) {
...@@ -182,6 +224,8 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) { ...@@ -182,6 +224,8 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
currentBlending = - 1; currentBlending = - 1;
currentDepthTest = - 1; currentDepthTest = - 1;
currentDepthWrite = - 1; currentDepthWrite = - 1;
currentDoubleSided = - 1;
currentFlipSided = - 1;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册