Просмотр исходного кода

Animation: Some more clean up.

Mr.doob 11 лет назад
Родитель
Сommit
18f4c2cdb6
1 измененных файлов с 11 добавлено и 8 удалено
  1. 11 8
      src/extras/animation/Animation.js

+ 11 - 8
src/extras/animation/Animation.js

@@ -129,10 +129,14 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
 
 	unloopedCurrentTime = this.currentTime;
 
-	//Mod operation fails on floats
-	//was this supposed to be in frames?
-	while (this.currentTime > this.data.length)
+	// Mod operation fails on floats
+	// was this supposed to be in frames?
+	while ( this.currentTime > this.data.length ) {
+
 		this.currentTime -= this.data.length;
+
+	}
+
 	currentTime = this.currentTime = this.currentTime % this.data.length;
 
 	
@@ -167,8 +171,8 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
 						prevKey = this.data.hierarchy[ h ].keys[ 0 ];
 						nextKey = this.getNextKeyWith( type, h, 1 );
 
-						//if(nextKey.index < prevKey.index ) then we have wrapped over the end, and nextKey.time < currentTime will loop forever
-						while( nextKey !== null && nextKey.time < currentTime  && nextKey.index > prevKey.index) {
+						// if ( nextKey.index < prevKey.index ) then we have wrapped over the end, and nextKey.time < currentTime will loop forever
+						while ( nextKey !== null && nextKey.time < currentTime && nextKey.index > prevKey.index) {
 
 							prevKey = nextKey;
 							nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
@@ -189,8 +193,8 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
 						prevKey = nextKey;
 						nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
 
-					} while( nextKey && nextKey.time < currentTime && nextKey.index > prevKey.index )
-					//if(nextKey.index < prevKey.index ) then we have wrapped over the end, and nextKey.time < currentTime will loop forever
+					} while ( nextKey !== null && nextKey.time < currentTime && nextKey.index > prevKey.index )
+					// if ( nextKey.index < prevKey.index ) then we have wrapped over the end, and nextKey.time < currentTime will loop forever
 
 				}
 
@@ -331,7 +335,6 @@ THREE.Animation.prototype.getNextKeyWith = function ( type, h, key ) {
 
 	var keys = this.data.hierarchy[ h ].keys;
 
-	if(keys.length === undefined) debugger;
 	if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM ||
 		 this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {