Sidebar.Outliner.Textures.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Sidebar.Outliner.Textures = function ( signals ) {
  2. var container = new UI.Panel();
  3. container.name = "TEX";
  4. container.setPadding( '10px' );
  5. var outliner = new UI.FancySelect().setWidth( '100%' ).setHeight('170px').setColor( '#444' ).setFontSize( '12px' ).onChange( selectFromOutliner );
  6. container.add( outliner );
  7. var textures = null;
  8. function getTextures() {
  9. var options = {};
  10. for ( var i in editor.textures ) {
  11. var texture = editor.textures[ i ];
  12. options[ i ] = '- ' + texture.name;
  13. }
  14. outliner.setOptions( options );
  15. getSelected();
  16. }
  17. function selectFromOutliner() {
  18. var id = outliner.getValue();
  19. editor.select( editor.textures[ id ] );
  20. }
  21. function getSelected() {
  22. var selectedIds = [];
  23. for ( var id in editor.selected ) {
  24. if ( editor.textures[ id ] ) selectedIds.push( id );
  25. }
  26. // TODO: implement multiple selection
  27. outliner.setValue( selectedIds.length ? selectedIds[0] : null );
  28. }
  29. // events
  30. var timeout;
  31. signals.sceneChanged.add( function () {
  32. clearTimeout( timeout );
  33. timeout = setTimeout( function () {
  34. getTextures();
  35. }, 100 );
  36. } );
  37. signals.selected.add( getSelected );
  38. return container;
  39. }
粤ICP备19079148号