فهرست منبع

fix bug where the keyframe track couldn't get back to the first key.

Ben Houston 10 سال پیش
والد
کامیت
a044dc9102
1فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 10 6
      src/animation/KeyframeTrack.js

+ 10 - 6
src/animation/KeyframeTrack.js

@@ -42,18 +42,22 @@ THREE.KeyframeTrack.prototype = {
 			this.lastIndex ++;
 		};
 
+		// this can not go lower than 0.
+		while( ( this.lastIndex > 0 ) && ( time < this.keys[this.lastIndex - 1].time ) ) {
+			this.lastIndex --;			
+		}
+
+		//if( /morph/i.test( this.name ) ) {
+		//	console.log( "lastIndex: ", this.lastIndex );
+		//}
+		
 		if( this.lastIndex >= this.keys.length ) {
 
-			this.setResult( this.keys[ this.lastIndex - 1 ].value );
+			this.setResult( this.keys[ this.keys.length - 1 ].value );
 			return this.result;
 
 		}
 
-		// this can not go lower than 0.
-		while( ( this.lastIndex > 0 ) && ( time < this.keys[this.lastIndex - 1].time ) ) {
-			this.lastIndex --;			
-		}
-
 		if( this.lastIndex === 0 ) {
 
 			this.setResult( this.keys[ 0 ].value );