فهرست منبع

Merge pull request #11097 from Mugen87/dev

MorphAnimation: Removal
Mr.doob 8 سال پیش
والد
کامیت
f7a394157d
3فایلهای تغییر یافته به همراه4 افزوده شده و 161 حذف شده
  1. 0 85
      editor/js/Sidebar.Animation.js
  2. 0 73
      examples/js/MorphAnimation.js
  3. 4 3
      utils/exporters/blender/tests/scripts/js/review.js

+ 0 - 85
editor/js/Sidebar.Animation.js

@@ -19,91 +19,6 @@ Sidebar.Animation = function ( editor ) {
 	var animationsRow = new UI.Row();
 	container.add( animationsRow );
 
-	/*
-
-	var animations = {};
-
-	signals.objectAdded.add( function ( object ) {
-
-		object.traverse( function ( child ) {
-
-			if ( child instanceof THREE.SkinnedMesh ) {
-
-				var material = child.material;
-
-				if ( material instanceof THREE.MultiMaterial ) {
-
-					for ( var i = 0; i < material.materials.length; i ++ ) {
-
-						material.materials[ i ].skinning = true;
-
-					}
-
-				} else {
-
-					child.material.skinning = true;
-
-				}
-
-				animations[ child.id ] = new THREE.Animation( child, child.geometry.animation );
-
-			} else if ( child instanceof THREE.MorphAnimMesh ) {
-
-				var animation = new THREE.MorphAnimation( child );
-				animation.duration = 30;
-
-				// temporal hack for THREE.AnimationHandler
-				animation._play = animation.play;
-				animation.play = function () {
-					this._play();
-					THREE.AnimationHandler.play( this );
-				};
-				animation.resetBlendWeights = function () {};
-				animation.stop = function () {
-					this.pause();
-					THREE.AnimationHandler.stop( this );
-				};
-
-				animations[ child.id ] = animation;
-
-			}
-
-		} );
-
-	} );
-
-	signals.objectSelected.add( function ( object ) {
-
-		container.setDisplay( 'none' );
-
-		if ( object instanceof THREE.SkinnedMesh || object instanceof THREE.MorphAnimMesh ) {
-
-			animationsRow.clear();
-
-			var animation = animations[ object.id ];
-
-			var playButton = new UI.Button( 'Play' ).onClick( function () {
-
-				animation.play();
-
-			} );
-			animationsRow.add( playButton );
-
-			var pauseButton = new UI.Button( 'Stop' ).onClick( function () {
-
-				animation.stop();
-
-			} );
-			animationsRow.add( pauseButton );
-
-			container.setDisplay( 'block' );
-
-		}
-
-	} );
-
-	*/
-
 	return container;
 
 };

+ 0 - 73
examples/js/MorphAnimation.js

@@ -1,73 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com
- * @author willy-vvu / http://willy-vvu.github.io
- */
-
-THREE.MorphAnimation = function ( mesh ) {
-
-	this.mesh = mesh;
-	this.frames = mesh.morphTargetInfluences.length;
-	this.currentTime = 0;
-	this.duration = 1000;
-	this.loop = true;
-	this.lastFrame = 0;
-	this.currentFrame = 0;
-
-	this.isPlaying = false;
-
-};
-
-THREE.MorphAnimation.prototype = {
-
-	constructor: THREE.MorphAnimation,
-
-	play: function () {
-
-		this.isPlaying = true;
-
-	},
-
-	pause: function () {
-
-		this.isPlaying = false;
-
-	},
-
-	update: function ( delta ) {
-
-		if ( this.isPlaying === false ) return;
-
-		this.currentTime += delta;
-
-		if ( this.loop === true && this.currentTime > this.duration ) {
-
-			this.currentTime %= this.duration;
-
-		}
-
-		this.currentTime = Math.min( this.currentTime, this.duration );
-
-		var frameTime = this.duration / this.frames;
-		var frame = Math.floor( this.currentTime / frameTime );
-
-		var influences = this.mesh.morphTargetInfluences;
-
-		if ( frame !== this.currentFrame ) {
-
-			influences[ this.lastFrame ] = 0;
-			influences[ this.currentFrame ] = 1;
-			influences[ frame ] = 0;
-
-			this.lastFrame = this.currentFrame;
-			this.currentFrame = frame;
-
-		}
-
-		var mix = ( this.currentTime % frameTime ) / frameTime;
-
-		influences[ frame ] = mix;
-		influences[ this.lastFrame ] = 1 - mix;
-
-	}
-
-};

+ 4 - 3
utils/exporters/blender/tests/scripts/js/review.js

@@ -147,13 +147,14 @@ function loadGeometry( data, url ) {
 
     } else {
 
-        mesh = new THREE.Mesh( data.geometry, material );
-
         if ( data.geometry.morphTargets.length > 0 ) {
 
             console.log( 'loading morph targets' );
             data.materials[ 0 ].morphTargets = true;
-            animation = new THREE.MorphAnimation( mesh );
+            mesh = new THREE.MorphAnimMesh( data.geometry, material );
+
+            mixer = mesh.mixer;
+            animation = mixer.clipAction( mesh.geometry.animations[ 0 ] );
             hasMorph = true;
 
         }