Przeglądaj źródła

update morphanimmesh to work with the new mixer.

Ben Houston 10 lat temu
rodzic
commit
4985ed03db

+ 1 - 1
examples/js/MD2Character.js

@@ -52,7 +52,7 @@ THREE.MD2Character = function () {
 			scope.root.add( mesh );
 
 			scope.meshBody = mesh;
-			scope.activeAnimationClipName = geo.firstAnimationClip.name;
+			scope.activeAnimationClipName = mesh.firstAnimationClip.name;
 
 			checkLoadingComplete();
 

+ 3 - 3
src/animation/PropertyBinding.js

@@ -23,8 +23,8 @@ THREE.PropertyBinding = function ( rootNode, trackName ) {
 	this.propertyName = parseResults.propertyName;
 	this.propertyIndex = parseResults.propertyIndex;
 
-	this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName );
-
+	this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName ) || rootNode;
+	
 	this.cumulativeValue = null;
 	this.cumulativeWeight = 0;
 };
@@ -340,7 +340,7 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 // TODO: Cache this at some point
 THREE.PropertyBinding.findNode = function( root, nodeName ) {
 
-	//console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')');
+	//console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')', root );
 	
 	if( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
 

+ 4 - 2
src/objects/MorphAnimMesh.js

@@ -36,7 +36,7 @@ THREE.MorphAnimMesh.prototype.parseAnimations = function () {
 
 };
 
-THREE.MorphAnimMesh.prototype.playAnimation = function ( label ) {
+THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
 
 	this.mixer.removeAllActions();
 
@@ -50,7 +50,9 @@ THREE.MorphAnimMesh.prototype.playAnimation = function ( label ) {
 	
 	if ( clip ) {
 
-		this.mixer.addAction( new THREE.AnimationAction( clip, 0, 1, 1, true ) );
+		var action = new THREE.AnimationAction( clip, 0, 1, 1, true );
+		action.timeScale = ( clip.tracks.length * fps ) / clip.duration;
+		this.mixer.addAction( action );
 
 	} else {