提交 9c0349a7 编写于 作者: M Mugen87

MorphAnimation: Removal

上级 6c5354f4
......@@ -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;
};
/**
* @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;
}
};
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册