Browse Source

allow for local roots on actions.

Ben Houston 10 years ago
parent
commit
3cf852751a

+ 1 - 1
examples/webgl_loader_json_blender.html

@@ -135,7 +135,7 @@
 						scene.add( mesh );
 						
 						var mixer = new THREE.AnimationMixer( mesh );
-						mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).wrapToDuration( 1000 ) );
+						mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( 1 ) );
 
 						// random animation offset
 						mixer.update( 1000 * Math.random() );

+ 2 - 2
examples/webgl_morphnormals.html

@@ -102,7 +102,7 @@
 					scene1.add( mesh );
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).wrapToDuration( 5000 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).warpToDuration( 5 ) );
 
 					mixers.push( mixer );
 
@@ -123,7 +123,7 @@
 					scene2.add( mesh );
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).wrapToDuration( 5000 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).warpToDuration( 5 ) );
 
 					mixers.push( mixer );
 

+ 1 - 1
examples/webgl_morphtargets_horse.html

@@ -69,7 +69,7 @@
 					mixer = new THREE.AnimationMixer( mesh );
 
 					var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 );
-					mixer.addAction( new THREE.AnimationAction( clip ).wrapToDuration( 3000 ) );
+					mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1.5 ) );
 
 				} );
 

+ 6 - 3
src/animation/AnimationMixer.js

@@ -59,10 +59,11 @@ THREE.AnimationMixer.prototype = {
 
 	},
 
-	getPropertyBindingIndex: function( trackName ) {
+	getPropertyBindingIndex: function( rootNode, trackName ) {
 		
 		for( var k = 0; k < this.propertyBindings.length; k ++ ) {
-			if( this.propertyBindings[k].trackName === trackName ) {
+			if( this.propertyBindings[k].trackName === trackName &&
+				this.propertyBindings[k].rootNode === rootNode ) {
 				return k;
 			}
 		}	
@@ -77,12 +78,14 @@ THREE.AnimationMixer.prototype = {
 
 			var action = this.actions[i];
 
+			var root = action.localRoot || this.root;
+
 			var propertyBindingIndices = [];
 
 			for( var j = 0; j < action.clip.tracks.length; j ++ ) {
 
 				var trackName = action.clip.tracks[j].name;
-				propertyBindingIndices.push( this.getPropertyBindingIndex( trackName ) );
+				propertyBindingIndices.push( this.getPropertyBindingIndex( root, trackName ) );
 			
 			}