Sidebar.Geometry.BufferGeometry.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Geometry.BufferGeometry = function ( editor ) {
  5. var signals = editor.signals;
  6. var container = new UI.Row();
  7. function update( object ) {
  8. if ( object === null ) return; // objectSelected.dispatch( null )
  9. if ( object === undefined ) return;
  10. var geometry = object.geometry;
  11. if ( geometry instanceof THREE.BufferGeometry ) {
  12. container.clear();
  13. container.setDisplay( 'block' );
  14. var text = new UI.Text( 'Attributes' ).setWidth( '90px' );
  15. container.add( text );
  16. var container2 = new UI.Span().setDisplay( 'inline-block' ).setWidth( '160px' );
  17. container.add( container2 );
  18. var index = geometry.index;
  19. if ( index !== null ) {
  20. container2.add( new UI.Text( 'index' ).setWidth( '80px' ) );
  21. container2.add( new UI.Text( ( index.count ).format() ).setFontSize( '12px' ) );
  22. container2.add( new UI.Break() );
  23. }
  24. var attributes = geometry.attributes;
  25. for ( var name in attributes ) {
  26. var attribute = attributes[ name ];
  27. container2.add( new UI.Text( name ).setWidth( '80px' ) );
  28. container2.add( new UI.Text( ( attribute.count ).format() + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
  29. container2.add( new UI.Break() );
  30. }
  31. } else {
  32. container.setDisplay( 'none' );
  33. }
  34. }
  35. signals.objectSelected.add( update );
  36. signals.geometryChanged.add( update );
  37. return container;
  38. };