Browse Source

fix off by one bugs in KeyframeTrack.shift/scale - was skipping first key.

Ben Houston 10 years ago
parent
commit
8b5f0d5b63
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/animation/KeyframeTrack.js

+ 6 - 3
src/animation/KeyframeTrack.js

@@ -26,7 +26,8 @@ THREE.KeyframeTrack.prototype = {
 	constructor: THREE.KeyframeTrack,
 
 	getAt: function( time ) {
-		
+
+
 		// this can not go higher than this.keys.length.
 		while( ( this.lastIndex < this.keys.length ) && ( time >= this.keys[this.lastIndex].time ) ) {
 			this.lastIndex ++;
@@ -40,6 +41,7 @@ THREE.KeyframeTrack.prototype = {
 		if( this.lastIndex >= this.keys.length ) {
 
 			this.setResult( this.keys[ this.keys.length - 1 ].value );
+
 			return this.result;
 
 		}
@@ -47,6 +49,7 @@ THREE.KeyframeTrack.prototype = {
 		if( this.lastIndex === 0 ) {
 
 			this.setResult( this.keys[ 0 ].value );
+
 			return this.result;
 
 		}
@@ -75,7 +78,7 @@ THREE.KeyframeTrack.prototype = {
 
 		if( timeOffset !== 0.0 ) {
 
-			for( var i = 1; i < this.keys.length; i ++ ) {
+			for( var i = 0; i < this.keys.length; i ++ ) {
 				this.keys[i].time += timeOffset;
 			}
 
@@ -90,7 +93,7 @@ THREE.KeyframeTrack.prototype = {
 
 		if( timeScale !== 1.0 ) {
 
-			for( var i = 1; i < this.keys.length; i ++ ) {
+			for( var i = 0; i < this.keys.length; i ++ ) {
 				this.keys[i].time *= timeScale;
 			}