Sidebar.Animation.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. if ( child instanceof THREE.SkinnedMesh ) {
  20. var material = child.material;
  21. if ( material instanceof THREE.MultiMaterial ) {
  22. for ( var i = 0; i < material.materials.length; i ++ ) {
  23. material.materials[ i ].skinning = true;
  24. }
  25. } else {
  26. child.material.skinning = true;
  27. }
  28. animations[ child.id ] = new THREE.Animation( child, child.geometry.animation );
  29. } else if ( child instanceof THREE.MorphAnimMesh ) {
  30. var animation = new THREE.MorphAnimation( child );
  31. animation.duration = 30;
  32. // temporal hack for THREE.AnimationHandler
  33. animation._play = animation.play;
  34. animation.play = function () {
  35. this._play();
  36. THREE.AnimationHandler.play( this );
  37. };
  38. animation.resetBlendWeights = function () {};
  39. animation.stop = function () {
  40. this.pause();
  41. THREE.AnimationHandler.stop( this );
  42. };
  43. animations[ child.id ] = animation;
  44. }
  45. } );
  46. } );
  47. signals.objectSelected.add( function ( object ) {
  48. container.setDisplay( 'none' );
  49. if ( object instanceof THREE.SkinnedMesh || object instanceof THREE.MorphAnimMesh ) {
  50. animationsRow.clear();
  51. var animation = animations[ object.id ];
  52. var playButton = new UI.Button( 'Play' ).onClick( function () {
  53. animation.play();
  54. } );
  55. animationsRow.add( playButton );
  56. var pauseButton = new UI.Button( 'Stop' ).onClick( function () {
  57. animation.stop();
  58. } );
  59. animationsRow.add( pauseButton );
  60. container.setDisplay( 'block' );
  61. }
  62. } );
  63. */
  64. return container;
  65. };