123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- Sidebar.Properties.Geometry = function ( signals ) {
- var container = new UI.Panel();
- container.setDisplay( 'none' );
- container.add( new UI.Text().setText( 'GEOMETRY' ).setColor( '#666' ) );
- container.add( new UI.Button( 'absolute' ).setRight( '0px' ).setText( 'Export' ).onClick( exportGeometry ) );
- container.add( new UI.Break(), new UI.Break() );
- container.add( new UI.Text().setText( 'Name' ).setColor( '#666' ) );
- var geometryName = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
- container.add( geometryName );
- container.add( new UI.HorizontalRule() );
- container.add( new UI.Text().setText( 'Class' ).setColor( '#666' ) );
- var geometryClass = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
- container.add( geometryClass );
- container.add( new UI.HorizontalRule() );
- container.add( new UI.Text().setText( 'Vertices' ).setColor( '#666' ) );
-
- var verticesCount = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
- container.add( verticesCount );
- container.add( new UI.HorizontalRule() );
- container.add( new UI.Text().setText( 'Faces' ).setColor( '#666' ) );
- var facesCount = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
- container.add( facesCount );
- container.add( new UI.Break(), new UI.Break(), new UI.Break() );
- //
- var selected = null;
- signals.objectSelected.add( function ( object ) {
- if ( object && object.geometry ) {
- selected = object.geometry;
- container.setDisplay( 'block' );
- geometryName.setText( object.geometry.name );
- geometryClass.setText( getGeometryInstanceName( object.geometry ) );
- verticesCount.setText( object.geometry.vertices.length );
- facesCount.setText( object.geometry.faces.length );
- } else {
- selected = null;
- container.setDisplay( 'none' );
- }
- } );
- function getGeometryInstanceName( geometry ) {
- // TODO: Is there a way of doing this automatically?
- if ( geometry instanceof THREE.ConvexGeometry ) return "ConvexGeometry";
- if ( geometry instanceof THREE.CubeGeometry ) return "CubeGeometry";
- if ( geometry instanceof THREE.CylinderGeometry ) return "CylinderGeometry";
- if ( geometry instanceof THREE.ExtrudeGeometry ) return "ExtrudeGeometry";
- if ( geometry instanceof THREE.IcosahedronGeometry ) return "IcosahedronGeometry";
- if ( geometry instanceof THREE.LatheGeometry ) return "LatheGeometry";
- if ( geometry instanceof THREE.OctahedronGeometry ) return "OctahedronGeometry";
- if ( geometry instanceof THREE.ParametricGeometry ) return "ParametricGeometry";
- if ( geometry instanceof THREE.PlaneGeometry ) return "PlaneGeometry";
- if ( geometry instanceof THREE.PolyhedronGeometry ) return "PolyhedronGeometry";
- if ( geometry instanceof THREE.SphereGeometry ) return "SphereGeometry";
- if ( geometry instanceof THREE.TetrahedronGeometry ) return "TetrahedronGeometry";
- if ( geometry instanceof THREE.TextGeometry ) return "TextGeometry";
- if ( geometry instanceof THREE.TorusGeometry ) return "TorusGeometry";
- if ( geometry instanceof THREE.TorusKnotGeometry ) return "TorusKnotGeometry";
- if ( geometry instanceof THREE.TubeGeometry ) return "TubeGeometry";
- if ( geometry instanceof THREE.Geometry ) return "Geometry";
- }
- function exportGeometry() {
- console.log( selected );
- }
- return container;
- }
|