James Kiefer 10 年之前
父節點
當前提交
24f376ed5e

+ 1 - 1
examples/js/loaders/AssimpJSONLoader.js

@@ -60,7 +60,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 	setTexturePath: function ( value ) {
 		this.texturePath = value;
-	}
+	},
 
 	extractUrlBase: function ( url ) { // from three/src/loaders/Loader.js
 		var parts = url.split( '/' );

+ 1 - 1
examples/js/loaders/BinaryLoader.js

@@ -684,7 +684,7 @@ THREE.BinaryLoader.prototype = {
 		Model.prototype.constructor = Model;
 
 		var geometry = new Model( texturePath );
-		var materials = THREE.Loader.prototype.initMaterials( jsonMaterials, texturePath );
+		var materials = THREE.Loader.prototype.initMaterials( jsonMaterials, texturePath, this.crossOrigin );
 
 		if ( THREE.Loader.prototype.needsTangents( materials ) ) geometry.computeTangents();
 

+ 1 - 1
src/loaders/CompressedTextureLoader.js

@@ -132,4 +132,4 @@ THREE.CompressedTextureLoader.prototype = {
 
 	},
 
-};
+};

+ 5 - 5
src/loaders/JSONLoader.js

@@ -19,7 +19,7 @@ THREE.JSONLoader.prototype = {
 
 		var scope = this;
 
-		this.texturePath = this.texturePath && ( typeof this.texturePath === "string" ) ? this.texturePath : this.extractUrlBase( url );
+		var texturePath = this.texturePath && ( typeof this.texturePath === "string" ) ? this.texturePath : THREE.Loader.prototype.extractUrlBase( url );
 
 		var loader = new THREE.XHRLoader( this.manager );
 		loader.setCrossOrigin( this.crossOrigin );
@@ -32,7 +32,7 @@ THREE.JSONLoader.prototype = {
 				return;
 			}
 
-			var object = scope.parse(json, texturePath);
+			var object = scope.parse( json, texturePath );
 			onLoad( object.geometry, object.materials );
 
 		} );
@@ -51,7 +51,7 @@ THREE.JSONLoader.prototype = {
 
 	},
 
