Sidebar.Geometry.BufferGeometry.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { UIRow, UIText, UISpan, UIBreak, UICheckbox } from './libs/ui.js';
  2. function SidebarGeometryBufferGeometry( editor ) {
  3. const strings = editor.strings;
  4. const signals = editor.signals;
  5. const container = new UIRow();
  6. function update( object ) {
  7. if ( object === null ) return; // objectSelected.dispatch( null )
  8. if ( object === undefined ) return;
  9. const geometry = object.geometry;
  10. if ( geometry ) {
  11. container.clear();
  12. container.setDisplay( 'block' );
  13. // attributes
  14. const attributesRow = new UIRow();
  15. const textAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass( 'Label' );
  16. attributesRow.add( textAttributes );
  17. const containerAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
  18. attributesRow.add( containerAttributes );
  19. const index = geometry.index;
  20. if ( index !== null ) {
  21. containerAttributes.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
  22. containerAttributes.add( new UIText( editor.utils.formatNumber( index.count ) ).setFontSize( '12px' ) );
  23. containerAttributes.add( new UIBreak() );
  24. }
  25. const attributes = geometry.attributes;
  26. for ( const name in attributes ) {
  27. const attribute = attributes[ name ];
  28. containerAttributes.add( new UIText( name ).setWidth( '80px' ) );
  29. containerAttributes.add( new UIText( editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
  30. containerAttributes.add( new UIBreak() );
  31. }
  32. container.add( attributesRow );
  33. // morph targets
  34. const morphAttributes = geometry.morphAttributes;
  35. const hasMorphTargets = Object.keys( morphAttributes ).length > 0;
  36. if ( hasMorphTargets === true ) {
  37. // morph attributes
  38. const rowMorphAttributes = new UIRow();
  39. const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass( 'Label' );
  40. rowMorphAttributes.add( textMorphAttributes );
  41. const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
  42. rowMorphAttributes.add( containerMorphAttributes );
  43. for ( const name in morphAttributes ) {
  44. const morphTargets = morphAttributes[ name ];
  45. containerMorphAttributes.add( new UIText( name ).setWidth( '80px' ) );
  46. containerMorphAttributes.add( new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize( '12px' ) );
  47. containerMorphAttributes.add( new UIBreak() );
  48. }
  49. container.add( rowMorphAttributes );
  50. // morph relative
  51. const rowMorphRelative = new UIRow();
  52. const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass( 'Label' );
  53. rowMorphRelative.add( textMorphRelative );
  54. const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
  55. rowMorphRelative.add( checkboxMorphRelative );
  56. container.add( rowMorphRelative );
  57. }
  58. } else {
  59. container.setDisplay( 'none' );
  60. }
  61. }
  62. signals.objectSelected.add( update );
  63. signals.geometryChanged.add( update );
  64. return container;
  65. }
  66. export { SidebarGeometryBufferGeometry };