|
@@ -31051,72 +31051,70 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
|
|
* @author mikael emtinger / http://gomo.se/
|
|
* @author mikael emtinger / http://gomo.se/
|
|
*/
|
|
*/
|
|
|
|
|
|
-THREE.AnimationHandler = (function() {
|
|
|
|
|
|
+THREE.AnimationHandler = ( function () {
|
|
|
|
|
|
var playing = [];
|
|
var playing = [];
|
|
var library = {};
|
|
var library = {};
|
|
var that = {};
|
|
var that = {};
|
|
|
|
|
|
|
|
+ that.update = function ( deltaTimeMS ) {
|
|
|
|
|
|
- //--- update ---
|
|
|
|
|
|
+ for ( var i = 0; i < playing.length; i ++ ) {
|
|
|
|
|
|
- that.update = function( deltaTimeMS ) {
|
|
|
|
-
|
|
|
|
- for( var i = 0; i < playing.length; i ++ )
|
|
|
|
playing[ i ].update( deltaTimeMS );
|
|
playing[ i ].update( deltaTimeMS );
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
- //--- add ---
|
|
|
|
|
|
+ that.addToUpdate = function ( animation ) {
|
|
|
|
|
|
- that.addToUpdate = function( animation ) {
|
|
|
|
|
|
+ if ( playing.indexOf( animation ) === -1 ) {
|
|
|
|
|
|
- if ( playing.indexOf( animation ) === -1 )
|
|
|
|
playing.push( animation );
|
|
playing.push( animation );
|
|
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- //--- remove ---
|
|
|
|
|
|
+ };
|
|
|
|
|
|
- that.removeFromUpdate = function( animation ) {
|
|
|
|
|
|
+ that.removeFromUpdate = function ( animation ) {
|
|
|
|
|
|
var index = playing.indexOf( animation );
|
|
var index = playing.indexOf( animation );
|
|
|
|
|
|
- if( index !== -1 )
|
|
|
|
|
|
+ if ( index !== -1 ) {
|
|
|
|
+
|
|
playing.splice( index, 1 );
|
|
playing.splice( index, 1 );
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
- //--- add ---
|
|
|
|
|
|
+ that.add = function ( data ) {
|
|
|
|
|
|
- that.add = function( data ) {
|
|
|
|
|
|
+ if ( library[ data.name ] !== undefined ) {
|
|
|
|
|
|
- if ( library[ data.name ] !== undefined )
|
|
|
|
console.log( "THREE.AnimationHandler.add: Warning! " + data.name + " already exists in library. Overwriting." );
|
|
console.log( "THREE.AnimationHandler.add: Warning! " + data.name + " already exists in library. Overwriting." );
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
library[ data.name ] = data;
|
|
library[ data.name ] = data;
|
|
initData( data );
|
|
initData( data );
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
- //--- remove ---
|
|
|
|
|
|
|
|
- that.remove = function( name ) {
|
|
|
|
|
|
+ that.remove = function ( name ) {
|
|
|
|
+
|
|
|
|
+ if ( library[ name ] === undefined ) {
|
|
|
|
|
|
- if ( library[ name ] === undefined )
|
|
|
|
console.log( "THREE.AnimationHandler.add: Warning! " + name + " doesn't exists in library. Doing nothing." );
|
|
console.log( "THREE.AnimationHandler.add: Warning! " + name + " doesn't exists in library. Doing nothing." );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
library[ name ] = undefined;
|
|
library[ name ] = undefined;
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
- //--- get ---
|
|
|
|
-
|
|
|
|
- that.get = function( name ) {
|
|
|
|
|
|
+ that.get = function ( name ) {
|
|
|
|
|
|
if ( typeof name === "string" ) {
|
|
if ( typeof name === "string" ) {
|
|
|
|
|
|
@@ -31139,9 +31137,7 @@ THREE.AnimationHandler = (function() {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- //--- parse ---
|
|
|
|
-
|
|
|
|
- that.parse = function( root ) {
|
|
|
|
|
|
+ that.parse = function ( root ) {
|
|
|
|
|
|
// setup hierarchy
|
|
// setup hierarchy
|
|
|
|
|
|
@@ -31149,7 +31145,7 @@ THREE.AnimationHandler = (function() {
|
|
|
|
|
|
if ( root instanceof THREE.SkinnedMesh ) {
|
|
if ( root instanceof THREE.SkinnedMesh ) {
|
|
|
|
|
|
- for( var b = 0; b < root.bones.length; b++ ) {
|
|
|
|
|
|
+ for ( var b = 0; b < root.bones.length; b++ ) {
|
|
|
|
|
|
hierarchy.push( root.bones[ b ] );
|
|
hierarchy.push( root.bones[ b ] );
|
|
|
|
|
|
@@ -31165,52 +31161,50 @@ THREE.AnimationHandler = (function() {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- var parseRecurseHierarchy = function( root, hierarchy ) {
|
|
|
|
|
|
+ var parseRecurseHierarchy = function ( root, hierarchy ) {
|
|
|
|
|
|
hierarchy.push( root );
|
|
hierarchy.push( root );
|
|
|
|
|
|
- for( var c = 0; c < root.children.length; c++ )
|
|
|
|
|
|
+ for ( var c = 0; c < root.children.length; c++ )
|
|
parseRecurseHierarchy( root.children[ c ], hierarchy );
|
|
parseRecurseHierarchy( root.children[ c ], hierarchy );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var initData = function ( data ) {
|
|
|
|
|
|
- //--- init data ---
|
|
|
|
-
|
|
|
|
- var initData = function( data ) {
|
|
|
|
-
|
|
|
|
- if( data.initialized === true )
|
|
|
|
|
|
+ if ( data.initialized === true )
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
|
|
// loop through all keys
|
|
// loop through all keys
|
|
|
|
|
|
- for( var h = 0; h < data.hierarchy.length; h ++ ) {
|
|
|
|
|
|
+ for ( var h = 0; h < data.hierarchy.length; h ++ ) {
|
|
|
|
|
|
- for( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
|
|
|
|
|
|
+ for ( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
|
|
|
|
|
|
// remove minus times
|
|
// remove minus times
|
|
|
|
|
|
- if( data.hierarchy[ h ].keys[ k ].time < 0 )
|
|
|
|
- data.hierarchy[ h ].keys[ k ].time = 0;
|
|
|
|
|
|
+ if ( data.hierarchy[ h ].keys[ k ].time < 0 ) {
|
|
|
|
+
|
|
|
|
+ data.hierarchy[ h ].keys[ k ].time = 0;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
// create quaternions
|
|
// create quaternions
|
|
|
|
|
|
- if( data.hierarchy[ h ].keys[ k ].rot !== undefined &&
|
|
|
|
- !( data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion ) ) {
|
|
|
|
|
|
+ if ( data.hierarchy[ h ].keys[ k ].rot !== undefined &&
|
|
|
|
+ !( data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion ) ) {
|
|
|
|
|
|
var quat = data.hierarchy[ h ].keys[ k ].rot;
|
|
var quat = data.hierarchy[ h ].keys[ k ].rot;
|
|
- data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion( quat[0], quat[1], quat[2], quat[3] );
|
|
|
|
|
|
+ data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion().fromArray( quat );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// prepare morph target keys
|
|
// prepare morph target keys
|
|
|
|
|
|
- if( data.hierarchy[ h ].keys.length && data.hierarchy[ h ].keys[ 0 ].morphTargets !== undefined ) {
|
|
|
|
|
|
+ if ( data.hierarchy[ h ].keys.length && data.hierarchy[ h ].keys[ 0 ].morphTargets !== undefined ) {
|
|
|
|
|
|
// get all used
|
|
// get all used
|
|
|
|
|
|
@@ -31288,8 +31282,6 @@ THREE.AnimationHandler = (function() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // done
|
|
|
|
-
|
|
|
|
data.initialized = true;
|
|
data.initialized = true;
|
|
|
|
|
|
};
|
|
};
|
|
@@ -31303,7 +31295,7 @@ THREE.AnimationHandler = (function() {
|
|
|
|
|
|
return that;
|
|
return that;
|
|
|
|
|
|
-}());
|
|
|
|
|
|
+}() );
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author mikael emtinger / http://gomo.se/
|
|
* @author mikael emtinger / http://gomo.se/
|