Sidebar.Geometry.BufferGeometry.js 1.6 KB

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