Browse Source

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

alteredq 13 years ago
parent
commit
3589747720
1 changed files with 11 additions and 9 deletions
  1. 11 9
      src/extras/animation/KeyFrameAnimation.js

+ 11 - 9
src/extras/animation/KeyFrameAnimation.js

@@ -142,13 +142,14 @@ THREE.KeyFrameAnimation.prototype.stop = function() {
 
 	// reset JIT matrix and remove cache
 
-	for ( var h = 0; h < this.hierarchy.length; h++ ) {
+	for ( var h = 0; h < this.data.hierarchy.length; h++ ) {
+        
+        var obj = this.hierarchy[ h ];
+		var node = this.data.hierarchy[ h ];
 
-		var obj = this.hierarchy[ h ];
+		if ( node.animationCache !== undefined ) {
 
-		if ( obj.animationCache !== undefined ) {
-
-			var original = obj.animationCache.originalMatrix;
+			var original = node.animationCache.originalMatrix;
 
 			if( obj instanceof THREE.Bone ) {
 
@@ -162,7 +163,7 @@ THREE.KeyFrameAnimation.prototype.stop = function() {
 
 			}
 
-			delete obj.animationCache;
+			delete node.animationCache;
 
 		}
 
@@ -226,7 +227,6 @@ THREE.KeyFrameAnimation.prototype.update = function( deltaTimeMS ) {
 						prev = this.getPrevKeyWith( sid, h, end );
 
 					if ( prev ) {
-
 						prev.apply( sid );
 
 					}
@@ -338,8 +338,10 @@ THREE.KeyFrameAnimation.prototype.update = function( deltaTimeMS ) {
 					animationCache.nextKey = nextKey;
 
 				}
-
-				prevKey.interpolate( nextKey, currentTime );
+                if(nextKey.time >= currentTime)
+                    prevKey.interpolate( nextKey, currentTime );
+                else
+                    prevKey.interpolate( nextKey, nextKey.time);
 
 			}