Преглед изворни кода

Revert conflicting cleanup.

tschw пре 9 година
родитељ
комит
70f29cc240

+ 22 - 21
src/animation/AnimationAction.js

@@ -1,14 +1,14 @@
 /**
 /**
  *
  *
  * A clip that has been explicitly scheduled.
  * A clip that has been explicitly scheduled.
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
 
 
 THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
 THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
 
 
-	if ( clip === undefined ) throw new Error( 'clip is null' );
+	if( clip === undefined ) throw new Error( 'clip is null' );
 	this.clip = clip;
 	this.clip = clip;
 	this.localRoot = null;
 	this.localRoot = null;
 	this.startTime = startTime || 0;
 	this.startTime = startTime || 0;
@@ -39,7 +39,7 @@ THREE.AnimationAction.prototype = {
 		this.localRoot = localRoot;
 		this.localRoot = localRoot;
 
 
 		return this;
 		return this;
-
+		
 	},
 	},
 
 
 	updateTime: function( clipDeltaTime ) {
 	updateTime: function( clipDeltaTime ) {
@@ -49,22 +49,23 @@ THREE.AnimationAction.prototype = {
    		var previousActionTime = this.actionTime;
    		var previousActionTime = this.actionTime;
 
 
 		var duration = this.clip.duration;
 		var duration = this.clip.duration;
-
+	
 		this.actionTime = this.actionTime + clipDeltaTime;
 		this.actionTime = this.actionTime + clipDeltaTime;
-
-		if ( this.loop === THREE.LoopOnce ) {
+	
+		if( this.loop === THREE.LoopOnce ) {
 
 
 			this.loopCount = 0;
 			this.loopCount = 0;
 			this.clipTime = Math.min( Math.max( this.actionTime, 0 ), duration );
 			this.clipTime = Math.min( Math.max( this.actionTime, 0 ), duration );
-
+	
 			// if time is changed since last time, see if we have hit a start/end limit
 			// if time is changed since last time, see if we have hit a start/end limit
-			if ( this.clipTime !== previousClipTime ) {
+			if( this.clipTime !== previousClipTime ) {
 
 
-				if ( this.clipTime === duration ) {
+				if( this.clipTime === duration ) {
 
 
 					this.mixer.dispatchEvent( { type: 'finished', action: this, direction: 1 } );
 					this.mixer.dispatchEvent( { type: 'finished', action: this, direction: 1 } );
 
 
-				} else if ( this.clipTime === 0 ) {
+				}
+				else if( this.clipTime === 0 ) {
 
 
 					this.mixer.dispatchEvent( { type: 'finished', action: this, direction: -1 } );
 					this.mixer.dispatchEvent( { type: 'finished', action: this, direction: -1 } );
 
 
@@ -72,20 +73,20 @@ THREE.AnimationAction.prototype = {
 
 
 			}
 			}
 
 
-
+		
 			return this.clipTime;
 			return this.clipTime;
 
 
 		}
 		}
-
+		
 		this.loopCount = Math.floor( this.actionTime / duration );
 		this.loopCount = Math.floor( this.actionTime / duration );
-
+	
 		var newClipTime = this.actionTime - this.loopCount * duration;
 		var newClipTime = this.actionTime - this.loopCount * duration;
 		newClipTime = newClipTime % duration;
 		newClipTime = newClipTime % duration;
-
+	
 		// if we are ping pong looping, ensure that we go backwards when appropriate
 		// if we are ping pong looping, ensure that we go backwards when appropriate
-		if ( this.loop == THREE.LoopPingPong ) {
+		if( this.loop == THREE.LoopPingPong ) {
 
 
-			if ( Math.abs( this.loopCount % 2 ) === 1 ) {
+			if( Math.abs( this.loopCount % 2 ) === 1 ) {
 
 
 				newClipTime = duration - newClipTime;
 				newClipTime = duration - newClipTime;
 
 
@@ -95,12 +96,12 @@ THREE.AnimationAction.prototype = {
 
 
 		this.clipTime = newClipTime;
 		this.clipTime = newClipTime;
 
 
-		if ( this.loopCount !== previousLoopCount ) {
+		if( this.loopCount !== previousLoopCount ) {
 
 
    			this.mixer.dispatchEvent( { type: 'loop', action: this, loopDelta: ( this.loopCount - this.loopCount ) } );
    			this.mixer.dispatchEvent( { type: 'loop', action: this, loopDelta: ( this.loopCount - this.loopCount ) } );
 
 
    		}
    		}
-
+	
 	   	return this.clipTime;
 	   	return this.clipTime;
 
 
 	},
 	},
@@ -135,12 +136,12 @@ THREE.AnimationAction.prototype = {
 		var clipResults = this.clip.getAt( this.clipTime );
 		var clipResults = this.clip.getAt( this.clipTime );
 
 
 		return clipResults;
 		return clipResults;
-
+		
 	},
 	},
 
 
 	getTimeScaleAt: function( time ) {
 	getTimeScaleAt: function( time ) {
 
 
-		if ( this.timeScale.getAt ) {
+		if( this.timeScale.getAt ) {
 			// pass in time, not clip time, allows for fadein/fadeout across multiple loops of the clip
 			// pass in time, not clip time, allows for fadein/fadeout across multiple loops of the clip
 			return this.timeScale.getAt( time );
 			return this.timeScale.getAt( time );
 
 
@@ -152,7 +153,7 @@ THREE.AnimationAction.prototype = {
 
 
 	getWeightAt: function( time ) {
 	getWeightAt: function( time ) {
 
 
-		if ( this.weight.getAt ) {
+		if( this.weight.getAt ) {
 			// pass in time, not clip time, allows for fadein/fadeout across multiple loops of the clip
 			// pass in time, not clip time, allows for fadein/fadeout across multiple loops of the clip
 			return this.weight.getAt( time );
 			return this.weight.getAt( time );
 
 

+ 33 - 31
src/animation/AnimationClip.js

@@ -13,8 +13,8 @@ THREE.AnimationClip = function ( name, duration, tracks ) {
 	this.duration = ( duration !== undefined ) ? duration : -1;
 	this.duration = ( duration !== undefined ) ? duration : -1;
 
 
 	// this means it should figure out its duration by scanning the tracks
 	// this means it should figure out its duration by scanning the tracks
-	if ( this.duration < 0 ) {
-		for ( var i = 0; i < this.tracks.length; i ++ ) {
+	if( this.duration < 0 ) {
+		for( var i = 0; i < this.tracks.length; i ++ ) {
 			var track = this.tracks[i];
 			var track = this.tracks[i];
 			this.duration = Math.max( track.keys[ track.keys.length - 1 ].time );
 			this.duration = Math.max( track.keys[ track.keys.length - 1 ].time );
 		}
 		}
@@ -37,7 +37,7 @@ THREE.AnimationClip.prototype = {
 
 
 		clipTime = Math.max( 0, Math.min( clipTime, this.duration ) );
 		clipTime = Math.max( 0, Math.min( clipTime, this.duration ) );
 
 
-		for ( var i = 0; i < this.tracks.length; i ++ ) {
+		for( var i = 0; i < this.tracks.length; i ++ ) {
 
 
 			var track = this.tracks[ i ];
 			var track = this.tracks[ i ];
 
 
@@ -50,7 +50,7 @@ THREE.AnimationClip.prototype = {
 
 
 	trim: function() {
 	trim: function() {
 
 
-		for ( var i = 0; i < this.tracks.length; i ++ ) {
+		for( var i = 0; i < this.tracks.length; i ++ ) {
 
 
 			this.tracks[ i ].trim( 0, this.duration );
 			this.tracks[ i ].trim( 0, this.duration );
 
 
@@ -62,7 +62,7 @@ THREE.AnimationClip.prototype = {
 
 
 	optimize: function() {
 	optimize: function() {
 
 
-		for ( var i = 0; i < this.tracks.length; i ++ ) {
+		for( var i = 0; i < this.tracks.length; i ++ ) {
 
 
 			this.tracks[ i ].optimize();
 			this.tracks[ i ].optimize();
 
 
@@ -81,7 +81,7 @@ THREE.AnimationClip.CreateFromMorphTargetSequence = function( name, morphTargetS
 	var numMorphTargets = morphTargetSequence.length;
 	var numMorphTargets = morphTargetSequence.length;
 	var tracks = [];
 	var tracks = [];
 
 
-	for ( var i = 0; i < numMorphTargets; i ++ ) {
+	for( var i = 0; i < numMorphTargets; i ++ ) {
 
 
 		var keys = [];
 		var keys = [];
 
 
@@ -92,7 +92,7 @@ THREE.AnimationClip.CreateFromMorphTargetSequence = function( name, morphTargetS
 		keys.sort( THREE.KeyframeTrack.keyComparer );
 		keys.sort( THREE.KeyframeTrack.keyComparer );
 
 
 		// if there is a key at the first frame, duplicate it as the last frame as well for perfect loop.
 		// if there is a key at the first frame, duplicate it as the last frame as well for perfect loop.
-		if ( keys[0].time === 0 ) {
+		if( keys[0].time === 0 ) {
 			keys.push( {
 			keys.push( {
 				time: numMorphTargets,
 				time: numMorphTargets,
 				value: keys[0].value
 				value: keys[0].value
@@ -108,9 +108,9 @@ THREE.AnimationClip.CreateFromMorphTargetSequence = function( name, morphTargetS
 
 
 THREE.AnimationClip.findByName = function( clipArray, name ) {
 THREE.AnimationClip.findByName = function( clipArray, name ) {
 
 
-	for ( var i = 0; i < clipArray.length; i ++ ) {
+	for( var i = 0; i < clipArray.length; i ++ ) {
 
 
-		if ( clipArray[i].name === name ) {
+		if( clipArray[i].name === name ) {
 
 
 			return clipArray[i];
 			return clipArray[i];
 
 
@@ -139,7 +139,7 @@ THREE.AnimationClip.CreateClipsFromMorphTargetSequences = function( morphTargets
 			var name = parts[ 1 ];
 			var name = parts[ 1 ];
 
 
 			var animationMorphTargets = animationToMorphTargets[ name ];
 			var animationMorphTargets = animationToMorphTargets[ name ];
-			if ( ! animationMorphTargets ) {
+			if( ! animationMorphTargets ) {
 				animationToMorphTargets[ name ] = animationMorphTargets = [];
 				animationToMorphTargets[ name ] = animationMorphTargets = [];
 			}
 			}
 
 
@@ -151,7 +151,7 @@ THREE.AnimationClip.CreateClipsFromMorphTargetSequences = function( morphTargets
 
 
 	var clips = [];
 	var clips = [];
 
 
-	for ( var name in animationToMorphTargets ) {
+	for( var name in animationToMorphTargets ) {
 
 
 		clips.push( THREE.AnimationClip.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps ) );
 		clips.push( THREE.AnimationClip.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps ) );
 	}
 	}
@@ -165,7 +165,7 @@ THREE.AnimationClip.parse = function( json ) {
 
 
 	var tracks = [];
 	var tracks = [];
 
 
-	for ( var i = 0; i < json.tracks.length; i ++ ) {
+	for( var i = 0; i < json.tracks.length; i ++ ) {
 
 
 		tracks.push( THREE.KeyframeTrack.parse( json.tracks[i] ).scale( 1.0 / json.fps ) );
 		tracks.push( THREE.KeyframeTrack.parse( json.tracks[i] ).scale( 1.0 / json.fps ) );
 
 
@@ -179,7 +179,7 @@ THREE.AnimationClip.parse = function( json ) {
 // parse the animation.hierarchy format
 // parse the animation.hierarchy format
 THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 
 
-	if ( ! animation ) {
+	if( ! animation ) {
 		console.error( "  no animation in JSONLoader data" );
 		console.error( "  no animation in JSONLoader data" );
 		return null;
 		return null;
 	}
 	}
@@ -188,11 +188,11 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 
 
 		var keys = [];
 		var keys = [];
 
 
-		for ( var k = 0; k < animationKeys.length; k ++ ) {
+		for( var k = 0; k < animationKeys.length; k ++ ) {
 
 
 			var animationKey = animationKeys[k];
 			var animationKey = animationKeys[k];
 
 
-			if ( animationKey[propertyName] !== undefined ) {
+			if( animationKey[propertyName] !== undefined ) {
 
 
 				keys.push( { time: animationKey.time, value: animationKeyToValueFunc( animationKey ) } );
 				keys.push( { time: animationKey.time, value: animationKeyToValueFunc( animationKey ) } );
 			}
 			}
@@ -200,7 +200,7 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 		}
 		}
 
 
 		// only return track if there are actually keys.
 		// only return track if there are actually keys.
-		if ( keys.length > 0 ) {
+		if( keys.length > 0 ) {
 
 
 			return new trackType( trackName, keys );
 			return new trackType( trackName, keys );
 
 
@@ -211,7 +211,7 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 	};
 	};
 
 
 	var tracks = [];
 	var tracks = [];
-	
+
 	var clipName = animation.name || 'default';
 	var clipName = animation.name || 'default';
 	var duration = animation.length || -1; // automatic length determination in AnimationClip.
 	var duration = animation.length || -1; // automatic length determination in AnimationClip.
 	var fps = animation.fps || 30;
 	var fps = animation.fps || 30;
@@ -223,19 +223,19 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 		var animationKeys = hierarchyTracks[ h ].keys;
 		var animationKeys = hierarchyTracks[ h ].keys;
 
 
 		// skip empty tracks
 		// skip empty tracks
-		if ( ! animationKeys || animationKeys.length == 0 ) {
+		if( ! animationKeys || animationKeys.length == 0 ) {
 			continue;
 			continue;
 		}
 		}
 
 
 		// process morph targets in a way exactly compatible with AnimationHandler.init( animation )
 		// process morph targets in a way exactly compatible with AnimationHandler.init( animation )
-		if ( animationKeys[0].morphTargets ) {
+		if( animationKeys[0].morphTargets ) {
 
 
 			// figure out all morph targets used in this track
 			// figure out all morph targets used in this track
 			var morphTargetNames = {};
 			var morphTargetNames = {};
-			for ( var k = 0; k < animationKeys.length; k ++ ) {
+			for( var k = 0; k < animationKeys.length; k ++ ) {
 
 
-				if ( animationKeys[k].morphTargets ) {
-					for ( var m = 0; m < animationKeys[k].morphTargets.length; m ++ ) {
+				if( animationKeys[k].morphTargets ) {
+					for( var m = 0; m < animationKeys[k].morphTargets.length; m ++ ) {
 
 
 						morphTargetNames[ animationKeys[k].morphTargets[m] ] = -1;
 						morphTargetNames[ animationKeys[k].morphTargets[m] ] = -1;
 					}
 					}
@@ -244,11 +244,11 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 			}
 			}
 
 
 			// create a track for each morph target with all zero morphTargetInfluences except for the keys in which the morphTarget is named.
 			// create a track for each morph target with all zero morphTargetInfluences except for the keys in which the morphTarget is named.
-			for ( var morphTargetName in morphTargetNames ) {
+			for( var morphTargetName in morphTargetNames ) {
 
 
 				var keys = [];
 				var keys = [];
 
 
-				for ( var m = 0; m < animationKeys[k].morphTargets.length; m ++ ) {
+				for( var m = 0; m < animationKeys[k].morphTargets.length; m ++ ) {
 
 
 					var animationKey = animationKeys[k];
 					var animationKey = animationKeys[k];
 
 
@@ -265,7 +265,8 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 
 
 			duration = morphTargetNames.length * ( fps || 1.0 );
 			duration = morphTargetNames.length * ( fps || 1.0 );
 
 
-		} else {
+		}
+		else {
 
 
 			var boneName = '.bones[' + bones[ h ].name + ']';
 			var boneName = '.bones[' + bones[ h ].name + ']';
 
 
@@ -274,30 +275,31 @@ THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 					return new THREE.Vector3().fromArray( animationKey.pos )
 					return new THREE.Vector3().fromArray( animationKey.pos )
 				} );
 				} );
 
 
-			if ( positionTrack ) tracks.push( positionTrack );
+			if( positionTrack ) tracks.push( positionTrack );
 
 
 			// track contains quaternions...
 			// track contains quaternions...
 			var quaternionTrack = convertTrack( boneName + '.quaternion', animationKeys, 'rot', THREE.QuaternionKeyframeTrack, function( animationKey ) {
 			var quaternionTrack = convertTrack( boneName + '.quaternion', animationKeys, 'rot', THREE.QuaternionKeyframeTrack, function( animationKey ) {
-					if ( animationKey.rot.slerp ) {
+					if( animationKey.rot.slerp ) {
 						return animationKey.rot.clone();
 						return animationKey.rot.clone();
-					} else {
+					}
+					else {
 						return new THREE.Quaternion().fromArray( animationKey.rot );
 						return new THREE.Quaternion().fromArray( animationKey.rot );
 					}
 					}
 				} );
 				} );
 
 
-			if ( quaternionTrack ) tracks.push( quaternionTrack );
+			if( quaternionTrack ) tracks.push( quaternionTrack );
 
 
 			// track contains quaternions...
 			// track contains quaternions...
 			var scaleTrack = convertTrack( boneName + '.scale', animationKeys, 'scl', THREE.VectorKeyframeTrack, function( animationKey ) {
 			var scaleTrack = convertTrack( boneName + '.scale', animationKeys, 'scl', THREE.VectorKeyframeTrack, function( animationKey ) {
 					return new THREE.Vector3().fromArray( animationKey.scl )
 					return new THREE.Vector3().fromArray( animationKey.scl )
 				} );
 				} );
 
 
-			if ( scaleTrack ) tracks.push( scaleTrack );
+			if( scaleTrack ) tracks.push( scaleTrack );
 
 
 		}
 		}
 	}
 	}
 
 
-	if ( tracks.length === 0 ) {
+	if( tracks.length === 0 ) {
 
 
 		return null;
 		return null;
 
 

+ 32 - 32
src/animation/AnimationMixer.js

@@ -33,23 +33,23 @@ THREE.AnimationMixer.prototype = {
 
 
 		var root = action.localRoot || this.root;
 		var root = action.localRoot || this.root;
 
 
-		for ( var i = 0; i < tracks.length; i ++ ) {
+		for( var i = 0; i < tracks.length; i ++ ) {
 
 
 			var track = tracks[ i ];
 			var track = tracks[ i ];
 
 
-			var propertyBindingKey = root.uuid + '-' + track.name;
+			var propertyBindingKey = root.uuid + '-' + track.name;			
 			var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
 			var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
 
 
-			if ( propertyBinding === undefined ) {
-
+			if( propertyBinding === undefined ) {
+			
 				propertyBinding = new THREE.PropertyBinding( root, track.name );
 				propertyBinding = new THREE.PropertyBinding( root, track.name );
 				this.propertyBindingMap[ propertyBindingKey ] = propertyBinding;
 				this.propertyBindingMap[ propertyBindingKey ] = propertyBinding;
-
+			
 			}
 			}
 
 
 			// push in the same order as the tracks.
 			// push in the same order as the tracks.
 			action.propertyBindings.push( propertyBinding );
 			action.propertyBindings.push( propertyBinding );
-
+			
 			// track usages of shared property bindings, because if we leave too many around, the mixer can get slow
 			// track usages of shared property bindings, because if we leave too many around, the mixer can get slow
 			propertyBinding.referenceCount += 1;
 			propertyBinding.referenceCount += 1;
 
 
@@ -59,14 +59,14 @@ THREE.AnimationMixer.prototype = {
 
 
 	removeAllActions: function() {
 	removeAllActions: function() {
 
 
-		for ( var i = 0; i < this.actions.length; i ++ ) {
+		for( var i = 0; i < this.actions.length; i ++ ) {
 
 
 			this.actions[i].mixer = null;
 			this.actions[i].mixer = null;
-
+			
 		}
 		}
 
 
 		// unbind all property bindings
 		// unbind all property bindings
-		for ( var properyBindingKey in this.propertyBindingMap ) {
+		for( var properyBindingKey in this.propertyBindingMap ) {
 
 
 			this.propertyBindingMap[ properyBindingKey ].unbind();
 			this.propertyBindingMap[ properyBindingKey ].unbind();
 
 
@@ -95,16 +95,16 @@ THREE.AnimationMixer.prototype = {
 		var root = action.localRoot || this.root;
 		var root = action.localRoot || this.root;
 		var tracks = action.clip.tracks;
 		var tracks = action.clip.tracks;
 
 
-		for ( var i = 0; i < tracks.length; i ++ ) {
-
+		for( var i = 0; i < tracks.length; i ++ ) {
+		
 			var track = tracks[ i ];
 			var track = tracks[ i ];
 
 
-			var propertyBindingKey = root.uuid + '-' + track.name;
+			var propertyBindingKey = root.uuid + '-' + track.name;			
 			var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
 			var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
-
+	
 			propertyBinding.referenceCount -= 1;
 			propertyBinding.referenceCount -= 1;
 
 
-			if ( propertyBinding.referenceCount <= 0 ) {
+			if( propertyBinding.referenceCount <= 0 ) {
 
 
 				propertyBinding.unbind();
 				propertyBinding.unbind();
 
 
@@ -120,9 +120,9 @@ THREE.AnimationMixer.prototype = {
 	// can be optimized if needed
 	// can be optimized if needed
 	findActionByName: function( name ) {
 	findActionByName: function( name ) {
 
 
-		for ( var i = 0; i < this.actions.length; i ++ ) {
+		for( var i = 0; i < this.actions.length; i ++ ) {
 
 
-			if ( this.actions[i].name === name ) return this.actions[i];
+			if( this.actions[i].name === name ) return this.actions[i];
 
 
 		}
 		}
 
 
@@ -145,7 +145,7 @@ THREE.AnimationMixer.prototype = {
 
 
 		keys.push( { time: this.time, value: 1 } );
 		keys.push( { time: this.time, value: 1 } );
 		keys.push( { time: this.time + duration, value: 0 } );
 		keys.push( { time: this.time + duration, value: 0 } );
-
+		
 		action.weight = new THREE.NumberKeyframeTrack( "weight", keys );
 		action.weight = new THREE.NumberKeyframeTrack( "weight", keys );
 
 
 		return this;
 		return this;
@@ -153,12 +153,12 @@ THREE.AnimationMixer.prototype = {
 	},
 	},
 
 
 	fadeIn: function( action, duration ) {
 	fadeIn: function( action, duration ) {
-
+		
 		var keys = [];
 		var keys = [];
-
+		
 		keys.push( { time: this.time, value: 0 } );
 		keys.push( { time: this.time, value: 0 } );
 		keys.push( { time: this.time + duration, value: 1 } );
 		keys.push( { time: this.time + duration, value: 1 } );
-
+		
 		action.weight = new THREE.NumberKeyframeTrack( "weight", keys );
 		action.weight = new THREE.NumberKeyframeTrack( "weight", keys );
 
 
 		return this;
 		return this;
@@ -168,10 +168,10 @@ THREE.AnimationMixer.prototype = {
 	warp: function( action, startTimeScale, endTimeScale, duration ) {
 	warp: function( action, startTimeScale, endTimeScale, duration ) {
 
 
 		var keys = [];
 		var keys = [];
-
+		
 		keys.push( { time: this.time, value: startTimeScale } );
 		keys.push( { time: this.time, value: startTimeScale } );
 		keys.push( { time: this.time + duration, value: endTimeScale } );
 		keys.push( { time: this.time + duration, value: endTimeScale } );
-
+		
 		action.timeScale = new THREE.NumberKeyframeTrack( "timeScale", keys );
 		action.timeScale = new THREE.NumberKeyframeTrack( "timeScale", keys );
 
 
 		return this;
 		return this;
@@ -183,8 +183,8 @@ THREE.AnimationMixer.prototype = {
 		this.fadeOut( fadeOutAction, duration );
 		this.fadeOut( fadeOutAction, duration );
 		this.fadeIn( fadeInAction, duration );
 		this.fadeIn( fadeInAction, duration );
 
 
-		if ( warp ) {
-
+		if( warp ) {
+	
 			var startEndRatio = fadeOutAction.clip.duration / fadeInAction.clip.duration;
 			var startEndRatio = fadeOutAction.clip.duration / fadeInAction.clip.duration;
 			var endStartRatio = 1.0 / startEndRatio;
 			var endStartRatio = 1.0 / startEndRatio;
 
 
@@ -194,7 +194,7 @@ THREE.AnimationMixer.prototype = {
 		}
 		}
 
 
 		return this;
 		return this;
-
+		
 	},
 	},
 
 
 	update: function( deltaTime ) {
 	update: function( deltaTime ) {
@@ -202,7 +202,7 @@ THREE.AnimationMixer.prototype = {
 		var mixerDeltaTime = deltaTime * this.timeScale;
 		var mixerDeltaTime = deltaTime * this.timeScale;
 		this.time += mixerDeltaTime;
 		this.time += mixerDeltaTime;
 
 
-		for ( var i = 0; i < this.actions.length; i ++ ) {
+		for( var i = 0; i < this.actions.length; i ++ ) {
 
 
 			var action = this.actions[i];
 			var action = this.actions[i];
 
 
@@ -210,12 +210,12 @@ THREE.AnimationMixer.prototype = {
 
 
 			var actionTimeScale = action.getTimeScaleAt( this.time );
 			var actionTimeScale = action.getTimeScaleAt( this.time );
 			var actionDeltaTime = mixerDeltaTime * actionTimeScale;
 			var actionDeltaTime = mixerDeltaTime * actionTimeScale;
-
+		
 			var actionResults = action.update( actionDeltaTime );
 			var actionResults = action.update( actionDeltaTime );
 
 
-			if ( action.weight <= 0 || ! action.enabled ) continue;
+			if( action.weight <= 0 || ! action.enabled ) continue;
 
 
-			for ( var j = 0; j < actionResults.length; j ++ ) {
+			for( var j = 0; j < actionResults.length; j ++ ) {
 
 
 				var name = action.clip.tracks[j].name;
 				var name = action.clip.tracks[j].name;
 
 
@@ -224,16 +224,16 @@ THREE.AnimationMixer.prototype = {
 			}
 			}
 
 
 		}
 		}
-
+	
 		// apply to nodes
 		// apply to nodes
-		for ( var propertyBindingKey in this.propertyBindingMap ) {
+		for( var propertyBindingKey in this.propertyBindingMap ) {
 
 
 			this.propertyBindingMap[ propertyBindingKey ].apply();
 			this.propertyBindingMap[ propertyBindingKey ].apply();
 
 
 		}
 		}
 
 
 		return this;
 		return this;
-
+		
 	}
 	}
 
 
 };
 };

+ 39 - 35
src/animation/AnimationUtils.js

@@ -3,27 +3,27 @@
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
 
 
-THREE.AnimationUtils = {
+ THREE.AnimationUtils = {
 
 
-	getEqualsFunc: function( exemplarValue ) {
+ 	getEqualsFunc: function( exemplarValue ) {
 
 
-		if ( exemplarValue.equals ) {
+		if( exemplarValue.equals ) {
 			return function equals_object( a, b ) {
 			return function equals_object( a, b ) {
 				return a.equals( b );
 				return a.equals( b );
 			}
 			}
 		}
 		}
 
 
 		return function equals_primitive( a, b ) {
 		return function equals_primitive( a, b ) {
-			return ( a === b );
+			return ( a === b );	
 		};
 		};
 
 
 	},
 	},
 
 
-	clone: function( exemplarValue ) {
+ 	clone: function( exemplarValue ) {
 
 
-		var typeName = typeof exemplarValue;
-		if ( typeName === "object" ) {
-			if ( exemplarValue.clone ) {
+ 		var typeName = typeof exemplarValue;
+		if( typeName === "object" ) {
+			if( exemplarValue.clone ) {
 				return exemplarValue.clone();
 				return exemplarValue.clone();
 			}
 			}
 			console.error( "can not figure out how to copy exemplarValue", exemplarValue );
 			console.error( "can not figure out how to copy exemplarValue", exemplarValue );
@@ -33,7 +33,7 @@ THREE.AnimationUtils = {
 
 
 	},
 	},
 
 
-	lerp: function( a, b, alpha, interTrack ) {
+ 	lerp: function( a, b, alpha, interTrack ) {
 
 
 		var lerpFunc = THREE.AnimationUtils.getLerpFunc( a, interTrack );
 		var lerpFunc = THREE.AnimationUtils.getLerpFunc( a, interTrack );
 
 
@@ -44,7 +44,7 @@ THREE.AnimationUtils = {
 	lerp_object: function( a, b, alpha ) {
 	lerp_object: function( a, b, alpha ) {
 		return a.lerp( b, alpha );
 		return a.lerp( b, alpha );
 	},
 	},
-
+	
 	slerp_object: function( a, b, alpha ) {
 	slerp_object: function( a, b, alpha ) {
 		return a.slerp( b, alpha );
 		return a.slerp( b, alpha );
 	},
 	},
@@ -60,53 +60,57 @@ THREE.AnimationUtils = {
 	lerp_boolean_immediate: function( a, b, alpha ) {
 	lerp_boolean_immediate: function( a, b, alpha ) {
 		return a;
 		return a;
 	},
 	},
-
+	
 	lerp_string: function( a, b, alpha ) {
 	lerp_string: function( a, b, alpha ) {
 		return ( alpha < 0.5 ) ? a : b;
 		return ( alpha < 0.5 ) ? a : b;
 	},
 	},
-
+	
 	lerp_string_immediate: function( a, b, alpha ) {
 	lerp_string_immediate: function( a, b, alpha ) {
- 		return a;
+ 		return a;		 		
  	},
  	},
 
 
-	// NOTE: this is an accumulator function that modifies the first argument (e.g. a).	This is to minimize memory alocations.
+	// NOTE: this is an accumulator function that modifies the first argument (e.g. a).  This is to minimize memory alocations.
 	getLerpFunc: function( exemplarValue, interTrack ) {
 	getLerpFunc: function( exemplarValue, interTrack ) {
 
 
-		if ( exemplarValue === undefined || exemplarValue === null ) throw new Error( "examplarValue is null" );
+		if( exemplarValue === undefined || exemplarValue === null ) throw new Error( "examplarValue is null" );
 
 
 		var typeName = typeof exemplarValue;
 		var typeName = typeof exemplarValue;
-
 		switch( typeName ) {
 		switch( typeName ) {
+		 	case "object": {
+
+				if( exemplarValue.lerp ) {
 
 
-			case "object":
-				if ( exemplarValue.lerp ) {
 					return THREE.AnimationUtils.lerp_object;
 					return THREE.AnimationUtils.lerp_object;
+
 				}
 				}
+				if( exemplarValue.slerp ) {
 
 
-				if ( exemplarValue.slerp ) {
 					return THREE.AnimationUtils.slerp_object;
 					return THREE.AnimationUtils.slerp_object;
+
 				}
 				}
 				break;
 				break;
-
-			case "number":
+			}
+		 	case "number": {
 				return THREE.AnimationUtils.lerp_number;
 				return THREE.AnimationUtils.lerp_number;
-
-			case "boolean":
-				if ( interTrack ) {
+		 	}	
+		 	case "boolean": {
+		 		if( interTrack ) {
 					return THREE.AnimationUtils.lerp_boolean;
 					return THREE.AnimationUtils.lerp_boolean;
-				} else {
+		 		}
+		 		else {
 					return THREE.AnimationUtils.lerp_boolean_immediate;
 					return THREE.AnimationUtils.lerp_boolean_immediate;
-				}
-
-			case "string":
-				if ( interTrack ) {
+		 		}
+		 	}
+		 	case "string": {
+		 		if( interTrack ) {
 					return THREE.AnimationUtils.lerp_string;
 					return THREE.AnimationUtils.lerp_string;
-				} else {
+		 		}
+		 		else {
 					return THREE.AnimationUtils.lerp_string_immediate;
 					return THREE.AnimationUtils.lerp_string_immediate;
-				}
-
-		}
+			 	}
+		 	}
+		};
 
 
 	}
 	}
-
-};
+	
+};

+ 25 - 25
src/animation/KeyframeTrack.js

@@ -8,8 +8,8 @@
 
 
 THREE.KeyframeTrack = function ( name, keys ) {
 THREE.KeyframeTrack = function ( name, keys ) {
 
 
-	if ( name === undefined ) throw new Error( "track name is undefined" );
-	if ( keys === undefined || keys.length === 0 ) throw new Error( "no keys in track named " + name );
+	if( name === undefined ) throw new Error( "track name is undefined" );
+	if( keys === undefined || keys.length === 0 ) throw new Error( "no keys in track named " + name );
 
 
 	this.name = name;
 	this.name = name;
 	this.keys = keys;	// time in seconds, value as value
 	this.keys = keys;	// time in seconds, value as value
@@ -19,7 +19,6 @@ THREE.KeyframeTrack = function ( name, keys ) {
 
 
 	this.validate();
 	this.validate();
 	this.optimize();
 	this.optimize();
-
 };
 };
 
 
 THREE.KeyframeTrack.prototype = {
 THREE.KeyframeTrack.prototype = {
@@ -39,7 +38,7 @@ THREE.KeyframeTrack.prototype = {
 			this.lastIndex --;
 			this.lastIndex --;
 		}
 		}
 
 
-		if ( this.lastIndex >= this.keys.length ) {
+		if( this.lastIndex >= this.keys.length ) {
 
 
 			this.setResult( this.keys[ this.keys.length - 1 ].value );
 			this.setResult( this.keys[ this.keys.length - 1 ].value );
 
 
@@ -47,7 +46,7 @@ THREE.KeyframeTrack.prototype = {
 
 
 		}
 		}
 
 
-		if ( this.lastIndex === 0 ) {
+		if( this.lastIndex === 0 ) {
 
 
 			this.setResult( this.keys[ 0 ].value );
 			this.setResult( this.keys[ 0 ].value );
 
 
@@ -59,7 +58,7 @@ THREE.KeyframeTrack.prototype = {
 		this.setResult( prevKey.value );
 		this.setResult( prevKey.value );
 
 
 		// if true, means that prev/current keys are identical, thus no interpolation required.
 		// if true, means that prev/current keys are identical, thus no interpolation required.
-		if ( prevKey.constantToNext ) {
+		if( prevKey.constantToNext ) {
 
 
 			return this.result;
 			return this.result;
 
 
@@ -77,9 +76,9 @@ THREE.KeyframeTrack.prototype = {
 	// move all keyframes either forwards or backwards in time
 	// move all keyframes either forwards or backwards in time
 	shift: function( timeOffset ) {
 	shift: function( timeOffset ) {
 
 
-		if ( timeOffset !== 0.0 ) {
+		if( timeOffset !== 0.0 ) {
 
 
-			for ( var i = 0; i < this.keys.length; i ++ ) {
+			for( var i = 0; i < this.keys.length; i ++ ) {
 				this.keys[i].time += timeOffset;
 				this.keys[i].time += timeOffset;
 			}
 			}
 
 
@@ -92,9 +91,9 @@ THREE.KeyframeTrack.prototype = {
 	// scale all keyframe times by a factor (useful for frame <-> seconds conversions)
 	// scale all keyframe times by a factor (useful for frame <-> seconds conversions)
 	scale: function( timeScale ) {
 	scale: function( timeScale ) {
 
 
-		if ( timeScale !== 1.0 ) {
+		if( timeScale !== 1.0 ) {
 
 
-			for ( var i = 0; i < this.keys.length; i ++ ) {
+			for( var i = 0; i < this.keys.length; i ++ ) {
 				this.keys[i].time *= timeScale;
 				this.keys[i].time *= timeScale;
 			}
 			}
 
 
@@ -109,23 +108,24 @@ THREE.KeyframeTrack.prototype = {
  	trim: function( startTime, endTime ) {
  	trim: function( startTime, endTime ) {
 
 
 		var firstKeysToRemove = 0;
 		var firstKeysToRemove = 0;
-		for ( var i = 1; i < this.keys.length; i ++ ) {
-			if ( this.keys[i] <= startTime ) {
+		for( var i = 1; i < this.keys.length; i ++ ) {
+			if( this.keys[i] <= startTime ) {
 				firstKeysToRemove ++;
 				firstKeysToRemove ++;
 			}
 			}
 		}
 		}
 
 
 		var lastKeysToRemove = 0;
 		var lastKeysToRemove = 0;
-		for ( var i = this.keys.length - 2; i > 0; i ++ ) {
-			if ( this.keys[i] >= endTime ) {
+		for( var i = this.keys.length - 2; i > 0; i ++ ) {
+			if( this.keys[i] >= endTime ) {
 				lastKeysToRemove ++;
 				lastKeysToRemove ++;
-			} else {
+			}
+			else {
 				break;
 				break;
 			}
 			}
 		}
 		}
 
 
 		// remove last keys first because it doesn't affect the position of the first keys (the otherway around doesn't work as easily)
 		// remove last keys first because it doesn't affect the position of the first keys (the otherway around doesn't work as easily)
-		if ( ( firstKeysToRemove + lastKeysToRemove ) > 0 ) {
+		if( ( firstKeysToRemove + lastKeysToRemove ) > 0 ) {
 			this.keys = this.keys.splice( firstKeysToRemove, this.keys.length - lastKeysToRemove - firstKeysToRemove );;
 			this.keys = this.keys.splice( firstKeysToRemove, this.keys.length - lastKeysToRemove - firstKeysToRemove );;
 		}
 		}
 
 
@@ -149,16 +149,16 @@ THREE.KeyframeTrack.prototype = {
 
 
 		var prevKey = null;
 		var prevKey = null;
 
 
-		if ( this.keys.length === 0 ) {
+		if( this.keys.length === 0 ) {
 			console.error( "  track is empty, no keys", this );
 			console.error( "  track is empty, no keys", this );
 			return;
 			return;
 		}
 		}
 
 
-		for ( var i = 0; i < this.keys.length; i ++ ) {
+		for( var i = 0; i < this.keys.length; i ++ ) {
 
 
 			var currKey = this.keys[i];
 			var currKey = this.keys[i];
 
 
-			if ( ! currKey ) {
+			if( ! currKey ) {
 				console.error( "  key is null in track", this, i );
 				console.error( "  key is null in track", this, i );
 				return;
 				return;
 			}
 			}
@@ -168,12 +168,12 @@ THREE.KeyframeTrack.prototype = {
 				return;
 				return;
 			}
 			}
 
 
-			if ( currKey.value === undefined || currKey.value === null) {
+			if( currKey.value === undefined || currKey.value === null) {
 				console.error( "  key.value is null in track", this, i, currKey );
 				console.error( "  key.value is null in track", this, i, currKey );
 				return;
 				return;
 			}
 			}
 
 
-			if ( prevKey && prevKey.time > currKey.time ) {
+			if( prevKey && prevKey.time > currKey.time ) {
 				console.error( "  key.time is less than previous key time, out of order keys", this, i, currKey, prevKey );
 				console.error( "  key.time is less than previous key time, out of order keys", this, i, currKey, prevKey );
 				return;
 				return;
 			}
 			}
@@ -195,20 +195,20 @@ THREE.KeyframeTrack.prototype = {
 
 
 		var equalsFunc = THREE.AnimationUtils.getEqualsFunc( prevKey.value );
 		var equalsFunc = THREE.AnimationUtils.getEqualsFunc( prevKey.value );
 
 
-		for ( var i = 1; i < this.keys.length - 1; i ++ ) {
+		for( var i = 1; i < this.keys.length - 1; i ++ ) {
 			var currKey = this.keys[i];
 			var currKey = this.keys[i];
 			var nextKey = this.keys[i+1];
 			var nextKey = this.keys[i+1];
 
 
 			// if prevKey & currKey are the same time, remove currKey.  If you want immediate adjacent keys, use an epsilon offset
 			// if prevKey & currKey are the same time, remove currKey.  If you want immediate adjacent keys, use an epsilon offset
 			// it is not possible to have two keys at the same time as we sort them.  The sort is not stable on keys with the same time.
 			// it is not possible to have two keys at the same time as we sort them.  The sort is not stable on keys with the same time.
-			if ( ( prevKey.time === currKey.time ) ) {
+			if( ( prevKey.time === currKey.time ) ) {
 
 
 				continue;
 				continue;
 
 
 			}
 			}
 
 
 			// remove completely unnecessary keyframes that are the same as their prev and next keys
 			// remove completely unnecessary keyframes that are the same as their prev and next keys
-			if ( this.compareValues( prevKey.value, currKey.value ) && this.compareValues( currKey.value, nextKey.value ) ) {
+			if( this.compareValues( prevKey.value, currKey.value ) && this.compareValues( currKey.value, nextKey.value ) ) {
 
 
 				continue;
 				continue;
 
 
@@ -236,7 +236,7 @@ THREE.KeyframeTrack.keyComparer = function keyComparator(key0, key1) {
 
 
 THREE.KeyframeTrack.parse = function( json ) {
 THREE.KeyframeTrack.parse = function( json ) {
 
 
-	if ( json.type === undefined ) throw new Error( "track type undefined, can not parse" );
+	if( json.type === undefined ) throw new Error( "track type undefined, can not parse" );
 
 
 	var trackType = THREE.KeyframeTrack.GetTrackTypeForTypeName( json.type );
 	var trackType = THREE.KeyframeTrack.GetTrackTypeForTypeName( json.type );
 
 

+ 98 - 96
src/animation/PropertyBinding.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A track bound to a real value in the scene graph.
  * A track bound to a real value in the scene graph.
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -23,7 +23,7 @@ THREE.PropertyBinding = function ( rootNode, trackName ) {
 	this.propertyIndex = parseResults.propertyIndex;
 	this.propertyIndex = parseResults.propertyIndex;
 
 
 	this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName ) || rootNode;
 	this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName ) || rootNode;
-
+	
 	this.cumulativeValue = null;
 	this.cumulativeValue = null;
 	this.cumulativeWeight = 0;
 	this.cumulativeWeight = 0;
 };
 };
@@ -40,21 +40,22 @@ THREE.PropertyBinding.prototype = {
 	},
 	},
 
 
 	accumulate: function( value, weight ) {
 	accumulate: function( value, weight ) {
+		
+		if( ! this.isBound ) this.bind();
 
 
-		if ( ! this.isBound ) this.bind();
-
-		if ( this.cumulativeWeight === 0 ) {
+		if( this.cumulativeWeight === 0 ) {
 
 
-			if ( weight > 0 ) {
+			if( weight > 0 ) {
 
 
-				if ( this.cumulativeValue === null ) {
+				if( this.cumulativeValue === null ) {
 					this.cumulativeValue = THREE.AnimationUtils.clone( value );
 					this.cumulativeValue = THREE.AnimationUtils.clone( value );
 				}
 				}
 				this.cumulativeWeight = weight;
 				this.cumulativeWeight = weight;
 
 
 			}
 			}
 
 
-		} else {
+		}
+		else {
 
 
 			var lerpAlpha = weight / ( this.cumulativeWeight + weight );
 			var lerpAlpha = weight / ( this.cumulativeWeight + weight );
 			this.cumulativeValue = this.lerpValue( this.cumulativeValue, value, lerpAlpha );
 			this.cumulativeValue = this.lerpValue( this.cumulativeValue, value, lerpAlpha );
@@ -66,7 +67,7 @@ THREE.PropertyBinding.prototype = {
 
 
 	unbind: function() {
 	unbind: function() {
 
 
-		if ( ! this.isBound ) return;
+		if( ! this.isBound ) return;
 
 
 		this.setValue( this.originalValue );
 		this.setValue( this.originalValue );
 
 
@@ -74,7 +75,7 @@ THREE.PropertyBinding.prototype = {
 		this.getValue = null;
 		this.getValue = null;
 		this.lerpValue = null;
 		this.lerpValue = null;
 		this.equalsValue = null;
 		this.equalsValue = null;
-		this.triggerDirty = null;
+		this.triggerDirty = null;	
 		this.isBound = false;
 		this.isBound = false;
 
 
 	},
 	},
@@ -82,57 +83,59 @@ THREE.PropertyBinding.prototype = {
 	// bind to the real property in the scene graph, remember original value, memorize various accessors for speed/inefficiency
 	// bind to the real property in the scene graph, remember original value, memorize various accessors for speed/inefficiency
 	bind: function() {
 	bind: function() {
 
 
-		if ( this.isBound ) return;
+		if( this.isBound ) return;
 
 
 		var targetObject = this.node;
 		var targetObject = this.node;
 
 
  		// ensure there is a value node
  		// ensure there is a value node
-		if ( ! targetObject ) {
+		if( ! targetObject ) {
 			console.error( "  trying to update node for track: " + this.trackName + " but it wasn't found." );
 			console.error( "  trying to update node for track: " + this.trackName + " but it wasn't found." );
 			return;
 			return;
 		}
 		}
 
 
-		if ( this.objectName ) {
+		if( this.objectName ) {
 			// special case were we need to reach deeper into the hierarchy to get the face materials....
 			// special case were we need to reach deeper into the hierarchy to get the face materials....
-			if ( this.objectName === "materials" ) {
-				if ( ! targetObject.material ) {
+			if( this.objectName === "materials" ) {
+				if( ! targetObject.material ) {
 					console.error( '  can not bind to material as node does not have a material', this );
 					console.error( '  can not bind to material as node does not have a material', this );
-					return;
+					return;				
 				}
 				}
-				if ( ! targetObject.material.materials ) {
+				if( ! targetObject.material.materials ) {
 					console.error( '  can not bind to material.materials as node.material does not have a materials array', this );
 					console.error( '  can not bind to material.materials as node.material does not have a materials array', this );
-					return;
+					return;				
 				}
 				}
 				targetObject = targetObject.material.materials;
 				targetObject = targetObject.material.materials;
-			} else if ( this.objectName === "bones" ) {
-				if ( ! targetObject.skeleton ) {
+			}
+			else if( this.objectName === "bones" ) {
+				if( ! targetObject.skeleton ) {
 					console.error( '  can not bind to bones as node does not have a skeleton', this );
 					console.error( '  can not bind to bones as node does not have a skeleton', this );
 					return;
 					return;
 				}
 				}
 				// potential future optimization: skip this if propertyIndex is already an integer, and convert the integer string to a true integer.
 				// potential future optimization: skip this if propertyIndex is already an integer, and convert the integer string to a true integer.
-
+				
 				targetObject = targetObject.skeleton.bones;
 				targetObject = targetObject.skeleton.bones;
 
 
 				// support resolving morphTarget names into indices.
 				// support resolving morphTarget names into indices.
-				for ( var i = 0; i < targetObject.length; i ++ ) {
-					if ( targetObject[i].name === this.objectIndex ) {
+				for( var i = 0; i < targetObject.length; i ++ ) {
+					if( targetObject[i].name === this.objectIndex ) {
 						this.objectIndex = i;
 						this.objectIndex = i;
 						break;
 						break;
 					}
 					}
 				}
 				}
-			} else {
+			}
+			else {
 
 
-				if ( targetObject[ this.objectName ] === undefined ) {
-					console.error( '  can not bind to objectName of node, undefined', this );
+				if( targetObject[ this.objectName ] === undefined ) {
+					console.error( '  can not bind to objectName of node, undefined', this );			
 					return;
 					return;
 				}
 				}
 				targetObject = targetObject[ this.objectName ];
 				targetObject = targetObject[ this.objectName ];
 			}
 			}
-
-			if ( this.objectIndex !== undefined ) {
-				if ( targetObject[ this.objectIndex ] === undefined ) {
+			
+			if( this.objectIndex !== undefined ) {
+				if( targetObject[ this.objectIndex ] === undefined ) {
 					console.error( "  trying to bind to objectIndex of objectName, but is undefined:", this, targetObject );
 					console.error( "  trying to bind to objectIndex of objectName, but is undefined:", this, targetObject );
-					return;
+					return;				
 				}
 				}
 
 
 				targetObject = targetObject[ this.objectIndex ];
 				targetObject = targetObject[ this.objectIndex ];
@@ -142,27 +145,27 @@ THREE.PropertyBinding.prototype = {
 
 
  		// special case mappings
  		// special case mappings
  		var nodeProperty = targetObject[ this.propertyName ];
  		var nodeProperty = targetObject[ this.propertyName ];
-		if ( ! nodeProperty ) {
-			console.error( "  trying to update property for track: " + this.nodeName + '.' + this.propertyName + " but it wasn't found.", targetObject );
+		if( ! nodeProperty ) {
+			console.error( "  trying to update property for track: " + this.nodeName + '.' + this.propertyName + " but it wasn't found.", targetObject );				
 			return;
 			return;
 		}
 		}
 
 
 		// access a sub element of the property array (only primitives are supported right now)
 		// access a sub element of the property array (only primitives are supported right now)
-		if ( this.propertyIndex !== undefined ) {
+		if( this.propertyIndex !== undefined ) {
 
 
-			if ( this.propertyName === "morphTargetInfluences" ) {
+			if( this.propertyName === "morphTargetInfluences" ) {
 				// potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer.
 				// potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer.
-
+				
 				// support resolving morphTarget names into indices.
 				// support resolving morphTarget names into indices.
-				if ( ! targetObject.geometry ) {
-					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry', this );
+				if( ! targetObject.geometry ) {
+					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry', this );				
 				}
 				}
-				if ( ! targetObject.geometry.morphTargets ) {
-					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets', this );
+				if( ! targetObject.geometry.morphTargets ) {
+					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets', this );				
 				}
 				}
-
-				for ( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {
-					if ( targetObject.geometry.morphTargets[i].name === this.propertyIndex ) {
+				
+				for( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {
+					if( targetObject.geometry.morphTargets[i].name === this.propertyIndex ) {
 						this.propertyIndex = i;
 						this.propertyIndex = i;
 						break;
 						break;
 					}
 					}
@@ -170,7 +173,7 @@ THREE.PropertyBinding.prototype = {
 			}
 			}
 
 
 			this.setValue = function setValue_propertyIndexed( value ) {
 			this.setValue = function setValue_propertyIndexed( value ) {
-				if ( ! this.equalsValue( nodeProperty[ this.propertyIndex ], value ) ) {
+				if( ! this.equalsValue( nodeProperty[ this.propertyIndex ], value ) ) {
 					nodeProperty[ this.propertyIndex ] = value;
 					nodeProperty[ this.propertyIndex ] = value;
 					return true;
 					return true;
 				}
 				}
@@ -182,11 +185,11 @@ THREE.PropertyBinding.prototype = {
 			};
 			};
 
 
 		}
 		}
-		// must use copy for Object3D.Euler/Quaternion
-		else if ( nodeProperty.copy ) {
-
+		// must use copy for Object3D.Euler/Quaternion		
+		else if( nodeProperty.copy ) {
+			
 			this.setValue = function setValue_propertyObject( value ) {
 			this.setValue = function setValue_propertyObject( value ) {
-				if ( ! this.equalsValue( nodeProperty, value ) ) {
+				if( ! this.equalsValue( nodeProperty, value ) ) {
 					nodeProperty.copy( value );
 					nodeProperty.copy( value );
 					return true;
 					return true;
 				}
 				}
@@ -202,8 +205,8 @@ THREE.PropertyBinding.prototype = {
 		else {
 		else {
 
 
 			this.setValue = function setValue_property( value ) {
 			this.setValue = function setValue_property( value ) {
-				if ( ! this.equalsValue( targetObject[ this.propertyName ], value ) ) {
-					targetObject[ this.propertyName ] = value;
+				if( ! this.equalsValue( targetObject[ this.propertyName ], value ) ) {
+					targetObject[ this.propertyName ] = value;	
 					return true;
 					return true;
 				}
 				}
 				return false;
 				return false;
@@ -215,15 +218,16 @@ THREE.PropertyBinding.prototype = {
 
 
 		}
 		}
 
 
-		// trigger node dirty
-		if ( targetObject.needsUpdate !== undefined ) { // material
-
+		// trigger node dirty			
+		if( targetObject.needsUpdate !== undefined ) { // material
+			
 			this.triggerDirty = function triggerDirty_needsUpdate() {
 			this.triggerDirty = function triggerDirty_needsUpdate() {
 				this.node.needsUpdate = true;
 				this.node.needsUpdate = true;
 			}
 			}
 
 
-		} else if ( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform
-
+		}			
+		else if( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform
+			
 			this.triggerDirty = function triggerDirty_matrixWorldNeedsUpdate() {
 			this.triggerDirty = function triggerDirty_matrixWorldNeedsUpdate() {
 				targetObject.matrixWorldNeedsUpdate = true;
 				targetObject.matrixWorldNeedsUpdate = true;
 			}
 			}
@@ -242,13 +246,13 @@ THREE.PropertyBinding.prototype = {
 	apply: function() {
 	apply: function() {
 
 
 		// for speed capture the setter pattern as a closure (sort of a memoization pattern: https://en.wikipedia.org/wiki/Memoization)
 		// for speed capture the setter pattern as a closure (sort of a memoization pattern: https://en.wikipedia.org/wiki/Memoization)
-		if ( ! this.isBound ) this.bind();
+		if( ! this.isBound ) this.bind();
 
 
 		// early exit if there is nothing to apply.
 		// early exit if there is nothing to apply.
-		if ( this.cumulativeWeight > 0 ) {
-
+		if( this.cumulativeWeight > 0 ) {
+		
 			// blend with original value
 			// blend with original value
-			if ( this.cumulativeWeight < 1 ) {
+			if( this.cumulativeWeight < 1 ) {
 
 
 				var remainingWeight = 1 - this.cumulativeWeight;
 				var remainingWeight = 1 - this.cumulativeWeight;
 				var lerpAlpha = remainingWeight / ( this.cumulativeWeight + remainingWeight );
 				var lerpAlpha = remainingWeight / ( this.cumulativeWeight + remainingWeight );
@@ -258,7 +262,7 @@ THREE.PropertyBinding.prototype = {
 
 
 			var valueChanged = this.setValue( this.cumulativeValue );
 			var valueChanged = this.setValue( this.cumulativeValue );
 
 
-			if ( valueChanged && this.triggerDirty ) {
+			if( valueChanged && this.triggerDirty ) {
 				this.triggerDirty();
 				this.triggerDirty();
 			}
 			}
 
 
@@ -285,10 +289,10 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 	//	  .bone[Armature.DEF_cog].position
 	//	  .bone[Armature.DEF_cog].position
 	// created and tested via https://regex101.com/#javascript
 	// created and tested via https://regex101.com/#javascript
 
 
-	var re = /^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_. ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/;
+	var re = /^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_. ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/; 
 	var matches = re.exec(trackName);
 	var matches = re.exec(trackName);
 
 
-	if ( ! matches ) {
+	if( ! matches ) {
 		throw new Error( "cannot parse trackName at all: " + trackName );
 		throw new Error( "cannot parse trackName at all: " + trackName );
 	}
 	}
 
 
@@ -305,7 +309,7 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 		propertyIndex: matches[11]	// allowed to be null, specifies that the whole property is set.
 		propertyIndex: matches[11]	// allowed to be null, specifies that the whole property is set.
 	};
 	};
 
 
-	if ( results.propertyName === null || results.propertyName.length === 0 ) {
+	if( results.propertyName === null || results.propertyName.length === 0 ) {
 		throw new Error( "can not parse propertyName from trackName: " + trackName );
 		throw new Error( "can not parse propertyName from trackName: " + trackName );
 	}
 	}
 
 
@@ -315,71 +319,69 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 
 
 THREE.PropertyBinding.findNode = function( root, nodeName ) {
 THREE.PropertyBinding.findNode = function( root, nodeName ) {
 
 
-	function searchSkeleton( skeleton ) {
+	if( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
 
 
-		for ( var i = 0; i < skeleton.bones.length; i ++ ) {
+		return root;
 
 
-			var bone = skeleton.bones[i];
+	}
 
 
-			if ( bone.name === nodeName ) {
+	// search into skeleton bones.
+	if( root.skeleton ) {
 
 
-				return bone;
+		var searchSkeleton = function( skeleton ) {
 
 
-			}
-		}
-
-		return null;
+			for( var i = 0; i < skeleton.bones.length; i ++ ) {
 
 
-	}
+				var bone = skeleton.bones[i];
 
 
-	function searchNodeSubtree( children ) {
+				if( bone.name === nodeName ) {
 
 
-		for ( var i = 0; i < children.length; i ++ ) {
+					return bone;
 
 
-			var childNode = children[i];
+				}
+			}
 
 
-			if ( childNode.name === nodeName || childNode.uuid === nodeName ) {
+			return null;
 
 
-				return childNode;
+		};
 
 
-			}
+		var bone = searchSkeleton( root.skeleton );
 
 
-			var result = searchNodeSubtree( childNode.children );
+		if( bone ) {
 
 
-			if ( result ) return result;
+			return bone;
 
 
 		}
 		}
+	}
 
 
-		return null;
+	// search into node subtree.
+	if( root.children ) {
 
 
-	}
+		var searchNodeSubtree = function( children ) {
 
 
-	//
+			for( var i = 0; i < children.length; i ++ ) {
 
 
-	if ( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
+				var childNode = children[i];
 
 
-		return root;
+				if( childNode.name === nodeName || childNode.uuid === nodeName ) {
 
 
-	}
+					return childNode;
 
 
-	// search into skeleton bones.
-	if ( root.skeleton ) {
+				}
 
 
-		var bone = searchSkeleton( root.skeleton );
+				var result = searchNodeSubtree( childNode.children );
 
 
-		if ( bone ) {
+				if( result ) return result;
 
 
-			return bone;
+			}
 
 
-		}
-	}
+			return null;	
 
 
-	// search into node subtree.
-	if ( root.children ) {
+		};
 
 
 		var subTreeNode = searchNodeSubtree( root.children );
 		var subTreeNode = searchNodeSubtree( root.children );
 
 
-		if ( subTreeNode ) {
+		if( subTreeNode ) {
 
 
 			return subTreeNode;
 			return subTreeNode;
 
 

+ 4 - 3
src/animation/tracks/BooleanKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Boolean
  * A Track that interpolates Boolean
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -43,8 +43,8 @@ THREE.BooleanKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -61,3 +61,4 @@ THREE.BooleanKeyframeTrack.parse = function( json ) {
 	return new THREE.BooleanKeyframeTrack( json.name, json.keys );
 	return new THREE.BooleanKeyframeTrack( json.name, json.keys );
 
 
 };
 };
+ 

+ 5 - 4
src/animation/tracks/ColorKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Color
  * A Track that interpolates Color
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -43,8 +43,8 @@ THREE.ColorKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -60,7 +60,7 @@ THREE.ColorKeyframeTrack.parse = function( json ) {
 
 
 	var keys = [];
 	var keys = [];
 
 
-	for ( var i = 0; i < json.keys.length; i ++ ) {
+	for( var i = 0; i < json.keys.length; i ++ ) {
 		var jsonKey = json.keys[i];
 		var jsonKey = json.keys[i];
 		keys.push( {
 		keys.push( {
 			value: new THREE.Color().fromArray( jsonKey.value ),
 			value: new THREE.Color().fromArray( jsonKey.value ),
@@ -71,3 +71,4 @@ THREE.ColorKeyframeTrack.parse = function( json ) {
 	return new THREE.ColorKeyframeTrack( json.name, keys );
 	return new THREE.ColorKeyframeTrack( json.name, keys );
 
 
 };
 };
+ 

+ 4 - 3
src/animation/tracks/NumberKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Numbers
  * A Track that interpolates Numbers
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -43,8 +43,8 @@ THREE.NumberKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -61,3 +61,4 @@ THREE.NumberKeyframeTrack.parse = function( json ) {
 	return new THREE.NumberKeyframeTrack( json.name, json.keys );
 	return new THREE.NumberKeyframeTrack( json.name, json.keys );
 
 
 };
 };
+ 

+ 8 - 7
src/animation/tracks/QuaternionKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Quaternion
  * A Track that interpolates Quaternion
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -14,7 +14,7 @@ THREE.QuaternionKeyframeTrack = function ( name, keys ) {
 	this.result = this.keys[0].value.clone();
 	this.result = this.keys[0].value.clone();
 
 
 };
 };
-
+ 
 THREE.QuaternionKeyframeTrack.prototype = Object.create( THREE.KeyframeTrack.prototype );
 THREE.QuaternionKeyframeTrack.prototype = Object.create( THREE.KeyframeTrack.prototype );
 
 
 THREE.QuaternionKeyframeTrack.prototype.constructor = THREE.QuaternionKeyframeTrack;
 THREE.QuaternionKeyframeTrack.prototype.constructor = THREE.QuaternionKeyframeTrack;
@@ -41,10 +41,10 @@ THREE.QuaternionKeyframeTrack.prototype.compareValues = function( value0, value1
 
 
 THREE.QuaternionKeyframeTrack.prototype.multiply = function( quat ) {
 THREE.QuaternionKeyframeTrack.prototype.multiply = function( quat ) {
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
+	for( var i = 0; i < this.keys.length; i ++ ) {
 
 
 		this.keys[i].value.multiply( quat );
 		this.keys[i].value.multiply( quat );
-
+		
 	}
 	}
 
 
 	return this;
 	return this;
@@ -55,8 +55,8 @@ THREE.QuaternionKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -72,7 +72,7 @@ THREE.QuaternionKeyframeTrack.parse = function( json ) {
 
 
 	var keys = [];
 	var keys = [];
 
 
-	for ( var i = 0; i < json.keys.length; i ++ ) {
+	for( var i = 0; i < json.keys.length; i ++ ) {
 		var jsonKey = json.keys[i];
 		var jsonKey = json.keys[i];
 		keys.push( {
 		keys.push( {
 			value: new THREE.Quaternion().fromArray( jsonKey.value ),
 			value: new THREE.Quaternion().fromArray( jsonKey.value ),
@@ -83,3 +83,4 @@ THREE.QuaternionKeyframeTrack.parse = function( json ) {
 	return new THREE.QuaternionKeyframeTrack( json.name, keys );
 	return new THREE.QuaternionKeyframeTrack( json.name, keys );
 
 
 };
 };
+ 

+ 4 - 3
src/animation/tracks/StringKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Strings
  * A Track that interpolates Strings
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -43,8 +43,8 @@ THREE.StringKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -61,3 +61,4 @@ THREE.StringKeyframeTrack.parse = function( json ) {
 	return new THREE.StringKeyframeTrack( json.name, json.keys );
 	return new THREE.StringKeyframeTrack( json.name, json.keys );
 
 
 };
 };
+ 

+ 5 - 4
src/animation/tracks/VectorKeyframeTrack.js

@@ -1,7 +1,7 @@
 /**
 /**
  *
  *
  * A Track that interpolates Vectors
  * A Track that interpolates Vectors
- *
+ * 
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
@@ -43,8 +43,8 @@ THREE.VectorKeyframeTrack.prototype.clone = function() {
 
 
 	var clonedKeys = [];
 	var clonedKeys = [];
 
 
-	for ( var i = 0; i < this.keys.length; i ++ ) {
-
+	for( var i = 0; i < this.keys.length; i ++ ) {
+		
 		var key = this.keys[i];
 		var key = this.keys[i];
 		clonedKeys.push( {
 		clonedKeys.push( {
 			time: key.time,
 			time: key.time,
@@ -63,7 +63,7 @@ THREE.VectorKeyframeTrack.parse = function( json ) {
 
 
 	var keys = [];
 	var keys = [];
 
 
-	for ( var i = 0; i < json.keys.length; i ++ ) {
+	for( var i = 0; i < json.keys.length; i ++ ) {
 		var jsonKey = json.keys[i];
 		var jsonKey = json.keys[i];
 		keys.push( {
 		keys.push( {
 			value: new valueType().fromArray( jsonKey.value ),
 			value: new valueType().fromArray( jsonKey.value ),
@@ -74,3 +74,4 @@ THREE.VectorKeyframeTrack.parse = function( json ) {
 	return new THREE.VectorKeyframeTrack( json.name, keys );
 	return new THREE.VectorKeyframeTrack( json.name, keys );
 
 
 };
 };
+