Browse Source

ColladaLoader: Clean up.

Mr.doob 10 years ago
parent
commit
df6e3f9f16
1 changed files with 49 additions and 49 deletions
  1. 49 49
      examples/js/loaders/ColladaLoader.js

+ 49 - 49
examples/js/loaders/ColladaLoader.js

@@ -66,9 +66,9 @@ THREE.ColladaLoader = function () {
 
 			request.onreadystatechange = function() {
 
-				if( request.readyState == 4 ) {
+				if( request.readyState === 4 ) {
 
-					if( request.status == 0 || request.status == 200 ) {
+					if( request.status === 0 || request.status === 200 ) {
 
 
 						if ( request.responseXML ) {
@@ -91,11 +91,11 @@ THREE.ColladaLoader = function () {
 
 					}
 
-				} else if ( request.readyState == 3 ) {
+				} else if ( request.readyState === 3 ) {
 
 					if ( progressCallback ) {
 
-						if ( length == 0 ) {
+						if ( length === 0 ) {
 
 							length = request.getResponseHeader( "Content-Length" );
 
@@ -261,7 +261,7 @@ THREE.ColladaLoader = function () {
 			var element = elements[j];
 			var daeElement = ( new classSpec() ).parse( element );
 
-			if ( !daeElement.id || daeElement.id.length == 0 ) daeElement.id = prefix + ( i ++ );
+			if ( !daeElement.id || daeElement.id.length === 0 ) daeElement.id = prefix + ( i ++ );
 			lib[ daeElement.id ] = daeElement;
 
 		}
@@ -505,7 +505,7 @@ THREE.ColladaLoader = function () {
 
 				node.world.copy( m );
 				node.localworld.copy(m);
-				if(frame == 0)
+				if(frame === 0)
 					node.matrix.copy(m);
 			}
 
@@ -540,7 +540,7 @@ THREE.ColladaLoader = function () {
 
 			for ( var j = 0; j < skin.joints.length; j ++ ) {
 
-				if ( bone.sid == skin.joints[ j ] ) {
+				if ( bone.sid === skin.joints[ j ] ) {
 
 					found = j;
 					break;
@@ -567,7 +567,7 @@ THREE.ColladaLoader = function () {
 
 						var w = skin.weights[ j ][ k ];
 
-						if ( w.joint == found ) {
+						if ( w.joint === found ) {
 
 							bone.weights.push( w );
 
@@ -704,7 +704,7 @@ THREE.ColladaLoader = function () {
 
 			for(var j =0; j < bonelist.length; j++) {
 
-				if(bonelist[j].name == joints[i]) {
+				if(bonelist[j].name === joints[i]) {
 
 					sortedbones[i] = bonelist[j];
 
@@ -719,7 +719,7 @@ THREE.ColladaLoader = function () {
 
 			for(var j =0; j < sortedbones.length; j++) {
 
-				if(sortedbones[i].parent == sortedbones[j].name) {
+				if(sortedbones[i].parent === sortedbones[j].name) {
 
 					sortedbones[i].parent = j;
 
@@ -790,13 +790,13 @@ THREE.ColladaLoader = function () {
 
 				for(var j = 0; j < animationdata.hierarchy.length; j ++) {
 
-					if(animationdata.hierarchy[j].name == bones[i].sid) {
+					if(animationdata.hierarchy[j].name === bones[i].sid) {
 
 						var key = {};
 						key.time = (frame/30);
 						key.matrix = bones[i].animatrix;
 
-						if(frame == 0)
+						if(frame === 0)
 							bones[i].matrix = key.matrix;
 
 						var data = [new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3()];
@@ -1121,7 +1121,7 @@ THREE.ColladaLoader = function () {
 				if ( !geometry.mesh || !geometry.mesh.primitives )
 					continue;
 
-				if ( obj.name.length == 0 ) {
+				if ( obj.name.length === 0 ) {
 
 					obj.name = geometry.id;
 
@@ -1157,7 +1157,7 @@ THREE.ColladaLoader = function () {
 						used_materials[ instance_material.symbol ] = num_materials;
 						used_materials_array.push( material3js );
 						first_material = material3js;
-						first_material.name = mat.name == null || mat.name === '' ? mat.id : mat.name;
+						first_material.name = mat.name === null || mat.name === '' ? mat.id : mat.name;
 						num_materials ++;
 
 					}
@@ -1329,7 +1329,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < skin.joints.length; i ++ ) {
 
-			if ( skin.joints[ i ] == id ) {
+			if ( skin.joints[ i ] === id ) {
 
 				return i;
 
@@ -1355,7 +1355,7 @@ THREE.ColladaLoader = function () {
 
 	};
 
-	function getChannelsForNode (node ) {
+	function getChannelsForNode ( node ) {
 
 		var channels = [];
 		var startTime = 1000000;
@@ -1536,7 +1536,7 @@ THREE.ColladaLoader = function () {
 
 							key = new Key( time );
 							var timeNdx = findTimeNdx( keys, time );
-							keys.splice( timeNdx == -1 ? keys.length : timeNdx, 0, key );
+							keys.splice( timeNdx === -1 ? keys.length : timeNdx, 0, key );
 
 						}
 
@@ -1582,7 +1582,7 @@ THREE.ColladaLoader = function () {
 
 		var retVal = null;
 
-		for ( var i = 0, il = keys.length; i < il && retVal == null; i++ ) {
+		for ( var i = 0, il = keys.length; i < il && retVal === null; i++ ) {
 
 			var key = keys[i];
 
@@ -1606,7 +1606,7 @@ THREE.ColladaLoader = function () {
 
 		var ndx = -1;
 
-		for ( var i = 0, il = keys.length; i < il && ndx == -1; i++ ) {
+		for ( var i = 0, il = keys.length; i < il && ndx === -1; i++ ) {
 
 			var key = keys[i];
 
@@ -1718,7 +1718,7 @@ THREE.ColladaLoader = function () {
 
 			var child = element.childNodes[ i ];
 
-			if ( child.nodeName == 'init_from' ) {
+			if ( child.nodeName === 'init_from' ) {
 
 				this.init_from = child.textContent;
 
@@ -1949,11 +1949,11 @@ THREE.ColladaLoader = function () {
 					var input = ( new Input() ).parse( child );
 					var source = sources[ input.source ];
 
-					if ( input.semantic == 'JOINT' ) {
+					if ( input.semantic === 'JOINT' ) {
 
 						this.joints = source.read();
 
-					} else if ( input.semantic == 'INV_BIND_MATRIX' ) {
+					} else if ( input.semantic === 'INV_BIND_MATRIX' ) {
 
 						this.invBindMatrices = source.read();
 
@@ -2058,7 +2058,7 @@ THREE.ColladaLoader = function () {
 		this.id = "";
 		this.name = "";
 		this.nodes = [];
-		this.scene = new THREE.Object3D();
+		this.scene = new THREE.Scene();
 
 	};
 
@@ -2173,7 +2173,7 @@ THREE.ColladaLoader = function () {
 
 			}
 
-			if ( sid == transformSid ) {
+			if ( sid === transformSid ) {
 
 				channel.info = { sid: sid, dotSyntax: dotSyntax, arrSyntax: arrSyntax, arrIndices: arrIndices };
 				return channel;
@@ -2188,7 +2188,7 @@ THREE.ColladaLoader = function () {
 
 	Node.prototype.getChildById = function ( id, recursive ) {
 
-		if ( this.id == id ) {
+		if ( this.id === id ) {
 
 			return this;
 
@@ -2216,7 +2216,7 @@ THREE.ColladaLoader = function () {
 
 	Node.prototype.getChildBySid = function ( sid, recursive ) {
 
-		if ( this.sid == sid ) {
+		if ( this.sid === sid ) {
 
 			return this;
 
@@ -2245,7 +2245,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < this.transforms.length; i ++ ) {
 
-			if ( this.transforms[ i ].sid == sid ) return this.transforms[ i ];
+			if ( this.transforms[ i ].sid === sid ) return this.transforms[ i ];
 
 		}
 
@@ -2263,7 +2263,7 @@ THREE.ColladaLoader = function () {
 		this.type = element.getAttribute('type');
 		this.layer = element.getAttribute('layer');
 
-		this.type = this.type == 'JOINT' ? this.type : 'NODE';
+		this.type = this.type === 'JOINT' ? this.type : 'NODE';
 
 		this.nodes = [];
 		this.transforms = [];
@@ -2686,7 +2686,7 @@ THREE.ColladaLoader = function () {
 			var child = element.childNodes[i];
 			if ( child.nodeType != 1 ) continue;
 
-			if ( child.nodeName == 'bind_material' ) {
+			if ( child.nodeName === 'bind_material' ) {
 
 				var instances = child.querySelectorAll('instance_material');
 
@@ -2928,7 +2928,7 @@ THREE.ColladaLoader = function () {
 
 				}
 
-				if ( ns.length == 0 ) {
+				if ( ns.length === 0 ) {
 
 					// check the vertices inputs
 					input = this.vertices.input.NORMAL;
@@ -2977,7 +2977,7 @@ THREE.ColladaLoader = function () {
 
 				}
 
-				if ( cs.length == 0 ) {
+				if ( cs.length === 0 ) {
 
 					// check the vertices inputs
 					input = this.vertices.input.COLOR;
@@ -3102,7 +3102,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < this.inputs.length; i ++ ) {
 
-			if ( this.inputs[ i ].source == vertices.id ) {
+			if ( this.inputs[ i ].source === vertices.id ) {
 
 				this.inputs[ i ].source = vertices.input[ 'POSITION' ].source;
 
@@ -3194,7 +3194,7 @@ THREE.ColladaLoader = function () {
 
 			var child = element.childNodes[ i ];
 
-			if ( child.nodeName == 'param' ) {
+			if ( child.nodeName === 'param' ) {
 
 				var param = {};
 				param[ 'name' ] = child.getAttribute( 'name' );
@@ -3221,7 +3221,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
-			if ( element.childNodes[i].nodeName == 'input' ) {
+			if ( element.childNodes[i].nodeName === 'input' ) {
 
 				var input = ( new Input() ).parse( element.childNodes[ i ] );
 				this.input[ input.semantic ] = input;
@@ -3250,7 +3250,7 @@ THREE.ColladaLoader = function () {
 		this.set = _attr_as_int(element, 'set', -1);
 		this.offset = _attr_as_int(element, 'offset', 0);
 
-		if ( this.semantic == 'TEXCOORD' && this.set < 0 ) {
+		if ( this.semantic === 'TEXCOORD' && this.set < 0 ) {
 
 			this.set = 0;
 
@@ -3306,7 +3306,7 @@ THREE.ColladaLoader = function () {
 
 					for ( var j = 0; j < child.childNodes.length; j ++ ) {
 
-						if ( child.childNodes[ j ].nodeName == 'accessor' ) {
+						if ( child.childNodes[ j ].nodeName === 'accessor' ) {
 
 							this.accessor = ( new Accessor() ).parse( child.childNodes[ j ] );
 							break;
@@ -3384,7 +3384,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
-			if ( element.childNodes[ i ].nodeName == 'instance_effect' ) {
+			if ( element.childNodes[ i ].nodeName === 'instance_effect' ) {
 
 				this.instance_effect = ( new InstanceEffect() ).parse( element.childNodes[ i ] );
 				break;
@@ -3411,7 +3411,7 @@ THREE.ColladaLoader = function () {
 
 	ColorOrTexture.prototype.isColor = function () {
 
-		return ( this.texture == null );
+		return ( this.texture === null );
 
 	};
 
@@ -3423,7 +3423,7 @@ THREE.ColladaLoader = function () {
 
 	ColorOrTexture.prototype.parse = function ( element ) {
 
-		if (element.nodeName == 'transparent') {
+		if (element.nodeName === 'transparent') {
 
 			this.opaque = element.getAttribute('opaque');
 
@@ -3895,7 +3895,7 @@ THREE.ColladaLoader = function () {
 
 	Effect.prototype.create = function () {
 
-		if ( this.shader == null ) {
+		if ( this.shader === null ) {
 
 			return null;
 
@@ -4386,7 +4386,7 @@ THREE.ColladaLoader = function () {
 
 			data = this.output[ ndx ];
 
-			if ( member && type == 'translate' ) {
+			if ( member && type === 'translate' ) {
 				data = getConvertedTranslation( member, data );
 			}
 
@@ -4549,7 +4549,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
-			if ( element.childNodes[ i ].nodeName == 'technique_common' ) {
+			if ( element.childNodes[ i ].nodeName === 'technique_common' ) {
 
 				var technique = element.childNodes[ i ];
 
@@ -4557,7 +4557,7 @@ THREE.ColladaLoader = function () {
 
 					this.technique = technique.childNodes[ j ].nodeName;
 
-					if ( this.technique == 'perspective' ) {
+					if ( this.technique === 'perspective' ) {
 
 						var perspective = technique.childNodes[ j ];
 
@@ -4587,7 +4587,7 @@ THREE.ColladaLoader = function () {
 
 						}
 
-					} else if ( this.technique == 'orthographic' ) {
+					} else if ( this.technique === 'orthographic' ) {
 
 						var orthographic = technique.childNodes[ j ];
 
@@ -5014,7 +5014,7 @@ THREE.ColladaLoader = function () {
 
 	function _nsResolver( nsPrefix ) {
 
-		if ( nsPrefix == "dae" ) {
+		if ( nsPrefix === "dae" ) {
 
 			return "http://www.collada.org/2005/11/COLLADASchema";
 
@@ -5031,7 +5031,7 @@ THREE.ColladaLoader = function () {
 
 		for ( var i = 0, l = raw.length; i < l; i ++ ) {
 
-			data.push( (raw[i] == 'true' || raw[i] == '1') ? true : false );
+			data.push( (raw[i] === 'true' || raw[i] === '1') ? true : false );
 
 		}
 
@@ -5286,13 +5286,13 @@ THREE.ColladaLoader = function () {
 
 		switch ( axis ) {
 			case 'X':
-				data = upConversion == 'XtoY' ? data * -1 : data;
+				data = upConversion === 'XtoY' ? data * -1 : data;
 				break;
 			case 'Y':
-				data = upConversion == 'YtoZ' || upConversion == 'YtoX' ? data * -1 : data;
+				data = upConversion === 'YtoZ' || upConversion === 'YtoX' ? data * -1 : data;
 				break;
 			case 'Z':
-				data = upConversion == 'ZtoY' ? data * -1 : data ;
+				data = upConversion === 'ZtoY' ? data * -1 : data ;
 				break;
 			default:
 				break;