Sidebar.Geometry.BufferGeometry.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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( '70px' ) );
  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( '70px' ) );
  29. let info = editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')';
  30. if ( attribute.isInterleavedBufferAttribute ) {
  31. info += ' (' + attribute.data.stride + ')';
  32. }
  33. containerAttributes.add( new UIText( info ).setFontSize( '12px' ) );
  34. containerAttributes.add( new UIBreak() );
  35. }
  36. container.add( attributesRow );
  37. // morph targets
  38. const morphAttributes = geometry.morphAttributes;
  39. const hasMorphTargets = Object.keys( morphAttributes ).length > 0;
  40. if ( hasMorphTargets === true ) {
  41. // morph attributes
  42. const rowMorphAttributes = new UIRow();
  43. const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass( 'Label' );
  44. rowMorphAttributes.add( textMorphAttributes );
  45. const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
  46. rowMorphAttributes.add( containerMorphAttributes );
  47. for ( const name in morphAttributes ) {
  48. const morphTargets = morphAttributes[ name ];
  49. containerMorphAttributes.add( new UIText( name ).setWidth( '70px' ) );
  50. containerMorphAttributes.add( new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize( '12px' ) );
  51. containerMorphAttributes.add( new UIBreak() );
  52. }
  53. container.add( rowMorphAttributes );
  54. // morph relative
  55. const rowMorphRelative = new UIRow();
  56. const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass( 'Label' );
  57. rowMorphRelative.add( textMorphRelative );
  58. const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
  59. rowMorphRelative.add( checkboxMorphRelative );
  60. container.add( rowMorphRelative );
  61. }
  62. } else {
  63. container.setDisplay( 'none' );
  64. }
  65. }
  66. signals.objectSelected.add( update );
  67. signals.geometryChanged.add( update );
  68. return container;
  69. }
  70. export { SidebarGeometryBufferGeometry };
粤ICP备19079148号