Sidebar.Geometry.BufferGeometry.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { UIRow, UIText, UISpan, UIBreak } from './libs/ui.js';
  2. function SidebarGeometryBufferGeometry( editor ) {
  3. var strings = editor.strings;
  4. var signals = editor.signals;
  5. var container = new UIRow();
  6. function update( object ) {
  7. if ( object === null ) return; // objectSelected.dispatch( null )
  8. if ( object === undefined ) return;
  9. var geometry = object.geometry;
  10. if ( geometry && geometry.isBufferGeometry ) {
  11. container.clear();
  12. container.setDisplay( 'block' );
  13. var text = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setWidth( '90px' );
  14. container.add( text );
  15. var container2 = new UISpan().setDisplay( 'inline-block' ).setWidth( '160px' );
  16. container.add( container2 );
  17. var index = geometry.index;
  18. if ( index !== null ) {
  19. container2.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
  20. container2.add( new UIText( ( index.count ).format() ).setFontSize( '12px' ) );
  21. container2.add( new UIBreak() );
  22. }
  23. var attributes = geometry.attributes;
  24. for ( var name in attributes ) {
  25. var attribute = attributes[ name ];
  26. container2.add( new UIText( name ).setWidth( '80px' ) );
  27. container2.add( new UIText( ( attribute.count ).format() + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
  28. container2.add( new UIBreak() );
  29. }
  30. } else {
  31. container.setDisplay( 'none' );
  32. }
  33. }
  34. signals.objectSelected.add( update );
  35. signals.geometryChanged.add( update );
  36. return container;
  37. }
  38. export { SidebarGeometryBufferGeometry };