Browse Source

a method to interpolate between two morph targets

does not fix #5051 but eases the pain for people trying to work around it
makc 11 years ago
parent
commit
76fd727731
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/objects/MorphAnimMesh.js

+ 16 - 0
src/objects/MorphAnimMesh.js

@@ -175,6 +175,22 @@ THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) {
 
 };
 
+THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) {
+	for ( var i = 0, n = this.morphTargetInfluences.length; i < n; i++ ) {
+		switch ( i ) {
+			case a:
+				this.morphTargetInfluences[ i ] = 1 - t;
+				break;
+			case b:
+				this.morphTargetInfluences[ i ] = t;
+				break;
+			default:
+				this.morphTargetInfluences[ i ] = 0;
+				break;
+		}
+	}
+};
+
 THREE.MorphAnimMesh.prototype.clone = function ( object ) {
 
 	if ( object === undefined ) object = new THREE.MorphAnimMesh( this.geometry, this.material );