Sidebar.Animation.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.CollapsiblePanel();
  9. container.setCollapsed( editor.config.getKey( 'ui/sidebar/animation/collapsed' ) );
  10. container.onCollapsedChange( function ( boolean ) {
  11. editor.config.setKey( 'ui/sidebar/animation/collapsed', boolean );
  12. } );
  13. container.setDisplay( 'none' );
  14. container.addStatic( new UI.Text( 'Animation' ).setTextTransform( 'uppercase' ) );
  15. container.add( new UI.Break() );
  16. var animationsRow = new UI.Row();
  17. container.add( animationsRow );
  18. /*
  19. var animations = {};
  20. signals.objectAdded.add( function ( object ) {
  21. object.traverse( function ( child ) {
  22. if ( child instanceof THREE.SkinnedMesh ) {
  23. var material = child.material;
  24. if ( material instanceof THREE.MultiMaterial ) {
  25. for ( var i = 0; i < material.materials.length; i ++ ) {
  26. material.materials[ i ].skinning = true;
  27. }
  28. } else {
  29. child.material.skinning = true;
  30. }
  31. animations[ child.id ] = new THREE.Animation( child, child.geometry.animation );
  32. } else if ( child instanceof THREE.MorphAnimMesh ) {
  33. var animation = new THREE.MorphAnimation( child );
  34. animation.duration = 30;
  35. // temporal hack for THREE.AnimationHandler
  36. animation._play = animation.play;
  37. animation.play = function () {
  38. this._play();
  39. THREE.AnimationHandler.play( this );
  40. };
  41. animation.resetBlendWeights = function () {};
  42. animation.stop = function () {
  43. this.pause();
  44. THREE.AnimationHandler.stop( this );
  45. };
  46. animations[ child.id ] = animation;
  47. }
  48. } );
  49. } );
  50. signals.objectSelected.add( function ( object ) {
  51. container.setDisplay( 'none' );
  52. if ( object instanceof THREE.SkinnedMesh || object instanceof THREE.MorphAnimMesh ) {
  53. animationsRow.clear();
  54. var animation = animations[ object.id ];
  55. var playButton = new UI.Button( 'Play' ).onClick( function () {
  56. animation.play();
  57. } );
  58. animationsRow.add( playButton );
  59. var pauseButton = new UI.Button( 'Stop' ).onClick( function () {
  60. animation.stop();
  61. } );
  62. animationsRow.add( pauseButton );
  63. container.setDisplay( 'block' );
  64. }
  65. } );
  66. */
  67. return container;
  68. }