Game Development Reference
In-Depth Information
The addToUpdate and removeFromUpdate functions add and delete animation objects
to and the from playing list, respectively, as shown in the following code snippet:
that.addToUpdate = function( animation ) {
if ( playing.indexOf( animation ) === -1 )
playing.push( animation );
};
that.removeFromUpdate = function( animation ) {
var index = playing.indexOf( animation );
if( index !== -1 )
playing.splice( index, 1 );
};
The add function pushes the animation data on to the library array, with the key as
the name of the animation data. It then invokes initData . The get function returns
the animation data from the array. The add function is defined as follows:
that.add = function( data ) {
library[ data.name ] = data;
initData( data );
};
that.get = function( name ) {
if ( typeof name === "string" ) {
if ( library[ name ] ) {
return library[ name ];
} else {
return null;
}
}
};
The parse function pushes all the bones of the RiggedMesh class to the hierarchy
array. This function is invoked from the Animation class. The Animation class
maintains the list of bones of the object. It updates the bones' properties ( position ,
rotation , and scale ) in its update function. The parse function is defined as follows:
that.parse = function( root ) {
// setup hierarchy
var hierarchy = [];
if ( root instanceof RiggedMesh ) {
for( var b = 0; b < root.bones.length; b++ ) {
hierarchy.push( root.bones[ b ] );
}
}
return hierarchy;
};
 
Search WWH ::




Custom Search