Sidebar.Geometry.Modifiers.js 1.3 KB

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