浏览代码

WebGLPrograms: Clean up.

Mr.doob 9 年之前
父节点
当前提交
8f15583b5f
共有 1 个文件被更改,包括 32 次插入21 次删除
  1. 32 21
      src/renderers/webgl/WebGLPrograms.js

+ 32 - 21
src/renderers/webgl/WebGLPrograms.js

@@ -67,6 +67,38 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 	}
 
+	function getTextureEncodingFromMap( map ) {
+
+		if ( ! map ) return false;
+
+		var encoding;
+
+		if ( map instanceof THREE.Texture ) {
+
+			encoding = map.encoding;
+
+		} else if ( map instanceof THREE.WebGLRenderTarget ) {
+
+			encoding = map.texture.encoding;
+
+		} else {
+
+			throw new Error( "can not determine texture encoding from map: " + map );
+
+		}
+
+		// add backwards compatibility for WebGLRenderer.gammaInput parameter, should probably be removed at some point.
+
+		if ( encoding === THREE.LinearEncoding && renderer.gammaInput ) {
+
+			encoding = THREE.GammaEncoding;
+
+		}
+
+		return encoding;
+
+	}
+
 	this.getParameters = function ( material, lights, fog, object ) {
 
 		var shaderID = shaderIDs[ material.type ];
@@ -88,27 +120,6 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 		}
 
-		var getTextureEncodingFromMap = function( map ) {
-			if( ! map ) { // no texture
-				return false;
-			}
-			var encoding;
-			if( map instanceof THREE.Texture ) {
-				encoding = map.encoding;
-			}
-			else if( map instanceof THREE.WebGLRenderTarget ) {
-				encoding = map.texture.encoding;
-			}
-			else {
-				throw new Error( "can not determine texture encoding from map: " + map );
-			}
-			// add backwards compatibility for WebGLRenderer.gammaInput parameter, should probably be removed at some point.
-			if( encoding === THREE.LinearEncoding && renderer.gammaInput ) {
-				encoding = THREE.GammaEncoding;
-			}
-			return encoding;
-		}
-
 		var parameters = {
 
 			shaderID: shaderID,