Sidebar.Properties.Geometry.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Sidebar.Properties.Geometry = function ( signals ) {
  2. var container = new UI.Panel();
  3. container.setDisplay( 'none' );
  4. container.add( new UI.Text().setText( 'GEOMETRY' ).setColor( '#666' ) );
  5. container.add( new UI.Break(), new UI.Break() );
  6. container.add( new UI.Text().setText( 'Name' ).setColor( '#666' ) );
  7. var geometryName = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
  8. container.add( geometryName );
  9. container.add( new UI.HorizontalRule() );
  10. container.add( new UI.Text().setText( 'Class' ).setColor( '#666' ) );
  11. var geometryClass = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
  12. container.add( geometryClass );
  13. container.add( new UI.HorizontalRule() );
  14. container.add( new UI.Text().setText( 'Vertices' ).setColor( '#666' ) );
  15. var verticesCount = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
  16. container.add( verticesCount );
  17. container.add( new UI.HorizontalRule() );
  18. container.add( new UI.Text().setText( 'Faces' ).setColor( '#666' ) );
  19. var facesCount = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
  20. container.add( facesCount );
  21. container.add( new UI.Break(), new UI.Break(), new UI.Break() );
  22. //
  23. signals.objectSelected.add( function ( object ) {
  24. if ( object && object.geometry ) {
  25. container.setDisplay( 'block' );
  26. geometryName.setText( object.geometry.name );
  27. geometryClass.setText( getGeometryInstanceName( object.geometry ) );
  28. verticesCount.setText( object.geometry.vertices.length );
  29. facesCount.setText( object.geometry.faces.length );
  30. } else {
  31. container.setDisplay( 'none' );
  32. }
  33. } );
  34. function getGeometryInstanceName( geometry ) {
  35. // TODO: Is there a way of doing this automatically?
  36. if ( geometry instanceof THREE.ConvexGeometry ) return "ConvexGeometry";
  37. if ( geometry instanceof THREE.CubeGeometry ) return "CubeGeometry";
  38. if ( geometry instanceof THREE.CylinderGeometry ) return "CylinderGeometry";
  39. if ( geometry instanceof THREE.ExtrudeGeometry ) return "ExtrudeGeometry";
  40. if ( geometry instanceof THREE.IcosahedronGeometry ) return "IcosahedronGeometry";
  41. if ( geometry instanceof THREE.LatheGeometry ) return "LatheGeometry";
  42. if ( geometry instanceof THREE.OctahedronGeometry ) return "OctahedronGeometry";
  43. if ( geometry instanceof THREE.ParametricGeometry ) return "ParametricGeometry";
  44. if ( geometry instanceof THREE.PlaneGeometry ) return "PlaneGeometry";
  45. if ( geometry instanceof THREE.PolyhedronGeometry ) return "PolyhedronGeometry";
  46. if ( geometry instanceof THREE.SphereGeometry ) return "SphereGeometry";
  47. if ( geometry instanceof THREE.TetrahedronGeometry ) return "TetrahedronGeometry";
  48. if ( geometry instanceof THREE.TextGeometry ) return "TextGeometry";
  49. if ( geometry instanceof THREE.TorusGeometry ) return "TorusGeometry";
  50. if ( geometry instanceof THREE.TorusKnotGeometry ) return "TorusKnotGeometry";
  51. if ( geometry instanceof THREE.TubeGeometry ) return "TubeGeometry";
  52. if ( geometry instanceof THREE.Geometry ) return "Geometry";
  53. }
  54. return container;
  55. }