Sidebar.Settings.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Settings = function ( editor ) {
  5. var config = editor.config;
  6. var signals = editor.signals;
  7. var strings = editor.strings;
  8. var container = new UI.Panel();
  9. container.setBorderTop( '0' );
  10. container.setPaddingTop( '20px' );
  11. container.setPaddingBottom( '20px' );
  12. // language
  13. var options = {
  14. 'en': 'English',
  15. 'zh': '中文'
  16. };
  17. var languageRow = new UI.Row();
  18. var language = new UI.Select().setWidth( '150px' );
  19. language.setOptions( options );
  20. if ( config.getKey( 'language' ) !== undefined ) {
  21. language.setValue( config.getKey( 'language' ) );
  22. }
  23. language.onChange( function () {
  24. var value = this.getValue();
  25. editor.config.setKey( 'language', value );
  26. } );
  27. languageRow.add( new UI.Text( strings.getKey( 'sidebar/settings/language' ) ).setWidth( '90px' ) );
  28. languageRow.add( language );
  29. container.add( languageRow );
  30. // theme
  31. var options = {
  32. 'css/light.css': strings.getKey( 'sidebar/settings/theme/light' ),
  33. 'css/dark.css': strings.getKey( 'sidebar/settings/theme/dark' )
  34. };
  35. var themeRow = new UI.Row();
  36. var theme = new UI.Select().setWidth( '150px' );
  37. theme.setOptions( options );
  38. if ( config.getKey( 'theme' ) !== undefined ) {
  39. theme.setValue( config.getKey( 'theme' ) );
  40. }
  41. theme.onChange( function () {
  42. var value = this.getValue();
  43. editor.setTheme( value );
  44. editor.config.setKey( 'theme', value );
  45. } );
  46. themeRow.add( new UI.Text( strings.getKey( 'sidebar/settings/theme' ) ).setWidth( '90px' ) );
  47. themeRow.add( theme );
  48. container.add( themeRow );
  49. // scene camera visible
  50. var sceneShowCameraRow = new UI.Row();
  51. container.add( sceneShowCameraRow );
  52. var sceneCameraCheckbox = new UI.Checkbox( config.getKey( 'project/renderer/showSceneCameras' ) || false ).onChange( function () {
  53. config.setKey( 'project/renderer/showSceneCameras', this.getValue() );
  54. signals.sceneCamerasChanged.dispatch();
  55. } );
  56. sceneShowCameraRow.add( new UI.Text( strings.getKey( 'sidebar/settings/showSceneCameras' ) ).setWidth( '90px' ), sceneCameraCheckbox );
  57. // show helpers
  58. var showHelpersRow = new UI.Row();
  59. container.add( showHelpersRow );
  60. var showHelpersCheckbox = new UI.Checkbox( config.getKey( 'project/renderer/showHelpers' ) || false ).onChange( function () {
  61. config.setKey( 'project/renderer/showHelpers', this.getValue() );
  62. signals.sceneGraphChanged.dispatch();
  63. } );
  64. showHelpersRow.add( new UI.Text( strings.getKey( 'sidebar/settings/showHelpers' ) ).setWidth( '90px' ), showHelpersCheckbox );
  65. container.add( new Sidebar.Settings.Shortcuts( editor ) );
  66. container.add( new Sidebar.Settings.Viewport( editor ) );
  67. return container;
  68. };