From 9c0349a7e790a755fe3ab8b398074467752725f4 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 31 Mar 2017 17:01:28 +0200 Subject: [PATCH] MorphAnimation: Removal --- editor/js/Sidebar.Animation.js | 85 ------------------- examples/js/MorphAnimation.js | 73 ---------------- .../blender/tests/scripts/js/review.js | 7 +- 3 files changed, 4 insertions(+), 161 deletions(-) delete mode 100644 examples/js/MorphAnimation.js diff --git a/editor/js/Sidebar.Animation.js b/editor/js/Sidebar.Animation.js index af576d2b71..eab588a13a 100644 --- a/editor/js/Sidebar.Animation.js +++ b/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; }; diff --git a/examples/js/MorphAnimation.js b/examples/js/MorphAnimation.js deleted file mode 100644 index 6c18bdab76..0000000000 --- a/examples/js/MorphAnimation.js +++ /dev/null @@ -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; - - } - -}; diff --git a/utils/exporters/blender/tests/scripts/js/review.js b/utils/exporters/blender/tests/scripts/js/review.js index 5a4f554a2a..4dd51f1a51 100644 --- a/utils/exporters/blender/tests/scripts/js/review.js +++ b/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; } -- GitLab