Sidebar.Animation.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Animation = function ( editor ) {
  5. var signals = editor.signals;
  6. var options = {};
  7. var possibleAnimations = {};
  8. var container = new UI.Panel();
  9. container.setDisplay( 'none' );
  10. container.add( new UI.Text( 'Animation' ).setTextTransform( 'uppercase' ) );
  11. container.add( new UI.Break() );
  12. container.add( new UI.Break() );
  13. var animationsRow = new UI.Row();
  14. container.add( animationsRow );
  15. /*
  16. var animations = {};
  17. signals.objectAdded.add( function ( object ) {
  18. object.traverse( function ( child ) {
  19. animations[ child.id ] = new THREE.Animation( child, child.geometry.animation );
  20. } else if ( child instanceof THREE.MorphAnimMesh ) {
  21. var animation = new THREE.MorphAnimation( child );
  22. animation.duration = 30;
  23. // temporal hack for THREE.AnimationHandler
  24. animation._play = animation.play;
  25. animation.play = function () {
  26. this._play();
  27. THREE.AnimationHandler.play( this );
  28. };
  29. animation.resetBlendWeights = function () {};
  30. animation.stop = function () {
  31. this.pause();
  32. THREE.AnimationHandler.stop( this );
  33. };
  34. animations[ child.id ] = animation;
  35. }
  36. } );
  37. } );
  38. signals.objectSelected.add( function ( object ) {
  39. container.setDisplay( 'none' );
  40. if ( object instanceof THREE.SkinnedMesh || object instanceof THREE.MorphAnimMesh ) {
  41. animationsRow.clear();
  42. var animation = animations[ object.id ];
  43. var playButton = new UI.Button( 'Play' ).onClick( function () {
  44. animation.play();
  45. } );
  46. animationsRow.add( playButton );
  47. var pauseButton = new UI.Button( 'Stop' ).onClick( function () {
  48. animation.stop();
  49. } );
  50. animationsRow.add( pauseButton );
  51. container.setDisplay( 'block' );
  52. }
  53. } );
  54. */
  55. return container;
  56. };