Game Development Reference
In-Depth Information
this.currentTime = startTimeMS !==
undefined ? startTimeMS : 0;
// reset key cache
var h, hl = this.hierarchy.length,object;
for ( h = 0; h < hl; h ++ ) {
object = this.hierarchy[ h ];
object.matrixAutoUpdate = true;
if ( object.animationCache === undefined ) {
object.animationCache = {};
object.animationCache.prevKey = { pos: 0, rot: 0,
scl: 0 };
object.animationCache.nextKey = { pos: 0, rot: 0,
scl: 0 };
object.animationCache.originalMatrix = object instanceof
Bone ? object.skinMatrix : object.matrix;
}
var prevKey = object.animationCache.prevKey;
var nextKey = object.animationCache.nextKey;
prevKey.pos = this.data.hierarchy[ h ].keys[ 0 ];
prevKey.rot = this.data.hierarchy[ h ].keys[ 0 ];
prevKey.scl = this.data.hierarchy[ h ].keys[ 0 ];
nextKey.pos = this.getNextKeyWith( "pos", h, 1 );
nextKey.rot = this.getNextKeyWith( "rot", h, 1 );
nextKey.scl = this.getNextKeyWith( "scl", h, 1 );
}
this.update( 0 );
}
this.isPaused = false;
AnimationHandler.addToUpdate( this );
};
The update function is the heart of the animation system. The types array holds
DOF names ( pos , rot , and scl ), which are indexed to get the key data. The update
function takes the elapse time ( deltaTimeMS ) as a parameter. It is invoked from the
AnimationHandler class's update function.
Animation.prototype.update = function ( deltaTimeMS ) {
if ( this.isPlaying === false ) return;
var types = [ "pos", "rot", "scl" ];
var type;
var scale;
var vector;
var prevXYZ, nextXYZ;
var prevKey, nextKey;
var object;
 
Search WWH ::




Custom Search