Forráskód Böngészése

Merge pull request #12168 from Mugen87/dev3

Loaders: Improve code quality
Mr.doob 7 éve
szülő
commit
9a6459939a

+ 34 - 30
examples/js/loaders/3MFLoader.js

@@ -18,7 +18,7 @@ THREE.ThreeMFLoader.prototype = {
 		var scope = this;
 		var loader = new THREE.FileLoader( scope.manager );
 		loader.setResponseType( 'arraybuffer' );
-		loader.load( url, function( buffer ) {
+		loader.load( url, function ( buffer ) {
 
 			onLoad( scope.parse( buffer ) );
 
@@ -49,7 +49,7 @@ THREE.ThreeMFLoader.prototype = {
 
 			try {
 
-				zip = new JSZip( data );
+				zip = new JSZip( data ); // eslint-disable-line no-undef
 
 			} catch ( e ) {
 
@@ -68,19 +68,19 @@ THREE.ThreeMFLoader.prototype = {
 
 					relsName = file;
 
-				} else if ( file.match(/^3D\/.*\.model$/) ) {
+				} else if ( file.match( /^3D\/.*\.model$/ ) ) {
 
 					modelPartNames.push( file );
 
-				} else if ( file.match(/^3D\/Metadata\/.*\.xml$/) ) {
+				} else if ( file.match( /^3D\/Metadata\/.*\.xml$/ ) ) {
 
 					printTicketPartNames.push( file );
 
-				} else if ( file.match(/^3D\/Textures\/.*/) ) {
+				} else if ( file.match( /^3D\/Textures\/.*/ ) ) {
 
 					texturesPartNames.push( file );
 
-				} else if ( file.match(/^3D\/Other\/.*/) ) {
+				} else if ( file.match( /^3D\/Other\/.*/ ) ) {
 
 					otherPartNames.push( file );
 
@@ -99,7 +99,7 @@ THREE.ThreeMFLoader.prototype = {
 			var relsFileText = new TextDecoder( 'utf-8' ).decode( relsView );
 			rels = parseRelsXml( relsFileText );
 
-			for ( var i = 0; i < modelPartNames.length; i++ ) {
+			for ( var i = 0; i < modelPartNames.length; i ++ ) {
 
 				var modelPart = modelPartNames[ i ];
 				var view = new DataView( zip.file( modelPart ).asArrayBuffer() );
@@ -116,7 +116,7 @@ THREE.ThreeMFLoader.prototype = {
 				var modelNode = xmlData.querySelector( 'model' );
 				var extensions = {};
 
-				for ( var i = 0; i < modelNode.attributes.length; i++ ) {
+				for ( var i = 0; i < modelNode.attributes.length; i ++ ) {
 
 					var attr = modelNode.attributes[ i ];
 					if ( attr.name.match( /^xmlns:(.+)$/ ) ) {
@@ -140,7 +140,7 @@ THREE.ThreeMFLoader.prototype = {
 
 			}
 
-			for ( var i = 0; i < texturesPartNames.length; i++ ) {
+			for ( var i = 0; i < texturesPartNames.length; i ++ ) {
 
 				var texturesPartName = texturesPartNames[ i ];
 				texturesParts[ texturesPartName ] = zip.file( texturesPartName ).asBinary();
@@ -154,6 +154,7 @@ THREE.ThreeMFLoader.prototype = {
 				texture: texturesParts,
 				other: otherParts
 			};
+
 		}
 
 		function parseRelsXml( relsFileText ) {
@@ -176,10 +177,10 @@ THREE.ThreeMFLoader.prototype = {
 
 			var metadataData = {};
 
-			for ( var i = 0; i < metadataNodes.length; i++ ) {
+			for ( var i = 0; i < metadataNodes.length; i ++ ) {
 
 				var metadataNode = metadataNodes[ i ];
-				var name = metadataNode.getAttribute('name');
+				var name = metadataNode.getAttribute( 'name' );
 				var validNames = [
 					'Title',
 					'Designer',
@@ -213,7 +214,7 @@ THREE.ThreeMFLoader.prototype = {
 			var vertices = [];
 			var vertexNodes = meshNode.querySelectorAll( 'vertices vertex' );
 
-			for ( var i = 0; i < vertexNodes.length; i++ ) {
+			for ( var i = 0; i < vertexNodes.length; i ++ ) {
 
 				var vertexNode = vertexNodes[ i ];
 				var x = vertexNode.getAttribute( 'x' );
@@ -226,7 +227,7 @@ THREE.ThreeMFLoader.prototype = {
 
 			meshData[ 'vertices' ] = new Float32Array( vertices.length );
 
-			for ( var i = 0; i < vertices.length; i++ ) {
+			for ( var i = 0; i < vertices.length; i ++ ) {
 
 				meshData[ 'vertices' ][ i ] = vertices[ i ];
 
@@ -236,7 +237,7 @@ THREE.ThreeMFLoader.prototype = {
 			var triangles = [];
 			var triangleNodes = meshNode.querySelectorAll( 'triangles triangle' );
 
-			for ( var i = 0; i < triangleNodes.length; i++ ) {
+			for ( var i = 0; i < triangleNodes.length; i ++ ) {
 
 				var triangleNode = triangleNodes[ i ];
 				var v1 = triangleNode.getAttribute( 'v1' );
@@ -280,12 +281,13 @@ THREE.ThreeMFLoader.prototype = {
 					triangleProperties.push( triangleProperty );
 
 				}
+
 			}
 
 			meshData[ 'triangleProperties' ] = triangleProperties;
 			meshData[ 'triangles' ] = new Uint32Array( triangles.length );
 
-			for ( var i = 0; i < triangles.length; i++ ) {
+			for ( var i = 0; i < triangles.length; i ++ ) {
 
 				meshData[ 'triangles' ][ i ] = triangles[ i ];
 
@@ -387,7 +389,7 @@ THREE.ThreeMFLoader.prototype = {
 			resourcesData[ 'object' ] = {};
 			var objectNodes = resourcesNode.querySelectorAll( 'object' );
 
-			for ( var i = 0; i < objectNodes.length; i++ ) {
+			for ( var i = 0; i < objectNodes.length; i ++ ) {
 
 				var objectNode = objectNodes[ i ];
 				var objectData = parseObjectNode( objectNode );
@@ -404,10 +406,10 @@ THREE.ThreeMFLoader.prototype = {
 			var buildData = [];
 			var itemNodes = buildNode.querySelectorAll( 'item' );
 
-			for ( var i = 0; i < itemNodes.length; i++ ) {
+			for ( var i = 0; i < itemNodes.length; i ++ ) {
 
 				var itemNode = itemNodes[ i ];
-				var buildItem =  {
+				var buildItem = {
 					objectid: itemNode.getAttribute( 'objectid' )
 				};
 				var transform = itemNode.getAttribute( 'transform' );
@@ -415,15 +417,17 @@ THREE.ThreeMFLoader.prototype = {
 				if ( transform ) {
 
 					var t = [];
-					transform.split( ' ' ).forEach( function( s ) {
+					transform.split( ' ' ).forEach( function ( s ) {
+
 						t.push( parseFloat( s ) );
+
 					} );
 					var mat4 = new THREE.Matrix4();
 					buildItem[ 'transform' ] = mat4.set(
-						t[ 0 ], t[  3 ], t[  6 ], t[  9 ],
-						t[ 1 ], t[  4 ], t[  7 ], t[ 10 ],
-						t[ 2 ], t[  5 ], t[  8 ], t[ 11 ],
-						   0.0,     0.0,     0.0,     1.0
+						t[ 0 ], t[ 3 ], t[ 6 ], t[ 9 ],
+						t[ 1 ], t[ 4 ], t[ 7 ], t[ 10 ],
+						t[ 2 ], t[ 5 ], t[ 8 ], t[ 11 ],
+						 0.0, 0.0, 0.0, 1.0
 					);
 
 				}
@@ -511,11 +515,11 @@ THREE.ThreeMFLoader.prototype = {
 			var availableExtensions = [];
 			var keys = Object.keys( extensions );
 
-			for ( var i = 0; i < keys.length; i++ ) {
+			for ( var i = 0; i < keys.length; i ++ ) {
 
 				var ns = keys[ i ];
 
-				for ( var j = 0; j < scope.availableExtensions.length; j++ ) {
+				for ( var j = 0; j < scope.availableExtensions.length; j ++ ) {
 
 					var extension = scope.availableExtensions[ j ];
 
@@ -529,7 +533,7 @@ THREE.ThreeMFLoader.prototype = {
 
 			}
 
-			for ( var i = 0; i < availableExtensions.length; i++ ) {
+			for ( var i = 0; i < availableExtensions.length; i ++ ) {
 
 				var extension = availableExtensions[ i ];
 				extension.apply( modelXml, extensions[ extension[ 'ns' ] ], meshData );
@@ -544,7 +548,7 @@ THREE.ThreeMFLoader.prototype = {
 			var meshes = {};
 			var modelsKeys = Object.keys( modelsData );
 
-			for ( var i = 0; i < modelsKeys.length; i++ ) {
+			for ( var i = 0; i < modelsKeys.length; i ++ ) {
 
 				var modelsKey = modelsKeys[ i ];
 				var modelData = modelsData[ modelsKey ];
@@ -553,7 +557,7 @@ THREE.ThreeMFLoader.prototype = {
 
 				var objectIds = Object.keys( modelData[ 'resources' ][ 'object' ] );
 
-				for ( var j = 0; j < objectIds.length; j++ ) {
+				for ( var j = 0; j < objectIds.length; j ++ ) {
 
 					var objectId = objectIds[ j ];
 					var objectData = modelData[ 'resources' ][ 'object' ][ objectId ];
@@ -574,7 +578,7 @@ THREE.ThreeMFLoader.prototype = {
 			var group = new THREE.Group();
 			var buildData = data3mf.model[ refs[ 'target' ].substring( 1 ) ][ 'build' ];
 
-			for ( var i = 0; i < buildData.length; i++ ) {
+			for ( var i = 0; i < buildData.length; i ++ ) {
 
 				var buildItem = buildData[ i ];
 				var mesh = meshes[ buildItem[ 'objectid' ] ];
@@ -600,7 +604,7 @@ THREE.ThreeMFLoader.prototype = {
 
 	},
 
-	addExtension: function( extension ) {
+	addExtension: function ( extension ) {
 
 		this.availableExtensions.push( extension );
 

+ 4 - 4
examples/js/loaders/AMFLoader.js

@@ -35,7 +35,7 @@ THREE.AMFLoader.prototype = {
 
 		var loader = new THREE.FileLoader( scope.manager );
 		loader.setResponseType( 'arraybuffer' );
-		loader.load( url, function( text ) {
+		loader.load( url, function ( text ) {
 
 			onLoad( scope.parse( text ) );
 
@@ -59,7 +59,7 @@ THREE.AMFLoader.prototype = {
 
 				try {
 
-					zip = new JSZip( data );
+					zip = new JSZip( data ); // eslint-disable-line no-undef
 
 				} catch ( e ) {
 
@@ -154,7 +154,7 @@ THREE.AMFLoader.prototype = {
 
 					if ( matChildEl.attributes.type.value === 'name' ) {
 
-						matname = matChildEl.textContent;
+						matName = matChildEl.textContent;
 
 					}
 
@@ -465,7 +465,7 @@ THREE.AMFLoader.prototype = {
 					newGeometry.setIndex( volume.triangles );
 					newGeometry.addAttribute( 'position', vertices.clone() );
 
-					if( normals ) {
+					if ( normals ) {
 
 						newGeometry.addAttribute( 'normal', normals.clone() );
 

+ 199 - 200
examples/js/loaders/AWDLoader.js

@@ -5,43 +5,43 @@
 
 ( function () {
 
-	var UNCOMPRESSED  = 0,
-			DEFLATE       = 1,
-			LZMA          = 2,
-
-			AWD_FIELD_INT8      = 1,
-			AWD_FIELD_INT16     = 2,
-			AWD_FIELD_INT32     = 3,
-			AWD_FIELD_UINT8     = 4,
-			AWD_FIELD_UINT16    = 5,
-			AWD_FIELD_UINT32    = 6,
-			AWD_FIELD_FLOAT32   = 7,
-			AWD_FIELD_FLOAT64   = 8,
-			AWD_FIELD_BOOL      = 21,
-			AWD_FIELD_COLOR     = 22,
-			AWD_FIELD_BADDR     = 23,
-			AWD_FIELD_STRING    = 31,
-			AWD_FIELD_BYTEARRAY = 32,
-			AWD_FIELD_VECTOR2x1 = 41,
-			AWD_FIELD_VECTOR3x1 = 42,
-			AWD_FIELD_VECTOR4x1 = 43,
-			AWD_FIELD_MTX3x2    = 44,
-			AWD_FIELD_MTX3x3    = 45,
-			AWD_FIELD_MTX4x3    = 46,
-			AWD_FIELD_MTX4x4    = 47,
-
-			BOOL       = 21,
-			COLOR      = 22,
-			BADDR      = 23,
-
-			INT8    = 1,
-			INT16   = 2,
-			INT32   = 3,
-			UINT8   = 4,
-			UINT16  = 5,
-			UINT32  = 6,
-			FLOAT32 = 7,
-			FLOAT64 = 8;
+	var UNCOMPRESSED = 0,
+		DEFLATE = 1,
+		LZMA = 2,
+
+		AWD_FIELD_INT8 = 1,
+		AWD_FIELD_INT16 = 2,
+		AWD_FIELD_INT32 = 3,
+		AWD_FIELD_UINT8 = 4,
+		AWD_FIELD_UINT16 = 5,
+		AWD_FIELD_UINT32 = 6,
+		AWD_FIELD_FLOAT32 = 7,
+		AWD_FIELD_FLOAT64 = 8,
+		AWD_FIELD_BOOL = 21,
+		AWD_FIELD_COLOR = 22,
+		AWD_FIELD_BADDR = 23,
+		AWD_FIELD_STRING = 31,
+		AWD_FIELD_BYTEARRAY = 32,
+		AWD_FIELD_VECTOR2x1 = 41,
+		AWD_FIELD_VECTOR3x1 = 42,
+		AWD_FIELD_VECTOR4x1 = 43,
+		AWD_FIELD_MTX3x2 = 44,
+		AWD_FIELD_MTX3x3 = 45,
+		AWD_FIELD_MTX4x3 = 46,
+		AWD_FIELD_MTX4x4 = 47,
+
+		BOOL = 21,
+		COLOR = 22,
+		BADDR = 23,
+
+		INT8 = 1,
+		INT16 = 2,
+		INT32 = 3,
+		UINT8 = 4,
+		UINT16 = 5,
+		UINT32 = 6,
+		FLOAT32 = 7,
+		FLOAT64 = 8;
 
 	var littleEndian = true;
 
@@ -55,17 +55,23 @@
 	function AWDProperties() {}
 
 	AWDProperties.prototype = {
-		set: function( key, value ) {
+		set: function ( key, value ) {
 
 			this[ key ] = value;
 
 		},
 
-		get: function( key, fallback ) {
+		get: function ( key, fallback ) {
+
+			if ( this.hasOwnProperty( key ) ) {
 
-			if ( this.hasOwnProperty( key ) )
 				return this[ key ];
-			else return fallback;
+
+			} else {
+
+				return fallback;
+
+			}
 
 		}
 	};
@@ -78,13 +84,13 @@
 
 		this.materialFactory = undefined;
 
-		this._url     = '';
+		this._url = '';
 		this._baseDir = '';
 
 		this._data = undefined;
 		this._ptr = 0;
 
-		this._version =  [];
+		this._version = [];
 		this._streaming = false;
 		this._optimized_for_accuracy = false;
 		this._compression = 0;
@@ -92,9 +98,9 @@
 
 		this._blocks = [ new Block() ];
 
-		this._accuracyMatrix  = false;
-		this._accuracyGeo     = false;
-		this._accuracyProps   = false;
+		this._accuracyMatrix = false;
+		this._accuracyGeo = false;
+		this._accuracyProps = false;
 
 	};
 
@@ -128,7 +134,7 @@
 
 			this._parseHeader( );
 
-			if ( this._compression != 0  ) {
+			if ( this._compression != 0 ) {
 
 				console.error( 'compressed AWD not supported' );
 
@@ -136,7 +142,7 @@
 
 			if ( ! this._streaming && this._bodylen != data.byteLength - this._ptr ) {
 
-				console.error( 'AWDLoader: body len does not match file length', this._bodylen,  blen - this._ptr );
+				console.error( 'AWDLoader: body len does not match file length', this._bodylen, blen - this._ptr );
 
 			}
 
@@ -150,62 +156,76 @@
 
 		},
 
-		parseNextBlock: function() {
+		parseNextBlock: function () {
 
 			var assetData,
-					ns, type, len, block,
-					blockId = this.readU32(),
-					ns      = this.readU8(),
-					type    = this.readU8(),
-					flags   = this.readU8(),
-					len     = this.readU32();
+				ns, type, len, block,
+				blockId = this.readU32(),
+				ns = this.readU8(),
+				type = this.readU8(),
+				flags = this.readU8(),
+				len = this.readU32();
 
 
 			switch ( type ) {
+
 				case 1:
 					assetData = this.parseMeshData( len );
 					break;
+
 				case 22:
 					assetData = this.parseContainer( len );
 					break;
+
 				case 23:
 					assetData = this.parseMeshInstance( len );
 					break;
+
 				case 81:
 					assetData = this.parseMaterial( len );
 					break;
+
 				case 82:
 					assetData = this.parseTexture( len );
 					break;
+
 				case 101:
 					assetData = this.parseSkeleton( len );
 					break;
 
-	//      case 111:
-	//        assetData = this.parseMeshPoseAnimation(len, true);
-	//        break;
+	    //  case 111:
+	    //    assetData = this.parseMeshPoseAnimation(len, true);
+	    //    break;
+
 				case 112:
 					assetData = this.parseMeshPoseAnimation( len, false );
 					break;
+
 				case 113:
 					assetData = this.parseVertexAnimationSet( len );
 					break;
+
 				case 102:
 					assetData = this.parseSkeletonPose( len );
 					break;
+
 				case 103:
 					assetData = this.parseSkeletonAnimation( len );
 					break;
+
 				case 122:
 					assetData = this.parseAnimatorSet( len );
 					break;
+
 				// case 121:
 				//  assetData = parseUVAnimation(len);
 				//  break;
+
 				default:
 					//debug('Ignoring block!',type, len);
 					this._ptr += len;
 					break;
+
 			}
 
 
@@ -220,10 +240,7 @@
 		_parseHeader: function () {
 
 			var version = this._version,
-					awdmagic =
-							( this.readU8() << 16 )
-					|   ( this.readU8() << 8 )
-					|     this.readU8();
+				awdmagic = ( this.readU8() << 16 ) | ( this.readU8() << 8 ) | this.readU8();
 
 			if ( awdmagic != 4282180 )
 				throw new Error( "AWDLoader - bad magic" );
@@ -237,17 +254,17 @@
 
 			if ( ( version[ 0 ] === 2 ) && ( version[ 1 ] === 1 ) ) {
 
-				this._accuracyMatrix =  ( flags & 0x2 ) === 0x2;
-				this._accuracyGeo =     ( flags & 0x4 ) === 0x4;
-				this._accuracyProps =   ( flags & 0x8 ) === 0x8;
+				this._accuracyMatrix = ( flags & 0x2 ) === 0x2;
+				this._accuracyGeo = ( flags & 0x4 ) === 0x4;
+				this._accuracyProps = ( flags & 0x8 ) === 0x8;
 
 			}
 
-			this._geoNrType     = this._accuracyGeo     ? FLOAT64 : FLOAT32;
-			this._matrixNrType  = this._accuracyMatrix  ? FLOAT64 : FLOAT32;
-			this._propsNrType   = this._accuracyProps   ? FLOAT64 : FLOAT32;
+			this._geoNrType = this._accuracyGeo ? FLOAT64 : FLOAT32;
+			this._matrixNrType = this._accuracyMatrix ? FLOAT64 : FLOAT32;
+			this._propsNrType = this._accuracyProps ? FLOAT64 : FLOAT32;
 
-			this._optimized_for_accuracy  = ( flags & 0x2 ) === 0x2;
+			this._optimized_for_accuracy = ( flags & 0x2 ) === 0x2;
 
 			this._compression = this.readU8();
 			this._bodylen = this.readU32();
@@ -257,9 +274,9 @@
 		parseContainer: function ( len ) {
 
 			var parent,
-					ctr     = new THREE.Object3D(),
-					par_id  = this.readU32(),
-					mtx     = this.parseMatrix4();
+				ctr = new THREE.Object3D(),
+				par_id = this.readU32(),
+				mtx = this.parseMatrix4();
 
 			ctr.name = this.readUTF();
 			ctr.applyMatrix( mtx );
@@ -283,18 +300,18 @@
 		parseMeshInstance: function ( len ) {
 
 			var name,
-					mesh, geometries, meshLen, meshes,
-					par_id, data_id,
-					mtx,
-					materials, mat, mat_id,
-					num_materials,
-					parent,
-					i;
-
-			par_id        = this.readU32();
-			mtx           = this.parseMatrix4();
-			name          = this.readUTF();
-			data_id       = this.readU32();
+				mesh, geometries, meshLen, meshes,
+				par_id, data_id,
+				mtx,
+				materials, mat, mat_id,
+				num_materials,
+				parent,
+				i;
+
+			par_id = this.readU32();
+			mtx = this.parseMatrix4();
+			name = this.readUTF();
+			data_id = this.readU32();
 			num_materials = this.readU16();
 
 			geometries = this.getBlock( data_id );
@@ -314,7 +331,7 @@
 
 			// TODO : BufferGeometry don't support "geometryGroups" for now.
 			// so we create sub meshes for each groups
-			if ( meshLen  > 1 ) {
+			if ( meshLen > 1 ) {
 
 				mesh = new THREE.Object3D();
 				for ( i = 0; i < meshLen; i ++ ) {
@@ -357,16 +374,16 @@
 		parseMaterial: function ( len ) {
 
 			var name,
-					type,
-					props,
-					mat,
-					attributes,
-					finalize,
-					num_methods,
-					methods_parsed;
-
-			name        = this.readUTF();
-			type        = this.readU8();
+				type,
+				props,
+				mat,
+				attributes,
+				finalize,
+				num_methods,
+				methods_parsed;
+
+			name = this.readUTF();
+			type = this.readU8();
 			num_methods = this.readU8();
 
 			//log( "AWDLoader parseMaterial ",name )
@@ -374,8 +391,8 @@
 			// Read material numerical properties
 			// (1=color, 2=bitmap url, 11=alpha_blending, 12=alpha_threshold, 13=repeat)
 			props = this.parseProperties( {
-				1:  AWD_FIELD_INT32,
-				2:  AWD_FIELD_BADDR,
+				1: AWD_FIELD_INT32,
+				2: AWD_FIELD_BADDR,
 				11: AWD_FIELD_BOOL,
 				12: AWD_FIELD_FLOAT32,
 				13: AWD_FIELD_BOOL
@@ -424,12 +441,12 @@
 
 		},
 
-		parseTexture: function( len ) {
+		parseTexture: function ( len ) {
 
 			var name = this.readUTF(),
-					type = this.readU8(),
-					asset,
-					data_len;
+				type = this.readU8(),
+				asset,
+				data_len;
 
 			// External
 			if ( type === 0 ) {
@@ -451,13 +468,13 @@
 
 		},
 
-		loadTexture: function( url ) {
+		loadTexture: function ( url ) {
 
 			var tex = new THREE.Texture();
 
 			var loader = new THREE.ImageLoader( this.manager );
 
-			loader.load( this._baseDir + url, function( image ) {
+			loader.load( this._baseDir + url, function ( image ) {
 
 				tex.image = image;
 				tex.needsUpdate = true;
@@ -468,13 +485,13 @@
 
 		},
 
-		parseSkeleton: function( len ) {
+		parseSkeleton: function ( len ) {
 
 			// Array<Bone>
-			var name          = this.readUTF(),
-					num_joints    = this.readU16(),
-					skeleton      = [],
-					joints_parsed = 0;
+			var name = this.readUTF(),
+				num_joints = this.readU16(),
+				skeleton = [],
+				joints_parsed = 0;
 
 			this.parseProperties( null );
 
@@ -509,7 +526,7 @@
 
 		},
 
-		parseSkeletonPose: function( blockID ) {
+		parseSkeletonPose: function ( blockID ) {
 
 			var name = this.readUTF();
 
@@ -552,7 +569,7 @@
 
 		},
 
-		parseSkeletonAnimation: function( blockID ) {
+		parseSkeletonAnimation: function ( blockID ) {
 
 			var frame_dur;
 			var pose_addr;
@@ -578,8 +595,8 @@
 				pose = this._blocks[ pose_addr ].data;
 				// debug( 'pose address ',pose[2].elements[12],pose[2].elements[13],pose[2].elements[14] );
 				clip.push( {
-					pose : pose,
-					duration : frame_dur
+					pose: pose,
+					duration: frame_dur
 				} );
 
 				frames_parsed ++;
@@ -598,14 +615,14 @@
 
 		},
 
-		parseVertexAnimationSet: function( len ) {
+		parseVertexAnimationSet: function ( len ) {
 
 			var poseBlockAdress,
-					name           = this.readUTF(),
-					num_frames     = this.readU16(),
-					props          = this.parseProperties( { 1: UINT16 } ),
-					frames_parsed  = 0,
-					skeletonFrames = [];
+				name = this.readUTF(),
+				num_frames = this.readU16(),
+				props = this.parseProperties( { 1: UINT16 } ),
+				frames_parsed = 0,
+				skeletonFrames = [];
 
 			while ( frames_parsed < num_frames ) {
 
@@ -622,7 +639,7 @@
 
 		},
 
-		parseAnimatorSet: function( len ) {
+		parseAnimatorSet: function ( len ) {
 
 			var targetMesh;
 
@@ -655,7 +672,7 @@
 
 				//      returnedArray = getAssetByID(meshAdresses[i], [AssetType.MESH]);
 				//      if (returnedArray[0])
-				targetMeshes.push( this._blocks[ meshAdresses[ i ]].data );
+				targetMeshes.push( this._blocks[ meshAdresses[ i ] ].data );
 
 			}
 
@@ -666,8 +683,8 @@
 
 
 				thisAnimator = {
-					animationSet : targetAnimationSet,
-					skeleton : this._blocks[ props.get( 1, 0 ) ].data
+					animationSet: targetAnimationSet,
+					skeleton: this._blocks[ props.get( 1, 0 ) ].data
 				};
 
 			} else if ( type == 2 ) {
@@ -688,14 +705,14 @@
 
 		parseMeshData: function ( len ) {
 
-			var name      = this.readUTF(),
-				num_subs  = this.readU16(),
+			var name = this.readUTF(),
+				num_subs = this.readU16(),
 				geom,
 				subs_parsed = 0,
 				buffer,
 				skinW, skinI,
 				geometries = [];
-			
+
 			// Ignore for now
 			this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } );
 
@@ -720,15 +737,15 @@
 				while ( this._ptr < sm_end ) {
 
 					var idx = 0,
-							str_type  = this.readU8(),
-							str_ftype = this.readU8(),
-							str_len   = this.readU32(),
-							str_end   = str_len + this._ptr;
+						str_type = this.readU8(),
+						str_ftype = this.readU8(),
+						str_len = this.readU32(),
+						str_end = str_len + this._ptr;
 
-					// VERTICES
-					// ------------------
 					if ( str_type === 1 ) {
 
+						// VERTICES
+
 						buffer = new Float32Array( ( str_len / 12 ) * 3 );
 						attrib = new THREE.BufferAttribute( buffer, 3 );
 
@@ -737,18 +754,16 @@
 
 						while ( this._ptr < str_end ) {
 
-							buffer[ idx ]   = - this.readF32();
+							buffer[ idx ] = - this.readF32();
 							buffer[ idx + 1 ] = this.readF32();
 							buffer[ idx + 2 ] = this.readF32();
 							idx += 3;
 
 						}
 
-					}
+					} else if ( str_type === 2 ) {
 
-					// INDICES
-					// -----------------
-					else if ( str_type === 2 ) {
+						// INDICES
 
 						buffer = new Uint16Array( str_len / 2 );
 						attrib = new THREE.BufferAttribute( buffer, 1 );
@@ -758,18 +773,16 @@
 
 						while ( this._ptr < str_end ) {
 
-							buffer[ idx + 1 ]   = this.readU16();
-							buffer[ idx ]     = this.readU16();
-							buffer[ idx + 2 ]   = this.readU16();
+							buffer[ idx + 1 ] = this.readU16();
+							buffer[ idx ] = this.readU16();
+							buffer[ idx + 2 ] = this.readU16();
 							idx += 3;
 
 						}
 
-					}
+					} else if ( str_type === 3 ) {
 
-					// UVS
-					// -------------------
-					else if ( str_type === 3 ) {
+						// UVS
 
 						buffer = new Float32Array( ( str_len / 8 ) * 2 );
 						attrib = new THREE.BufferAttribute( buffer, 2 );
@@ -779,16 +792,15 @@
 
 						while ( this._ptr < str_end ) {
 
-							buffer[ idx ]   = this.readF32();
+							buffer[ idx ] = this.readF32();
 							buffer[ idx + 1 ] = 1.0 - this.readF32();
 							idx += 2;
 
 						}
 
-					}
+					} else if ( str_type === 4 ) {
 
-					// NORMALS
-					else if ( str_type === 4 ) {
+						// NORMALS
 
 						buffer = new Float32Array( ( str_len / 12 ) * 3 );
 						attrib = new THREE.BufferAttribute( buffer, 3 );
@@ -797,35 +809,14 @@
 
 						while ( this._ptr < str_end ) {
 
-							buffer[ idx ]   = - this.readF32();
+							buffer[ idx ] = - this.readF32();
 							buffer[ idx + 1 ] = this.readF32();
 							buffer[ idx + 2 ] = this.readF32();
 							idx += 3;
 
 						}
 
-					}
-
-					// else if (str_type == 6) {
-					//   skinI = new Float32Array( str_len>>1 );
-					//   idx = 0
-
-					//   while (this._ptr < str_end) {
-					//     skinI[idx]   = this.readU16();
-					//     idx++;
-					//   }
-
-					// }
-					// else if (str_type == 7) {
-					//   skinW = new Float32Array( str_len>>2 );
-					//   idx = 0;
-
-					//   while (this._ptr < str_end) {
-					//     skinW[idx]   = this.readF32();
-					//     idx++;
-					//   }
-					// }
-					else {
+					} else {
 
 						this._ptr = str_end;
 
@@ -849,31 +840,31 @@
 
 		},
 
-		parseMeshPoseAnimation: function( len, poseOnly ) {
+		parseMeshPoseAnimation: function ( len, poseOnly ) {
 
 			var num_frames = 1,
-					num_submeshes,
-					frames_parsed,
-					subMeshParsed,
-					frame_dur,
-					x, y, z,
-
-					str_len,
-					str_end,
-					geom,
-					subGeom,
-					idx = 0,
-					clip = {},
-					indices,
-					verts,
-					num_Streams,
-					streamsParsed,
-					streamtypes = [],
-
-					props,
-					thisGeo,
-					name = this.readUTF(),
-					geoAdress = this.readU32();
+				num_submeshes,
+				frames_parsed,
+				subMeshParsed,
+				frame_dur,
+				x, y, z,
+
+				str_len,
+				str_end,
+				geom,
+				subGeom,
+				idx = 0,
+				clip = {},
+				indices,
+				verts,
+				num_Streams,
+				streamsParsed,
+				streamtypes = [],
+
+				props,
+				thisGeo,
+				name = this.readUTF(),
+				geoAdress = this.readU32();
 
 			var mesh = this.getBlock( geoAdress );
 
@@ -929,7 +920,7 @@
 							//geom.addAttribute( 'morphTarget'+frames_parsed, Float32Array, str_len/12, 3 );
 							var buffer = new Float32Array( str_len / 4 );
 							geom.morphTargets.push( {
-								array : buffer
+								array: buffer
 							} );
 
 							//buffer = geom.attributes['morphTarget'+frames_parsed].array
@@ -937,9 +928,9 @@
 
 							while ( this._ptr < str_end ) {
 
-								buffer[ idx ]     = this.readF32();
-								buffer[ idx + 1 ]   = this.readF32();
-								buffer[ idx + 2 ]   = this.readF32();
+								buffer[ idx ] = this.readF32();
+								buffer[ idx + 1 ] = this.readF32();
+								buffer[ idx + 2 ] = this.readF32();
 								idx += 3;
 
 							}
@@ -1052,40 +1043,49 @@
 			var read_func;
 
 			switch ( type ) {
+
 				case AWD_FIELD_INT8:
 					elem_len = 1;
 					read_func = this.readI8;
 					break;
+
 				case AWD_FIELD_INT16:
 					elem_len = 2;
 					read_func = this.readI16;
 					break;
+
 				case AWD_FIELD_INT32:
 					elem_len = 4;
 					read_func = this.readI32;
 					break;
+
 				case AWD_FIELD_BOOL:
 				case AWD_FIELD_UINT8:
 					elem_len = 1;
 					read_func = this.readU8;
 					break;
+
 				case AWD_FIELD_UINT16:
 					elem_len = 2;
 					read_func = this.readU16;
 					break;
+
 				case AWD_FIELD_UINT32:
 				case AWD_FIELD_BADDR:
 					elem_len = 4;
 					read_func = this.readU32;
 					break;
+
 				case AWD_FIELD_FLOAT32:
 					elem_len = 4;
 					read_func = this.readF32;
 					break;
+
 				case AWD_FIELD_FLOAT64:
 					elem_len = 8;
 					read_func = this.readF64;
 					break;
+
 				case AWD_FIELD_VECTOR2x1:
 				case AWD_FIELD_VECTOR3x1:
 				case AWD_FIELD_VECTOR4x1:
@@ -1096,6 +1096,7 @@
 					elem_len = 8;
 					read_func = this.readF64;
 					break;
+
 			}
 
 			if ( elem_len < len ) {
@@ -1216,9 +1217,7 @@
 
 					var c2 = this._data.getUint8( this._ptr ++, littleEndian );
 					var c3 = this._data.getUint8( this._ptr ++, littleEndian );
-					out[ c ++ ] = String.fromCharCode(
-							( c1 & 15 ) << 12 | ( c2 & 63 ) << 6 | c3 & 63
-					);
+					out[ c ++ ] = String.fromCharCode( ( c1 & 15 ) << 12 | ( c2 & 63 ) << 6 | c3 & 63 );
 
 				}
 

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

@@ -149,7 +149,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 					case '$tex.file': {
 
-						var semantic =  property.semantic;
+						var semantic = property.semantic;
 
 						// prop.semantic gives the type of the texture
 						// 1: diffuse
@@ -255,8 +255,8 @@ THREE.AssimpJSONLoader.prototype = {
 		var textureLoader = new THREE.TextureLoader( this.manager );
 		textureLoader.setPath( path ).setCrossOrigin( this.crossOrigin );
 
-		var meshes = parseList ( json.meshes, parseMesh );
-		var materials = parseList ( json.materials, parseMaterial );
+		var meshes = parseList( json.meshes, parseMesh );
+		var materials = parseList( json.materials, parseMaterial );
 		return parseObject( json, json.rootnode, meshes, materials );
 
 	}

+ 49 - 30
examples/js/loaders/AssimpLoader.js

@@ -69,7 +69,7 @@ THREE.AssimpLoader.prototype = {
 				//      var keyscl =  key.parentspaceScl || key.scl;
 				var key2pos = nextKey.position;
 				var key2rot = nextKey.quaternion;
-					//  var key2scl =  key2.parentspaceScl || key2.scl;
+				//  var key2scl =  key2.parentspaceScl || key2.scl;
 				Virtulous.KeyFrame.tempAniPos.x = keypos.x * l2 + key2pos.x * l;
 				Virtulous.KeyFrame.tempAniPos.y = keypos.y * l2 + key2pos.y * l;
 				Virtulous.KeyFrame.tempAniPos.z = keypos.z * l2 + key2pos.z * l;
@@ -513,7 +513,7 @@ THREE.AssimpLoader.prototype = {
 			rootBone.position.copy( root.position );
 			rootBone.quaternion.copy( root.quaternion );
 			rootBone.scale.copy( root.scale );
-			scene.nodeCount++;
+			scene.nodeCount ++;
 			rootBone.name = "bone_" + root.name + scene.nodeCount.toString();
 
 			if ( ! scene.nodeToBoneMap[ root.name ] )
@@ -544,7 +544,11 @@ THREE.AssimpLoader.prototype = {
 
 			}
 
-			pairs.sort( function ( a, b ) { return b.w - a.w } );
+			pairs.sort( function ( a, b ) {
+
+				return b.w - a.w;
+
+			 } );
 
 			while ( pairs.length < 4 ) {
 
@@ -1202,9 +1206,21 @@ THREE.AssimpLoader.prototype = {
 			this.getLength = function () {
 
 				return Math.max(
-					Math.max.apply( null, this.mPositionKeys.map( function ( a ) { return a.mTime } ) ),
-					Math.max.apply( null, this.mRotationKeys.map( function ( a ) { return a.mTime } ) ),
-					Math.max.apply( null, this.mScalingKeys.map( function ( a ) { return a.mTime } ) )
+					Math.max.apply( null, this.mPositionKeys.map( function ( a ) {
+
+						return a.mTime;
+
+					} ) ),
+					Math.max.apply( null, this.mRotationKeys.map( function ( a ) {
+
+						return a.mTime;
+
+					} ) ),
+					Math.max.apply( null, this.mScalingKeys.map( function ( a ) {
+
+						return a.mTime;
+
+				 } ) )
 				);
 
 			};
@@ -1277,7 +1293,11 @@ THREE.AssimpLoader.prototype = {
 
 				}
 
-				animationHandle.length = Math.max.apply( null, animationHandle.tracks.map( function ( e ) { return e.length } ) );
+				animationHandle.length = Math.max.apply( null, animationHandle.tracks.map( function ( e ) {
+
+					return e.length;
+
+				} ) );
 				return animationHandle;
 
 			};
@@ -1397,9 +1417,9 @@ THREE.AssimpLoader.prototype = {
 
 				var m = new THREE.Matrix4();
 
-				for ( var i = 0; i < 4; ++i ) {
+				for ( var i = 0; i < 4; ++ i ) {
 
-					for ( var i2 = 0; i2 < 4; ++i2 ) {
+					for ( var i2 = 0; i2 < 4; ++ i2 ) {
 
 						m.elements[ i * 4 + i2 ] = this.elements[ i2 ][ i ];
 
@@ -1547,9 +1567,9 @@ THREE.AssimpLoader.prototype = {
 
 			var m = new aiMatrix4();
 
-			for ( var i = 0; i < 4; ++i ) {
+			for ( var i = 0; i < 4; ++ i ) {
 
-				for ( var i2 = 0; i2 < 4; ++i2 ) {
+				for ( var i2 = 0; i2 < 4; ++ i2 ) {
 
 					m.elements[ i ][ i2 ] = readFloat( stream );
 
@@ -1659,7 +1679,7 @@ THREE.AssimpLoader.prototype = {
 
 				node.mMeshes = [];
 
-				for ( var i = 0; i < node.mNumMeshes; ++i ) {
+				for ( var i = 0; i < node.mNumMeshes; ++ i ) {
 
 					node.mMeshes[ i ] = Read_unsigned_int( stream );
 
@@ -1671,7 +1691,7 @@ THREE.AssimpLoader.prototype = {
 
 				node.mChildren = [];
 
-				for ( var i = 0; i < node.mNumChildren; ++i ) {
+				for ( var i = 0; i < node.mNumChildren; ++ i ) {
 
 					var node2 = ReadBinaryNode( stream, node, depth ++ );
 					node.mChildren[ i ] = node2;
@@ -1787,7 +1807,7 @@ THREE.AssimpLoader.prototype = {
 
 			}
 
-			for ( var n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS; ++n ) {
+			for ( var n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS; ++ n ) {
 
 				if ( ! ( c & ASSBIN_MESH_HAS_COLOR( n ) ) ) break;
 
@@ -1809,7 +1829,7 @@ THREE.AssimpLoader.prototype = {
 
 			mesh.mTexCoordsBuffers = [];
 
-			for ( var n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++n ) {
+			for ( var n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++ n ) {
 
 				if ( ! ( c & ASSBIN_MESH_HAS_TEXCOORD( n ) ) ) break;
 
@@ -1857,14 +1877,14 @@ THREE.AssimpLoader.prototype = {
 				var indexCounter = 0;
 				mesh.mIndexArray = [];
 
-				for ( var i = 0; i < mesh.mNumFaces; ++i ) {
+				for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
 
 					var f = mesh.mFaces[ i ] = new aiFace();
 					// BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
 					f.mNumIndices = Read_uint16_t( stream );
 					f.mIndices = [];
 
-					for ( var a = 0; a < f.mNumIndices; ++a ) {
+					for ( var a = 0; a < f.mNumIndices; ++ a ) {
 
 						if ( mesh.mNumVertices < ( 1 << 16 ) ) {
 
@@ -1880,14 +1900,13 @@ THREE.AssimpLoader.prototype = {
 
 					}
 
-					if(f.mNumIndices === 3) {
+					if ( f.mNumIndices === 3 ) {
 
 						mesh.mIndexArray.push( f.mIndices[ 0 ] );
 						mesh.mIndexArray.push( f.mIndices[ 1 ] );
 						mesh.mIndexArray.push( f.mIndices[ 2 ] );
 
-					}
-					else if(f.mNumIndices === 4) {
+					} else if ( f.mNumIndices === 4 ) {
 
 						mesh.mIndexArray.push( f.mIndices[ 0 ] );
 						mesh.mIndexArray.push( f.mIndices[ 1 ] );
@@ -1898,7 +1917,7 @@ THREE.AssimpLoader.prototype = {
 
 					} else {
 
-						throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." ))
+						throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." ) );
 
 					}
 
@@ -1912,7 +1931,7 @@ THREE.AssimpLoader.prototype = {
 
 				mesh.mBones = [];
 
-				for ( var a = 0; a < mesh.mNumBones; ++a ) {
+				for ( var a = 0; a < mesh.mNumBones; ++ a ) {
 
 					mesh.mBones[ a ] = new aiBone();
 					ReadBinaryBone( stream, mesh.mBones[ a ] );
@@ -1959,7 +1978,7 @@ THREE.AssimpLoader.prototype = {
 
 				mat.mProperties = [];
 
-				for ( var i = 0; i < mat.mNumProperties; ++i ) {
+				for ( var i = 0; i < mat.mNumProperties; ++ i ) {
 
 					mat.mProperties[ i ] = new aiMaterialProperty();
 					ReadBinaryMaterialProperty( stream, mat.mProperties[ i ] );
@@ -2051,7 +2070,7 @@ THREE.AssimpLoader.prototype = {
 
 				anim.mChannels = [];
 
-				for ( var a = 0; a < anim.mNumChannels; ++a ) {
+				for ( var a = 0; a < anim.mNumChannels; ++ a ) {
 
 					anim.mChannels[ a ] = new aiNodeAnim();
 					ReadBinaryNodeAnim( stream, anim.mChannels[ a ] );
@@ -2158,7 +2177,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mMeshes = [];
 
-				for ( var i = 0; i < scene.mNumMeshes; ++i ) {
+				for ( var i = 0; i < scene.mNumMeshes; ++ i ) {
 
 					scene.mMeshes[ i ] = new aiMesh();
 					ReadBinaryMesh( stream, scene.mMeshes[ i ] );
@@ -2171,7 +2190,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mMaterials = [];
 
-				for ( var i = 0; i < scene.mNumMaterials; ++i ) {
+				for ( var i = 0; i < scene.mNumMaterials; ++ i ) {
 
 					scene.mMaterials[ i ] = new aiMaterial();
 					ReadBinaryMaterial( stream, scene.mMaterials[ i ] );
@@ -2184,7 +2203,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mAnimations = [];
 
-				for ( var i = 0; i < scene.mNumAnimations; ++i ) {
+				for ( var i = 0; i < scene.mNumAnimations; ++ i ) {
 
 					scene.mAnimations[ i ] = new aiAnimation();
 					ReadBinaryAnim( stream, scene.mAnimations[ i ] );
@@ -2197,7 +2216,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mTextures = [];
 
-				for ( var i = 0; i < scene.mNumTextures; ++i ) {
+				for ( var i = 0; i < scene.mNumTextures; ++ i ) {
 
 					scene.mTextures[ i ] = new aiTexture();
 					ReadBinaryTexture( stream, scene.mTextures[ i ] );
@@ -2210,7 +2229,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mLights = [];
 
-				for ( var i = 0; i < scene.mNumLights; ++i ) {
+				for ( var i = 0; i < scene.mNumLights; ++ i ) {
 
 					scene.mLights[ i ] = new aiLight();
 					ReadBinaryLight( stream, scene.mLights[ i ] );
@@ -2223,7 +2242,7 @@ THREE.AssimpLoader.prototype = {
 
 				scene.mCameras = [];
 
-				for ( var i = 0; i < scene.mNumCameras; ++i ) {
+				for ( var i = 0; i < scene.mNumCameras; ++ i ) {
 
 					scene.mCameras[ i ] = new aiCamera();
 					ReadBinaryCamera( stream, scene.mCameras[ i ] );

+ 25 - 25
examples/js/loaders/BVHLoader.js

@@ -8,7 +8,7 @@
  *
  */
 
-THREE.BVHLoader = function( manager ) {
+THREE.BVHLoader = function ( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
 
@@ -26,7 +26,7 @@ THREE.BVHLoader.prototype = {
 		var scope = this;
 
 		var loader = new THREE.FileLoader( scope.manager );
-		loader.load( url, function( text ) {
+		loader.load( url, function ( text ) {
 
 			onLoad( scope.parse( text ) );
 
@@ -137,29 +137,29 @@ THREE.BVHLoader.prototype = {
 
 				switch ( bone.channels[ i ] ) {
 
-				case 'Xposition':
-					keyframe.position.x = parseFloat( data.shift().trim() );
-					break;
-				case 'Yposition':
-					keyframe.position.y = parseFloat( data.shift().trim() );
-					break;
-				case 'Zposition':
-					keyframe.position.z = parseFloat( data.shift().trim() );
-					break;
-				case 'Xrotation':
-					quat.setFromAxisAngle( vx, parseFloat( data.shift().trim() ) * Math.PI / 180 );
-					keyframe.rotation.multiply( quat );
-					break;
-				case 'Yrotation':
-					quat.setFromAxisAngle( vy, parseFloat( data.shift().trim() ) * Math.PI / 180 );
-					keyframe.rotation.multiply( quat );
-					break;
-				case 'Zrotation':
-					quat.setFromAxisAngle( vz, parseFloat( data.shift().trim() ) * Math.PI / 180 );
-					keyframe.rotation.multiply( quat );
-					break;
-				default:
-					console.warn( 'THREE.BVHLoader: Invalid channel type.' );
+					case 'Xposition':
+						keyframe.position.x = parseFloat( data.shift().trim() );
+						break;
+					case 'Yposition':
+						keyframe.position.y = parseFloat( data.shift().trim() );
+						break;
+					case 'Zposition':
+						keyframe.position.z = parseFloat( data.shift().trim() );
+						break;
+					case 'Xrotation':
+						quat.setFromAxisAngle( vx, parseFloat( data.shift().trim() ) * Math.PI / 180 );
+						keyframe.rotation.multiply( quat );
+						break;
+					case 'Yrotation':
+						quat.setFromAxisAngle( vy, parseFloat( data.shift().trim() ) * Math.PI / 180 );
+						keyframe.rotation.multiply( quat );
+						break;
+					case 'Zrotation':
+						quat.setFromAxisAngle( vz, parseFloat( data.shift().trim() ) * Math.PI / 180 );
+						keyframe.rotation.multiply( quat );
+						break;
+					default:
+						console.warn( 'THREE.BVHLoader: Invalid channel type.' );
 
 				}
 

+ 1 - 0
examples/js/loaders/BabylonLoader.js

@@ -177,6 +177,7 @@ THREE.BabylonLoader.prototype = {
 					case 3:
 						light = new THREE.HemisphereLight();
 						break;
+
 				}
 
 				light.name = data.name;

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

@@ -33,7 +33,7 @@ THREE.BinaryLoader.prototype = {
 		// todo: unify load API to for easier SceneLoader use
 
 		var texturePath = this.texturePath || THREE.Loader.prototype.extractUrlBase( url );
-		var binaryPath  = this.binaryPath || THREE.Loader.prototype.extractUrlBase( url );
+		var binaryPath = this.binaryPath || THREE.Loader.prototype.extractUrlBase( url );
 
 		// #1 load JS part via web worker
 
@@ -83,7 +83,7 @@ THREE.BinaryLoader.prototype = {
 
 	parse: function ( data, callback, texturePath, jsonMaterials ) {
 
-		var Model = function ( texturePath ) {
+		var Model = function () {
 
 			var scope = this,
 				currentOffset = 0,
@@ -110,17 +110,17 @@ THREE.BinaryLoader.prototype = {
 			*/
 			// buffers sizes
 
-			tri_size =  md.vertex_index_bytes * 3 + md.material_index_bytes;
+			tri_size = md.vertex_index_bytes * 3 + md.material_index_bytes;
 			quad_size = md.vertex_index_bytes * 4 + md.material_index_bytes;
 
-			len_tri_flat      = md.ntri_flat      * ( tri_size );
-			len_tri_smooth    = md.ntri_smooth    * ( tri_size + md.normal_index_bytes * 3 );
-			len_tri_flat_uv   = md.ntri_flat_uv   * ( tri_size + md.uv_index_bytes * 3 );
+			len_tri_flat = md.ntri_flat * ( tri_size );
+			len_tri_smooth = md.ntri_smooth * ( tri_size + md.normal_index_bytes * 3 );
+			len_tri_flat_uv = md.ntri_flat_uv * ( tri_size + md.uv_index_bytes * 3 );
 			len_tri_smooth_uv = md.ntri_smooth_uv * ( tri_size + md.normal_index_bytes * 3 + md.uv_index_bytes * 3 );
 
-			len_quad_flat      = md.nquad_flat      * ( quad_size );
-			len_quad_smooth    = md.nquad_smooth    * ( quad_size + md.normal_index_bytes * 4 );
-			len_quad_flat_uv   = md.nquad_flat_uv   * ( quad_size + md.uv_index_bytes * 4 );
+			len_quad_flat = md.nquad_flat * ( quad_size );
+			len_quad_smooth = md.nquad_smooth * ( quad_size + md.normal_index_bytes * 4 );
+			len_quad_flat_uv = md.nquad_flat_uv * ( quad_size + md.uv_index_bytes * 4 );
 
 			// read buffers
 
@@ -131,15 +131,15 @@ THREE.BinaryLoader.prototype = {
 
 			currentOffset += init_uvs( currentOffset );
 
-			start_tri_flat 		= currentOffset;
-			start_tri_smooth    = start_tri_flat    + len_tri_flat    + handlePadding( md.ntri_flat * 2 );
-			start_tri_flat_uv   = start_tri_smooth  + len_tri_smooth  + handlePadding( md.ntri_smooth * 2 );
+			start_tri_flat = currentOffset;
+			start_tri_smooth = start_tri_flat + len_tri_flat + handlePadding( md.ntri_flat * 2 );
+			start_tri_flat_uv = start_tri_smooth + len_tri_smooth + handlePadding( md.ntri_smooth * 2 );
 			start_tri_smooth_uv = start_tri_flat_uv + len_tri_flat_uv + handlePadding( md.ntri_flat_uv * 2 );
 
-			start_quad_flat     = start_tri_smooth_uv + len_tri_smooth_uv  + handlePadding( md.ntri_smooth_uv * 2 );
-			start_quad_smooth   = start_quad_flat     + len_quad_flat	   + handlePadding( md.nquad_flat * 2 );
-			start_quad_flat_uv  = start_quad_smooth   + len_quad_smooth    + handlePadding( md.nquad_smooth * 2 );
-			start_quad_smooth_uv = start_quad_flat_uv  + len_quad_flat_uv   + handlePadding( md.nquad_flat_uv * 2 );
+			start_quad_flat = start_tri_smooth_uv + len_tri_smooth_uv + handlePadding( md.ntri_smooth_uv * 2 );
+			start_quad_smooth = start_quad_flat + len_quad_flat	+ handlePadding( md.nquad_flat * 2 );
+			start_quad_flat_uv = start_quad_smooth + len_quad_smooth + handlePadding( md.nquad_smooth * 2 );
+			start_quad_smooth_uv = start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 );
 
 			// have to first process faces with uvs
 			// so that face and uv indices match
@@ -170,31 +170,31 @@ THREE.BinaryLoader.prototype = {
 
 				var metaData = {
 
-					'signature'               : parseString( data, offset,  12 ),
-					'header_bytes'            : parseUChar8( data, offset + 12 ),
+					'signature': parseString( data, offset, 12 ),
+					'header_bytes': parseUChar8( data, offset + 12 ),
 
-					'vertex_coordinate_bytes' : parseUChar8( data, offset + 13 ),
-					'normal_coordinate_bytes' : parseUChar8( data, offset + 14 ),
-					'uv_coordinate_bytes'     : parseUChar8( data, offset + 15 ),
+					'vertex_coordinate_bytes': parseUChar8( data, offset + 13 ),
+					'normal_coordinate_bytes': parseUChar8( data, offset + 14 ),
+					'uv_coordinate_bytes': parseUChar8( data, offset + 15 ),
 
-					'vertex_index_bytes'      : parseUChar8( data, offset + 16 ),
-					'normal_index_bytes'      : parseUChar8( data, offset + 17 ),
-					'uv_index_bytes'          : parseUChar8( data, offset + 18 ),
-					'material_index_bytes'    : parseUChar8( data, offset + 19 ),
+					'vertex_index_bytes': parseUChar8( data, offset + 16 ),
+					'normal_index_bytes': parseUChar8( data, offset + 17 ),
+					'uv_index_bytes': parseUChar8( data, offset + 18 ),
+					'material_index_bytes': parseUChar8( data, offset + 19 ),
 
-					'nvertices'    : parseUInt32( data, offset + 20 ),
-					'nnormals'     : parseUInt32( data, offset + 20 + 4 * 1 ),
-					'nuvs'         : parseUInt32( data, offset + 20 + 4 * 2 ),
+					'nvertices': parseUInt32( data, offset + 20 ),
+					'nnormals': parseUInt32( data, offset + 20 + 4 * 1 ),
+					'nuvs': parseUInt32( data, offset + 20 + 4 * 2 ),
 
-					'ntri_flat'      : parseUInt32( data, offset + 20 + 4 * 3 ),
-					'ntri_smooth'    : parseUInt32( data, offset + 20 + 4 * 4 ),
-					'ntri_flat_uv'   : parseUInt32( data, offset + 20 + 4 * 5 ),
-					'ntri_smooth_uv' : parseUInt32( data, offset + 20 + 4 * 6 ),
+					'ntri_flat': parseUInt32( data, offset + 20 + 4 * 3 ),
+					'ntri_smooth': parseUInt32( data, offset + 20 + 4 * 4 ),
+					'ntri_flat_uv': parseUInt32( data, offset + 20 + 4 * 5 ),
+					'ntri_smooth_uv': parseUInt32( data, offset + 20 + 4 * 6 ),
 
-					'nquad_flat'      : parseUInt32( data, offset + 20 + 4 * 7 ),
-					'nquad_smooth'    : parseUInt32( data, offset + 20 + 4 * 8 ),
-					'nquad_flat_uv'   : parseUInt32( data, offset + 20 + 4 * 9 ),
-					'nquad_smooth_uv' : parseUInt32( data, offset + 20 + 4 * 10 )
+					'nquad_flat': parseUInt32( data, offset + 20 + 4 * 7 ),
+					'nquad_smooth': parseUInt32( data, offset + 20 + 4 * 8 ),
+					'nquad_flat_uv': parseUInt32( data, offset + 20 + 4 * 9 ),
+					'nquad_smooth_uv': parseUInt32( data, offset + 20 + 4 * 10 )
 
 				};
 				/*
@@ -689,7 +689,7 @@ THREE.BinaryLoader.prototype = {
 		Model.prototype = Object.create( THREE.Geometry.prototype );
 		Model.prototype.constructor = Model;
 
-		var geometry = new Model( texturePath );
+		var geometry = new Model();
 		var materials = THREE.Loader.prototype.initMaterials( jsonMaterials, texturePath, this.crossOrigin );
 
 		callback( geometry, materials );

+ 20 - 24
examples/js/loaders/ColladaLoader2.js

@@ -130,7 +130,7 @@ THREE.ColladaLoader.prototype = {
 
 		function isEmpty( object ) {
 
-			return  Object.keys( object ).length === 0;
+			return Object.keys( object ).length === 0;
 
 		}
 
@@ -346,13 +346,11 @@ THREE.ColladaLoader.prototype = {
 
 					var inputId = sampler.inputs.INPUT;
 					var outputId = sampler.inputs.OUTPUT;
-					var interpolationId = sampler.inputs.INTERPOLATION;
 
 					var inputSource = sources[ inputId ];
 					var outputSource = sources[ outputId ];
-					var interpolationSource = sources[ interpolationId ];
 
-					var animation = buildAnimationChannel( channel, inputSource, outputSource, interpolationSource );
+					var animation = buildAnimationChannel( channel, inputSource, outputSource );
 
 					createKeyframeTracks( animation, tracks );
 
@@ -370,7 +368,7 @@ THREE.ColladaLoader.prototype = {
 
 		}
 
-		function buildAnimationChannel( channel, inputSource, outputSource, interpolationSource ) {
+		function buildAnimationChannel( channel, inputSource, outputSource ) {
 
 			var node = library.nodes[ channel.id ];
 			var object3D = getNode( node.id );
@@ -437,7 +435,7 @@ THREE.ColladaLoader.prototype = {
 			var animation = {
 				name: object3D.uuid,
 				keyframes: keyframes
-			}
+			};
 
 			return animation;
 
@@ -578,7 +576,7 @@ THREE.ColladaLoader.prototype = {
 					prev = getPrev( keyframes, i, property );
 					next = getNext( keyframes, i, property );
 
-					if ( prev === null )  {
+					if ( prev === null ) {
 
 						keyframe.value[ property ] = next.value[ property ];
 						continue;
@@ -743,7 +741,7 @@ THREE.ColladaLoader.prototype = {
 
 			var data = {
 				sources: {}
-			}
+			};
 
 			for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
 
@@ -782,7 +780,7 @@ THREE.ColladaLoader.prototype = {
 
 			var data = {
 				inputs: {}
-			}
+			};
 
 			for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
 
@@ -810,7 +808,7 @@ THREE.ColladaLoader.prototype = {
 
 			var data = {
 				inputs: {}
-			}
+			};
 
 			for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
 
@@ -1392,7 +1390,7 @@ THREE.ColladaLoader.prototype = {
 
 					var extra = textureObject.extra;
 
-					if ( extra !== undefined && extra.technique !== undefined  && isEmpty( extra.technique ) === false ) {
+					if ( extra !== undefined && extra.technique !== undefined && isEmpty( extra.technique ) === false ) {
 
 						var technique = extra.technique;
 
@@ -1861,7 +1859,7 @@ THREE.ColladaLoader.prototype = {
 			var primitive = {
 				type: xml.nodeName,
 				material: xml.getAttribute( 'material' ),
-				count:  parseInt( xml.getAttribute( 'count' ) ),
+				count: parseInt( xml.getAttribute( 'count' ) ),
 				inputs: {},
 				stride: 0
 			};
@@ -1960,7 +1958,6 @@ THREE.ColladaLoader.prototype = {
 			var materialKeys = [];
 
 			var start = 0, count = 0;
-			var array;
 
 			for ( var p = 0; p < primitives.length; p ++ ) {
 
@@ -2008,7 +2005,7 @@ THREE.ColladaLoader.prototype = {
 						case 'VERTEX':
 							for ( var key in vertices ) {
 
-								var id =  vertices[ key ];
+								var id = vertices[ key ];
 
 								switch ( key ) {
 
@@ -2198,7 +2195,7 @@ THREE.ColladaLoader.prototype = {
 
 			library.kinematicsModels[ xml.getAttribute( 'id' ) ] = data;
 
-		};
+		}
 
 		function buildKinematicsModel( data ) {
 
@@ -2266,7 +2263,7 @@ THREE.ColladaLoader.prototype = {
 		function parseKinematicsJointParameter( xml, data ) {
 
 			var data = {
-				sid:  xml.getAttribute( 'sid' ),
+				sid: xml.getAttribute( 'sid' ),
 				name: xml.getAttribute( 'name' ) || '',
 				axis: new THREE.Vector3(),
 				limits: {
@@ -2528,11 +2525,10 @@ THREE.ColladaLoader.prototype = {
 
 			function connect( jointIndex, visualElement ) {
 
-				var visualElementId = visualElement.getAttribute( 'id' );
 				var visualElementName = visualElement.getAttribute( 'name' );
 				var joint = kinematicsModel.joints[ jointIndex ];
 
-				visualScene.traverse( function( object ) {
+				visualScene.traverse( function ( object ) {
 
 					if ( object.name === visualElementName ) {
 
@@ -2547,7 +2543,7 @@ THREE.ColladaLoader.prototype = {
 
 				} );
 
-			};
+			}
 
 			var m0 = new THREE.Matrix4();
 
@@ -2555,7 +2551,7 @@ THREE.ColladaLoader.prototype = {
 
 				joints: kinematicsModel && kinematicsModel.joints,
 
-				getJointValue: function( jointIndex ) {
+				getJointValue: function ( jointIndex ) {
 
 					var jointData = jointMap[ jointIndex ];
 
@@ -2571,7 +2567,7 @@ THREE.ColladaLoader.prototype = {
 
 				},
 
-				setJointValue: function( jointIndex, value ) {
+				setJointValue: function ( jointIndex, value ) {
 
 					var jointData = jointMap[ jointIndex ];
 
@@ -2603,7 +2599,7 @@ THREE.ColladaLoader.prototype = {
 
 								// if there is a connection of the transform node with a joint, apply the joint value
 
-								if ( transform.sid && transform.sid.indexOf( jointIndex ) !== -1 ) {
+								if ( transform.sid && transform.sid.indexOf( jointIndex ) !== - 1 ) {
 
 									switch ( joint.type ) {
 
@@ -2705,7 +2701,7 @@ THREE.ColladaLoader.prototype = {
 						var array = parseFloats( child.textContent );
 						var vector = new THREE.Vector3().fromArray( array );
 						var angle = THREE.Math.degToRad( array[ 3 ] );
-						transforms.push({
+						transforms.push( {
 							sid: child.getAttribute( 'sid' ),
 							type: child.nodeName,
 							obj: vector,
@@ -2950,7 +2946,7 @@ THREE.ColladaLoader.prototype = {
 
 			// setup bone data from visual scene
 
-			root.traverse( function( object ) {
+			root.traverse( function ( object ) {
 
 				if ( object.isBone === true ) {
 

+ 3 - 2
examples/js/loaders/DDSLoader.js

@@ -186,7 +186,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 				&& header[ off_RBitMask ] & 0xff0000
 				&& header[ off_GBitMask ] & 0xff00
 				&& header[ off_BBitMask ] & 0xff
-				&& header[ off_ABitMask ] & 0xff000000  ) {
+				&& header[ off_ABitMask ] & 0xff000000 ) {
 
 				isRGBAUncompressed = true;
 				blockBytes = 64;
@@ -198,6 +198,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 				return dds;
 
 			}
+
 	}
 
 	dds.mipmapCount = 1;
@@ -217,7 +218,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 		! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) ||
 		! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) ||
 		! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ )
-		) ) {
+	) ) {
 
 		console.error( 'THREE.DDSLoader.parse: Incomplete cubemap faces' );
 		return dds;

+ 12 - 9
examples/js/loaders/FBXLoader.js

@@ -1426,7 +1426,7 @@
 						}
 						if ( 'color' in geometry.attributes ) {
 
-							for ( var materialIndex = 0, numMaterials = materials.length; materialIndex < numMaterials; ++materialIndex ) {
+							for ( var materialIndex = 0, numMaterials = materials.length; materialIndex < numMaterials; ++ materialIndex ) {
 
 								materials[ materialIndex ].vertexColors = THREE.VertexColors;
 
@@ -3659,7 +3659,9 @@
 					var nodeAttrs = match[ 2 ].split( ',' );
 
 					for ( var i = 0, l = nodeAttrs.length; i < l; i ++ ) {
+
 						nodeAttrs[ i ] = nodeAttrs[ i ].trim().replace( /^"/, '' ).replace( /"$/, '' );
+
 					}
 
 					this.parseNodeBegin( l, nodeName, nodeAttrs || null );
@@ -3925,7 +3927,9 @@
 			var props = propValue.split( '",' );
 
 			for ( var i = 0, l = props.length; i < l; i ++ ) {
+
 				props[ i ] = props[ i ].trim().replace( /^\"/, '' ).replace( /\s/, '_' );
+
 			}
 
 			var innerPropName = props[ 0 ];
@@ -4027,7 +4031,7 @@
 		 * @param {BinaryReader} reader
 		 * @returns {boolean}
 		 */
-		endOfContent: function( reader ) {
+		endOfContent: function ( reader ) {
 
 			// footer size: 160bytes + 16-byte alignment padding
 			// - 16bytes: magic
@@ -4039,7 +4043,7 @@
 			// - 16bytes: magic
 			if ( reader.size() % 16 === 0 ) {
 
-				return ( ( reader.getOffset() + 160 + 16 ) & ~0xf ) >= reader.size();
+				return ( ( reader.getOffset() + 160 + 16 ) & ~ 0xf ) >= reader.size();
 
 			} else {
 
@@ -4061,7 +4065,6 @@
 			// The first three data sizes depends on version.
 			var endOffset = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
 			var numProperties = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
-			var propertyListLen = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
 			var nameLen = reader.getUint8();
 			var name = reader.getString( nameLen );
 
@@ -4355,7 +4358,7 @@
 
 					}
 
-					var inflate = new Zlib.Inflate( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) );
+					var inflate = new Zlib.Inflate( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef
 					var reader2 = new BinaryReader( inflate.decompress().buffer );
 
 					switch ( type ) {
@@ -4602,8 +4605,8 @@
 			// calculate negative value
 			if ( high & 0x80000000 ) {
 
-				high = ~high & 0xFFFFFFFF;
-				low = ~low & 0xFFFFFFFF;
+				high = ~ high & 0xFFFFFFFF;
+				low = ~ low & 0xFFFFFFFF;
 
 				if ( low === 0xFFFFFFFF ) high = ( high + 1 ) & 0xFFFFFFFF;
 
@@ -4731,7 +4734,7 @@
 			while ( size > 0 ) {
 
 				var value = this.getUint8();
-				size--;
+				size --;
 
 				if ( value === 0 ) break;
 
@@ -5092,7 +5095,7 @@
 
 		}
 
-		return -1;
+		return - 1;
 
 	}
 

+ 34 - 29
examples/js/loaders/GLTFLoader.js

@@ -92,19 +92,19 @@ THREE.GLTFLoader = ( function () {
 
 			if ( json.extensionsUsed ) {
 
-				if( json.extensionsUsed.indexOf( EXTENSIONS.KHR_LIGHTS ) >= 0 ) {
+				if ( json.extensionsUsed.indexOf( EXTENSIONS.KHR_LIGHTS ) >= 0 ) {
 
 					extensions[ EXTENSIONS.KHR_LIGHTS ] = new GLTFLightsExtension( json );
 
 				}
 
-				if( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_COMMON ) >= 0 ) {
+				if ( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_COMMON ) >= 0 ) {
 
 					extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] = new GLTFMaterialsCommonExtension( json );
 
 				}
 
-				if( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ) >= 0 ) {
+				if ( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ) >= 0 ) {
 
 					extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
 
@@ -347,7 +347,7 @@ THREE.GLTFLoader = ( function () {
 
 		var materialValues = {};
 
-		keys.forEach( function( v ) {
+		keys.forEach( function ( v ) {
 
 			if ( khrMaterial[ v ] !== undefined ) materialValues[ v ] = khrMaterial[ v ];
 
@@ -519,14 +519,14 @@ THREE.GLTFLoader = ( function () {
 				].join( '\n' );
 
 				var fragmentShader = shader.fragmentShader
-							.replace( '#include <specularmap_fragment>', '' )
-							.replace( 'uniform float roughness;', 'uniform vec3 specular;' )
-							.replace( 'uniform float metalness;', 'uniform float glossiness;' )
-							.replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk )
-							.replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk )
-							.replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk )
-							.replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk )
-							.replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
+					.replace( '#include <specularmap_fragment>', '' )
+					.replace( 'uniform float roughness;', 'uniform vec3 specular;' )
+					.replace( 'uniform float metalness;', 'uniform float glossiness;' )
+					.replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk )
+					.replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk )
+					.replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk )
+					.replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk )
+					.replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
 
 				delete uniforms.roughness;
 				delete uniforms.metalness;
@@ -728,7 +728,7 @@ THREE.GLTFLoader = ( function () {
 
 				uniforms.envMap.value = material.envMap;
 				uniforms.envMapIntensity.value = material.envMapIntensity;
-				uniforms.flipEnvMap.value = ( material.envMap && material.envMap.isCubeTexture ) ? -1 : 1;
+				uniforms.flipEnvMap.value = ( material.envMap && material.envMap.isCubeTexture ) ? - 1 : 1;
 
 				uniforms.refractionRatio.value = material.refractionRatio;
 
@@ -845,8 +845,8 @@ THREE.GLTFLoader = ( function () {
 	};
 
 	var WEBGL_SIDES = {
-		1028: THREE.BackSide,  // Culling front
-		1029: THREE.FrontSide  // Culling back
+		1028: THREE.BackSide, // Culling front
+		1029: THREE.FrontSide // Culling back
 		//1032: THREE.NoSide   // Culling front and back, what to do?
 	};
 
@@ -929,8 +929,10 @@ THREE.GLTFLoader = ( function () {
 
 	function _each( object, callback, thisObj ) {
 
-		if ( !object ) {
+		if ( ! object ) {
+
 			return Promise.resolve();
+
 		}
 
 		var results;
@@ -952,11 +954,11 @@ THREE.GLTFLoader = ( function () {
 
 					if ( value instanceof Promise ) {
 
-						value.then( function( key, value ) {
+						value.then( function ( key, value ) {
 
 							results[ key ] = value;
 
-						}.bind( this, idx ));
+						}.bind( this, idx ) );
 
 					} else {
 
@@ -984,11 +986,11 @@ THREE.GLTFLoader = ( function () {
 
 						if ( value instanceof Promise ) {
 
-							value.then( function( key, value ) {
+							value.then( function ( key, value ) {
 
 								results[ key ] = value;
 
-							}.bind( this, key ));
+							}.bind( this, key ) );
 
 						} else {
 
@@ -1004,11 +1006,11 @@ THREE.GLTFLoader = ( function () {
 
 		}
 
-		return Promise.all( fns ).then( function() {
+		return Promise.all( fns ).then( function () {
 
 			return results;
 
-		});
+		} );
 
 	}
 
@@ -1091,7 +1093,7 @@ THREE.GLTFLoader = ( function () {
 	 * @param {GLTF.Primitive} primitiveDef
 	 * @param {Object} dependencies
 	 */
-	function addMorphTargets ( mesh, meshDef, primitiveDef, dependencies ) {
+	function addMorphTargets( mesh, meshDef, primitiveDef, dependencies ) {
 
 		var geometry = mesh.geometry;
 		var material = mesh.material;
@@ -1310,7 +1312,7 @@ THREE.GLTFLoader = ( function () {
 		var cacheKey = type + ':' + index;
 		var dependency = this.cache.get( cacheKey );
 
-		if ( !dependency ) {
+		if ( ! dependency ) {
 
 			var fnName = 'load' + type.charAt( 0 ).toUpperCase() + type.slice( 1 );
 			dependency = this[ fnName ]( index );
@@ -1350,7 +1352,7 @@ THREE.GLTFLoader = ( function () {
 
 			var loader = new THREE.FileLoader();
 			loader.setResponseType( 'arraybuffer' );
-			loader.load( resolveURL( bufferDef.uri, options.path ), resolve);
+			loader.load( resolveURL( bufferDef.uri, options.path ), resolve );
 
 		} );
 
@@ -1630,6 +1632,7 @@ THREE.GLTFLoader = ( function () {
 					materialParams.normalScale.set( material.normalTexture.scale, material.normalTexture.scale );
 
 				}
+
 			}
 
 			if ( material.occlusionTexture !== undefined ) {
@@ -1690,7 +1693,7 @@ THREE.GLTFLoader = ( function () {
 
 				// Normal map textures use OpenGL conventions:
 				// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture
-				_material.normalScale.x = -_material.normalScale.x;
+				_material.normalScale.x = - _material.normalScale.x;
 
 				if ( material.extras ) _material.userData = material.extras;
 
@@ -1926,7 +1929,7 @@ THREE.GLTFLoader = ( function () {
 
 			var params = camera[ camera.type ];
 
-			if ( !params ) {
+			if ( ! params ) {
 
 				console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
 				return;
@@ -1942,7 +1945,7 @@ THREE.GLTFLoader = ( function () {
 
 			} else if ( camera.type === 'orthographic' ) {
 
-				_camera = new THREE.OrthographicCamera( params.xmag / -2, params.xmag / 2, params.ymag / 2, params.ymag / -2, params.znear, params.zfar );
+				_camera = new THREE.OrthographicCamera( params.xmag / - 2, params.xmag / 2, params.ymag / 2, params.ymag / - 2, params.znear, params.zfar );
 
 			}
 
@@ -2185,11 +2188,12 @@ THREE.GLTFLoader = ( function () {
 
 					var mesh = node.mesh;
 
-					if ( mesh !== undefined) {
+					if ( mesh !== undefined ) {
 
 						var group = dependencies.meshes[ mesh ];
 
 						if ( group !== undefined ) {
+
 							// do not clone children as they will be replaced anyway
 							var clonedgroup = group.clone( false );
 
@@ -2290,6 +2294,7 @@ THREE.GLTFLoader = ( function () {
 							}
 
 							_node.add( clonedgroup );
+
 						} else {
 
 							console.warn( 'THREE.GLTFLoader: Could not find node "' + mesh + '".' );

+ 61 - 46
examples/js/loaders/ImageBitmapLoader.js

@@ -2,46 +2,59 @@
  * @author thespite / http://clicktorelease.com/
  */
 
- function detectCreateImageBitmap() {
+function detectCreateImageBitmap() {
 
 	var url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
 
-	return new Promise(function (resolve, reject) {
+	return new Promise( function ( resolve, reject ) {
+
+		if ( ! ( 'createImageBitmap' in window ) ) {
 
-		if (!('createImageBitmap' in window)) {
 			reject();
 			return;
+
 		}
 
-		fetch(url).then(function (res) {
+		fetch( url ).then( function ( res ) {
+
 			return res.blob();
-		}).then(function (blob) {
-			Promise.all([
-				createImageBitmap(blob, { imageOrientation: "none", premultiplyAlpha: "none" }),
-				createImageBitmap(blob, { imageOrientation: "flipY", premultiplyAlpha: "none" }),
-				createImageBitmap(blob, { imageOrientation: "none", premultiplyAlpha: "premultiply" }),
-				createImageBitmap(blob, { imageOrientation: "flipY", premultiplyAlpha: "premultiply" })
-			]).then(function (res) {
+
+		} ).then( function ( blob ) {
+
+			Promise.all( [
+				createImageBitmap( blob, { imageOrientation: 'none', premultiplyAlpha: 'none' } ),
+				createImageBitmap( blob, { imageOrientation: 'flipY', premultiplyAlpha: 'none' } ),
+				createImageBitmap( blob, { imageOrientation: 'none', premultiplyAlpha: 'premultiply' } ),
+				createImageBitmap( blob, { imageOrientation: 'flipY', premultiplyAlpha: 'premultiply' } )
+			] ).then( function () {
+
 				resolve();
-			}).catch(function (e) {
+
+			} ).catch( function () {
+
 				reject();
-			});
-		});
-	});
+
+			} );
+
+		} );
+
+	} );
 
 }
 
 var canUseImageBitmap = detectCreateImageBitmap();
-canUseImageBitmap
-.then( function( res ) {
-	console.log( 'createImageBitmap supported' );
-})
-.catch( function( res ) {
-	console.log( 'createImageBitmap not supported' );
-});
+canUseImageBitmap.then( function () {
+
+	console.log( 'THREE.ImageBitmapLoader: createImageBitmap() supported.' );
+
+} ).catch( function () {
 
+	console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' );
 
-THREE.ImageBitmapLoader = function (manager) {
+} );
+
+
+THREE.ImageBitmapLoader = function ( manager ) {
 
 	this.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager;
 	this.options = {};
@@ -52,62 +65,64 @@ THREE.ImageBitmapLoader.prototype = {
 
 	constructor: THREE.ImageBitmapLoader,
 
-	setOptions: function setOptions(options) {
+	setOptions: function setOptions( options ) {
 
 		this.options = options;
 		return this;
 
 	},
 
-	load: function load(url, onLoad, onProgress, onError) {
+	load: function load( url, onLoad, onProgress, onError ) {
 
-		if (url === undefined) url = '';
+		if ( url === undefined ) url = '';
 
-		if (this.path !== undefined) url = this.path + url;
+		if ( this.path !== undefined ) url = this.path + url;
 
 		var scope = this;
 
-		var cached = THREE.Cache.get(url);
+		var cached = THREE.Cache.get( url );
 
-		if (cached !== undefined) {
+		if ( cached !== undefined ) {
 
-			scope.manager.itemStart(url);
+			scope.manager.itemStart( url );
 
-			setTimeout(function () {
+			setTimeout( function () {
 
-				if (onLoad) onLoad(cached);
+				if ( onLoad ) onLoad( cached );
 
-				scope.manager.itemEnd(url);
+				scope.manager.itemEnd( url );
 
-			}, 0);
+			}, 0 );
 
 			return cached;
+
 		}
 
-		fetch(url).then(function (res) {
+		fetch( url ).then( function ( res ) {
 
 			return res.blob();
 
-		}).then(function (res) {
+		} ).then( function ( res ) {
+
+			return createImageBitmap( res, scope.options );
 
-			return createImageBitmap(res, scope.options);
+		} ).then( function ( res ) {
 
-		}).then(function (res) {
+			THREE.Cache.add( url, res );
 
-			THREE.Cache.add(url, res);
+			if ( onLoad ) onLoad( res );
 
-			if (onLoad) onLoad(res);
+			scope.manager.itemEnd( url );
 
-			scope.manager.itemEnd(url);
+		} ).catch( function ( e ) {
 
-		}).catch(function (e) {
+			if ( onError ) onError( e );
 
-			if (onError) onError(e);
+			scope.manager.itemEnd( url );
+			scope.manager.itemError( url );
 
-			scope.manager.itemEnd(url);
-			scope.manager.itemError(url);
+		} );
 
-		});
 	}
 
 };

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

@@ -28,7 +28,7 @@ THREE.KMZLoader.prototype = {
 
 	parse: function ( data ) {
 
-		var zip = new JSZip( data );
+		var zip = new JSZip( data ); // eslint-disable-line no-undef
 
 		// console.log( zip );
 

+ 104 - 104
examples/js/loaders/MMDLoader.js

@@ -137,7 +137,7 @@ THREE.MMDLoader.prototype.loadVmds = function ( urls, callback, onProgress, onEr
 	var vmds = [];
 	urls = urls.slice();
 
-	function run () {
+	function run() {
 
 		var url = urls.shift();
 
@@ -195,7 +195,7 @@ THREE.MMDLoader.prototype.loadVpd = function ( url, callback, onProgress, onErro
 THREE.MMDLoader.prototype.parseModel = function ( buffer, modelExtension ) {
 
 	// Should I judge from model data header?
-	switch( modelExtension.toLowerCase() ) {
+	switch ( modelExtension.toLowerCase() ) {
 
 		case 'pmd':
 			return this.parsePmd( buffer );
@@ -310,7 +310,7 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) {
 				interpolations = interpolations.slice();
 
 				var stride = values.length / times.length;
-				var interpolateStride = ( stride === 3 ) ? 12 : 4;  // 3: Vector3, others: Quaternion or Number
+				var interpolateStride = ( stride === 3 ) ? 12 : 4; // 3: Vector3, others: Quaternion or Number
 
 				var index = 1;
 
@@ -358,7 +358,7 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) {
 
 		};
 
-		for ( var i = 0; i < orderedMotions.length; i++ ) {
+		for ( var i = 0; i < orderedMotions.length; i ++ ) {
 
 			var m = orderedMotions[ i ];
 
@@ -369,10 +369,10 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) {
 			var fov = m.fov;
 			var interpolation = m.interpolation;
 
-			position.set( 0, 0, -distance );
+			position.set( 0, 0, - distance );
 			center.set( pos[ 0 ], pos[ 1 ], pos[ 2 ] );
 
-			euler.set( -rot[ 0 ], -rot[ 1 ], -rot[ 2 ] );
+			euler.set( - rot[ 0 ], - rot[ 1 ], - rot[ 2 ] );
 			quaternion.setFromEuler( euler );
 
 			position.add( center );
@@ -424,7 +424,7 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) {
 		tracks.push( createTrack( '.position', 'VectorKeyframeTrackEx', times, positions, pInterpolations ) );
 		tracks.push( createTrack( '.fov', 'NumberKeyframeTrackEx', times, fovs, fInterpolations ) );
 
-		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, -1, tracks );
+		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, - 1, tracks );
 
 		if ( camera.center === undefined ) camera.center = new THREE.Vector3( 0, 0, 0 );
 		if ( camera.animations === undefined ) camera.animations = [];
@@ -491,7 +491,6 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 	var scope = this;
 	var geometry = new THREE.BufferGeometry();
 	var materials = [];
-	var helper = new THREE.MMDLoader.DataCreationHelper();
 
 	var buffer = {};
 
@@ -504,7 +503,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 	var initVartices = function () {
 
-		for ( var i = 0; i < model.metadata.vertexCount; i++ ) {
+		for ( var i = 0; i < model.metadata.vertexCount; i ++ ) {
 
 			var v = model.vertices[ i ];
 
@@ -544,7 +543,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 	var initFaces = function () {
 
-		for ( var i = 0; i < model.metadata.faceCount; i++ ) {
+		for ( var i = 0; i < model.metadata.faceCount; i ++ ) {
 
 			var f = model.faces[ i ];
 
@@ -577,7 +576,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		}
 
-		for ( var i = 0; i < model.metadata.boneCount; i++ ) {
+		for ( var i = 0; i < model.metadata.boneCount; i ++ ) {
 
 			var bone = {};
 			var b = model.bones[ i ];
@@ -588,7 +587,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 			bone.rotq = [ 0, 0, 0, 1 ];
 			bone.scl = [ 1, 1, 1 ];
 
-			if ( bone.parent !== -1 ) {
+			if ( bone.parent !== - 1 ) {
 
 				bone.pos[ 0 ] -= model.bones[ bone.parent ].position[ 0 ];
 				bone.pos[ 1 ] -= model.bones[ bone.parent ].position[ 1 ];
@@ -596,7 +595,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 			}
 
-			bone.rigidBodyType = dictionary[ i ] !== undefined ? dictionary[ i ] : -1;
+			bone.rigidBodyType = dictionary[ i ] !== undefined ? dictionary[ i ] : - 1;
 
 			bones.push( bone );
 
@@ -613,9 +612,9 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 		// TODO: remove duplicated codes between PMD and PMX
 		if ( model.metadata.format === 'pmd' ) {
 
-			for ( var i = 0; i < model.metadata.ikCount; i++ ) {
+			for ( var i = 0; i < model.metadata.ikCount; i ++ ) {
 
-				var ik = model.iks[i];
+				var ik = model.iks[ i ];
 				var param = {};
 
 				param.target = ik.target;
@@ -624,7 +623,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 				param.maxAngle = ik.maxAngle * 4;
 				param.links = [];
 
-				for ( var j = 0; j < ik.links.length; j++ ) {
+				for ( var j = 0; j < ik.links.length; j ++ ) {
 
 					var link = {};
 					link.index = ik.links[ j ].index;
@@ -645,7 +644,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		} else {
 
-			for ( var i = 0; i < model.metadata.boneCount; i++ ) {
+			for ( var i = 0; i < model.metadata.boneCount; i ++ ) {
 
 				var b = model.bones[ i ];
 				var ik = b.ik;
@@ -664,7 +663,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 				param.maxAngle = ik.maxAngle;
 				param.links = [];
 
-				for ( var j = 0; j < ik.links.length; j++ ) {
+				for ( var j = 0; j < ik.links.length; j ++ ) {
 
 					var link = {};
 					link.index = ik.links[ j ].index;
@@ -703,7 +702,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		var grants = [];
 
-		for ( var i = 0; i < model.metadata.boneCount; i++ ) {
+		for ( var i = 0; i < model.metadata.boneCount; i ++ ) {
 
 			var b = model.bones[ i ];
 			var grant = b.grant;
@@ -750,7 +749,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		function updateVertices( attribute, m, ratio ) {
 
-			for ( var i = 0; i < m.elementCount; i++ ) {
+			for ( var i = 0; i < m.elementCount; i ++ ) {
 
 				var v = m.elements[ i ];
 
@@ -775,7 +774,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 		var morphTargets = [];
 		var attributes = [];
 
-		for ( var i = 0; i < model.metadata.morphCount; i++ ) {
+		for ( var i = 0; i < model.metadata.morphCount; i ++ ) {
 
 			var m = model.morphs[ i ];
 			var params = { name: m.name };
@@ -783,7 +782,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 			var attribute = new THREE.Float32BufferAttribute( model.metadata.vertexCount * 3, 3 );
 			attribute.name = m.name;
 
-			for ( var j = 0; j < model.metadata.vertexCount * 3; j++ ) {
+			for ( var j = 0; j < model.metadata.vertexCount * 3; j ++ ) {
 
 				attribute.array[ j ] = buffer.vertices[ j ];
 
@@ -799,9 +798,9 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 			} else {
 
-				if ( m.type === 0 ) {    // group
+				if ( m.type === 0 ) { // group
 
-					for ( var j = 0; j < m.elementCount; j++ ) {
+					for ( var j = 0; j < m.elementCount; j ++ ) {
 
 						var m2 = model.morphs[ m.elements[ j ].index ];
 						var ratio = m.elements[ j ].ratio;
@@ -818,35 +817,35 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 					}
 
-				} else if ( m.type === 1 ) {    // vertex
+				} else if ( m.type === 1 ) { // vertex
 
 					updateVertices( attribute, m, 1.0 );
 
-				} else if ( m.type === 2 ) {    // bone
+				} else if ( m.type === 2 ) { // bone
 
 					// TODO: implement
 
-				} else if ( m.type === 3 ) {    // uv
+				} else if ( m.type === 3 ) { // uv
 
 					// TODO: implement
 
-				} else if ( m.type === 4 ) {    // additional uv1
+				} else if ( m.type === 4 ) { // additional uv1
 
 					// TODO: implement
 
-				} else if ( m.type === 5 ) {    // additional uv2
+				} else if ( m.type === 5 ) { // additional uv2
 
 					// TODO: implement
 
-				} else if ( m.type === 6 ) {    // additional uv3
+				} else if ( m.type === 6 ) { // additional uv3
 
 					// TODO: implement
 
-				} else if ( m.type === 7 ) {    // additional uv4
+				} else if ( m.type === 7 ) { // additional uv4
 
 					// TODO: implement
 
-				} else if ( m.type === 8 ) {    // material
+				} else if ( m.type === 8 ) { // material
 
 					// TODO: implement
 
@@ -876,7 +875,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		if ( scope.textureCrossOrigin !== null ) textureLoader.setCrossOrigin( scope.textureCrossOrigin );
 
-		function loadTexture ( filePath, params ) {
+		function loadTexture( filePath, params ) {
 
 			if ( params === undefined ) {
 
@@ -931,8 +930,8 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 					context.clearRect( 0, 0, width, height );
 					context.translate( width / 2.0, height / 2.0 );
-					context.rotate( 0.5 * Math.PI );  // 90.0 * Math.PI / 180.0
-					context.translate( -width / 2.0, -height / 2.0 );
+					context.rotate( 0.5 * Math.PI ); // 90.0 * Math.PI / 180.0
+					context.translate( - width / 2.0, - height / 2.0 );
 					context.drawImage( image, 0, 0 );
 
 					t.image = context.getImageData( 0, 0, width, height );
@@ -943,7 +942,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 				t.wrapS = THREE.RepeatWrapping;
 				t.wrapT = THREE.RepeatWrapping;
 
-				for ( var i = 0; i < texture.readyCallbacks.length; i++ ) {
+				for ( var i = 0; i < texture.readyCallbacks.length; i ++ ) {
 
 					texture.readyCallbacks[ i ]( texture );
 
@@ -979,7 +978,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		}
 
-		for ( var i = 0; i < model.metadata.materialCount; i++ ) {
+		for ( var i = 0; i < model.metadata.materialCount; i ++ ) {
 
 			var m = model.materials[ i ];
 			var params = {};
@@ -1040,7 +1039,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 					}
 
-					for ( var j = 0; j < fileNames.length; j++ ) {
+					for ( var j = 0; j < fileNames.length; j ++ ) {
 
 						var n = fileNames[ j ];
 
@@ -1070,7 +1069,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 			} else {
 
-				if ( m.textureIndex !== -1 ) {
+				if ( m.textureIndex !== - 1 ) {
 
 					var n = model.textures[ m.textureIndex ];
 					params.map = loadTexture( n );
@@ -1078,7 +1077,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 				}
 
 				// TODO: support m.envFlag === 3
-				if ( m.envTextureIndex !== -1 && ( m.envFlag === 1 || m.envFlag == 2 ) ) {
+				if ( m.envTextureIndex !== - 1 && ( m.envFlag === 1 || m.envFlag == 2 ) ) {
 
 					var n = model.textures[ m.envTextureIndex ];
 					params.envMap = loadTexture( n, { sphericalReflectionMapping: true } );
@@ -1104,7 +1103,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		}
 
-		for ( var i = 0; i < materialParams.length; i++ ) {
+		for ( var i = 0; i < materialParams.length; i ++ ) {
 
 			var p = materialParams[ i ];
 			var p2 = model.materials[ i ];
@@ -1133,12 +1132,12 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 				m.faceNum = p.faceNum;
 
 				// Check if this part of the texture image the material uses requires transparency
-				function checkTextureTransparency ( m ) {
+				function checkTextureTransparency( m ) {
 
 					m.map.readyCallbacks.push( function ( t ) {
 
 						// Is there any efficient ways?
-						function createImageData ( image ) {
+						function createImageData( image ) {
 
 							var c = document.createElement( 'canvas' );
 							c.width = image.width;
@@ -1168,7 +1167,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 								var centerUV = { x: 0.0, y: 0.0 };
 
-								for ( var j = 0; j < 3; j++ ) {
+								for ( var j = 0; j < 3; j ++ ) {
 
 									var index = indices[ i * 3 + j ];
 									var uv = { x: uvs[ index * 2 + 0 ], y: uvs[ index * 2 + 1 ] };
@@ -1206,7 +1205,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 						 *   t.wrapT = THREE.RepeatWrapping
 						 * TODO: more precise
 						 */
-						function getAlphaByUv ( image, uv ) {
+						function getAlphaByUv( image, uv ) {
 
 							var width = image.width;
 							var height = image.height;
@@ -1270,7 +1269,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 			if ( model.metadata.format === 'pmd' ) {
 
-				function isDefaultToonTexture ( n ) {
+				function isDefaultToonTexture( n ) {
 
 					if ( n.length !== 10 ) {
 
@@ -1291,7 +1290,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 				if ( m.outlineParameters.thickness === 0.0 ) m.outlineParameters.visible = false;
 
-				var toonFileName = ( p2.toonIndex === -1 ) ? 'toon00.bmp' : model.toonTextures[ p2.toonIndex ].fileName;
+				var toonFileName = ( p2.toonIndex === - 1 ) ? 'toon00.bmp' : model.toonTextures[ p2.toonIndex ].fileName;
 				var uuid = loadTexture( toonFileName, { isToonTexture: true, defaultTexturePath: isDefaultToonTexture( toonFileName ) } );
 				m.gradientMap = getTexture( uuid, textures );
 
@@ -1308,7 +1307,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 				var toonFileName, isDefaultToon;
 
-				if ( p2.toonIndex === -1 || p2.toonFlag !== 0 ) {
+				if ( p2.toonIndex === - 1 || p2.toonFlag !== 0 ) {
 
 					var num = p2.toonIndex + 1;
 					toonFileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp';
@@ -1332,7 +1331,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		if ( model.metadata.format === 'pmx' ) {
 
-			function checkAlphaMorph ( morph, elements ) {
+			function checkAlphaMorph( morph, elements ) {
 
 				if ( morph.type !== 8 ) {
 
@@ -1340,11 +1339,11 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 				}
 
-				for ( var i = 0; i < elements.length; i++ ) {
+				for ( var i = 0; i < elements.length; i ++ ) {
 
 					var e = elements[ i ];
 
-					if ( e.index === -1 ) {
+					if ( e.index === - 1 ) {
 
 						continue;
 
@@ -1362,14 +1361,14 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 			}
 
-			for ( var i = 0; i < model.morphs.length; i++ ) {
+			for ( var i = 0; i < model.morphs.length; i ++ ) {
 
 				var morph = model.morphs[ i ];
 				var elements = morph.elements;
 
 				if ( morph.type === 0 ) {
 
-					for ( var j = 0; j < elements.length; j++ ) {
+					for ( var j = 0; j < elements.length; j ++ ) {
 
 						var morph2 = model.morphs[ elements[ j ].index ];
 						var elements2 = morph2.elements;
@@ -1395,14 +1394,14 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 		var rigidBodies = [];
 		var constraints = [];
 
-		for ( var i = 0; i < model.metadata.rigidBodyCount; i++ ) {
+		for ( var i = 0; i < model.metadata.rigidBodyCount; i ++ ) {
 
 			var b = model.rigidBodies[ i ];
 			var keys = Object.keys( b );
 
 			var p = {};
 
-			for ( var j = 0; j < keys.length; j++ ) {
+			for ( var j = 0; j < keys.length; j ++ ) {
 
 				var key = keys[ j ];
 				p[ key ] = b[ key ];
@@ -1416,7 +1415,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 			 */
 			if ( model.metadata.format === 'pmx' ) {
 
-				if ( p.boneIndex !== -1 ) {
+				if ( p.boneIndex !== - 1 ) {
 
 					var bone = model.bones[ p.boneIndex ];
 					p.position[ 0 ] -= bone.position[ 0 ];
@@ -1431,14 +1430,14 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 		}
 
-		for ( var i = 0; i < model.metadata.constraintCount; i++ ) {
+		for ( var i = 0; i < model.metadata.constraintCount; i ++ ) {
 
 			var c = model.constraints[ i ];
 			var keys = Object.keys( c );
 
 			var p = {};
 
-			for ( var j = 0; j < keys.length; j++ ) {
+			for ( var j = 0; j < keys.length; j ++ ) {
 
 				var key = keys[ j ];
 				p[ key ] = c[ key ];
@@ -1453,7 +1452,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 			 */
 			if ( bodyA.type !== 0 && bodyB.type === 2 ) {
 
-				if ( bodyA.boneIndex !== -1 && bodyB.boneIndex !== -1 &&
+				if ( bodyA.boneIndex !== - 1 && bodyB.boneIndex !== - 1 &&
 				     model.bones[ bodyB.boneIndex ].parentIndex === bodyA.boneIndex ) {
 
 					bodyB.type = 1;
@@ -1522,14 +1521,14 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
 
 		var pushInterpolation = function ( array, interpolation, index ) {
 
-			array.push( interpolation[ index + 0 ] / 127 );  // x1
-			array.push( interpolation[ index + 8 ] / 127 );  // x2
-			array.push( interpolation[ index + 4 ] / 127 );  // y1
+			array.push( interpolation[ index + 0 ] / 127 ); // x1
+			array.push( interpolation[ index + 8 ] / 127 ); // x2
+			array.push( interpolation[ index + 4 ] / 127 ); // y1
 			array.push( interpolation[ index + 12 ] / 127 ); // y2
 
 		};
 
-		for ( var i = 0; i < orderedMotions.length; i++ ) {
+		for ( var i = 0; i < orderedMotions.length; i ++ ) {
 
 			var times = [];
 			var positions = [];
@@ -1540,7 +1539,7 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
 			var bone = bones[ i ];
 			var array = orderedMotions[ i ];
 
-			for ( var j = 0; j < array.length; j++ ) {
+			for ( var j = 0; j < array.length; j ++ ) {
 
 				var time = array[ j ].frameNum / 30;
 				var pos = array[ j ].position;
@@ -1580,7 +1579,7 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
 
 		}
 
-		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, -1, tracks );
+		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, - 1, tracks );
 
 		if ( mesh.geometry.animations === undefined ) mesh.geometry.animations = [];
 		mesh.geometry.animations.push( clip );
@@ -1599,13 +1598,13 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
 
 		var tracks = [];
 
-		for ( var i = 0; i < orderedMorphs.length; i++ ) {
+		for ( var i = 0; i < orderedMorphs.length; i ++ ) {
 
 			var times = [];
 			var values = [];
 			var array = orderedMorphs[ i ];
 
-			for ( var j = 0; j < array.length; j++ ) {
+			for ( var j = 0; j < array.length; j ++ ) {
 
 				times.push( array[ j ].frameNum / 30 );
 				values.push( array[ j ].weight );
@@ -1618,7 +1617,7 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
 
 		}
 
-		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name + 'Morph', -1, tracks );
+		var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name + 'Morph', - 1, tracks );
 
 		if ( mesh.geometry.animations === undefined ) mesh.geometry.animations = [];
 		mesh.geometry.animations.push( clip );
@@ -1648,9 +1647,9 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 		var str = '';
 
-		for ( var i = 0; i < s.length; i++ ) {
+		for ( var i = 0; i < s.length; i ++ ) {
 
-			str += '0x' + ( '0000' + s[ i ].charCodeAt().toString( 16 ) ).substr( -4 );
+			str += '0x' + ( '0000' + s[ i ].charCodeAt().toString( 16 ) ).substr( - 4 );
 
 		}
 
@@ -1662,7 +1661,7 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 		var dict = {};
 
-		for ( var i = 0; i < array.length; i++ ) {
+		for ( var i = 0; i < array.length; i ++ ) {
 
 			dict[ array[ i ].name ] = i;
 
@@ -1676,7 +1675,7 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 		var result = [];
 
-		for ( var i = 0; i < array.length; i++ ) {
+		for ( var i = 0; i < array.length; i ++ ) {
 
 			result[ i ] = [];
 
@@ -1692,13 +1691,13 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 			return a.frameNum - b.frameNum;
 
-		} ) ;
+		} );
 
 	},
 
 	sortMotionArrays: function ( arrays ) {
 
-		for ( var i = 0; i < arrays.length; i++ ) {
+		for ( var i = 0; i < arrays.length; i ++ ) {
 
 			this.sortMotionArray( arrays[ i ] );
 
@@ -1710,7 +1709,7 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 		var result = [];
 
-		for ( var i = 0; i < array.length; i++ ) {
+		for ( var i = 0; i < array.length; i ++ ) {
 
 			result.push( array[ i ] );
 
@@ -1722,7 +1721,7 @@ THREE.MMDLoader.DataCreationHelper.prototype = {
 
 	createMotionArrays: function ( array, result, dict, key ) {
 
-		for ( var i = 0; i < array.length; i++ ) {
+		for ( var i = 0; i < array.length; i ++ ) {
 
 			var a = array[ i ];
 			var num = dict[ a[ key ] ];
@@ -1777,13 +1776,13 @@ THREE.MMDLoader.VectorKeyframeTrackEx.prototype = Object.create( THREE.VectorKey
 THREE.MMDLoader.VectorKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.VectorKeyframeTrackEx;
 THREE.MMDLoader.VectorKeyframeTrackEx.prototype.TimeBufferType = Float64Array;
 
-THREE.MMDLoader.VectorKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function( result ) {
+THREE.MMDLoader.VectorKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) {
 
 	return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters );
 
 };
 
-THREE.MMDLoader.VectorKeyframeTrackEx.prototype.setInterpolation = function( interpolation ) {
+THREE.MMDLoader.VectorKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) {
 
 	this.createInterpolant = this.InterpolantFactoryMethodCubicBezier;
 
@@ -1801,13 +1800,13 @@ THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype = Object.create( THREE.Quate
 THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.QuaternionKeyframeTrackEx;
 THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.TimeBufferType = Float64Array;
 
-THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function( result ) {
+THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) {
 
 	return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters );
 
 };
 
-THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.setInterpolation = function( interpolation ) {
+THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) {
 
 	this.createInterpolant = this.InterpolantFactoryMethodCubicBezier;
 
@@ -1825,13 +1824,13 @@ THREE.MMDLoader.NumberKeyframeTrackEx.prototype = Object.create( THREE.NumberKey
 THREE.MMDLoader.NumberKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.NumberKeyframeTrackEx;
 THREE.MMDLoader.NumberKeyframeTrackEx.prototype.TimeBufferType = Float64Array;
 
-THREE.MMDLoader.NumberKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function( result ) {
+THREE.MMDLoader.NumberKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) {
 
 	return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters );
 
 };
 
-THREE.MMDLoader.NumberKeyframeTrackEx.prototype.setInterpolation = function( interpolation ) {
+THREE.MMDLoader.NumberKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) {
 
 	this.createInterpolant = this.InterpolantFactoryMethodCubicBezier;
 
@@ -1843,12 +1842,12 @@ THREE.MMDLoader.CubicBezierInterpolation = function ( parameterPositions, sample
 
 	this.params = params;
 
-}
+};
 
 THREE.MMDLoader.CubicBezierInterpolation.prototype = Object.create( THREE.LinearInterpolant.prototype );
 THREE.MMDLoader.CubicBezierInterpolation.prototype.constructor = THREE.MMDLoader.CubicBezierInterpolation;
 
-THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function( i1, t0, t, t1 ) {
+THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function ( i1, t0, t, t1 ) {
 
 	var result = this.resultBuffer;
 	var values = this.sampleValues;
@@ -1859,7 +1858,7 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function( i1,
 
 	var weight1 = ( t - t0 ) / ( t1 - t0 );
 
-	if ( stride === 4 ) {  // Quaternion
+	if ( stride === 4 ) { // Quaternion
 
 		var x1 = this.params[ i1 * 4 + 0 ];
 		var x2 = this.params[ i1 * 4 + 1 ];
@@ -1870,7 +1869,7 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function( i1,
 
 		THREE.Quaternion.slerpFlat( result, 0, values, offset0, values, offset1, ratio );
 
-	} else if ( stride === 3 ) {  // Vector3
+	} else if ( stride === 3 ) { // Vector3
 
 		for ( var i = 0; i !== stride; ++ i ) {
 
@@ -1885,7 +1884,7 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function( i1,
 
 		}
 
-	} else {  // Number
+	} else { // Number
 
 		var x1 = this.params[ i1 * 4 + 0 ];
 		var x2 = this.params[ i1 * 4 + 1 ];
@@ -1902,7 +1901,7 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function( i1,
 
 };
 
-THREE.MMDLoader.CubicBezierInterpolation.prototype._calculate = function( x1, x2, y1, y2, x ) {
+THREE.MMDLoader.CubicBezierInterpolation.prototype._calculate = function ( x1, x2, y1, y2, x ) {
 
 	/*
 	 * Cubic Bezier curves
@@ -1962,7 +1961,7 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype._calculate = function( x1, x2
 
 		c /= 2.0;
 
-		t += ( ft < 0 ) ? c : -c;
+		t += ( ft < 0 ) ? c : - c;
 		s = 1.0 - t;
 
 	}
@@ -2173,7 +2172,7 @@ THREE.MMDHelper.prototype = {
 
 	setPhysicses: function ( params ) {
 
-		for ( var i = 0; i < this.meshes.length; i++ ) {
+		for ( var i = 0; i < this.meshes.length; i ++ ) {
 
 			this.setPhysics( this.meshes[ i ], params );
 
@@ -2226,6 +2225,7 @@ THREE.MMDHelper.prototype = {
 				return this.masterPhysics;
 
 			}
+
 		}
 
 		return null;
@@ -2286,7 +2286,7 @@ THREE.MMDHelper.prototype = {
 
 	setAnimations: function () {
 
-		for ( var i = 0; i < this.meshes.length; i++ ) {
+		for ( var i = 0; i < this.meshes.length; i ++ ) {
 
 			this.setAnimation( this.meshes[ i ] );
 
@@ -2315,7 +2315,7 @@ THREE.MMDHelper.prototype = {
 			var foundAnimation = false;
 			var foundMorphAnimation = false;
 
-			for ( var i = 0; i < mesh.geometry.animations.length; i++ ) {
+			for ( var i = 0; i < mesh.geometry.animations.length; i ++ ) {
 
 				var clip = mesh.geometry.animations[ i ];
 
@@ -2386,7 +2386,7 @@ THREE.MMDHelper.prototype = {
 		var audioManager = this.audioManager;
 
 		// check the longest duration
-		for ( var i = 0; i < this.meshes.length; i++ ) {
+		for ( var i = 0; i < this.meshes.length; i ++ ) {
 
 			var mesh = this.meshes[ i ];
 			var mixer = mesh.mixer;
@@ -2397,7 +2397,7 @@ THREE.MMDHelper.prototype = {
 
 			}
 
-			for ( var j = 0; j < mixer._actions.length; j++ ) {
+			for ( var j = 0; j < mixer._actions.length; j ++ ) {
 
 				var action = mixer._actions[ j ];
 				max = Math.max( max, action._clip.duration );
@@ -2410,7 +2410,7 @@ THREE.MMDHelper.prototype = {
 
 			var mixer = camera.mixer;
 
-			for ( var i = 0; i < mixer._actions.length; i++ ) {
+			for ( var i = 0; i < mixer._actions.length; i ++ ) {
 
 				var action = mixer._actions[ i ];
 				max = Math.max( max, action._clip.duration );
@@ -2432,7 +2432,7 @@ THREE.MMDHelper.prototype = {
 		}
 
 		// set the duration
-		for ( var i = 0; i < this.meshes.length; i++ ) {
+		for ( var i = 0; i < this.meshes.length; i ++ ) {
 
 			var mesh = this.meshes[ i ];
 			var mixer = mesh.mixer;
@@ -2443,7 +2443,7 @@ THREE.MMDHelper.prototype = {
 
 			}
 
-			for ( var j = 0; j < mixer._actions.length; j++ ) {
+			for ( var j = 0; j < mixer._actions.length; j ++ ) {
 
 				var action = mixer._actions[ j ];
 				action._clip.duration = max;
@@ -2456,7 +2456,7 @@ THREE.MMDHelper.prototype = {
 
 			var mixer = camera.mixer;
 
-			for ( var i = 0; i < mixer._actions.length; i++ ) {
+			for ( var i = 0; i < mixer._actions.length; i ++ ) {
 
 				var action = mixer._actions[ i ];
 				action._clip.duration = max;
@@ -2489,7 +2489,7 @@ THREE.MMDHelper.prototype = {
 
 		this.controlAudio( delta );
 
-		for ( var i = 0; i < this.meshes.length; i++ ) {
+		for ( var i = 0; i < this.meshes.length; i ++ ) {
 
 			this.animateOneMesh( delta, this.meshes[ i ] );
 
@@ -2620,7 +2620,7 @@ THREE.MMDHelper.prototype = {
 
 		var table = {};
 
-		for ( var i = 0; i < bones.length; i++ ) {
+		for ( var i = 0; i < bones.length; i ++ ) {
 
 			table[ bones[ i ].name ] = i;
 
@@ -2629,7 +2629,7 @@ THREE.MMDHelper.prototype = {
 		var thV = new THREE.Vector3();
 		var thQ = new THREE.Quaternion();
 
-		for ( var i = 0; i < bones2.length; i++ ) {
+		for ( var i = 0; i < bones2.length; i ++ ) {
 
 			var b = bones2[ i ];
 			var index = table[ b.name ];
@@ -2680,7 +2680,7 @@ THREE.MMDHelper.prototype = {
 
 		mesh.skeleton.backupBones = [];
 
-		for ( var i = 0; i < mesh.skeleton.bones.length; i++ ) {
+		for ( var i = 0; i < mesh.skeleton.bones.length; i ++ ) {
 
 			mesh.skeleton.backupBones.push( mesh.skeleton.bones[ i ].clone() );
 
@@ -2692,7 +2692,7 @@ THREE.MMDHelper.prototype = {
 
 		mesh.skeleton.backupBoneIsSaved = true;
 
-		for ( var i = 0; i < mesh.skeleton.bones.length; i++ ) {
+		for ( var i = 0; i < mesh.skeleton.bones.length; i ++ ) {
 
 			var b = mesh.skeleton.backupBones[ i ];
 			var b2 = mesh.skeleton.bones[ i ];
@@ -2713,7 +2713,7 @@ THREE.MMDHelper.prototype = {
 
 		mesh.skeleton.backupBoneIsSaved = false;
 
-		for ( var i = 0; i < mesh.skeleton.bones.length; i++ ) {
+		for ( var i = 0; i < mesh.skeleton.bones.length; i ++ ) {
 
 			var b = mesh.skeleton.bones[ i ];
 			var b2 = mesh.skeleton.backupBones[ i ];

+ 2 - 2
examples/js/loaders/MTLLoader.js

@@ -448,7 +448,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 					break;
 
 				case 'd':
-					n = parseFloat(value);
+					n = parseFloat( value );
 
 					if ( n < 1 ) {
 
@@ -460,7 +460,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 					break;
 
 				case 'tr':
-					n = parseFloat(value);
+					n = parseFloat( value );
 
 					if ( n > 0 ) {
 

+ 15 - 13
examples/js/loaders/NRRDLoader.js

@@ -91,7 +91,7 @@ THREE.NRRDLoader.prototype = {
 
 			// increase the data pointer in-place
 			var _bytes = new _array_type( _data.slice( _dataPointer,
-			_dataPointer += chunks * _chunkSize ) );
+				_dataPointer += chunks * _chunkSize ) );
 
 			// if required, flip the endianness of the bytes
 			if ( _nativeLittleEndian != _littleEndian ) {
@@ -285,7 +285,7 @@ THREE.NRRDLoader.prototype = {
 
 			// we need to decompress the datastream
 			// here we start the unzipping and get a typed Uint8Array back
-			var inflate = new Zlib.Gunzip( new Uint8Array( _data ) );
+			var inflate = new Zlib.Gunzip( new Uint8Array( _data ) ); // eslint-disable-line no-undef
 			_data = inflate.decompress();
 
 		} else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) {
@@ -330,11 +330,11 @@ THREE.NRRDLoader.prototype = {
 		volume.zLength = volume.dimensions[ 2 ];
 		// spacing
 		var spacingX = ( new THREE.Vector3( headerObject.vectors[ 0 ][ 0 ], headerObject.vectors[ 0 ][ 1 ],
-		headerObject.vectors[ 0 ][ 2 ] ) ).length();
+			headerObject.vectors[ 0 ][ 2 ] ) ).length();
 		var spacingY = ( new THREE.Vector3( headerObject.vectors[ 1 ][ 0 ], headerObject.vectors[ 1 ][ 1 ],
-		headerObject.vectors[ 1 ][ 2 ] ) ).length();
+			headerObject.vectors[ 1 ][ 2 ] ) ).length();
 		var spacingZ = ( new THREE.Vector3( headerObject.vectors[ 2 ][ 0 ], headerObject.vectors[ 2 ][ 1 ],
-		headerObject.vectors[ 2 ][ 2 ] ) ).length();
+			headerObject.vectors[ 2 ][ 2 ] ) ).length();
 		volume.spacing = [ spacingX, spacingY, spacingZ ];
 
 
@@ -359,19 +359,21 @@ THREE.NRRDLoader.prototype = {
 
 		if ( ! headerObject.vectors ) {
 
-			volume.matrix.set( _spaceX, 0, 0, 0,
-			0, _spaceY, 0, 0,
-			0, 0, _spaceZ, 0,
-			0, 0, 0, 1 );
+			volume.matrix.set(
+				_spaceX, 0, 0, 0,
+				0, _spaceY, 0, 0,
+				0, 0, _spaceZ, 0,
+				0, 0, 0, 1 );
 
 		} else {
 
 			var v = headerObject.vectors;
 
-			volume.matrix.set( _spaceX * v[ 0 ][ 0 ], _spaceX * v[ 1 ][ 0 ], _spaceX * v[ 2 ][ 0 ], 0,
-			_spaceY * v[ 0 ][ 1 ], _spaceY * v[ 1 ][ 1 ], _spaceY * v[ 2 ][ 1 ], 0,
-			_spaceZ * v[ 0 ][ 2 ], _spaceZ * v[ 1 ][ 2 ], _spaceZ * v[ 2 ][ 2 ], 0,
-			0, 0, 0, 1 );
+			volume.matrix.set(
+				_spaceX * v[ 0 ][ 0 ], _spaceX * v[ 1 ][ 0 ], _spaceX * v[ 2 ][ 0 ], 0,
+				_spaceY * v[ 0 ][ 1 ], _spaceY * v[ 1 ][ 1 ], _spaceY * v[ 2 ][ 1 ], 0,
+				_spaceZ * v[ 0 ][ 2 ], _spaceZ * v[ 1 ][ 2 ], _spaceZ * v[ 2 ][ 2 ], 0,
+				0, 0, 0, 1 );
 
 		}
 

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
examples/js/loaders/PDBLoader.js


+ 17 - 17
examples/js/loaders/PLYLoader.js

@@ -92,7 +92,7 @@ THREE.PLYLoader.prototype = {
 
 			if ( result !== null ) {
 
-				headerText = result [ 1 ];
+				headerText = result[ 1 ];
 				headerLength = result[ 0 ].length;
 
 			}
@@ -203,14 +203,14 @@ THREE.PLYLoader.prototype = {
 
 			switch ( type ) {
 
-			case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':
-			case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':
+				case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':
+				case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':
 
-				return parseInt( n );
+					return parseInt( n );
 
-			case 'float': case 'double': case 'float32': case 'float64':
+				case 'float': case 'double': case 'float32': case 'float64':
 
-				return parseFloat( n );
+					return parseFloat( n );
 
 			}
 
@@ -254,11 +254,11 @@ THREE.PLYLoader.prototype = {
 			// PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
 
 			var buffer = {
-				indices : [],
-				vertices : [],
-				normals : [],
-				uvs : [],
-				colors : []
+				indices: [],
+				vertices: [],
+				normals: [],
+				uvs: [],
+				colors: []
 			};
 
 			var result;
@@ -267,7 +267,7 @@ THREE.PLYLoader.prototype = {
 			var body = '';
 			if ( ( result = patternBody.exec( data ) ) !== null ) {
 
-				body = result [ 1 ];
+				body = result[ 1 ];
 
 			}
 
@@ -447,11 +447,11 @@ THREE.PLYLoader.prototype = {
 		function parseBinary( data, header ) {
 
 			var buffer = {
-				indices : [],
-				vertices : [],
-				normals : [],
-				uvs : [],
-				colors : []
+				indices: [],
+				vertices: [],
+				normals: [],
+				uvs: [],
+				colors: []
 			};
 
 			var little_endian = ( header.format === 'binary_little_endian' );

+ 1 - 3
examples/js/loaders/PRWMLoader.js

@@ -5,7 +5,7 @@
 
 ( function ( THREE ) {
 
-	"use strict";
+	'use strict';
 
 	var bigEndianPlatform = null;
 
@@ -146,7 +146,6 @@
 			attributeName,
 			char,
 			attributeType,
-			attributeNormalized,
 			cardinality,
 			encodingType,
 			arrayType,
@@ -178,7 +177,6 @@
 			flags = array[ pos ];
 
 			attributeType = flags >> 7 & 0x01;
-			attributeNormalized = !! ( flags >> 6 & 0x01 );
 			cardinality = ( flags >> 4 & 0x03 ) + 1;
 			encodingType = flags & 0x0F;
 			arrayType = InvertedEncodingTypes[ encodingType ];

+ 54 - 77
examples/js/loaders/PVRLoader.js

@@ -27,24 +27,25 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
 
 	var pvrDatas = {
 		buffer: buffer,
-		header : header,
-		loadMipmaps : loadMipmaps
+		header: header,
+		loadMipmaps: loadMipmaps
 	};
 
-	// PVR v3
 	if ( header[ 0 ] === 0x03525650 ) {
 
+		// PVR v3
+
 		return THREE.PVRLoader._parseV3( pvrDatas );
 
-	}
-	// PVR v2
-	else if ( header[ 11 ] === 0x21525650 ) {
+	} else if ( header[ 11 ] === 0x21525650 ) {
+
+		// PVR v2
 
 		return THREE.PVRLoader._parseV2( pvrDatas );
 
 	} else {
 
-		throw new Error( "[THREE.PVRLoader] Unknown PVR format" );
+		console.error( 'THREE.PVRLoader: Unknown PVR format.' );
 
 	}
 
@@ -56,43 +57,48 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
 	var bpp, format;
 
 
-	var metaLen 	  = header[ 12 ],
-		pixelFormat   =  header[ 2 ],
-		height        =  header[ 6 ],
-		width         =  header[ 7 ],
-		numSurfs      =  header[ 9 ],
-		numFaces      =  header[ 10 ],
-		numMipmaps    =  header[ 11 ];
+	var metaLen = header[ 12 ],
+		pixelFormat = header[ 2 ],
+		height = header[ 6 ],
+		width = header[ 7 ],
+		// numSurfs = header[ 9 ],
+		numFaces = header[ 10 ],
+		numMipmaps = header[ 11 ];
 
 	switch ( pixelFormat ) {
+
 		case 0 : // PVRTC 2bpp RGB
 			bpp = 2;
 			format = THREE.RGB_PVRTC_2BPPV1_Format;
 			break;
+
 		case 1 : // PVRTC 2bpp RGBA
 			bpp = 2;
 			format = THREE.RGBA_PVRTC_2BPPV1_Format;
 			break;
+
 		case 2 : // PVRTC 4bpp RGB
 			bpp = 4;
 			format = THREE.RGB_PVRTC_4BPPV1_Format;
 			break;
+
 		case 3 : // PVRTC 4bpp RGBA
 			bpp = 4;
 			format = THREE.RGBA_PVRTC_4BPPV1_Format;
 			break;
+
 		default :
-			throw new Error( "pvrtc - unsupported PVR format " + pixelFormat );
+			console.error( 'THREE.PVRLoader: Unsupported PVR format:', pixelFormat );
+
 	}
 
-	pvrDatas.dataPtr 	 = 52 + metaLen;
-	pvrDatas.bpp 		 = bpp;
-	pvrDatas.format 	 = format;
-	pvrDatas.width 		 = width;
-	pvrDatas.height 	 = height;
+	pvrDatas.dataPtr = 52 + metaLen;
+	pvrDatas.bpp = bpp;
+	pvrDatas.format = format;
+	pvrDatas.width = width;
+	pvrDatas.height = height;
 	pvrDatas.numSurfaces = numFaces;
-	pvrDatas.numMipmaps  = numMipmaps;
-
+	pvrDatas.numMipmaps = numMipmaps;
 	pvrDatas.isCubemap 	= ( numFaces === 6 );
 
 	return THREE.PVRLoader._extract( pvrDatas );
@@ -103,19 +109,19 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
 
 	var header = pvrDatas.header;
 
-	var headerLength  =  header[ 0 ],
-		height        =  header[ 1 ],
-		width         =  header[ 2 ],
-		numMipmaps    =  header[ 3 ],
-		flags         =  header[ 4 ],
-		dataLength    =  header[ 5 ],
-		// bpp           =  header[ 6 ],
-		bitmaskRed    =  header[ 7 ],
-		bitmaskGreen  =  header[ 8 ],
-		bitmaskBlue   =  header[ 9 ],
-		bitmaskAlpha  =  header[ 10 ],
-		pvrTag        =  header[ 11 ],
-		numSurfs      =  header[ 12 ];
+	var headerLength = header[ 0 ],
+		height = header[ 1 ],
+		width = header[ 2 ],
+		numMipmaps = header[ 3 ],
+		flags = header[ 4 ],
+		// dataLength = header[ 5 ],
+		// bpp =  header[ 6 ],
+		// bitmaskRed = header[ 7 ],
+		// bitmaskGreen = header[ 8 ],
+		// bitmaskBlue = header[ 9 ],
+		bitmaskAlpha = header[ 10 ],
+		// pvrTag = header[ 11 ],
+		numSurfs = header[ 12 ];
 
 
 	var TYPE_MASK = 0xff;
@@ -124,8 +130,6 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
 
 	var formatFlags = flags & TYPE_MASK;
 
-
-
 	var bpp, format;
 	var _hasAlpha = bitmaskAlpha > 0;
 
@@ -139,18 +143,19 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
 		format = _hasAlpha ? THREE.RGBA_PVRTC_2BPPV1_Format : THREE.RGB_PVRTC_2BPPV1_Format;
 		bpp = 2;
 
-	} else
-		throw new Error( "pvrtc - unknown format " + formatFlags );
+	} else {
 
+		console.error( 'THREE.PVRLoader: Unknown PVR format:', formatFlags );
 
+	}
 
-	pvrDatas.dataPtr 	 = headerLength;
-	pvrDatas.bpp 		 = bpp;
-	pvrDatas.format 	 = format;
-	pvrDatas.width 		 = width;
-	pvrDatas.height 	 = height;
+	pvrDatas.dataPtr = headerLength;
+	pvrDatas.bpp = bpp;
+	pvrDatas.format = format;
+	pvrDatas.width = width;
+	pvrDatas.height = height;
 	pvrDatas.numSurfaces = numSurfs;
-	pvrDatas.numMipmaps  = numMipmaps + 1;
+	pvrDatas.numMipmaps = numMipmaps + 1;
 
 	// guess cubemap type seems tricky in v2
 	// it juste a pvr containing 6 surface (no explicit cubemap type)
@@ -169,32 +174,11 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 		height: pvrDatas.height,
 		format: pvrDatas.format,
 		mipmapCount: pvrDatas.numMipmaps,
-		isCubemap : pvrDatas.isCubemap
+		isCubemap: pvrDatas.isCubemap
 	};
 
 	var buffer = pvrDatas.buffer;
 
-
-
-	// console.log( "--------------------------" );
-
-	// console.log( "headerLength ", headerLength);
-	// console.log( "height       ", height      );
-	// console.log( "width        ", width       );
-	// console.log( "numMipmaps   ", numMipmaps  );
-	// console.log( "flags        ", flags       );
-	// console.log( "dataLength   ", dataLength  );
-	// console.log( "bpp          ", bpp         );
-	// console.log( "bitmaskRed   ", bitmaskRed  );
-	// console.log( "bitmaskGreen ", bitmaskGreen);
-	// console.log( "bitmaskBlue  ", bitmaskBlue );
-	// console.log( "bitmaskAlpha ", bitmaskAlpha);
-	// console.log( "pvrTag       ", pvrTag      );
-	// console.log( "numSurfs     ", numSurfs    );
-
-
-
-
 	var dataOffset = pvrDatas.dataPtr,
 		bpp = pvrDatas.bpp,
 		numSurfs = pvrDatas.numSurfaces,
@@ -205,8 +189,6 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 		widthBlocks = 0,
 		heightBlocks = 0;
 
-
-
 	if ( bpp === 2 ) {
 
 		blockWidth = 8;
@@ -228,20 +210,17 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 	while ( mipLevel < pvrDatas.numMipmaps ) {
 
 		var sWidth = pvrDatas.width >> mipLevel,
-		sHeight = pvrDatas.height >> mipLevel;
+			sHeight = pvrDatas.height >> mipLevel;
 
 		widthBlocks = sWidth / blockWidth;
 		heightBlocks = sHeight / blockHeight;
 
 		// Clamp to minimum number of blocks
-		if ( widthBlocks < 2 )
-			widthBlocks = 2;
-		if ( heightBlocks < 2 )
-			heightBlocks = 2;
+		if ( widthBlocks < 2 ) widthBlocks = 2;
+		if ( heightBlocks < 2 ) heightBlocks = 2;
 
 		dataSize = widthBlocks * heightBlocks * blockSize;
 
-
 		for ( var surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) {
 
 			var byteArray = new Uint8Array( buffer, dataOffset, dataSize );
@@ -256,14 +235,12 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 
 			dataOffset += dataSize;
 
-
 		}
 
 		mipLevel ++;
 
 	}
 
-
 	return pvr;
 
 };

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

@@ -181,7 +181,7 @@ THREE.PlayCanvasLoader.prototype = {
 
 			var parent = model.parents[ i ];
 
-			if ( parent === -1 ) continue;
+			if ( parent === - 1 ) continue;
 
 			model.nodes[ parent ]._object.add( model.nodes[ i ]._object );
 

+ 32 - 35
examples/js/loaders/RGBELoader.js

@@ -15,50 +15,52 @@ THREE.HDRLoader = THREE.RGBELoader = function ( manager ) {
 THREE.RGBELoader.prototype = Object.create( THREE.DataTextureLoader.prototype );
 
 // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
-THREE.RGBELoader.prototype._parser = function( buffer ) {
+THREE.RGBELoader.prototype._parser = function ( buffer ) {
 
 	var
 		/* return codes for rgbe routines */
-		RGBE_RETURN_SUCCESS =  0,
+		RGBE_RETURN_SUCCESS = 0,
 		RGBE_RETURN_FAILURE = - 1,
 
 		/* default error routine.  change this to change error handling */
-		rgbe_read_error     = 1,
-		rgbe_write_error    = 2,
-		rgbe_format_error   = 3,
-		rgbe_memory_error   = 4,
-		rgbe_error = function( rgbe_error_code, msg ) {
+		rgbe_read_error = 1,
+		rgbe_write_error = 2,
+		rgbe_format_error = 3,
+		rgbe_memory_error = 4,
+		rgbe_error = function ( rgbe_error_code, msg ) {
 
 			switch ( rgbe_error_code ) {
+
 				case rgbe_read_error: console.error( "THREE.RGBELoader Read Error: " + ( msg || '' ) );
 					break;
 				case rgbe_write_error: console.error( "THREE.RGBELoader Write Error: " + ( msg || '' ) );
 					break;
-				case rgbe_format_error:  console.error( "THREE.RGBELoader Bad File Format: " + ( msg || '' ) );
+				case rgbe_format_error: console.error( "THREE.RGBELoader Bad File Format: " + ( msg || '' ) );
 					break;
 				default:
-				case rgbe_memory_error:  console.error( "THREE.RGBELoader: Error: " + ( msg || '' ) );
+				case rgbe_memory_error: console.error( "THREE.RGBELoader: Error: " + ( msg || '' ) );
+
 			}
 			return RGBE_RETURN_FAILURE;
 
 		},
 
 		/* offsets to red, green, and blue components in a data (float) pixel */
-		RGBE_DATA_RED      = 0,
-		RGBE_DATA_GREEN    = 1,
-		RGBE_DATA_BLUE     = 2,
+		RGBE_DATA_RED = 0,
+		RGBE_DATA_GREEN = 1,
+		RGBE_DATA_BLUE = 2,
 
 		/* number of floats per pixel, use 4 since stored in rgba image format */
-		RGBE_DATA_SIZE     = 4,
+		RGBE_DATA_SIZE = 4,
 
 		/* flags indicating which fields in an rgbe_header_info are valid */
-		RGBE_VALID_PROGRAMTYPE      = 1,
-		RGBE_VALID_FORMAT           = 2,
-		RGBE_VALID_DIMENSIONS       = 4,
+		RGBE_VALID_PROGRAMTYPE = 1,
+		RGBE_VALID_FORMAT = 2,
+		RGBE_VALID_DIMENSIONS = 4,
 
 		NEWLINE = "\n",
 
-		fgets = function( buffer, lineLimit, consume ) {
+		fgets = function ( buffer, lineLimit, consume ) {
 
 			lineLimit = ! lineLimit ? 1024 : lineLimit;
 			var p = buffer.pos,
@@ -90,7 +92,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 		},
 
 		/* minimal header reading.  modify if you want to parse more information */
-		RGBE_ReadHeader = function( buffer ) {
+		RGBE_ReadHeader = function ( buffer ) {
 
 			var line, match,
 
@@ -104,28 +106,23 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 				// RGBE format header struct
 				header = {
 
-					valid: 0,                         /* indicate which fields are valid */
+					valid: 0, /* indicate which fields are valid */
 
-					string: '',                       /* the actual header string */
+					string: '', /* the actual header string */
 
-					comments: '',                     /* comments found in header */
+					comments: '', /* comments found in header */
 
-					programtype: 'RGBE',              /* listed at beginning of file to identify it
-													* after "#?".  defaults to "RGBE" */
+					programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
 
-					format: '',                       /* RGBE format, default 32-bit_rle_rgbe */
+					format: '', /* RGBE format, default 32-bit_rle_rgbe */
 
-					gamma: 1.0,                       /* image has already been gamma corrected with
-													* given gamma.  defaults to 1.0 (no correction) */
+					gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
 
-					exposure: 1.0,                    /* a value of 1.0 in an image corresponds to
-													* <exposure> watts/steradian/m^2.
-													* defaults to 1.0 */
+					exposure: 1.0, /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
 
-					width: 0, height: 0               /* image dimensions, width/height */
+					width: 0, height: 0 /* image dimensions, width/height */
 
-				}
-			;
+				};
 
 			if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
 
@@ -198,7 +195,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 
 		},
 
-		RGBE_ReadPixels_RLE = function( buffer, w, h ) {
+		RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
 
 			var data_rgba, offset, pos, count, byteValue,
 				scanline_buffer, ptr, ptr_end, i, l, off, isEncodedRun,
@@ -326,8 +323,8 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 	if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) {
 
 		var w = rgbe_header_info.width,
-			h = rgbe_header_info.height
-			, image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h )
+			h = rgbe_header_info.height,
+			image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h )
 		;
 		if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
 

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

@@ -88,7 +88,7 @@ THREE.STLLoader.prototype = {
  			}
 
 			// First 5 bytes read "solid"; declare it to be an ASCII STL
-			
+
 			return false;
 
 		}

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

@@ -22,7 +22,7 @@ THREE.SVGLoader.prototype = {
 		var loader = new THREE.FileLoader( scope.manager );
 		loader.load( url, function ( svgString ) {
 
-			var doc = parser.parseFromString( svgString, 'image/svg+xml' );  // application/xml
+			var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml
 
 			onLoad( doc.documentElement );
 

+ 60 - 65
examples/js/loaders/TDSLoader.js

@@ -29,7 +29,7 @@ THREE.TDSLoader = function ( manager ) {
 THREE.TDSLoader.prototype = {
 
 	constructor: THREE.TDSLoader,
-	
+
 	/**
 	 * Load 3ds file from url.
 	 *
@@ -39,7 +39,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {Function} onProgress onProgress callback.
 	 * @param {Function} onError onError callback.
 	 */
-	load : function ( url, onLoad, onProgress, onError ) {
+	load: function ( url, onLoad, onProgress, onError ) {
 
 		var scope = this;
 
@@ -63,7 +63,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {String} path Path for external resources.
 	 * @return {Object3D} Group loaded from 3ds file.
 	 */
-	parse : function ( arraybuffer ) {
+	parse: function ( arraybuffer ) {
 
 		this.group = new THREE.Group();
 		this.position = 0;
@@ -88,7 +88,7 @@ THREE.TDSLoader.prototype = {
 	 * @method readFile
 	 * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
 	 */
-	readFile : function ( arraybuffer ) {
+	readFile: function ( arraybuffer ) {
 
 		var data = new DataView( arraybuffer );
 		var chunk = this.readChunk( data );
@@ -131,7 +131,7 @@ THREE.TDSLoader.prototype = {
 	 * @method readMeshData
 	 * @param {Dataview} data Dataview in use.
 	 */
-	readMeshData : function ( data ) {
+	readMeshData: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var next = this.nextChunk( data, chunk );
@@ -179,7 +179,7 @@ THREE.TDSLoader.prototype = {
 	 * @method readNamedObject
 	 * @param {Dataview} data Dataview in use.
 	 */
-	readNamedObject : function ( data ) {
+	readNamedObject: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var name = this.readString( data, 64 );
@@ -215,7 +215,7 @@ THREE.TDSLoader.prototype = {
 	 * @method readMaterialEntry
 	 * @param {Dataview} data Dataview in use.
 	 */
-	readMaterialEntry : function ( data ) {
+	readMaterialEntry: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var next = this.nextChunk( data, chunk );
@@ -270,25 +270,25 @@ THREE.TDSLoader.prototype = {
 				material.shininess = shininess;
 				this.debugMessage( '   Shininess : ' + shininess );
 
-			} else if( next === MAT_TEXMAP ) {
+			} else if ( next === MAT_TEXMAP ) {
 
 				this.debugMessage( '   ColorMap' );
 				this.resetPosition( data );
 				material.map = this.readMap( data );
 
-			} else if( next === MAT_BUMPMAP ) {
+			} else if ( next === MAT_BUMPMAP ) {
 
 				this.debugMessage( '   BumpMap' );
 				this.resetPosition( data );
 				material.bumpMap = this.readMap( data );
 
-			} else if( next == MAT_OPACMAP ) {
+			} else if ( next === MAT_OPACMAP ) {
 
 				this.debugMessage( '   OpacityMap' );
 				this.resetPosition( data );
 				material.alphaMap = this.readMap( data );
 
-			} else if( next == MAT_SPECMAP ) {
+			} else if ( next === MAT_SPECMAP ) {
 
 				this.debugMessage( '   SpecularMap' );
 				this.resetPosition( data );
@@ -316,7 +316,7 @@ THREE.TDSLoader.prototype = {
 	 * @method readMesh
 	 * @param {Dataview} data Dataview in use.
 	 */
-	readMesh : function ( data ) {
+	readMesh: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var next = this.nextChunk( data, chunk );
@@ -412,44 +412,44 @@ THREE.TDSLoader.prototype = {
 				this.debugMessage( '   Tranformation Matrix (TODO)' );
 
 				var values = [];
-				for( var i = 0; i < 12; i++ ) {
+				for ( var i = 0; i < 12; i ++ ) {
 
 					values[ i ] = this.readFloat( data );
-				
+
 				}
 
 				var matrix = new THREE.Matrix4();
 
 				//X Line
-				matrix.elements[0] = values[0];
-				matrix.elements[1] = values[6];
-				matrix.elements[2] = values[3];
-				matrix.elements[3] = values[9];
+				matrix.elements[ 0 ] = values[ 0 ];
+				matrix.elements[ 1 ] = values[ 6 ];
+				matrix.elements[ 2 ] = values[ 3 ];
+				matrix.elements[ 3 ] = values[ 9 ];
 
 				//Y Line
-				matrix.elements[4] = values[2];
-				matrix.elements[5] = values[8];
-				matrix.elements[6] = values[5];
-				matrix.elements[7] = values[11];
+				matrix.elements[ 4 ] = values[ 2 ];
+				matrix.elements[ 5 ] = values[ 8 ];
+				matrix.elements[ 6 ] = values[ 5 ];
+				matrix.elements[ 7 ] = values[ 11 ];
 
 				//Z Line
-				matrix.elements[8] = values[1];
-				matrix.elements[9] = values[7];
-				matrix.elements[10] = values[4];
-				matrix.elements[11] = values[10];
+				matrix.elements[ 8 ] = values[ 1 ];
+				matrix.elements[ 9 ] = values[ 7 ];
+				matrix.elements[ 10 ] = values[ 4 ];
+				matrix.elements[ 11 ] = values[ 10 ];
 
 				//W Line
-				matrix.elements[12] = 0;
-				matrix.elements[13] = 0;
-				matrix.elements[14] = 0;
-				matrix.elements[15] = 1;
+				matrix.elements[ 12 ] = 0;
+				matrix.elements[ 13 ] = 0;
+				matrix.elements[ 14 ] = 0;
+				matrix.elements[ 15 ] = 1;
 
 				matrix.transpose();
 
 				var inverse = new THREE.Matrix4();
 				inverse.getInverse( matrix, true );
 				geometry.applyMatrix( inverse );
-				
+
 				matrix.decompose( mesh.position, mesh.quaternion, mesh.scale );
 
 			} else {
@@ -479,8 +479,8 @@ THREE.TDSLoader.prototype = {
 				}
 
 				geometry.faceVertexUvs[ 0 ] = faceUV;
-	
-			}		
+
+			}
 
 			geometry.computeVertexNormals();
 
@@ -497,7 +497,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {Dataview} data Dataview in use.
 	 * @param {Mesh} mesh Mesh to be filled with the data read.
 	 */
-	readFaceArray : function ( data, mesh ) {
+	readFaceArray: function ( data, mesh ) {
 
 		var chunk = this.readChunk( data );
 		var faces = this.readWord( data );
@@ -561,7 +561,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Texture} Texture read from this data chunk.
 	 */
-	readMap : function( data ) {
+	readMap: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var next = this.nextChunk( data, chunk );
@@ -570,7 +570,7 @@ THREE.TDSLoader.prototype = {
 		var loader = new THREE.TextureLoader();
 		loader.setPath( this.path );
 
-		while( next !== 0 ) {
+		while ( next !== 0 ) {
 
 			if ( next === MAT_MAPNAME ) {
 
@@ -579,32 +579,27 @@ THREE.TDSLoader.prototype = {
 
 				this.debugMessage( '      File: ' + this.path + name );
 
-			}
-			else if ( next === MAT_MAP_UOFFSET) {
+			} else if ( next === MAT_MAP_UOFFSET ) {
 
 				texture.offset.x = this.readFloat( data );
 				this.debugMessage( '      OffsetX: ' + texture.offset.x );
 
-			}
-			else if ( next === MAT_MAP_VOFFSET) {
+			} else if ( next === MAT_MAP_VOFFSET ) {
 
 				texture.offset.y = this.readFloat( data );
 				this.debugMessage( '      OffsetY: ' + texture.offset.y );
 
-			}
-			else if ( next === MAT_MAP_USCALE) {
+			} else if ( next === MAT_MAP_USCALE ) {
 
 				texture.repeat.x = this.readFloat( data );
 				this.debugMessage( '      RepeatX: ' + texture.repeat.x );
 
-			}
-			else if ( next === MAT_MAP_VSCALE) {
+			} else if ( next === MAT_MAP_VSCALE ) {
 
 				texture.repeat.y = this.readFloat( data );
 				this.debugMessage( '      RepeatY: ' + texture.repeat.y );
 
-			}
-			else {
+			} else {
 
 				this.debugMessage( '      Unknown map chunk: ' + next.toString( 16 ) );
 
@@ -627,7 +622,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Object} Object with name and index of the object.
 	 */
-	readMaterialGroup : function ( data ) {
+	readMaterialGroup: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var name = this.readString( data, 64 );
@@ -654,7 +649,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview.
 	 * @return {Color} Color value read..
 	 */
-	readColor : function ( data ) {
+	readColor: function ( data ) {
 
 		var chunk = this.readChunk( data );
 		var color = new THREE.Color();
@@ -681,7 +676,7 @@ THREE.TDSLoader.prototype = {
 
 		}	else {
 
-			this.debugMessage( '      Unknown color chunk: ' + c.toString( 16 ) );
+			this.debugMessage( '      Unknown color chunk: ' + chunk.toString( 16 ) );
 
 		}
 
@@ -697,7 +692,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview.
 	 * @return {Object} Chunk of data read.
 	 */
-	readChunk : function ( data ) {
+	readChunk: function ( data ) {
 
 		var chunk = {};
 
@@ -717,7 +712,7 @@ THREE.TDSLoader.prototype = {
 	 * @method endChunk
 	 * @param {Object} chunk Data chunk.
 	 */
-	endChunk : function ( chunk ) {
+	endChunk: function ( chunk ) {
 
 		this.position = chunk.end;
 
@@ -730,7 +725,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview.
 	 * @param {Object} chunk Data chunk.
 	 */
-	nextChunk : function ( data, chunk ) {
+	nextChunk: function ( data, chunk ) {
 
 		if ( chunk.cur >= chunk.end ) {
 
@@ -761,7 +756,7 @@ THREE.TDSLoader.prototype = {
 	 * @method resetPosition
 	 * @param {DataView} data Dataview.
 	 */
-	resetPosition : function ( data, chunk ) {
+	resetPosition: function () {
 
 		this.position -= 6;
 
@@ -774,7 +769,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readByte : function ( data ) {
+	readByte: function ( data ) {
 
 		var v = data.getUint8( this.position, true );
 		this.position += 1;
@@ -789,7 +784,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readFloat : function ( data ) {
+	readFloat: function ( data ) {
 
 		try {
 
@@ -812,7 +807,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readInt : function ( data ) {
+	readInt: function ( data ) {
 
 		var v = data.getInt32( this.position, true );
 		this.position += 4;
@@ -827,7 +822,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readShort : function ( data ) {
+	readShort: function ( data ) {
 
 		var v = data.getInt16( this.position, true );
 		this.position += 2;
@@ -842,7 +837,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readDWord : function ( data ) {
+	readDWord: function ( data ) {
 
 		var v = data.getUint32( this.position, true );
 		this.position += 4;
@@ -857,7 +852,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readWord : function ( data ) {
+	readWord: function ( data ) {
 
 		var v = data.getUint16( this.position, true );
 		this.position += 2;
@@ -873,7 +868,7 @@ THREE.TDSLoader.prototype = {
 	 * @param {Number} maxLength Max size of the string to be read.
 	 * @return {String} Data read from the dataview.
 	 */
-	readString : function ( data, maxLength ) {
+	readString: function ( data, maxLength ) {
 
 		var s = '';
 
@@ -901,11 +896,12 @@ THREE.TDSLoader.prototype = {
 	 * @param {String} path Path to resources.
 	 * @return Self for chaining.
 	 */
-	setPath : function ( path ) {
+	setPath: function ( path ) {
+
+		if ( path !== undefined ) {
 
-		if(path !== undefined)
-		{
 			this.path = path;
+
 		}
 
 		return this;
@@ -920,7 +916,7 @@ THREE.TDSLoader.prototype = {
 	 * @method debugMessage
 	 * @param {Object} message Debug message to print to the console.
 	 */
-	debugMessage : function ( message ) {
+	debugMessage: function ( message ) {
 
 		if ( this.debug ) {
 
@@ -1148,4 +1144,3 @@ var VIEWPORT_DATA = 0x7011;
 var VIEWPORT_DATA_3 = 0x7012;
 var VIEWPORT_SIZE = 0x7020;
 var NETWORK_VIEW = 0x7030;
-

+ 63 - 56
examples/js/loaders/TGALoader.js

@@ -80,7 +80,7 @@ THREE.TGALoader.prototype = {
 				// Invalid type ?
 
 				default:
-					console.error( 'THREE.TGALoader: Invalid type "%s".',  header.image_type );
+					console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type );
 
 			}
 
@@ -94,7 +94,7 @@ THREE.TGALoader.prototype = {
 
 			// check image pixel size
 
-			if ( header.pixel_size !== 8  && header.pixel_size !== 16 &&
+			if ( header.pixel_size !== 8 && header.pixel_size !== 16 &&
 				header.pixel_size !== 24 && header.pixel_size !== 32 ) {
 
 				console.error( 'THREE.TGALoader: Invalid pixel size "%s".', header.pixel_size );
@@ -339,6 +339,7 @@ THREE.TGALoader.prototype = {
 				y_end;
 
 			switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) {
+
 				default:
 				case TGA_ORIGIN_UL:
 					x_start = 0;
@@ -381,20 +382,25 @@ THREE.TGALoader.prototype = {
 			if ( use_grey ) {
 
 				switch ( header.pixel_size ) {
+
 					case 8:
 						tgaGetImageDataGrey8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
 						break;
+
 					case 16:
 						tgaGetImageDataGrey16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
 						break;
+
 					default:
 						console.error( 'THREE.TGALoader: Format not supported.' );
 						break;
+
 				}
 
 			} else {
 
 				switch ( header.pixel_size ) {
+
 					case 8:
 						tgaGetImageData8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image, palette );
 						break;
@@ -414,6 +420,7 @@ THREE.TGALoader.prototype = {
 					default:
 						console.error( 'THREE.TGALoader: Format not supported.' );
 						break;
+
 				}
 
 			}
@@ -428,19 +435,19 @@ THREE.TGALoader.prototype = {
 		// TGA constants
 
 		var TGA_TYPE_NO_DATA = 0,
-		TGA_TYPE_INDEXED = 1,
-		TGA_TYPE_RGB = 2,
-		TGA_TYPE_GREY = 3,
-		TGA_TYPE_RLE_INDEXED = 9,
-		TGA_TYPE_RLE_RGB = 10,
-		TGA_TYPE_RLE_GREY = 11,
-
-		TGA_ORIGIN_MASK = 0x30,
-		TGA_ORIGIN_SHIFT = 0x04,
-		TGA_ORIGIN_BL = 0x00,
-		TGA_ORIGIN_BR = 0x01,
-		TGA_ORIGIN_UL = 0x02,
-		TGA_ORIGIN_UR = 0x03;
+			TGA_TYPE_INDEXED = 1,
+			TGA_TYPE_RGB = 2,
+			TGA_TYPE_GREY = 3,
+			TGA_TYPE_RLE_INDEXED = 9,
+			TGA_TYPE_RLE_RGB = 10,
+			TGA_TYPE_RLE_GREY = 11,
+
+			TGA_ORIGIN_MASK = 0x30,
+			TGA_ORIGIN_SHIFT = 0x04,
+			TGA_ORIGIN_BL = 0x00,
+			TGA_ORIGIN_BR = 0x01,
+			TGA_ORIGIN_UL = 0x02,
+			TGA_ORIGIN_UR = 0x03;
 
 		if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' );
 
@@ -465,68 +472,68 @@ THREE.TGALoader.prototype = {
 
 			// check tga if it is valid format
 
-			tgaCheckHeader( header );
+		tgaCheckHeader( header );
 
-			if ( header.id_length + offset > buffer.length ) {
+		if ( header.id_length + offset > buffer.length ) {
 
-				console.error( 'THREE.TGALoader: No data.' );
+			console.error( 'THREE.TGALoader: No data.' );
 
-			}
+		}
 
-			// skip the needn't data
+		// skip the needn't data
 
-			offset += header.id_length;
+		offset += header.id_length;
 
-			// get targa information about RLE compression and palette
+		// get targa information about RLE compression and palette
 
-			var use_rle = false,
-				use_pal = false,
-				use_grey = false;
+		var use_rle = false,
+			use_pal = false,
+			use_grey = false;
 
-			switch ( header.image_type ) {
+		switch ( header.image_type ) {
 
-				case TGA_TYPE_RLE_INDEXED:
-					use_rle = true;
-					use_pal = true;
-					break;
+			case TGA_TYPE_RLE_INDEXED:
+				use_rle = true;
+				use_pal = true;
+				break;
 
-				case TGA_TYPE_INDEXED:
-					use_pal = true;
-					break;
+			case TGA_TYPE_INDEXED:
+				use_pal = true;
+				break;
 
-				case TGA_TYPE_RLE_RGB:
-					use_rle = true;
-					break;
+			case TGA_TYPE_RLE_RGB:
+				use_rle = true;
+				break;
 
-				case TGA_TYPE_RGB:
-					break;
+			case TGA_TYPE_RGB:
+				break;
 
-				case TGA_TYPE_RLE_GREY:
-					use_rle = true;
-					use_grey = true;
-					break;
+			case TGA_TYPE_RLE_GREY:
+				use_rle = true;
+				use_grey = true;
+				break;
 
-				case TGA_TYPE_GREY:
-					use_grey = true;
-					break;
+			case TGA_TYPE_GREY:
+				use_grey = true;
+				break;
 
-			}
+		}
 
-			//
+		//
 
-			var canvas = document.createElement( 'canvas' );
-			canvas.width = header.width;
-			canvas.height = header.height;
+		var canvas = document.createElement( 'canvas' );
+		canvas.width = header.width;
+		canvas.height = header.height;
 
-			var context = canvas.getContext( '2d' );
-			var imageData = context.createImageData( header.width, header.height );
+		var context = canvas.getContext( '2d' );
+		var imageData = context.createImageData( header.width, header.height );
 
-			var result = tgaParse( use_rle, use_pal, header, offset, content );
-			var rgbaData = getTgaRGBA( imageData.data, header.width, header.height, result.pixel_data, result.palettes );
+		var result = tgaParse( use_rle, use_pal, header, offset, content );
+		var rgbaData = getTgaRGBA( imageData.data, header.width, header.height, result.pixel_data, result.palettes );
 
-			context.putImageData( imageData, 0, 0 );
+		context.putImageData( imageData, 0, 0 );
 
-			return canvas;
+		return canvas;
 
 	}
 

+ 96 - 96
examples/js/loaders/UTF8Loader.js

@@ -50,7 +50,7 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 	for ( i = offset; i < end; i += stride ) {
 
-		positions[ j ++ ] = attribArray[ i     ];
+		positions[ j ++ ] = attribArray[ i ];
 		positions[ j ++ ] = attribArray[ i + 1 ];
 		positions[ j ++ ] = attribArray[ i + 2 ];
 
@@ -63,8 +63,9 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 	for ( i = offset; i < end; i += stride ) {
 
-		uvs[ j ++ ] = attribArray[ i     ];
+		uvs[ j ++ ] = attribArray[ i ];
 		uvs[ j ++ ] = attribArray[ i + 1 ];
+
 	}
 
 	// extract normals
@@ -74,7 +75,7 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 	for ( i = offset; i < end; i += stride ) {
 
-		normals[ j ++ ] = attribArray[ i     ];
+		normals[ j ++ ] = attribArray[ i ];
 		normals[ j ++ ] = attribArray[ i + 1 ];
 		normals[ j ++ ] = attribArray[ i + 2 ];
 
@@ -117,18 +118,18 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 var DEFAULT_DECODE_PARAMS = {
 
-    decodeOffsets: [ -4095, -4095, -4095, 0, 0, -511, -511, -511 ],
-    decodeScales: [ 1 / 8191, 1 / 8191, 1 / 8191, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023 ]
+	decodeOffsets: [ - 4095, - 4095, - 4095, 0, 0, - 511, - 511, - 511 ],
+	decodeScales: [ 1 / 8191, 1 / 8191, 1 / 8191, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023 ]
 
-    // TODO: normal decoding? (see walt.js)
-    // needs to know: input, output (from vertex format!)
-    //
-    // Should split attrib/index.
-    // 1) Decode position and non-normal attributes.
-    // 2) Decode indices, computing normals
-    // 3) Maybe normalize normals? Only necessary for refinement, or fixed?
-    // 4) Maybe refine normals? Should this be part of regular refinement?
-    // 5) Morphing
+	// TODO: normal decoding? (see walt.js)
+	// needs to know: input, output (from vertex format!)
+	//
+	// Should split attrib/index.
+	// 1) Decode position and non-normal attributes.
+	// 2) Decode indices, computing normals
+	// 3) Maybe normalize normals? Only necessary for refinement, or fixed?
+	// 4) Maybe refine normals? Should this be part of regular refinement?
+	// 5) Morphing
 
 };
 
@@ -139,15 +140,14 @@ var DEFAULT_DECODE_PARAMS = {
 // decodeScale?
 
 THREE.UTF8Loader.prototype.decompressAttribsInner_ = function ( str, inputStart, inputEnd,
-                                                                  output, outputStart, stride,
-                                                                  decodeOffset, decodeScale ) {
+	output, outputStart, stride, decodeOffset, decodeScale ) {
 
 	var prev = 0;
 
 	for ( var j = inputStart; j < inputEnd; j ++ ) {
 
 		var code = str.charCodeAt( j );
-		prev += ( code >> 1 ) ^ ( -( code & 1 ) );
+		prev += ( code >> 1 ) ^ ( - ( code & 1 ) );
 
 		output[ outputStart ] = decodeScale * ( prev + decodeOffset );
 		outputStart += stride;
@@ -156,8 +156,7 @@ THREE.UTF8Loader.prototype.decompressAttribsInner_ = function ( str, inputStart,
 
 };
 
-THREE.UTF8Loader.prototype.decompressIndices_ = function( str, inputStart, numIndices,
-                                                            output, outputStart ) {
+THREE.UTF8Loader.prototype.decompressIndices_ = function ( str, inputStart, numIndices, output, outputStart ) {
 
 	var highest = 0;
 
@@ -177,8 +176,8 @@ THREE.UTF8Loader.prototype.decompressIndices_ = function( str, inputStart, numIn
 
 };
 
-THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBoxen,
-                                                           decodeOffsets, decodeScales ) {
+THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBoxen, decodeOffsets, decodeScales ) {
+
 	var numFloats = 6 * numBBoxen;
 
 	var inputEnd = inputStart + numFloats;
@@ -188,21 +187,21 @@ THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBo
 
 	for ( var i = inputStart; i < inputEnd; i += 6 ) {
 
-		var minX = str.charCodeAt(i + 0) + decodeOffsets[0];
-		var minY = str.charCodeAt(i + 1) + decodeOffsets[1];
-		var minZ = str.charCodeAt(i + 2) + decodeOffsets[2];
+		var minX = str.charCodeAt( i + 0 ) + decodeOffsets[ 0 ];
+		var minY = str.charCodeAt( i + 1 ) + decodeOffsets[ 1 ];
+		var minZ = str.charCodeAt( i + 2 ) + decodeOffsets[ 2 ];
 
-		var radiusX = (str.charCodeAt(i + 3) + 1) >> 1;
-		var radiusY = (str.charCodeAt(i + 4) + 1) >> 1;
-		var radiusZ = (str.charCodeAt(i + 5) + 1) >> 1;
+		var radiusX = ( str.charCodeAt( i + 3 ) + 1 ) >> 1;
+		var radiusY = ( str.charCodeAt( i + 4 ) + 1 ) >> 1;
+		var radiusZ = ( str.charCodeAt( i + 5 ) + 1 ) >> 1;
 
-		bboxen[ outputStart ++ ] = decodeScales[0] * (minX + radiusX);
-		bboxen[ outputStart ++ ] = decodeScales[1] * (minY + radiusY);
-		bboxen[ outputStart ++ ] = decodeScales[2] * (minZ + radiusZ);
+		bboxen[ outputStart ++ ] = decodeScales[ 0 ] * ( minX + radiusX );
+		bboxen[ outputStart ++ ] = decodeScales[ 1 ] * ( minY + radiusY );
+		bboxen[ outputStart ++ ] = decodeScales[ 2 ] * ( minZ + radiusZ );
 
-		bboxen[ outputStart ++ ] = decodeScales[0] * radiusX;
-		bboxen[ outputStart ++ ] = decodeScales[1] * radiusY;
-		bboxen[ outputStart ++ ] = decodeScales[2] * radiusZ;
+		bboxen[ outputStart ++ ] = decodeScales[ 0 ] * radiusX;
+		bboxen[ outputStart ++ ] = decodeScales[ 1 ] * radiusY;
+		bboxen[ outputStart ++ ] = decodeScales[ 2 ] * radiusZ;
 
 	}
 
@@ -210,51 +209,49 @@ THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBo
 
 };
 
-THREE.UTF8Loader.prototype.decompressMesh =  function ( str, meshParams, decodeParams, name, idx, callback ) {
+THREE.UTF8Loader.prototype.decompressMesh = function ( str, meshParams, decodeParams, name, idx, callback ) {
 
-    // Extract conversion parameters from attribArrays.
+	// Extract conversion parameters from attribArrays.
 
 	var stride = decodeParams.decodeScales.length;
 
 	var decodeOffsets = decodeParams.decodeOffsets;
 	var decodeScales = decodeParams.decodeScales;
 
-	var attribStart = meshParams.attribRange[0];
-	var numVerts = meshParams.attribRange[1];
+	var attribStart = meshParams.attribRange[ 0 ];
+	var numVerts = meshParams.attribRange[ 1 ];
 
-    // Decode attributes.
+	// Decode attributes.
 
 	var inputOffset = attribStart;
 	var attribsOut = new Float32Array( stride * numVerts );
 
-	for (var j = 0; j < stride; j ++ ) {
+	for ( var j = 0; j < stride; j ++ ) {
 
 		var end = inputOffset + numVerts;
 
-		var decodeScale = decodeScales[j];
+		var decodeScale = decodeScales[ j ];
 
 		if ( decodeScale ) {
 
-            // Assume if decodeScale is never set, simply ignore the
-            // attribute.
+			// Assume if decodeScale is never set, simply ignore the
+			// attribute.
+
+			this.decompressAttribsInner_( str, inputOffset, end, attribsOut, j, stride, decodeOffsets[ j ], decodeScale );
 
-			this.decompressAttribsInner_( str, inputOffset, end,
-                attribsOut, j, stride,
-                decodeOffsets[j], decodeScale );
 		}
 
 		inputOffset = end;
 
 	}
 
-	var indexStart = meshParams.indexRange[ 0 ];
 	var numIndices = 3 * meshParams.indexRange[ 1 ];
 
 	var indicesOut = new Uint16Array( numIndices );
 
 	this.decompressIndices_( str, inputOffset, numIndices, indicesOut, 0 );
 
-    // Decode bboxen.
+	// Decode bboxen.
 
 	var bboxen = undefined;
 	var bboxOffset = meshParams.bboxes;
@@ -262,6 +259,7 @@ THREE.UTF8Loader.prototype.decompressMesh =  function ( str, meshParams, decodeP
 	if ( bboxOffset ) {
 
 		bboxen = this.decompressAABBs_( str, bboxOffset, meshParams.names.length, decodeOffsets, decodeScales );
+
 	}
 
 	callback( name, idx, attribsOut, indicesOut, bboxen, meshParams );
@@ -279,17 +277,17 @@ THREE.UTF8Loader.prototype.copyAttrib = function ( stride, attribsOutFixed, last
 };
 
 THREE.UTF8Loader.prototype.decodeAttrib2 = function ( str, stride, decodeOffsets, decodeScales, deltaStart,
-                                                        numVerts, attribsOut, attribsOutFixed, lastAttrib,
-                                                        index ) {
+	numVerts, attribsOut, attribsOutFixed, lastAttrib, index ) {
 
 	for ( var j = 0; j < 5; j ++ ) {
 
 		var code = str.charCodeAt( deltaStart + numVerts * j + index );
-		var delta = ( code >> 1) ^ (-(code & 1));
+		var delta = ( code >> 1 ) ^ ( - ( code & 1 ) );
 
 		lastAttrib[ j ] += delta;
 		attribsOutFixed[ stride * index + j ] = lastAttrib[ j ];
 		attribsOut[ stride * index + j ] = decodeScales[ j ] * ( lastAttrib[ j ] + decodeOffsets[ j ] );
+
 	}
 
 };
@@ -320,25 +318,25 @@ THREE.UTF8Loader.prototype.accumulateNormal = function ( i0, i1, i2, attribsOutF
 	p0y = p1z * p2x - p1x * p2z;
 	p0z = p1x * p2y - p1y * p2x;
 
-	crosses[ 3 * i0 ]     += p0x;
+	crosses[ 3 * i0 ] += p0x;
 	crosses[ 3 * i0 + 1 ] += p0y;
 	crosses[ 3 * i0 + 2 ] += p0z;
 
-	crosses[ 3 * i1 ]     += p0x;
+	crosses[ 3 * i1 ] += p0x;
 	crosses[ 3 * i1 + 1 ] += p0y;
 	crosses[ 3 * i1 + 2 ] += p0z;
 
-	crosses[ 3 * i2 ]     += p0x;
+	crosses[ 3 * i2 ] += p0x;
 	crosses[ 3 * i2 + 1 ] += p0y;
 	crosses[ 3 * i2 + 2 ] += p0z;
 
 };
 
-THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodeParams, name, idx, callback ) {
+THREE.UTF8Loader.prototype.decompressMesh2 = function ( str, meshParams, decodeParams, name, idx, callback ) {
 
 	var MAX_BACKREF = 96;
 
-    // Extract conversion parameters from attribArrays.
+	// Extract conversion parameters from attribArrays.
 
 	var stride = decodeParams.decodeScales.length;
 
@@ -349,7 +347,6 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 	var numVerts = meshParams.attribRange[ 1 ];
 
 	var codeStart = meshParams.codeRange[ 0 ];
-	var codeLength = meshParams.codeRange[ 1 ];
 
 	var numIndices = 3 * meshParams.codeRange[ 2 ];
 
@@ -373,7 +370,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 
 		if ( code < max_backref ) {
 
-            // Parallelogram
+  		// Parallelogram
 
 			var winding = code % 3;
 			var backref = i - ( code - winding );
@@ -414,16 +411,16 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 
 			if ( code === 0 ) {
 
-				for (var j = 0; j < 5; j ++ ) {
+				for ( var j = 0; j < 5; j ++ ) {
 
 					var deltaCode = str.charCodeAt( deltaStart + numVerts * j + highest );
 
-					var prediction = ((deltaCode >> 1) ^ (-(deltaCode & 1))) +
-                        attribsOutFixed[stride * i0 + j] +
-                        attribsOutFixed[stride * i1 + j] -
-                        attribsOutFixed[stride * i2 + j];
+					var prediction = ( ( deltaCode >> 1 ) ^ ( - ( deltaCode & 1 ) ) ) +
+						attribsOutFixed[ stride * i0 + j ] +
+						attribsOutFixed[ stride * i1 + j ] -
+						attribsOutFixed[ stride * i2 + j ];
 
-					lastAttrib[j] = prediction;
+					lastAttrib[ j ] = prediction;
 
 					attribsOutFixed[ stride * highest + j ] = prediction;
 					attribsOut[ stride * highest + j ] = decodeScales[ j ] * ( prediction + decodeOffsets[ j ] );
@@ -442,7 +439,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 
 		} else {
 
-            // Simple
+			// Simple
 
 			var index0 = highest - ( code - max_backref );
 
@@ -451,12 +448,11 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 			if ( code === max_backref ) {
 
 				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
-                    numVerts, attribsOut, attribsOutFixed, lastAttrib,
-                    highest ++ );
+					numVerts, attribsOut, attribsOutFixed, lastAttrib, highest ++ );
 
 			} else {
 
-				this.copyAttrib(stride, attribsOutFixed, lastAttrib, index0);
+				this.copyAttrib( stride, attribsOutFixed, lastAttrib, index0 );
 
 			}
 
@@ -468,8 +464,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 			if ( code === 0 ) {
 
 				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
-                    numVerts, attribsOut, attribsOutFixed, lastAttrib,
-                    highest ++ );
+					numVerts, attribsOut, attribsOutFixed, lastAttrib, highest ++ );
 
 			} else {
 
@@ -491,8 +486,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 				}
 
 				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
-                    numVerts, attribsOut, attribsOutFixed, lastAttrib,
-                    highest ++ );
+					numVerts, attribsOut, attribsOutFixed, lastAttrib, highest ++ );
 
 			} else {
 
@@ -518,9 +512,10 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
 		var cy = str.charCodeAt( deltaStart + 6 * numVerts + i );
 		var cz = str.charCodeAt( deltaStart + 7 * numVerts + i );
 
-		attribsOut[ stride * i + 5 ] = norm * nx + ((cx >> 1) ^ (-(cx & 1)));
-		attribsOut[ stride * i + 6 ] = norm * ny + ((cy >> 1) ^ (-(cy & 1)));
-		attribsOut[ stride * i + 7 ] = norm * nz + ((cz >> 1) ^ (-(cz & 1)));
+		attribsOut[ stride * i + 5 ] = norm * nx + ( ( cx >> 1 ) ^ ( - ( cx & 1 ) ) );
+		attribsOut[ stride * i + 6 ] = norm * ny + ( ( cy >> 1 ) ^ ( - ( cy & 1 ) ) );
+		attribsOut[ stride * i + 7 ] = norm * nz + ( ( cz >> 1 ) ^ ( - ( cz & 1 ) ) );
+
 	}
 
 	callback( name, idx, attribsOut, indicesOut, undefined, meshParams );
@@ -555,6 +550,7 @@ THREE.UTF8Loader.prototype.downloadMesh = function ( path, name, meshEntry, deco
 				if ( data.length < meshEnd ) break;
 
 				loader.decompressMesh2( data, meshParams, decodeParams, name, idx, callback );
+
 			}
 
 			++ idx;
@@ -563,13 +559,13 @@ THREE.UTF8Loader.prototype.downloadMesh = function ( path, name, meshEntry, deco
 
 	}
 
-	getHttpRequest( path, function( data ) {
+	getHttpRequest( path, function ( data ) {
 
 		onprogress( data );
 
-        // TODO: handle errors.
+		// TODO: handle errors.
 
-	});
+	} );
 
 };
 
@@ -577,14 +573,14 @@ THREE.UTF8Loader.prototype.downloadMeshes = function ( path, meshUrlMap, decodeP
 
 	for ( var url in meshUrlMap ) {
 
-		var meshEntry = meshUrlMap[url];
+		var meshEntry = meshUrlMap[ url ];
 		this.downloadMesh( path + url, url, meshEntry, decodeParams, callback );
 
 	}
 
 };
 
-THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadModelInfo, allDoneCallback ) {
+THREE.UTF8Loader.prototype.createMeshCallback = function ( materialBaseUrl, loadModelInfo, allDoneCallback ) {
 
 	var nCompletedUrls = 0;
 	var nExpectedUrls = 0;
@@ -609,7 +605,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
 
 	var model = new THREE.Object3D();
 
-    // Prepare materials first...
+	// Prepare materials first...
 
 	var materialCreator = new THREE.MTLLoader.MaterialCreator( materialBaseUrl, loadModelInfo.options );
 	materialCreator.setMaterials( loadModelInfo.materials );
@@ -620,16 +616,16 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
 
 	var bufferGeometryCreator = new THREE.UTF8Loader.BufferGeometryCreator();
 
-	var meshCallback = function( name, idx, attribArray, indexArray, bboxen, meshParams ) {
+	var meshCallback = function ( name, idx, attribArray, indexArray, bboxen, meshParams ) {
 
-        // Got ourselves a new mesh
+		// Got ourselves a new mesh
 
-        // name identifies this part of the model (url)
-        // idx is the mesh index of this mesh of the part
-        // attribArray defines the vertices
-        // indexArray defines the faces
-        // bboxen defines the bounding box
-        // meshParams contains the material info
+		// name identifies this part of the model (url)
+		// idx is the mesh index of this mesh of the part
+		// attribArray defines the vertices
+		// indexArray defines the faces
+		// bboxen defines the bounding box
+		// meshParams contains the material info
 
 		var geometry = bufferGeometryCreator.create( attribArray, indexArray );
 		var material = materialCreator.create( meshParams.material );
@@ -637,7 +633,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
 		var mesh = new THREE.Mesh( geometry, material );
 		modelParts[ name ].add( mesh );
 
-        //model.add(new THREE.Mesh(geometry, material));
+		//model.add(new THREE.Mesh(geometry, material));
 
 		decodedMeshesPerUrl[ name ] ++;
 
@@ -649,7 +645,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
 
 			if ( nCompletedUrls === nExpectedUrls ) {
 
-                // ALL DONE!!!
+				// ALL DONE!!!
 
 				allDoneCallback( model );
 
@@ -672,7 +668,7 @@ THREE.UTF8Loader.prototype.downloadModel = function ( geometryBase, materialBase
 
 THREE.UTF8Loader.prototype.downloadModelJson = function ( jsonUrl, callback, options ) {
 
-	getJsonRequest( jsonUrl, function( loaded ) {
+	getJsonRequest( jsonUrl, function ( loaded ) {
 
 		if ( ! loaded.decodeParams ) {
 
@@ -711,7 +707,7 @@ THREE.UTF8Loader.prototype.downloadModelJson = function ( jsonUrl, callback, opt
 
 			if ( materialBase.charAt( materialBase.length - 1 ) !== "/" ) {
 
-				materialBase = materialBase  + "/";
+				materialBase = materialBase + "/";
 
 			}
 
@@ -734,19 +730,23 @@ function getHttpRequest( url, onload, opt_onprogress ) {
 
 function getJsonRequest( url, onjson ) {
 
-	getHttpRequest( url,
-        function( e ) { onjson( JSON.parse( e ) ); },
-        function() {} );
+	getHttpRequest( url, function ( e ) {
+
+		onjson( JSON.parse( e ) );
+
+	},
+	function () {} );
 
 }
 
 function addListeners( dom, listeners ) {
 
-    // TODO: handle event capture, object binding.
+	// TODO: handle event capture, object binding.
 
 	for ( var key in listeners ) {
 
 		dom.addEventListener( key, listeners[ key ] );
 
 	}
+
 }

+ 93 - 78
examples/js/loaders/VRMLLoader.js

@@ -16,7 +16,7 @@ THREE.VRMLLoader.prototype = {
 	isRecordingPoints: false,
 	isRecordingFaces: false,
 	points: [],
-	indexes : [],
+	indexes: [],
 
 	// for Background support
 	isRecordingAngles: false,
@@ -54,11 +54,11 @@ THREE.VRMLLoader.prototype = {
 		var textureLoader = new THREE.TextureLoader( this.manager );
 		textureLoader.setCrossOrigin( this.crossOrigin );
 
-		function parseV1( lines, scene ) {
+		function parseV1() {
 
 			console.warn( 'THREE.VRMLLoader: V1.0 not supported yet.' );
 
-		};
+		}
 
 		function parseV2( lines, scene ) {
 
@@ -179,7 +179,7 @@ THREE.VRMLLoader.prototype = {
 
 				geometry.addAttribute( 'color', colorAttribute );
 
-			};
+			}
 
 			var index = [];
 
@@ -193,7 +193,7 @@ THREE.VRMLLoader.prototype = {
 				 */
 				var regex = /[^\s,\[\]]+/g;
 
-				var point, angles, colors;
+				var point;
 
 				while ( null !== ( part = regex.exec( line ) ) ) {
 
@@ -206,6 +206,7 @@ THREE.VRMLLoader.prototype = {
 
 				// trigger several recorders
 				switch ( fieldName ) {
+
 					case 'skyAngle':
 					case 'groundAngle':
 						this.recordingFieldname = fieldName;
@@ -232,6 +233,7 @@ THREE.VRMLLoader.prototype = {
 						this.isRecordingFaces = true;
 						this.indexes = [];
 						break;
+
 				}
 
 				if ( this.isRecordingFaces ) {
@@ -283,36 +285,40 @@ THREE.VRMLLoader.prototype = {
 						index = [];
 
 						this.isRecordingFaces = false;
-						node[this.recordingFieldname] = this.indexes;
+						node[ this.recordingFieldname ] = this.indexes;
 
 					}
 
 				} else if ( this.isRecordingPoints ) {
 
-					if ( node.nodeType == 'Coordinate' )
+					if ( node.nodeType == 'Coordinate' ) {
 
-					while ( null !== ( parts = float3_pattern.exec( line ) ) ) {
+						while ( null !== ( parts = float3_pattern.exec( line ) ) ) {
 
-						point = {
-							x: parseFloat( parts[ 1 ] ),
-							y: parseFloat( parts[ 2 ] ),
-							z: parseFloat( parts[ 3 ] )
-						};
+							point = {
+								x: parseFloat( parts[ 1 ] ),
+								y: parseFloat( parts[ 2 ] ),
+								z: parseFloat( parts[ 3 ] )
+							};
+
+							this.points.push( point );
 
-						this.points.push( point );
+						}
 
 					}
 
-					if ( node.nodeType == 'TextureCoordinate' )
+					if ( node.nodeType == 'TextureCoordinate' ) {
 
-					while ( null !== ( parts = float2_pattern.exec( line ) ) ) {
+						while ( null !== ( parts = float2_pattern.exec( line ) ) ) {
 
-						point = {
-							x: parseFloat( parts[ 1 ] ),
-							y: parseFloat( parts[ 2 ] )
-						};
+							point = {
+								x: parseFloat( parts[ 1 ] ),
+								y: parseFloat( parts[ 2 ] )
+							};
+
+							this.points.push( point );
 
-						this.points.push( point );
+						}
 
 					}
 
@@ -470,6 +476,7 @@ THREE.VRMLLoader.prototype = {
 							property = parts[ 1 ] === 'TRUE' ? true : false;
 
 							break;
+
 					}
 
 					node[ fieldName ] = property;
@@ -478,7 +485,7 @@ THREE.VRMLLoader.prototype = {
 
 				return property;
 
-			};
+			}
 
 			function getTree( lines ) {
 
@@ -494,7 +501,7 @@ THREE.VRMLLoader.prototype = {
 					var line = lines[ i ];
 
 					// omit whitespace only lines
-					if ( null !== ( result = /^\s+?$/g.exec( line ) ) ) {
+					if ( null !== ( /^\s+?$/g.exec( line ) ) ) {
 
 						continue;
 
@@ -525,7 +532,7 @@ THREE.VRMLLoader.prototype = {
 
 						// first subpattern should match the Node name
 
-						var block = { 'nodeType' : matches[ 1 ], 'string': line, 'parent': current, 'children': [], 'comment' : comment };
+						var block = { 'nodeType': matches[ 1 ], 'string': line, 'parent': current, 'children': [], 'comment': comment };
 						current.children.push( block );
 						current = block;
 
@@ -559,7 +566,7 @@ THREE.VRMLLoader.prototype = {
 
 				return tree;
 
-			};
+			}
 
 			function parseNode( data, parent ) {
 
@@ -610,7 +617,7 @@ THREE.VRMLLoader.prototype = {
 
 				object = parent;
 
-				if ( data.string.indexOf( 'AmbientLight') > - 1 && data.nodeType === 'PointLight' ) {
+				if ( data.string.indexOf( 'AmbientLight' ) > - 1 && data.nodeType === 'PointLight' ) {
 
 					data.nodeType = 'AmbientLight';
 
@@ -626,7 +633,7 @@ THREE.VRMLLoader.prototype = {
 
 				}
 
-				if ( 'AmbientLight' === data.nodeType){
+				if ( 'AmbientLight' === data.nodeType ) {
 
 					object = new THREE.AmbientLight( l_color, l_intensity );
 					object.visible = l_visible;
@@ -635,43 +642,43 @@ THREE.VRMLLoader.prototype = {
 
 				} else if ( 'PointLight' === data.nodeType ) {
 
-						var l_distance = 0;
+					var l_distance = 0;
 
-						if ( data.radius !== undefined && data.radius < 1000 ){
+					if ( data.radius !== undefined && data.radius < 1000 ) {
 
-							l_distance = data.radius;
+						l_distance = data.radius;
 
-						}
+					}
 
-						object=new THREE.PointLight( l_color, l_intensity, l_distance );
-						object.visible = l_visible;
+					object = new THREE.PointLight( l_color, l_intensity, l_distance );
+					object.visible = l_visible;
 
-						parent.add( object );
+					parent.add( object );
 
 				} else if ( 'SpotLight' === data.nodeType ) {
 
-						var l_intensity = 1;
-						var l_distance = 0;
-						var l_angle = Math.PI/3;
-						var l_penumbra = 0;
-						var l_visible = true;
+					var l_intensity = 1;
+					var l_distance = 0;
+					var l_angle = Math.PI / 3;
+					var l_penumbra = 0;
+					var l_visible = true;
 
-						if ( data.radius !== undefined && data.radius < 1000 ) {
+					if ( data.radius !== undefined && data.radius < 1000 ) {
 
-							l_distance = data.radius;
+						l_distance = data.radius;
 
-						}
+					}
 
-						if ( data.cutOffAngle !== undefined ) {
+					if ( data.cutOffAngle !== undefined ) {
 
-							l_angle = data.cutOffAngle;
+						l_angle = data.cutOffAngle;
 
-						}
+					}
 
-						object = new THREE.SpotLight( l_color, l_intensity, l_distance, l_angle, l_penumbra );
-						object.visible = l_visible;
+					object = new THREE.SpotLight( l_color, l_intensity, l_distance, l_angle, l_penumbra );
+					object.visible = l_visible;
 
-						parent.add( object );
+					parent.add( object );
 
 				} else if ( 'Transform' === data.nodeType || 'Group' === data.nodeType ) {
 
@@ -739,7 +746,7 @@ THREE.VRMLLoader.prototype = {
 
 						paintFaces( skyGeometry, radius, data.skyAngle, data.skyColor, true );
 
-						skyMaterial.vertexColors = THREE.VertexColors
+						skyMaterial.vertexColors = THREE.VertexColors;
 
 					} else {
 
@@ -789,7 +796,6 @@ THREE.VRMLLoader.prototype = {
 
 						var geometry = new THREE.BufferGeometry();
 
-						var index = [];
 						var positions = [];
 						var uvs = [];
 
@@ -833,7 +839,7 @@ THREE.VRMLLoader.prototype = {
 
 								}
 
-								if ( child.string.indexOf ( 'DEF' ) > - 1 ) {
+								if ( child.string.indexOf( 'DEF' ) > - 1 ) {
 
 									var name = /DEF\s+([^\s]+)/.exec( child.string )[ 1 ];
 
@@ -841,7 +847,7 @@ THREE.VRMLLoader.prototype = {
 
 								}
 
-								if ( child.string.indexOf ( 'USE' ) > - 1 ) {
+								if ( child.string.indexOf( 'USE' ) > - 1 ) {
 
 									var defineKey = /USE\s+([^\s]+)/.exec( child.string )[ 1 ];
 
@@ -1006,9 +1012,9 @@ THREE.VRMLLoader.prototype = {
 
 						if ( 'ImageTexture' === child.nodeType ) {
 
-							var textureName = /"([^"]+)"/.exec(child.children[ 0 ]);
+							var textureName = /"([^"]+)"/.exec( child.children[ 0 ] );
 
-							if (textureName) {
+							if ( textureName ) {
 
 								parent.material.name = textureName[ 1 ];
 
@@ -1030,48 +1036,57 @@ THREE.VRMLLoader.prototype = {
 
 				}
 
-			};
+			}
 
 			parseNode( getTree( lines ), scene );
 
-		};
+		}
 
 		var scene = new THREE.Scene();
 
 		var lines = data.split( '\n' );
 
 		// some lines do not have breaks
-		for (var i = lines.length -1; i > -1; i--) {
+		for ( var i = lines.length - 1; i > - 1; i -- ) {
 
 			// split lines with {..{ or {..[ - some have both
-			if (/{.*[{\[]/.test (lines[i])) {
-				var parts = lines[i].split ('{').join ('{\n').split ('\n');
-				parts.unshift(1);
-				parts.unshift(i);
-				lines.splice.apply(lines, parts);
-			} else
-
-			// split lines with ]..}
-			if (/\].*}/.test (lines[i])) {
-				var parts = lines[i].split (']').join (']\n').split ('\n');
-				parts.unshift(1);
-				parts.unshift(i);
-				lines.splice.apply(lines, parts);
+			if ( /{.*[{\[]/.test( lines[ i ] ) ) {
+
+				var parts = lines[ i ].split( '{' ).join( '{\n' ).split( '\n' );
+				parts.unshift( 1 );
+				parts.unshift( i );
+				lines.splice.apply( lines, parts );
+
+			} else if ( /\].*}/.test( lines[ i ] ) ) {
+
+				// split lines with ]..}
+				var parts = lines[ i ].split( ']' ).join( ']\n' ).split( '\n' );
+				parts.unshift( 1 );
+				parts.unshift( i );
+				lines.splice.apply( lines, parts );
+
 			}
 
-			// split lines with }..}
-			if (/}.*}/.test (lines[i])) {
-				var parts = lines[i].split ('}').join ('}\n').split ('\n');
-				parts.unshift(1);
-				parts.unshift(i);
-				lines.splice.apply(lines, parts);
+			if ( /}.*}/.test( lines[ i ] ) ) {
+
+				// split lines with }..}
+
+				var parts = lines[ i ].split( '}' ).join( '}\n' ).split( '\n' );
+				parts.unshift( 1 );
+				parts.unshift( i );
+				lines.splice.apply( lines, parts );
+
 			}
 
 			// force the parser to create Coordinate node for empty coords
 			// coord USE something -> coord USE something Coordinate {}
-			if((lines[i].indexOf ('coord') > -1) && (lines[i].indexOf ('[') < 0) && (lines[i].indexOf ('{') < 0)) {
-				lines[i] += ' Coordinate {}';
+
+			if ( ( lines[ i ].indexOf( 'coord' ) > - 1 ) && ( lines[ i ].indexOf( '[' ) < 0 ) && ( lines[ i ].indexOf( '{' ) < 0 ) ) {
+
+				lines[ i ] += ' Coordinate {}';
+
 			}
+
 		}
 
 		var header = lines.shift();

+ 185 - 124
examples/js/loaders/VTKLoader.js

@@ -1,7 +1,7 @@
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author Alex Pletzer
- * 
+ *
  * Updated on 22.03.2017
  * VTK header is now parsed and used to extract all the compressed data
  * @author Andrii Iudin https://github.com/andreyyudin
@@ -9,7 +9,7 @@
  * @author Sriram Somasundharam https://github.com/raamssundar
  */
 
-THREE.VTKLoader = function( manager ) {
+THREE.VTKLoader = function ( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
 
@@ -23,7 +23,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 		var loader = new THREE.FileLoader( scope.manager );
 		loader.setResponseType( 'arraybuffer' );
-		loader.load( url, function( text ) {
+		loader.load( url, function ( text ) {
 
 			onLoad( scope.parse( text ) );
 
@@ -286,7 +286,6 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 				var numTriangles = indices.length / 3;
 				var numPoints = positions.length / 3;
-				var va, vb, vc;
 				var face;
 				var ia, ib, ic;
 				var x, y, z;
@@ -332,9 +331,9 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 		function parseBinary( data ) {
 
-			var count, pointIndex, i, numberOfPoints, pt, s;
-			var buffer = new Uint8Array ( data );
-			var dataView = new DataView ( data );
+			var count, pointIndex, i, numberOfPoints, s;
+			var buffer = new Uint8Array( data );
+			var dataView = new DataView( data );
 
 			// Points and normals, by default, are empty
 			var points = [];
@@ -352,16 +351,16 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 				var s = [];
 				while ( c != 10 ) {
 
-					s.push ( String.fromCharCode ( c ) );
+					s.push( String.fromCharCode( c ) );
 					index ++;
 					c = buffer[ index ];
 
 				}
 
 				return { start: start,
-						end: index,
-						next: index + 1,
-						parsedString: s.join( '' ) };
+					end: index,
+					next: index + 1,
+					parsedString: s.join( '' ) };
 
 			}
 
@@ -370,14 +369,14 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 			while ( true ) {
 
 				// Get a string
-				state = findString ( buffer, index );
+				state = findString( buffer, index );
 				line = state.parsedString;
 
-				if ( line.indexOf ( 'POINTS' ) === 0 ) {
+				if ( line.indexOf( 'POINTS' ) === 0 ) {
 
-					vtk.push ( line );
+					vtk.push( line );
 					// Add the points
-					numberOfPoints = parseInt ( line.split( ' ' )[ 1 ], 10 );
+					numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 );
 
 					// Each point is 3 4-byte floats
 					count = numberOfPoints * 4 * 3;
@@ -396,10 +395,10 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 					// increment our next pointer
 					state.next = state.next + count + 1;
 
-				} else if ( line.indexOf ( 'TRIANGLE_STRIPS' ) === 0 ) {
+				} else if ( line.indexOf( 'TRIANGLE_STRIPS' ) === 0 ) {
 
-					var numberOfStrips = parseInt ( line.split( ' ' )[ 1 ], 10 );
-					var size = parseInt ( line.split ( ' ' )[ 2 ], 10 );
+					var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
+					var size = parseInt( line.split( ' ' )[ 2 ], 10 );
 					// 4 byte integers
 					count = size * 4;
 
@@ -415,7 +414,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						pointIndex += 4;
 						for ( s = 0; s < indexCount; s ++ ) {
 
-							strip.push ( dataView.getInt32( pointIndex, false ) );
+							strip.push( dataView.getInt32( pointIndex, false ) );
 							pointIndex += 4;
 
 						}
@@ -444,10 +443,10 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 					// increment our next pointer
 					state.next = state.next + count + 1;
 
-				} else if ( line.indexOf ( 'POLYGONS' ) === 0 ) {
+				} else if ( line.indexOf( 'POLYGONS' ) === 0 ) {
 
-					var numberOfStrips = parseInt ( line.split( ' ' )[ 1 ], 10 );
-					var size = parseInt ( line.split ( ' ' )[ 2 ], 10 );
+					var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
+					var size = parseInt( line.split( ' ' )[ 2 ], 10 );
 					// 4 byte integers
 					count = size * 4;
 
@@ -463,11 +462,11 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						pointIndex += 4;
 						for ( s = 0; s < indexCount; s ++ ) {
 
-							strip.push ( dataView.getInt32( pointIndex, false ) );
+							strip.push( dataView.getInt32( pointIndex, false ) );
 							pointIndex += 4;
 
 						}
-						var i0 = strip[ 0 ];
+
 						// divide the polygon in n-2 triangle
 						for ( var j = 1; j < indexCount - 1; j ++ ) {
 
@@ -481,12 +480,12 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 					// increment our next pointer
 					state.next = state.next + count + 1;
 
-				} else if ( line.indexOf ( 'POINT_DATA' ) === 0 ) {
+				} else if ( line.indexOf( 'POINT_DATA' ) === 0 ) {
 
-					numberOfPoints = parseInt ( line.split( ' ' )[ 1 ], 10 );
+					numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 );
 
 					// Grab the next line
-					state = findString ( buffer, state.next );
+					state = findString( buffer, state.next );
 
 					// Now grab the binary data
 					count = numberOfPoints * 4 * 3;
@@ -532,24 +531,26 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 		}
 
-		function Float32Concat(first, second) {
-		    var firstLength = first.length,
-		        result = new Float32Array(firstLength + second.length);
+		function Float32Concat( first, second ) {
+
+		    var firstLength = first.length, result = new Float32Array( firstLength + second.length );
 
-		    result.set(first);
-		    result.set(second, firstLength);
+		    result.set( first );
+		    result.set( second, firstLength );
 
 		    return result;
+
 		}
 
-		function Int32Concat(first, second) {
-		    var firstLength = first.length,
-		        result = new Int32Array(firstLength + second.length);
+		function Int32Concat( first, second ) {
+
+		    var firstLength = first.length, result = new Int32Array( firstLength + second.length );
 
-		    result.set(first);
-		    result.set(second, firstLength);
+		    result.set( first );
+		    result.set( second, firstLength );
 
 		    return result;
+
 		}
 
 		function parseXML( stringFile ) {
@@ -596,7 +597,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						var item = xml.childNodes.item( i );
 						var nodeName = item.nodeName;
 
-						if ( typeof( obj[ nodeName ] ) === 'undefined' ) {
+						if ( typeof obj[ nodeName ] === 'undefined' ) {
 
 							var tmp = xmlToJson( item );
 
@@ -604,7 +605,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 						} else {
 
-							if ( typeof( obj[ nodeName ].push ) === 'undefined' ) {
+							if ( typeof obj[ nodeName ].push === 'undefined' ) {
 
 								var old = obj[ nodeName ];
 								obj[ nodeName ] = [ old ];
@@ -692,106 +693,151 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 			}
 
 			function parseDataArray( ele, compressed ) {
+
 				var numBytes = 0;
-				if ( json.attributes.header_type == 'UInt64' )
+
+				if ( json.attributes.header_type == 'UInt64' ) {
+
 					numBytes = 8;
-				else if( json.attributes.header_type == 'UInt32' )
+
+				}	else if ( json.attributes.header_type == 'UInt32' ) {
+
 					numBytes = 4;
 
+				}
+
+
 				// Check the format
 				if ( ele.attributes.format == 'binary' && compressed ) {
-						var rawData, content, byteData, blocks, cSizeStart, headerSize, padding, dataOffsets, currentOffset;
 
-						if ( ele.attributes.type == 'Float32' ) {
-							var txt = new Float32Array( );
-						} else if ( ele.attributes.type === 'Int64' ) {
-							var txt = new Int32Array( );
-						}
+					var rawData, content, byteData, blocks, cSizeStart, headerSize, padding, dataOffsets, currentOffset;
+
+					if ( ele.attributes.type == 'Float32' ) {
+
+						var txt = new Float32Array( );
+
+					} else if ( ele.attributes.type === 'Int64' ) {
+
+						var txt = new Int32Array( );
+
+					}
+
+					// VTP data with the header has the following structure:
+					// [#blocks][#u-size][#p-size][#c-size-1][#c-size-2]...[#c-size-#blocks][DATA]
+					//
+					// Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are:
+					// [#blocks] = Number of blocks
+					// [#u-size] = Block size before compression
+					// [#p-size] = Size of last partial block (zero if it not needed)
+					// [#c-size-i] = Size in bytes of block i after compression
+					//
+					// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
+					// computed by summing the compressed block sizes from preceding blocks according to the header.
+
+					rawData = ele[ '#text' ];
+
+					byteData = Base64toByteArray( rawData );
+
+					blocks = byteData[ 0 ];
+					for ( var i = 1; i < numBytes - 1; i ++ ) {
+
+						blocks = blocks | ( byteData[ i ] << ( i * numBytes ) );
+
+					}
+
+					headerSize = ( blocks + 3 ) * numBytes;
+					padding = ( ( headerSize % 3 ) > 0 ) ? 3 - ( headerSize % 3 ) : 0;
+					headerSize = headerSize + padding;
+
+					dataOffsets = [];
+					currentOffset = headerSize;
+					dataOffsets.push( currentOffset );
+
+					// Get the blocks sizes after the compression.
+					// There are three blocks before c-size-i, so we skip 3*numBytes
+					cSizeStart = 3 * numBytes;
+
+					for ( var i = 0; i < blocks; i ++ ) {
+
+						var currentBlockSize = byteData[ i * numBytes + cSizeStart ];
+
+						for ( var j = 1; j < numBytes - 1; j ++ ) {
+
+							// Each data point consists of 8 bytes regardless of the header type
+							currentBlockSize = currentBlockSize | ( byteData[ i * numBytes + cSizeStart + j ] << ( j * 8 ) );
 
-						// VTP data with the header has the following structure:
-						// [#blocks][#u-size][#p-size][#c-size-1][#c-size-2]...[#c-size-#blocks][DATA]
-						//
-						// Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are:
-						// [#blocks] = Number of blocks
-						// [#u-size] = Block size before compression
-						// [#p-size] = Size of last partial block (zero if it not needed)
-						// [#c-size-i] = Size in bytes of block i after compression
-						//
-						// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is 
-						// computed by summing the compressed block sizes from preceding blocks according to the header. 
-
-						rawData = ele[ '#text' ];
-
-						byteData = Base64toByteArray( rawData );
-
-						blocks = byteData[0]
-						for ( var i = 1; i<numBytes-1; i++ ) {
-							blocks = blocks | ( byteData[i] << (i*numBytes) );
 						}
 
-						headerSize = (blocks + 3) * numBytes;
-						padding = ( (headerSize % 3) > 0 ) ? 3 - (headerSize % 3) : 0;
-						headerSize = headerSize + padding;
-						
-						dataOffsets = [];
-						currentOffset = headerSize;
+						currentOffset = currentOffset + currentBlockSize;
 						dataOffsets.push( currentOffset );
 
-						// Get the blocks sizes after the compression.
-						// There are three blocks before c-size-i, so we skip 3*numBytes
-						cSizeStart = 3*numBytes;
-						for ( var i = 0; i<blocks; i++ ) {
-							var currentBlockSize = byteData[i*numBytes + cSizeStart];
-							for ( var j = 1; j<numBytes-1; j++ ) {
-								// Each data point consists of 8 bytes regardless of the header type
-								currentBlockSize = currentBlockSize | ( byteData[i*numBytes + cSizeStart + j] << (j*8) );
-							}
-							
-							currentOffset = currentOffset + currentBlockSize;
-							dataOffsets.push( currentOffset );
+					}
+
+					for ( var i = 0; i < dataOffsets.length - 1; i ++ ) {
+
+						var inflate = new Zlib.Inflate( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ), { resize: true, verify: true } ); // eslint-disable-line no-undef
+						content = inflate.decompress();
+						content = content.buffer;
+
+						if ( ele.attributes.type == 'Float32' ) {
+
+							content = new Float32Array( content );
+							txt = Float32Concat( txt, content );
+
+						} else if ( ele.attributes.type === 'Int64' ) {
+
+							content = new Int32Array( content );
+							txt = Int32Concat( txt, content );
+
 						}
 
-						for ( var i=0; i<dataOffsets.length-1; i++ ) {
-							var inflate = new Zlib.Inflate( byteData.slice( dataOffsets[i], dataOffsets[i+1] ), { resize: true, verify: true } );
-							content = inflate.decompress();
-							content = content.buffer;
-
-							if ( ele.attributes.type == 'Float32' ) {
-								content = new Float32Array( content );
-								txt = Float32Concat(txt, content);
-							} else if ( ele.attributes.type === 'Int64' ) {
-								content = new Int32Array( content );
-								txt = Int32Concat(txt, content);
+					}
+
+					delete ele[ '#text' ];
+
+					// Get the content and optimize it
+					if ( ele.attributes.type == 'Float32' ) {
+
+						if ( ele.attributes.format == 'binary' ) {
+
+							if ( ! compressed ) {
+
+								txt = txt.filter( function ( el, idx ) {
+
+									if ( idx !== 0 ) return true;
+
+								} );
+
 							}
+
 						}
 
-						delete ele[ '#text' ];
+					} else if ( ele.attributes.type === 'Int64' ) {
 
-						// Get the content and optimize it
-						if ( ele.attributes.type == 'Float32' ) {
-							if ( ele.attributes.format == 'binary' ) {
-								if ( ! compressed ) {
-									txt = txt.filter( function( el, idx, arr ) {
-										if ( idx !== 0 ) return true;
-									} );
-								}
-							}
+						if ( ele.attributes.format == 'binary' ) {
 
-						} else if ( ele.attributes.type === 'Int64' ) {
-							if ( ele.attributes.format == 'binary' ) {
-								if ( ! compressed ) {
-									txt = txt.filter( function ( el, idx, arr ) {
-										if ( idx !== 0 ) return true;
-									} );
-								}
+							if ( ! compressed ) {
+
+								txt = txt.filter( function ( el, idx ) {
+
+									if ( idx !== 0 ) return true;
 
-								txt = txt.filter( function ( el, idx, arr ) {
-									if ( idx % 2 !== 1 ) return true;
 								} );
+
 							}
+
+							txt = txt.filter( function ( el, idx ) {
+
+								if ( idx % 2 !== 1 ) return true;
+
+							} );
+
 						}
 
+					}
+
 				} else {
+
 					if ( ele.attributes.format == 'binary' && ! compressed ) {
 
 						var content = Base64toByteArray( ele[ '#text' ] );
@@ -799,16 +845,22 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						//  VTP data for the uncompressed case has the following structure:
 						// [#bytes][DATA]
 						// where "[#bytes]" is an integer value specifying the number of bytes in the block of data following it.
-						content = content.slice(numBytes).buffer;
+						content = content.slice( numBytes ).buffer;
 
 					} else {
 
 						if ( ele[ '#text' ] ) {
-							var content = ele[ '#text' ].replace( /\n/g, ' ' ).split( ' ' ).filter( function ( el, idx, arr ) {
+
+							var content = ele[ '#text' ].replace( /\n/g, ' ' ).split( ' ' ).filter( function ( el ) {
+
 								if ( el !== '' ) return el;
+
 							} );
+
 						} else {
+
 							var content = new Int32Array( 0 ).buffer;
+
 						}
 
 					}
@@ -821,13 +873,19 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						var txt = new Float32Array( content );
 
 					} else if ( ele.attributes.type === 'Int64' ) {
+
 						var txt = new Int32Array( content );
 
 						if ( ele.attributes.format == 'binary' ) {
-							txt = txt.filter( function ( el, idx, arr ) {
+
+							txt = txt.filter( function ( el, idx ) {
+
 								if ( idx % 2 !== 1 ) return true;
+
 							} );
+
 						}
+
 					}
 
 				} // endif ( ele.attributes.format == 'binary' && compressed )
@@ -856,10 +914,10 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 				try {
 
-					dom = new ActiveXObject( 'Microsoft.XMLDOM' );
+					dom = new ActiveXObject( 'Microsoft.XMLDOM' ); // eslint-disable-line no-undef
 					dom.async = false;
 
-					if ( ! dom.loadXML( xml ) ) {
+					if ( ! dom.loadXML( /* xml */ ) ) {
 
 						throw new Error( dom.parseError.reason + dom.parseError.srcText );
 
@@ -920,10 +978,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 						while ( dataArrayIndex < numberOfDataArrays ) {
 
 							// Parse the DataArray
-							if ( ('#text' in arr[ dataArrayIndex ]) && (arr[ dataArrayIndex ][ '#text' ].length > 0) ) {
+							if ( ( '#text' in arr[ dataArrayIndex ] ) && ( arr[ dataArrayIndex ][ '#text' ].length > 0 ) ) {
+
 								arr[ dataArrayIndex ].text = parseDataArray( arr[ dataArrayIndex ], compressed );
+
 							}
-								dataArrayIndex ++;
+
+							dataArrayIndex ++;
 
 						}
 
@@ -985,13 +1046,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 									var indicesIndex = 0;
 
-									for ( var i = 0,len = numberOfStrips; i < len; i ++ ) {
+									for ( var i = 0, len = numberOfStrips; i < len; i ++ ) {
 
 										var strip = [];
 
 										for ( var s = 0, len1 = offset[ i ], len0 = 0; s < len1 - len0; s ++ ) {
 
-											strip.push ( connectivity[ s ] );
+											strip.push( connectivity[ s ] );
 
 											if ( i > 0 ) len0 = offset[ i - 1 ];
 
@@ -1038,7 +1099,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 									var size = numberOfPolys + connectivity.length;
 									indices = new Uint32Array( 3 * size - 9 * numberOfPolys );
 									var indicesIndex = 0, connectivityIndex = 0;
-									var i = 0,len = numberOfPolys, len0 = 0;
+									var i = 0, len = numberOfPolys, len0 = 0;
 
 									while ( i < len ) {
 

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott