浏览代码

get rid of another map used in a tight inner loop.

Ben Houston 10 年之前
父节点
当前提交
8da58ca3d3
共有 2 个文件被更改,包括 31 次插入1 次删除
  1. 2 0
      src/animation/AnimationAction.js
  2. 29 1
      src/animation/AnimationMixer.js

+ 2 - 0
src/animation/AnimationAction.js

@@ -17,6 +17,8 @@ THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
 	this.enabled = true;	// allow for easy disabling of the action.
 
 	this.clipTime = 0;
+
+	this.propertyBindingIndices = [];
 };
 
 THREE.AnimationAction.prototype = {

+ 29 - 1
src/animation/AnimationMixer.js

@@ -48,6 +48,32 @@ THREE.AnimationMixer.prototype = {
 
 		}
 
+		this.updatePropertyBindingIndices();
+
+	},
+
+	updatePropertyBindingIndices: function() {
+
+		for( var i = 0; i < this.actions.length; i++ ) {
+
+			var action = this.actions[i];
+
+			var propertyBindingIndices = [];
+
+			for( var j = 0; j < action.clip.tracks.length; j ++ ) {
+				var trackName = action.clip.tracks[j].name;
+
+				for( var k = 0; k < this.propertyBindingsArray.length; k ++ ) {
+					if( this.propertyBindingsArray[k].trackName === trackName ) {
+						propertyBindingIndices.push( k );
+						break;
+					}
+				}	
+			}
+
+			action.propertyBindingIndices = propertyBindingIndices;
+		}
+
 	},
 
 	removeAllActions: function() {
@@ -102,6 +128,8 @@ THREE.AnimationMixer.prototype = {
 			}
 		}
 
+		this.updatePropertyBindingIndices();
+
 	},
 
 	play: function( action, optionalFadeInDuration ) {
@@ -182,7 +210,7 @@ THREE.AnimationMixer.prototype = {
 
 				var name = action.clip.tracks[j].name;
 
-				this.propertyBindings[name].accumulate( actionResults[j], weight );
+				this.propertyBindingsArray[ action.propertyBindingIndices[ j ] ].accumulate( actionResults[j], weight );
 
 			}