-	parse = function ( json, texturePath ) {
+	parse: function ( json, texturePath ) {
 
 		var scope = this,
 		geometry = new THREE.Geometry(),
@@ -478,9 +478,9 @@ THREE.JSONLoader.prototype = {
 
 		} else {
 
-			var materials = this.initMaterials( json.materials, texturePath );
+			var materials = THREE.Loader.prototype.initMaterials( json.materials, texturePath, this.crossOrigin );
 
-			if ( this.needsTangents( materials ) ) {
+			if ( THREE.Loader.prototype.needsTangents( materials ) ) {
 
 				geometry.computeTangents();
 

+ 260 - 251
src/loaders/Loader.js

@@ -2,476 +2,485 @@
  * @author alteredq / http://alteredqualia.com/
  */
 
-THREE.Loader = function ( showStatus ) {
+(function(){
 
-	this.showStatus = showStatus;
-	this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null;
+	var globalImageLoader = null;
 
-	this.imageLoader = new THREE.ImageLoader();
+	THREE.Loader = function ( showStatus ) {
 
-	this.onLoadStart = function () {};
-	this.onLoadProgress = function () {};
-	this.onLoadComplete = function () {};
+		this.showStatus = showStatus;
+		this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null;
 
-};
+		this.onLoadStart = function () {};
+		this.onLoadProgress = function () {};
+		this.onLoadComplete = function () {};
 
-THREE.Loader.prototype = {
+	};
 
-	constructor: THREE.Loader,
+	THREE.Loader.prototype = {
 
-	crossOrigin: undefined,
+		constructor: THREE.Loader,
 
-	addStatusElement: function () {
+		crossOrigin: undefined,
 
-		var e = document.createElement( 'div' );
+		addStatusElement: function () {
 
-		e.style.position = 'absolute';
-		e.style.right = '0px';
-		e.style.top = '0px';
-		e.style.fontSize = '0.8em';
-		e.style.textAlign = 'left';
-		e.style.background = 'rgba(0,0,0,0.25)';
-		e.style.color = '#fff';
-		e.style.width = '120px';
-		e.style.padding = '0.5em 0.5em 0.5em 0.5em';
-		e.style.zIndex = 1000;
+			var e = document.createElement( 'div' );
 
-		e.innerHTML = 'Loading ...';
+			e.style.position = 'absolute';
+			e.style.right = '0px';
+			e.style.top = '0px';
+			e.style.fontSize = '0.8em';
+			e.style.textAlign = 'left';
+			e.style.background = 'rgba(0,0,0,0.25)';
+			e.style.color = '#fff';
+			e.style.width = '120px';
+			e.style.padding = '0.5em 0.5em 0.5em 0.5em';
+			e.style.zIndex = 1000;
 
-		return e;
+			e.innerHTML = 'Loading ...';
 
-	},
+			return e;
 
-	updateProgress: function ( progress ) {
+		},
 
-		var message = 'Loaded ';
+		updateProgress: function ( progress ) {
 
-		if ( progress.total ) {
+			var message = 'Loaded ';
 
-			message += ( 100 * progress.loaded / progress.total ).toFixed( 0 ) + '%';
+			if ( progress.total ) {
 
+				message += ( 100 * progress.loaded / progress.total ).toFixed( 0 ) + '%';
 
-		} else {
 
-			message += ( progress.loaded / 1024 ).toFixed( 2 ) + ' KB';
+			} else {
 
-		}
+				message += ( progress.loaded / 1024 ).toFixed( 2 ) + ' KB';
 
-		this.statusDomElement.innerHTML = message;
+			}
 
-	},
+			this.statusDomElement.innerHTML = message;
 
-	extractUrlBase: function ( url ) {
+		},
 
-		var parts = url.split( '/' );
+		extractUrlBase: function ( url ) {
 
-		if ( parts.length === 1 ) return './';
+			var parts = url.split( '/' );
 
-		parts.pop();
+			if ( parts.length === 1 ) return './';
 
-		return parts.join( '/' ) + '/';
+			parts.pop();
 
-	},
+			return parts.join( '/' ) + '/';
 
-	initMaterials: function ( materials, texturePath ) {
+		},
 
-		var array = [];
+		initMaterials: function ( materials, texturePath, crossOrigin ) {
 
-		for ( var i = 0; i < materials.length; ++ i ) {
+			var array = [];
 
-			array[ i ] = this.createMaterial( materials[ i ], texturePath );
+			for ( var i = 0; i < materials.length; ++ i ) {
 
-		}
+				array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );
 
-		return array;
+			}
 
-	},
+			return array;
 
-	needsTangents: function ( materials ) {
+		},
 
-		for ( var i = 0, il = materials.length; i < il; i ++ ) {
+		needsTangents: function ( materials ) {
 
-			var m = materials[ i ];
+			for ( var i = 0, il = materials.length; i < il; i ++ ) {
 
-			if ( m instanceof THREE.ShaderMaterial ) return true;
+				var m = materials[ i ];
 
-		}
+				if ( m instanceof THREE.ShaderMaterial ) return true;
 
-		return false;
+			}
 
-	},
+			return false;
 
-	createMaterial: function ( m, texturePath ) {
+		},
 
-		var scope = this;
+		createMaterial: function ( m, texturePath, crossOrigin ) {
 
-		function nearest_pow2( n ) {
+			var scope = this;
 
-			var l = Math.log( n ) / Math.LN2;
-			return Math.pow( 2, Math.round(  l ) );
+			if ( crossOrigin === undefined && scope.crossOrigin !== undefined ) crossOrigin = scope.crossOrigin;
 
-		}
+			if ( globalImageLoader === null ) globalImageLoader = new THREE.ImageLoader();
 
-		function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
 
-			var fullPath = texturePath + sourceFile;
+			function nearest_pow2( n ) {
 
-			var texture;
+				var l = Math.log( n ) / Math.LN2;
+				return Math.pow( 2, Math.round(  l ) );
 
-			var loader = THREE.Loader.Handlers.get( fullPath );
+			}
 
-			if ( loader !== null ) {
+			function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
 
-				texture = loader.load( fullPath );
+				var fullPath = texturePath + sourceFile;
 
-			} else {
+				var texture;
 
-				texture = new THREE.Texture();
+				var loader = THREE.Loader.Handlers.get( fullPath );
 
-				loader = scope.imageLoader;
-				loader.crossOrigin = scope.crossOrigin;
-				loader.load( fullPath, function ( image ) {
+				if ( loader !== null ) {
 
-					if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
-						 THREE.Math.isPowerOfTwo( image.height ) === false ) {
+					texture = loader.load( fullPath );
 
-						var width = nearest_pow2( image.width );
-						var height = nearest_pow2( image.height );
+				} else {
 
-						var canvas = document.createElement( 'canvas' );
-						canvas.width = width;
-						canvas.height = height;
+					texture = new THREE.Texture();
 
-						var context = canvas.getContext( '2d' );
-						context.drawImage( image, 0, 0, width, height );
+					loader = globalImageLoader;
+					loader.setCrossOrigin( crossOrigin );
+					loader.load( fullPath, function ( image ) {
 
-						texture.image = canvas;
+						if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
+							 THREE.Math.isPowerOfTwo( image.height ) === false ) {
 
-					} else {
+							var width = nearest_pow2( image.width );
+							var height = nearest_pow2( image.height );
 
-						texture.image = image;
+							var canvas = document.createElement( 'canvas' );
+							canvas.width = width;
+							canvas.height = height;
 
-					}
+							var context = canvas.getContext( '2d' );
+							context.drawImage( image, 0, 0, width, height );
 
-					texture.needsUpdate = true;
+							texture.image = canvas;
 
-				} );
+						} else {
 
-			}
+							texture.image = image;
 
-			texture.sourceFile = sourceFile;
+						}
 
-			if ( repeat ) {
+						texture.needsUpdate = true;
 
-				texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
+					} );
 
-				if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
-				if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
+				}
 
-			}
+				texture.sourceFile = sourceFile;
 
-			if ( offset ) {
+				if ( repeat ) {
 
-				texture.offset.set( offset[ 0 ], offset[ 1 ] );
+					texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
 
-			}
+					if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
+					if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
+
+				}
+
+				if ( offset ) {
 
-			if ( wrap ) {
+					texture.offset.set( offset[ 0 ], offset[ 1 ] );
 
-				var wrapMap = {
-					'repeat': THREE.RepeatWrapping,
-					'mirror': THREE.MirroredRepeatWrapping
 				}
 
-				if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
-				if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
+				if ( wrap ) {
 
-			}
+					var wrapMap = {
+						'repeat': THREE.RepeatWrapping,
+						'mirror': THREE.MirroredRepeatWrapping
+					}
 
-			if ( anisotropy ) {
+					if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
+					if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
 
-				texture.anisotropy = anisotropy;
+				}
 
-			}
+				if ( anisotropy ) {
 
-			where[ name ] = texture;
+					texture.anisotropy = anisotropy;
 
-		}
+				}
 
-		function rgb2hex( rgb ) {
+				where[ name ] = texture;
 
-			return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
+			}
 
-		}
+			function rgb2hex( rgb ) {
 
-		// defaults
+				return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
 
-		var mtype = 'MeshLambertMaterial';
-		var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
+			}
 
-		// parameters from model file
+			// defaults
 
-		if ( m.shading ) {
+			var mtype = 'MeshLambertMaterial';
+			var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
 
-			var shading = m.shading.toLowerCase();
+			// parameters from model file
 
-			if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
-			else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
+			if ( m.shading ) {
 
-		}
+				var shading = m.shading.toLowerCase();
 
-		if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
+				if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
+				else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
 
-			mpars.blending = THREE[ m.blending ];
+			}
 
-		}
+			if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
 
-		if ( m.transparent !== undefined || m.opacity < 1.0 ) {
+				mpars.blending = THREE[ m.blending ];
 
-			mpars.transparent = m.transparent;
+			}
 
-		}
+			if ( m.transparent !== undefined || m.opacity < 1.0 ) {
 
-		if ( m.depthTest !== undefined ) {
+				mpars.transparent = m.transparent;
 
-			mpars.depthTest = m.depthTest;
+			}
 
-		}
+			if ( m.depthTest !== undefined ) {
 
-		if ( m.depthWrite !== undefined ) {
+				mpars.depthTest = m.depthTest;
 
-			mpars.depthWrite = m.depthWrite;
+			}
 
-		}
+			if ( m.depthWrite !== undefined ) {
 
-		if ( m.visible !== undefined ) {
+				mpars.depthWrite = m.depthWrite;
 
-			mpars.visible = m.visible;
+			}
 
-		}
+			if ( m.visible !== undefined ) {
 
-		if ( m.flipSided !== undefined ) {
+				mpars.visible = m.visible;
 
-			mpars.side = THREE.BackSide;
+			}
 
-		}
+			if ( m.flipSided !== undefined ) {
 
-		if ( m.doubleSided !== undefined ) {
+				mpars.side = THREE.BackSide;
 
-			mpars.side = THREE.DoubleSide;
+			}
 
-		}
+			if ( m.doubleSided !== undefined ) {
 
-		if ( m.wireframe !== undefined ) {
+				mpars.side = THREE.DoubleSide;
 
-			mpars.wireframe = m.wireframe;
+			}
 
-		}
+			if ( m.wireframe !== undefined ) {
+
+				mpars.wireframe = m.wireframe;
 
-		if ( m.vertexColors !== undefined ) {
+			}
+
+			if ( m.vertexColors !== undefined ) {
 
-			if ( m.vertexColors === 'face' ) {
+				if ( m.vertexColors === 'face' ) {
 
-				mpars.vertexColors = THREE.FaceColors;
+					mpars.vertexColors = THREE.FaceColors;
 
-			} else if ( m.vertexColors ) {
+				} else if ( m.vertexColors ) {
 
-				mpars.vertexColors = THREE.VertexColors;
+					mpars.vertexColors = THREE.VertexColors;
+
+				}
 
 			}
 
-		}
+			// colors
 
-		// colors
+			if ( m.colorDiffuse ) {
 
-		if ( m.colorDiffuse ) {
+				mpars.color = rgb2hex( m.colorDiffuse );
 
-			mpars.color = rgb2hex( m.colorDiffuse );
+			} else if ( m.DbgColor ) {
 
-		} else if ( m.DbgColor ) {
+				mpars.color = m.DbgColor;
 
-			mpars.color = m.DbgColor;
+			}
 
-		}
+			if ( m.colorSpecular ) {
 
-		if ( m.colorSpecular ) {
+				mpars.specular = rgb2hex( m.colorSpecular );
 
-			mpars.specular = rgb2hex( m.colorSpecular );
+			}
 
-		}
+			if ( m.colorAmbient ) {
 
-		if ( m.colorAmbient ) {
+				mpars.ambient = rgb2hex( m.colorAmbient );
 
-			mpars.ambient = rgb2hex( m.colorAmbient );
+			}
 
-		}
+			if ( m.colorEmissive ) {
 
-		if ( m.colorEmissive ) {
+				mpars.emissive = rgb2hex( m.colorEmissive );
 
-			mpars.emissive = rgb2hex( m.colorEmissive );
+			}
 
-		}
+			// modifiers
 
-		// modifiers
+			if ( m.transparency ) {
 
-		if ( m.transparency ) {
+				mpars.opacity = m.transparency;
 
-			mpars.opacity = m.transparency;
+			}
 
-		}
+			if ( m.specularCoef ) {
 
-		if ( m.specularCoef ) {
+				mpars.shininess = m.specularCoef;
 
-			mpars.shininess = m.specularCoef;
+			}
 
-		}
+			// textures
 
-		// textures
+			if ( m.mapDiffuse && texturePath ) {
 
-		if ( m.mapDiffuse && texturePath ) {
+				create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
 
-			create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
+			}
 
-		}
+			if ( m.mapLight && texturePath ) {
 
-		if ( m.mapLight && texturePath ) {
+				create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
 
-			create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
+			}
 
-		}
+			if ( m.mapBump && texturePath ) {
 
-		if ( m.mapBump && texturePath ) {
+				create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
 
-			create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
+			}
 
-		}
+			if ( m.mapNormal && texturePath ) {
 
-		if ( m.mapNormal && texturePath ) {
+				create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
 
-			create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
+			}
 
-		}
+			if ( m.mapSpecular && texturePath ) {
 
-		if ( m.mapSpecular && texturePath ) {
+				create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
 
-			create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
+			}
 
-		}
+			if ( m.mapAlpha && texturePath ) {
 
-		if ( m.mapAlpha && texturePath ) {
+				create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
 
-			create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
+			}
 
-		}
+			//
 
-		//
+			if ( m.mapBumpScale ) {
 
-		if ( m.mapBumpScale ) {
+				mpars.bumpScale = m.mapBumpScale;
 
-			mpars.bumpScale = m.mapBumpScale;
+			}
 
-		}
+			// special case for normal mapped material
 
-		// special case for normal mapped material
+			if ( m.mapNormal ) {
 
-		if ( m.mapNormal ) {
+				var shader = THREE.ShaderLib[ 'normalmap' ];
+				var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
-			var shader = THREE.ShaderLib[ 'normalmap' ];
-			var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+				uniforms[ 'tNormal' ].value = mpars.normalMap;
 
-			uniforms[ 'tNormal' ].value = mpars.normalMap;
+				if ( m.mapNormalFactor ) {
 
-			if ( m.mapNormalFactor ) {
+					uniforms[ 'uNormalScale' ].value.set( m.mapNormalFactor, m.mapNormalFactor );
 
-				uniforms[ 'uNormalScale' ].value.set( m.mapNormalFactor, m.mapNormalFactor );
+				}
 
-			}
+				if ( mpars.map ) {
 
-			if ( mpars.map ) {
+					uniforms[ 'tDiffuse' ].value = mpars.map;
+					uniforms[ 'enableDiffuse' ].value = true;
 
-				uniforms[ 'tDiffuse' ].value = mpars.map;
-				uniforms[ 'enableDiffuse' ].value = true;
+				}
 
-			}
+				if ( mpars.specularMap ) {
 
-			if ( mpars.specularMap ) {
+					uniforms[ 'tSpecular' ].value = mpars.specularMap;
+					uniforms[ 'enableSpecular' ].value = true;
 
-				uniforms[ 'tSpecular' ].value = mpars.specularMap;
-				uniforms[ 'enableSpecular' ].value = true;
+				}
 
-			}
+				if ( mpars.lightMap ) {
 
-			if ( mpars.lightMap ) {
+					uniforms[ 'tAO' ].value = mpars.lightMap;
+					uniforms[ 'enableAO' ].value = true;
 
-				uniforms[ 'tAO' ].value = mpars.lightMap;
-				uniforms[ 'enableAO' ].value = true;
+				}
 
-			}
+				// for the moment don't handle displacement texture
 
-			// for the moment don't handle displacement texture
+				uniforms[ 'diffuse' ].value.setHex( mpars.color );
+				uniforms[ 'specular' ].value.setHex( mpars.specular );
+				uniforms[ 'ambient' ].value.setHex( mpars.ambient );
 
-			uniforms[ 'diffuse' ].value.setHex( mpars.color );
-			uniforms[ 'specular' ].value.setHex( mpars.specular );
-			uniforms[ 'ambient' ].value.setHex( mpars.ambient );
+				uniforms[ 'shininess' ].value = mpars.shininess;
 
-			uniforms[ 'shininess' ].value = mpars.shininess;
+				if ( mpars.opacity !== undefined ) {
 
-			if ( mpars.opacity !== undefined ) {
+					uniforms[ 'opacity' ].value = mpars.opacity;
 
-				uniforms[ 'opacity' ].value = mpars.opacity;
+				}
 
-			}
+				var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
+				var material = new THREE.ShaderMaterial( parameters );
 
-			var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
-			var material = new THREE.ShaderMaterial( parameters );
+				if ( mpars.transparent ) {
 
-			if ( mpars.transparent ) {
+					material.transparent = true;
 
-				material.transparent = true;
+				}
 
-			}
+			} else {
 
-		} else {
+				var material = new THREE[ mtype ]( mpars );
 
-			var material = new THREE[ mtype ]( mpars );
+			}
 
-		}
+			if ( m.DbgName !== undefined ) material.name = m.DbgName;
 
-		if ( m.DbgName !== undefined ) material.name = m.DbgName;
+			return material;
 
-		return material;
+		}
 
-	}
+	};
 
-};
+	THREE.Loader.Handlers = {
 
-THREE.Loader.Handlers = {
+		handlers: [],
 
-	handlers: [],
+		add: function ( regex, loader ) {
 
-	add: function ( regex, loader ) {
+			this.handlers.push( regex, loader );
 
-		this.handlers.push( regex, loader );
+		},
 
-	},
+		get: function ( file ) {
 
-	get: function ( file ) {
+			for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
 
-		for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
+				var regex = this.handlers[ i ];
+				var loader  = this.handlers[ i + 1 ];
 
-			var regex = this.handlers[ i ];
-			var loader  = this.handlers[ i + 1 ];
+				if ( regex.test( file ) ) {
 
-			if ( regex.test( file ) ) {
+					return loader;
 
-				return loader;
+				}
 
 			}
 
-		}
+			return null;
 
-		return null;
+		}
 
-	}
+	};
 
-};
+})();