|
@@ -128,7 +128,14 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
|
|
this.currentTime += deltaTimeMS * this.timeScale;
|
|
this.currentTime += deltaTimeMS * this.timeScale;
|
|
|
|
|
|
unloopedCurrentTime = this.currentTime;
|
|
unloopedCurrentTime = this.currentTime;
|
|
|
|
+
|
|
|
|
+ //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;
|
|
currentTime = this.currentTime = this.currentTime % this.data.length;
|
|
|
|
+
|
|
|
|
+
|
|
frame = parseInt( Math.min( currentTime * this.data.fps, this.data.length * this.data.fps ), 10 );
|
|
frame = parseInt( Math.min( currentTime * this.data.fps, this.data.length * this.data.fps ), 10 );
|
|
|
|
|
|
|
|
|
|
@@ -148,19 +155,20 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
|
|
nextKey = animationCache.nextKey[ type ];
|
|
nextKey = animationCache.nextKey[ type ];
|
|
|
|
|
|
// switch keys?
|
|
// switch keys?
|
|
-
|
|
|
|
|
|
+ if(!nextKey) debugger;
|
|
if ( nextKey.time <= unloopedCurrentTime ) {
|
|
if ( nextKey.time <= unloopedCurrentTime ) {
|
|
|
|
|
|
// did we loop?
|
|
// did we loop?
|
|
|
|
|
|
- if ( currentTime < unloopedCurrentTime ) {
|
|
|
|
|
|
+ if ( currentTime <= unloopedCurrentTime ) {
|
|
|
|
|
|
if ( this.loop ) {
|
|
if ( this.loop ) {
|
|
|
|
|
|
prevKey = this.data.hierarchy[ h ].keys[ 0 ];
|
|
prevKey = this.data.hierarchy[ h ].keys[ 0 ];
|
|
nextKey = this.getNextKeyWith( type, h, 1 );
|
|
nextKey = this.getNextKeyWith( type, h, 1 );
|
|
|
|
|
|
- while( nextKey.time < currentTime ) {
|
|
|
|
|
|
+ //if(nextKey.index < prevKey.index ) then we have wrapped over the end, and nextKey.time < currentTime will loop forever
|
|
|
|
+ while( nextKey && nextKey.time < currentTime && nextKey.index > prevKey.index) {
|
|
|
|
|
|
prevKey = nextKey;
|
|
prevKey = nextKey;
|
|
nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
|
|
nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
|
|
@@ -181,7 +189,8 @@ THREE.Animation.prototype.update = function ( deltaTimeMS ) {
|
|
prevKey = nextKey;
|
|
prevKey = nextKey;
|
|
nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
|
|
nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
|
|
|
|
|
|
- } while( nextKey.time < currentTime )
|
|
|
|
|
|
+ } 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
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -322,6 +331,7 @@ THREE.Animation.prototype.getNextKeyWith = function ( type, h, key ) {
|
|
|
|
|
|
var keys = this.data.hierarchy[ h ].keys;
|
|
var keys = this.data.hierarchy[ h ].keys;
|
|
|
|
|
|
|
|
+ if(keys.length === undefined) debugger;
|
|
if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM ||
|
|
if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM ||
|
|
this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {
|
|
this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {
|
|
|
|
|