Browse Source

remove debugging output.

Ben Houston 10 years ago
parent
commit
86523359e4

+ 1 - 30
src/animation/AnimationClip.js

@@ -12,7 +12,7 @@ THREE.AnimationClip = function ( name, duration, tracks ) {
 	this.tracks = tracks;
 	this.duration = duration || 1;
 
-	// TODO: maybe only do these on demand, as doing them here could potentially slow down loading
+	// maybe only do these on demand, as doing them here could potentially slow down loading
 	// but leaving these here during development as this ensures a lot of testing of these functions
 	this.trim();
 	this.optimize();
@@ -32,7 +32,6 @@ THREE.AnimationClip.prototype = {
 		for( var i = 0; i < this.tracks.length; i ++ ) {
 
 			var track = this.tracks[ i ];
-			//console.log( 'track', track );
 
 			this.results[ track.name ] = track.getAt( clipTime );
 
@@ -64,29 +63,10 @@ THREE.AnimationClip.prototype = {
 };
 
 
-/*
-	"animation" : {
-	    "name"      : "Action",
-        "fps"       : 25,
-        "length"    : 2.0,
-        "hierarchy" : [
-            {
-                "parent" : -1,
-                "keys"   : [
-                    {
-                        "time":0,
-                        "pos" :[0.532239,5.88733,-0.119685],
-                        "rot" :[-0.451519,0.544179,0.544179,0.451519],
-                        "scl" :[1,1,1]
-                    },
-*/
-
 THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames, duration ) {
-	//console.log( morphTargetNames, duration );
 
 	var tracks = [];
 	var frameStep = duration / morphTargetNames.length;
-	//console.log( 'frameStep', frameStep );
 
 	for( var i = 0; i < morphTargetNames.length; i ++ ) {
 
@@ -113,8 +93,6 @@ THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames,
 
 		}
 
-		//console.log( 'keys', keys );
-
 		var morphName = morphTargetNames[i];
 		var trackName = '.morphTargetInfluences[' + morphName + ']';
 		var track = new THREE.KeyframeTrack( trackName, keys );
@@ -123,7 +101,6 @@ THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames,
 	}
 
 	var clip = new THREE.AnimationClip( 'morphAnimation', duration, tracks );
-	//console.log( 'morphAnimationClip', clip );
 
 	return clip;
 };
@@ -170,8 +147,6 @@ THREE.AnimationClip.FromImplicitMorphTargetAnimations = function( morphTargets,
 
 	}
 
-	//console.log( animations );
-
 	var clips = [];
 
 	for( var i = 0; i < animationsArray.length; i ++ ) {
@@ -190,7 +165,6 @@ THREE.AnimationClip.FromImplicitMorphTargetAnimations = function( morphTargets,
 
 THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeName ) {
 
-	//var animation = jsonLoader.animation;
 	if( ! animation ) {
 		console.error( "  no animation in JSONLoader data" );
 		return null;
@@ -228,7 +202,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa
 
 	var tracks = [];
 
-	//var boneList = jsonLoader.bones;
 	var animationTracks = animation.hierarchy;
 
 	for ( var h = 0; h < animationTracks.length; h ++ ) {
@@ -282,7 +255,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa
 		else {
 
 			var boneName = nodeName + '.bones[' + bones[ h ].name + ']';
-			//console.log( 'boneName', boneName );
 		
 			// track contains positions...
 			var positionTrack = convertTrack( boneName + '.position', animationKeys, 'pos', function( animationKey ) {
@@ -314,7 +286,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa
 	}
 
 	var clip = new THREE.AnimationClip( clipName, duration, tracks );
-	//console.log( 'clipFromJSONLoaderAnimation', clip );
 
 	return clip;
 

+ 0 - 6
src/animation/AnimationMixer.js

@@ -2,7 +2,6 @@
  *
  * Mixes together the AnimationClips scheduled by AnimationActions and applies them to the root and subtree
  *
- * TODO: MUST add support for blending between AnimationActions based on their weights, right now only the last AnimationAction is applied at full weight.
  *
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
@@ -24,7 +23,6 @@ THREE.AnimationMixer.prototype = {
 	constructor: THREE.AnimationMixer,
 
 	addAction: function( action ) {
-		//console.log( this.root.name + ".AnimationMixer.addAnimationAction( " + action.name + " )" );
 
 		this.actions.push( action );
 
@@ -67,7 +65,6 @@ THREE.AnimationMixer.prototype = {
 	},
 
 	removeAction: function( action ) {
-		//console.log( this.root.name + ".AnimationMixer.addRemove( " + action.name + " )" );
 
 		var index = this.actions.indexOf( action );
 
@@ -160,14 +157,11 @@ THREE.AnimationMixer.prototype = {
 		var mixerDeltaTime = deltaTime * this.timeScale;
 		this.time += mixerDeltaTime;
 
-		//console.log( this.root.name + ".AnimationMixer.update( " + time + " )" );
-
 		for( var i = 0; i < this.actions.length; i ++ ) {
 
 			var action = this.actions[i];
 
 			var weight = action.getWeightAt( this.time );
-			//console.log( action.clip.name, weight, this.time );
 
 			var actionTimeScale = action.getTimeScaleAt( this.time );
 			var actionDeltaTime = mixerDeltaTime * actionTimeScale;

+ 0 - 2
src/animation/AnimationUtils.js

@@ -53,7 +53,6 @@
 				if( exemplarValue.lerp ) {
 
 					return function( a, b, alpha ) {
-						//console.log( a, b );
 						return a.lerp( b, alpha );
 					}
 
@@ -61,7 +60,6 @@
 				if( exemplarValue.slerp ) {
 
 					return function( a, b, alpha ) {
-						//console.log( a, b );
 						return a.slerp( b, alpha );
 					}
 

+ 6 - 37
src/animation/KeyframeTrack.js

@@ -1,8 +1,6 @@
 /**
  *
- * A Track that returns a keyframe interpolated value.
- *
- * TODO: Add cubic in addition to linear interpolation.
+ * A Track that returns a keyframe interpolated value, currently linearly interpolated 
  * 
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
@@ -17,10 +15,8 @@ THREE.KeyframeTrack = function ( name, keys ) {
 
 	// local cache of value type to avoid allocations during runtime.
 	this.result = THREE.AnimationUtils.clone( this.keys[0].value );
-	//console.log( 'constructor result', this.result )
 
 	// the index of the last result, used as a starting point for local search.
-	// TODO: this is okay in the keyframetrack, but it would be better stored in AnimationAction eventually.
 	this.lastIndex = 0;
 
 	this.sort();
@@ -33,9 +29,6 @@ THREE.KeyframeTrack.prototype = {
 	constructor: THREE.KeyframeTrack,
 
 	getAt: function( time ) {
-		//if( /morph/i.test( this.name ) ) {
-		//	console.log( 'KeyframeTrack[' + this.name + '].getAt( ' + time + ' )' );
-		//}
 		
 		// this can not go higher than this.keys.length.
 		while( ( this.lastIndex < this.keys.length ) && ( time >= this.keys[this.lastIndex].time ) ) {
@@ -47,10 +40,6 @@ THREE.KeyframeTrack.prototype = {
 			this.lastIndex --;			
 		}
 
-		//if( /morph/i.test( this.name ) ) {
-		//	console.log( "lastIndex: ", this.lastIndex );
-		//}
-
 		if( this.lastIndex >= this.keys.length ) {
 
 			this.setResult( this.keys[ this.keys.length - 1 ].value );
@@ -80,19 +69,6 @@ THREE.KeyframeTrack.prototype = {
 		var alpha = ( time - prevKey.time ) / ( currentKey.time - prevKey.time );
 		this.result = this.lerp( this.result, currentKey.value, alpha );
 
-		//console.log( 'lerp result', this.result )
-		/*if( /morph/i.test( this.name ) ) {
-			console.log( '   interpolated: ', {
-				index: this.lastIndex, 
-				value: this.result, 
-				alpha: alpha,
-				time0: this.keys[ this.lastIndex - 1 ].time,
-				time1: this.keys[ this.lastIndex ].time,
-				value0: this.keys[ this.lastIndex - 1 ].value,
-				value1: this.keys[ this.lastIndex ].value
-			} );
-		}*/
-
 		return this.result;
 
 	},
@@ -143,7 +119,7 @@ THREE.KeyframeTrack.prototype = {
 	}(),
 
 	// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
-	// TODO: ensure that all key.values in a track are all of the same type (otherwise interpolation makes no sense.)
+	// One could eventually ensure that all key.values in a track are all of the same type (otherwise interpolation makes no sense.)
 	validate: function() {
 
 		var prevKey = null;
@@ -184,7 +160,6 @@ THREE.KeyframeTrack.prototype = {
 	},
 
 	// currently only removes equivalent sequential keys (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0), which are common in morph target animations
-	// TODO: linear based interpolation optimization with an error threshold.
 	optimize: function() {
 
 		var newKeys = [];
@@ -196,22 +171,21 @@ THREE.KeyframeTrack.prototype = {
 		for( var i = 1; i < this.keys.length - 1; i ++ ) {
 			var currKey = this.keys[i];
 			var nextKey = this.keys[i+1];
-			//console.log( prevKey, currKey, nextKey );
 
 			// 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.
 			if( ( prevKey.time === currKey.time ) ) {
-				//console.log(  'removing key at the same time', currKey );
+
 				continue;
+
 			}
 
 			// remove completely unnecessary keyframes that are the same as their prev and next keys
 			if( equalsFunc( prevKey.value, currKey.value ) && equalsFunc( currKey.value, nextKey.value ) ) {
-				//console.log(  'removing key identical to prev and next', currKey );
+
 				continue;
-			}
 
-			// TODO:add here a check for linear interpolation optimization.
+			}
 
 			// determine if interpolation is required
 			prevKey.constantToNext = equalsFunc( prevKey.value, currKey.value );
@@ -221,9 +195,6 @@ THREE.KeyframeTrack.prototype = {
 		}
 		newKeys.push( this.keys[ this.keys.length - 1 ] );
 
-		//if( ( this.keys.length - newKeys.length ) > 0 ) {
-			//console.log( '  optimizing removed keys:', ( this.keys.length - newKeys.length ), this.name );
-		//}
 		this.keys = newKeys;
 
 	},
@@ -251,9 +222,7 @@ THREE.KeyframeTrack.prototype = {
 
 		// 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 ) {
-			//console.log(  '  triming removed keys: first and last', firstKeysToRemove, lastKeysToRemove, this.keys );
 			this.keys = this.keys.splice( firstKeysToRemove, this.keys.length - lastKeysToRemove - firstKeysToRemove );;
-			//console.log(  '  result', this.keys );
 		}
 
 	}

+ 3 - 30
src/animation/PropertyBinding.js

@@ -15,7 +15,6 @@ THREE.PropertyBinding = function ( rootNode, trackName ) {
 
 	var parseResults = THREE.PropertyBinding.parseTrackName( trackName );
 
-	//console.log( parseResults );
 	this.directoryName = parseResults.directoryName;
 	this.nodeName = parseResults.nodeName;
 	this.objectName = parseResults.objectName;
@@ -54,7 +53,6 @@ THREE.PropertyBinding.prototype = {
 				this.cumulativeWeight = weight;
 
 			}
-			//console.log( this );
 
 		}
 		else {
@@ -62,7 +60,6 @@ THREE.PropertyBinding.prototype = {
 			var lerpAlpha = weight / ( this.cumulativeWeight + weight );
 			this.cumulativeValue = this.lerpValue( this.cumulativeValue, value, lerpAlpha );
 			this.cumulativeWeight += weight;
-			//console.log( this );
 
 		}
 
@@ -83,16 +80,10 @@ THREE.PropertyBinding.prototype = {
 
 	},
 
-	// creates the member functions:
-	//	- setValue( value )
-	//  - getValue()
-	//  - triggerDirty()
-
+	// bind to the real property in the scene graph, remember original value, memorize various accessors for speed/inefficiency
 	bind: function() {
 
 		if( this.isBound ) return;
-		
-		//console.log( "PropertyBinding", this );
 
 		var targetObject = this.node;
 
@@ -120,15 +111,13 @@ THREE.PropertyBinding.prototype = {
 					console.error( '  can not bind to bones as node does not have a skeleton', this );
 					return;
 				}
-				// TODO/OPTIMIZE, 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;
 
 				// support resolving morphTarget names into indices.
-				//console.log( "  resolving bone name: ", this.objectIndex );
 				for( var i = 0; i < targetObject.length; i ++ ) {
 					if( targetObject[i].name === this.objectIndex ) {
-						//console.log( "  resolved to index: ", i );
 						this.objectIndex = i;
 						break;
 					}
@@ -165,10 +154,9 @@ THREE.PropertyBinding.prototype = {
 		if( this.propertyIndex !== undefined ) {
 
 			if( this.propertyName === "morphTargetInfluences" ) {
-				// TODO/OPTIMIZE, 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.
-				//console.log( "  resolving morphTargetInfluence name: ", this.propertyIndex );
 				if( ! targetObject.geometry ) {
 					console.error( '  can not bind to morphTargetInfluences becasuse node does not have a geometry', this );				
 				}
@@ -178,14 +166,12 @@ THREE.PropertyBinding.prototype = {
 				
 				for( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {
 					if( targetObject.geometry.morphTargets[i].name === this.propertyIndex ) {
-						//console.log( "  resolved to index: ", i );
 						this.propertyIndex = i;
 						break;
 					}
 				}
 			}
 
-			//console.log( '  update property array ' + this.propertyName + '[' + this.propertyIndex + '] via assignment.' );				
 			this.setValue = function( value ) {
 				if( ! this.equalsValue( nodeProperty[ this.propertyIndex ], value ) ) {
 					nodeProperty[ this.propertyIndex ] = value;
@@ -202,7 +188,6 @@ THREE.PropertyBinding.prototype = {
 		// must use copy for Object3D.Euler/Quaternion		
 		else if( nodeProperty.copy ) {
 			
-			//console.log( '  update property ' + this.name + '.' + this.propertyName + ' via a set() function.' );				
 			this.setValue = function( value ) {
 				if( ! this.equalsValue( nodeProperty, value ) ) {
 					nodeProperty.copy( value );
@@ -219,7 +204,6 @@ THREE.PropertyBinding.prototype = {
 		// otherwise just set the property directly on the node (do not use nodeProperty as it may not be a reference object)
 		else {
 
-			//console.log( '  update property ' + this.name + '.' + this.propertyName + ' via assignment.' );				
 			this.setValue = function( value ) {
 				if( ! this.equalsValue( targetObject[ this.propertyName ], value ) ) {
 					targetObject[ this.propertyName ] = value;	
@@ -237,7 +221,6 @@ THREE.PropertyBinding.prototype = {
 		// trigger node dirty			
 		if( targetObject.needsUpdate !== undefined ) { // material
 			
-			//console.log( '  triggering material as dirty' );
 			this.triggerDirty = function() {
 				this.node.needsUpdate = true;
 			}
@@ -245,7 +228,6 @@ THREE.PropertyBinding.prototype = {
 		}			
 		else if( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform
 			
-			//console.log( '  triggering node as dirty' );
 			this.triggerDirty = function() {
 				targetObject.matrixWorldNeedsUpdate = true;
 			}
@@ -327,8 +309,6 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 		propertyIndex: matches[11]	// allowed to be null, specifies that the whole property is set.
 	};
 
-	//console.log( "PropertyBinding.parseTrackName", trackName, results, matches );
-
 	if( results.propertyName === null || results.propertyName.length === 0 ) {
 		throw new Error( "can not parse propertyName from trackName: " + trackName );
 	}
@@ -340,11 +320,8 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 // TODO: Cache this at some point
 THREE.PropertyBinding.findNode = function( root, nodeName ) {
 
-	//console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')', root );
-	
 	if( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
 
-		//console.log( '  root.' );
 		return root;
 
 	}
@@ -373,7 +350,6 @@ THREE.PropertyBinding.findNode = function( root, nodeName ) {
 
 		if( bone ) {
 
-			//console.log( '  bone: ' + bone.name + '.' );
 			return bone;
 
 		}
@@ -408,14 +384,11 @@ THREE.PropertyBinding.findNode = function( root, nodeName ) {
 
 		if( subTreeNode ) {
 
-			//console.log( '  node: ' + subTreeNode.name + '.' );
 			return subTreeNode;
 
 		}
 
 	}
 
-	//console.log( "   <null>.  No node found for name: " + nodeName );
-
 	return null;
 }