Sidebar.Geometry.Modifiers.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Geometry.Modifiers = function ( signals, object ) {
  5. var container = new UI.Panel().setPaddingLeft( '90px' );
  6. var geometry = object.geometry;
  7. // Compute Vertex Normals
  8. var button = new UI.Button( 'Compute Vertex Normals' );
  9. button.onClick( function () {
  10. geometry.computeVertexNormals();
  11. if ( geometry instanceof THREE.BufferGeometry ) {
  12. geometry.attributes.normal.needsUpdate = true;
  13. } else {
  14. geometry.normalsNeedUpdate = true;
  15. }
  16. signals.geometryChanged.dispatch( object );
  17. } );
  18. container.add( button );
  19. // Convert to Geometry/BufferGeometry
  20. var isBufferGeometry = geometry instanceof THREE.BufferGeometry;
  21. if ( geometry instanceof THREE.BufferGeometry ) {
  22. var button = new UI.Button( 'Convert to Geometry' );
  23. button.onClick( function () {
  24. if ( confirm( 'Are you sure?' ) === false ) return;
  25. object.geometry = new THREE.Geometry().fromBufferGeometry( object.geometry );
  26. signals.geometryChanged.dispatch( object );
  27. } );
  28. container.add( button );
  29. } else {
  30. var button = new UI.Button( 'Convert to BufferGeometry' );
  31. button.onClick( function () {
  32. if ( confirm( 'Are you sure?' ) === false ) return;
  33. object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
  34. signals.geometryChanged.dispatch( object );
  35. } );
  36. container.add( button );
  37. }
  38. //
  39. return container;
  40. }