From d0cb1baab42bf4511692b967c0615071c0463be1 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 18 Aug 2016 23:07:03 -0700 Subject: [PATCH] WebGLRenderer: Removed unneeded checks. --- src/renderers/WebGLRenderer.js | 76 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 3c16b6f7d3..24274b51c4 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -632,7 +632,9 @@ function WebGLRenderer( parameters ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal ); - if ( material.type !== 'MeshPhongMaterial' && material.type !== 'MeshStandardMaterial' && material.type !== 'MeshPhysicalMaterial' && material.shading === FlatShading ) { + if ( ! material.isMeshPhongMaterial && + ! material.isMeshStandardMaterial && + material.shading === FlatShading ) { for ( var i = 0, l = object.count * 3; i < l; i += 9 ) { @@ -1442,7 +1444,7 @@ function WebGLRenderer( parameters ) { var geometry = objects.update( object ); - if ( material && material.isMultiMaterial ) { + if ( material.isMultiMaterial ) { var groups = geometry.groups; var materials = material.materials; @@ -1625,9 +1627,9 @@ function WebGLRenderer( parameters ) { var uniforms = materialProperties.__webglShader.uniforms; - if ( ! ( material && material.isShaderMaterial ) && - ! ( material && material.isRawShaderMaterial ) || - material.clipping === true ) { + if ( ! material.isShaderMaterial && + ! material.isRawShaderMaterial | + material.clipping === true ) { materialProperties.numClippingPlanes = _clipping.numPlanes; uniforms.clippingPlanes = _clipping.uniform; @@ -1806,10 +1808,10 @@ function WebGLRenderer( parameters ) { // load material specific uniforms // (shader material also gets them for the sake of genericity) - if ( ( material && material.isShaderMaterial ) || - ( material && material.isMeshPhongMaterial ) || - ( material && material.isMeshStandardMaterial ) || - material.envMap ) { + if ( material.isShaderMaterial || + material.isMeshPhongMaterial || + material.isMeshStandardMaterial || + material.envMap ) { var uCamPos = p_uniforms.map.cameraPosition; @@ -1822,12 +1824,12 @@ function WebGLRenderer( parameters ) { } - if ( ( material && material.isMeshPhongMaterial ) || - ( material && material.isMeshLambertMaterial ) || - ( material && material.isMeshBasicMaterial ) || - ( material && material.isMeshStandardMaterial ) || - ( material && material.isShaderMaterial ) || - material.skinning ) { + if ( material.isMeshPhongMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial || + material.skinning ) { p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); @@ -1892,11 +1894,11 @@ function WebGLRenderer( parameters ) { } - if ( ( material && material.isMeshBasicMaterial ) || - ( material && material.isMeshLambertMaterial ) || - ( material && material.isMeshPhongMaterial ) || - ( material && material.isMeshStandardMaterial ) || - ( material && material.isMeshDepthMaterial ) ) { + if ( material.isMeshBasicMaterial || + material.isMeshLambertMaterial || + material.isMeshPhongMaterial || + material.isMeshStandardMaterial || + material.isMeshDepthMaterial ) { refreshUniformsCommon( m_uniforms, material ); @@ -1904,36 +1906,36 @@ function WebGLRenderer( parameters ) { // refresh single material specific uniforms - if ( material && material.isLineBasicMaterial ) { + if ( material.isLineBasicMaterial ) { refreshUniformsLine( m_uniforms, material ); - } else if ( material && material.isLineDashedMaterial ) { + } else if ( material.isLineDashedMaterial ) { refreshUniformsLine( m_uniforms, material ); refreshUniformsDash( m_uniforms, material ); - } else if ( material && material.isPointsMaterial ) { + } else if ( material.isPointsMaterial ) { refreshUniformsPoints( m_uniforms, material ); - } else if ( material && material.isMeshLambertMaterial ) { + } else if ( material.isMeshLambertMaterial ) { refreshUniformsLambert( m_uniforms, material ); - } else if ( material && material.isMeshPhongMaterial ) { + } else if ( material.isMeshPhongMaterial ) { refreshUniformsPhong( m_uniforms, material ); - } else if ( material && material.isMeshPhysicalMaterial ) { + } else if ( material.isMeshPhysicalMaterial ) { refreshUniformsPhysical( m_uniforms, material ); - } else if ( material && material.isMeshStandardMaterial ) { + } else if ( material.isMeshStandardMaterial ) { refreshUniformsStandard( m_uniforms, material ); - } else if ( material && material.isMeshDepthMaterial ) { + } else if ( material.isMeshDepthMaterial ) { if ( material.displacementMap ) { @@ -1943,7 +1945,7 @@ function WebGLRenderer( parameters ) { } - } else if ( material && material.isMeshNormalMaterial ) { + } else if ( material.isMeshNormalMaterial ) { m_uniforms.opacity.value = material.opacity; @@ -2055,7 +2057,7 @@ function WebGLRenderer( parameters ) { if ( uvScaleMap !== undefined ) { // backwards compatibility - if ( (uvScaleMap && uvScaleMap.isWebGLRenderTarget) ) { + if ( uvScaleMap.isWebGLRenderTarget ) { uvScaleMap = uvScaleMap.texture; @@ -2120,12 +2122,12 @@ function WebGLRenderer( parameters ) { uniforms.fogColor.value = fog.color; - if ( fog && fog.isFog ) { + if ( fog.isFog ) { uniforms.fogNear.value = fog.near; uniforms.fogFar.value = fog.far; - } else if ( fog && fog.isFogExp2 ) { + } else if ( fog.isFogExp2 ) { uniforms.fogDensity.value = fog.density; @@ -2323,13 +2325,13 @@ function WebGLRenderer( parameters ) { shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null; - if ( light && light.isAmbientLight ) { + if ( light.isAmbientLight ) { r += color.r * intensity; g += color.g * intensity; b += color.b * intensity; - } else if ( light && light.isDirectionalLight ) { + } else if ( light.isDirectionalLight ) { var uniforms = lightCache.get( light ); @@ -2353,7 +2355,7 @@ function WebGLRenderer( parameters ) { _lights.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix; _lights.directional[ directionalLength ++ ] = uniforms; - } else if ( light && light.isSpotLight ) { + } else if ( light.isSpotLight ) { var uniforms = lightCache.get( light ); @@ -2386,7 +2388,7 @@ function WebGLRenderer( parameters ) { _lights.spotShadowMatrix[ spotLength ] = light.shadow.matrix; _lights.spot[ spotLength ++ ] = uniforms; - } else if ( light && light.isPointLight ) { + } else if ( light.isPointLight ) { var uniforms = lightCache.get( light ); @@ -2422,7 +2424,7 @@ function WebGLRenderer( parameters ) { _lights.point[ pointLength ++ ] = uniforms; - } else if ( light && light.isHemisphereLight ) { + } else if ( light.isHemisphereLight ) { var uniforms = lightCache.get( light ); -- GitLab