|
@@ -16,6 +16,7 @@ THREE.Mixer.prototype = {
|
|
|
constructor: THREE.Mixer,
|
|
|
|
|
|
addAction: function( action ) {
|
|
|
+ console.log( root.name + ".Mixer.addAction( " + action.name + " )" );
|
|
|
|
|
|
this.actions.push( action );
|
|
|
|
|
@@ -30,7 +31,20 @@ THREE.Mixer.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ removeAction: function( action ) {
|
|
|
+ console.log( root.name + ".Mixer.addRemove( " + action.name + " )" );
|
|
|
+
|
|
|
+ var index = this.actions.indexOf( action );
|
|
|
+
|
|
|
+ if ( index !== - 1 ) {
|
|
|
+
|
|
|
+ this.actions.splice( index, 1 );
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
update: function( time ) {
|
|
|
+ console.log( root.name + ".Mixer.update( " + time + " )" );
|
|
|
|
|
|
var mixerResults = {};
|
|
|
|
|
@@ -38,40 +52,71 @@ THREE.Mixer.prototype = {
|
|
|
|
|
|
var action = this.actions[i];
|
|
|
|
|
|
- var actionResults = action.update( time );
|
|
|
+ if( action.weight <= 0 || ! action.enabled ) continue;
|
|
|
+
|
|
|
+ var actionResults = action.getAt( time );
|
|
|
|
|
|
- foreach( var result in actionResults ) {
|
|
|
+ for( var j = 0; j < actionResults.length; j ++ ) {
|
|
|
+
|
|
|
+ var actionResult = actionResults[j];
|
|
|
|
|
|
// TODO: do iterative linear interpolator based on cumulative weight ratios
|
|
|
- mixerResults[result.name].value = result.value;
|
|
|
+ if( ! mixerResults[ actionResult.name ] ) {
|
|
|
+
|
|
|
+ mixerResults[actionResult.name] = {
|
|
|
+ name: actionResult.name
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ mixerResults[actionResult.name].value = result.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ console.log( " mixerResults: ", mixerResults );
|
|
|
+
|
|
|
|
|
|
// apply to nodes
|
|
|
- foreach( var mixerResult in mixerResults ) {
|
|
|
+ for ( var name in mixerResults ) {
|
|
|
+
|
|
|
+ var mixerResult = mixerResults[ name ];
|
|
|
+
|
|
|
+ var trackInfo = this.trackInfos[ name ];
|
|
|
|
|
|
- var trackInfo = this.trackInfos[mixerResult.name];
|
|
|
+ var node = trackInfo.node;
|
|
|
+
|
|
|
+ if( ! node ) {
|
|
|
+ console.log( " trying to update node for track: " + name + " but it wasn't found." );
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ var propertyName = trackInfo.propertyName;
|
|
|
+
|
|
|
+ if( ! node[ propertyName ] ) {
|
|
|
+ console.log( " trying to update property for track: " + name + '.' + propertyName + " but it wasn't found." );
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
// must use copy for Object3D.Euler/Quaternion
|
|
|
- if( trackInfo.node[trackInfo.propertyName].copy ) {
|
|
|
- trackInfo.node[trackInfo.propertyName].copy( mixerResult.value );
|
|
|
+ if( node[ propertyName ].copy ) {
|
|
|
+ console.log( ' update property ' + name + '.' + propertyName + ' via a set() function.' );
|
|
|
+ node[ propertyName ].copy( mixerResult.value );
|
|
|
}
|
|
|
// otherwise just copy across value
|
|
|
else {
|
|
|
- trackInfo.node[trackInfo.propertyName] = mixerResult.value;
|
|
|
+ console.log( ' update property ' + name + '.' + propertyName + ' via assignment.' );
|
|
|
+ node[ propertyName ] = mixerResult.value;
|
|
|
}
|
|
|
|
|
|
|
|
|
// trigger node dirty
|
|
|
- if( trackInfo.node.needsUpdate ) { // material
|
|
|
- trackInfo.node.needsUpdate = true;
|
|
|
+ if( node.needsUpdate ) { // material
|
|
|
+ node.needsUpdate = true;
|
|
|
}
|
|
|
- if( trackInfo.node.matrixWorldNeedsUpdate && ! this.matrixAutoUpdate ) { // node transform
|
|
|
- trackInfo.node.matrixWorldNeedsUpdate = true;
|
|
|
+ if( node.matrixWorldNeedsUpdate && ! this.matrixAutoUpdate ) { // node transform
|
|
|
+ node.matrixWorldNeedsUpdate = true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|