|
@@ -11,84 +11,73 @@ Sidebar.Animation = function ( editor ) {
|
|
|
container.addStatic( new UI.Text( 'ANIMATION' ) );
|
|
|
container.add( new UI.Break() );
|
|
|
|
|
|
- var AnimationsRow = new UI.Panel();
|
|
|
- var Animations = new UI.Select().setOptions( options ).setWidth( '130px' ).setColor( '#444' ).setFontSize( '12px' );
|
|
|
- AnimationsRow.add( new UI.Text( 'animations' ).setWidth( '90px' ) );
|
|
|
- AnimationsRow.add( Animations );
|
|
|
+ var animationsRow = new UI.Panel();
|
|
|
+ container.add( animationsRow );
|
|
|
|
|
|
- container.add( AnimationsRow );
|
|
|
- container.add( new UI.Break() );
|
|
|
+ var animations = {};
|
|
|
|
|
|
- var PlayRow = new UI.Panel();
|
|
|
- var playButton = new UI.Button().setLabel( 'Play' ).onClick( play );
|
|
|
- PlayRow.add( playButton );
|
|
|
+ signals.objectAdded.add( function ( object ) {
|
|
|
|
|
|
- container.add( PlayRow );
|
|
|
- container.add( new UI.Break() );
|
|
|
+ object.traverse( function ( child ) {
|
|
|
|
|
|
- function play() {
|
|
|
+ if ( child instanceof THREE.SkinnedMesh ) {
|
|
|
|
|
|
- var value = Animations.getValue();
|
|
|
+ var material = child.material;
|
|
|
|
|
|
- if ( possibleAnimations[ value ] ) {
|
|
|
+ if ( material instanceof THREE.MeshFaceMaterial ) {
|
|
|
|
|
|
- var anims = possibleAnimations[value]
|
|
|
+ for ( var i = 0; i < material.materials.length; i ++ ) {
|
|
|
|
|
|
- for ( var i = 0; i < anims.length; i ++ ) {
|
|
|
+ material.materials[ i ].skinning = true;
|
|
|
|
|
|
- anims[ i ].play();
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- signals.playAnimations.dispatch( anims );
|
|
|
+ child.material.skinning = true;
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ console.log( child.geometry );
|
|
|
|
|
|
- signals.objectAdded.add( function ( object ) {
|
|
|
+ animations[ child.id ] = new THREE.Animation( child );
|
|
|
|
|
|
- if ( object instanceof THREE.SkinnedMesh ) {
|
|
|
-
|
|
|
- var geometry = object.geometry;
|
|
|
- var material = object.material;
|
|
|
+ }
|
|
|
|
|
|
- material.skinning = true;
|
|
|
+ } );
|
|
|
|
|
|
- var name = geometry.animation.name;
|
|
|
+ } );
|
|
|
|
|
|
- options[ name ] = name
|
|
|
+ signals.objectSelected.add( function ( object ) {
|
|
|
|
|
|
- Animations.setOptions( options );
|
|
|
+ container.setDisplay( 'none' );
|
|
|
|
|
|
- THREE.AnimationHandler.add( geometry.animation );
|
|
|
+ if ( object instanceof THREE.SkinnedMesh ) {
|
|
|
|
|
|
- var animation = new THREE.Animation( object, name );
|
|
|
+ animationsRow.clear();
|
|
|
|
|
|
- if ( possibleAnimations[ name ] ){
|
|
|
+ var animation = animations[ object.id ];
|
|
|
|
|
|
- possibleAnimations[ name ].push( animation );
|
|
|
+ var playButton = new UI.Button().setLabel( 'Play' ).onClick( function () {
|
|
|
|
|
|
- } else {
|
|
|
+ animation.play();
|
|
|
|
|
|
- possibleAnimations[ name ] = [ animation ];
|
|
|
+ signals.playAnimation.dispatch( animation );
|
|
|
|
|
|
- }
|
|
|
+ } );
|
|
|
+ animationsRow.add( playButton );
|
|
|
|
|
|
- }
|
|
|
+ var pauseButton = new UI.Button().setLabel( 'Stop' ).onClick( function () {
|
|
|
|
|
|
- } );
|
|
|
+ animation.stop();
|
|
|
|
|
|
- signals.objectSelected.add( function ( object ) {
|
|
|
+ signals.stopAnimation.dispatch( animation );
|
|
|
|
|
|
- if ( object && object.geometry && object.geometry.animation ) {
|
|
|
+ } );
|
|
|
+ animationsRow.add( pauseButton );
|
|
|
|
|
|
container.setDisplay( 'block' );
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- container.setDisplay( 'none' );
|
|
|
-
|
|
|
}
|
|
|
|
|
|
} );
|