addons/MTLLoader.js
function ( text ) {

			var lines = text.split( "\n" );
			var info = {};
			var delimiter_pattern = /\s+/;
			var materialsInfo = {};

			for ( var i = 0; i < lines.length; i ++ ) {

				var line = lines[ i ];
				line = line.trim();

				if ( line.length === 0 || line.charAt( 0 ) === '#' ) {

					// Blank line or comment ignore
					continue;

				}

				var pos = line.indexOf( ' ' );

				var key = ( pos >= 0 ) ? line.substring( 0, pos ) : line;
				key = key.toLowerCase();

				var value = ( pos >= 0 ) ? line.substring( pos + 1 ) : "";
				value = value.trim();

				if ( key === "newmtl" ) {

					// New material

					info = { name: value };
					materialsInfo[ value ] = info;

				} else if ( info ) {

					if ( key === "ka" || key === "kd" || key === "ks" ) {

						var ss = value.split( delimiter_pattern, 3 );
						info[ key ] = [ parseFloat( ss[ 0 ] ), parseFloat( ss[ 1 ] ), parseFloat( ss[ 2 ] ) ];

					} else {

						info[ key ] = value;

					}

				}

			}

			var materialCreator = new THREE.MTLLoader.MaterialCreator( this.baseUrl, this.materialOptions );
			materialCreator.setCrossOrigin( this.crossOrigin );
			materialCreator.setManager( this.manager );
			materialCreator.setMaterials( materialsInfo );
			return materialCreator;

		}
function ( text ) {

			var lines = text.split( "\n" );
			var info = {};
			var delimiter_pattern = /\s+/;
			var materialsInfo = {};

			for ( var i = 0; i < lines.length; i ++ ) {

				var line = lines[ i ];
				line = line.trim();

				if ( line.length === 0 || line.charAt( 0 ) === '#' ) {

					// Blank line or comment ignore
					continue;

				}

				var pos = line.indexOf( ' ' );

				var key = ( pos >= 0 ) ? line.substring( 0, pos ) : line;
				key = key.toLowerCase();

				var value = ( pos >= 0 ) ? line.substring( pos + 1 ) : "";
				value = value.trim();

				if ( key === "newmtl" ) {

					// New material

					info = { name: value };
					materialsInfo[ value ] = info;

				} else if ( info ) {

					if ( key === "ka" || key === "kd" || key === "ks" ) {

						var ss = value.split( delimiter_pattern, 3 );
						info[ key ] = [ parseFloat( ss[ 0 ] ), parseFloat( ss[ 1 ] ), parseFloat( ss[ 2 ] ) ];

					} else {

						info[ key ] = value;

					}

				}

			}

			var materialCreator = new THREE.MTLLoader.MaterialCreator( this.baseUrl, this.materialOptions );
			materialCreator.setCrossOrigin( this.crossOrigin );
			materialCreator.setManager( this.manager );
			materialCreator.setMaterials( materialsInfo );
			return materialCreator;

		}
function ( text ) { var lines = text . split ( "\n" ) ; var info = { } ; var delimiter_pattern = / \s+ / ; var materialsInfo = { } ; for ( var i = 0 ; i < lines . length ; i ++ ) { var line = lines [ i ] ; line = line . trim ( ) ; if ( line . length === 0 || line . charAt ( 0 ) === '#' ) { // Blank line or comment ignore continue ; } var pos = line . indexOf ( ' ' ) ; var key = ( pos >= 0 ) ? line . substring ( 0 , pos ) : line ; key = key . toLowerCase ( ) ; var value = ( pos >= 0 ) ? line . substring ( pos + 1 ) : "" ; value = value . trim ( ) ; if ( key === "newmtl" ) { // New material info = { name : value } ; materialsInfo [ value ] = info ; } else if ( info ) { if ( key === "ka" || key === "kd" || key === "ks" ) { var ss = value . split ( delimiter_pattern , 3 ) ; info [ key ] = [ parseFloat ( ss [ 0 ] ) , parseFloat ( ss [ 1 ] ) , parseFloat ( ss [ 2 ] ) ] ; } else { info [ key ] = value ; } } } var materialCreator = new THREE . MTLLoader . MaterialCreator ( this . baseUrl , this . materialOptions ) ; materialCreator . setCrossOrigin ( this . crossOrigin ) ; materialCreator . setManager ( this . manager ) ; materialCreator . setMaterials ( materialsInfo ) ; return materialCreator ; }
Parses loaded MTL file
@param text - Content of MTL file
@return {THREE.MTLLoader.MaterialCreator}
Parses loaded MTL file