Browse Source

Merge pull request #18718 from Mugen87/dev11

Editor: Make decimal precision on export configurable.
Mr.doob 5 years ago
parent
commit
d77016c1c3
4 changed files with 27 additions and 4 deletions
  1. 1 0
      editor/js/Config.js
  2. 3 3
      editor/js/Menubar.File.js
  3. 21 1
      editor/js/Sidebar.Settings.js
  4. 2 0
      editor/js/Strings.js

+ 1 - 0
editor/js/Config.js

@@ -8,6 +8,7 @@ var Config = function () {
 
 	var storage = {
 		'language': 'en',
+		'exportPrecision': 6,
 
 		'autosave': true,
 

+ 3 - 3
editor/js/Menubar.File.js

@@ -14,11 +14,11 @@ import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js';
 
 var MenubarFile = function ( editor ) {
 
-	var NUMBER_PRECISION = 6;
-
 	function parseNumber( key, value ) {
 
-		return typeof value === 'number' ? parseFloat( value.toFixed( NUMBER_PRECISION ) ) : value;
+		var precision = config.getKey( 'exportPrecision' );
+
+		return typeof value === 'number' ? parseFloat( value.toFixed( precision ) ) : value;
 
 	}
 

+ 21 - 1
editor/js/Sidebar.Settings.js

@@ -2,7 +2,7 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
-import { UIPanel, UIRow, UISelect, UIText } from './libs/ui.js';
+import { UIPanel, UIRow, UISelect, UIText, UIInteger } from './libs/ui.js';
 
 import { SidebarSettingsViewport } from './Sidebar.Settings.Viewport.js';
 import { SidebarSettingsShortcuts } from './Sidebar.Settings.Shortcuts.js';
@@ -47,6 +47,26 @@ var SidebarSettings = function ( editor ) {
 
 	container.add( languageRow );
 
+	// export precision
+
+	var exportPrecisionRow = new UIRow();
+	var exportPrecision = new UIInteger( config.getKey( 'exportPrecision' ) ).setRange( 2, Infinity );
+
+	exportPrecision.onChange( function () {
+
+		var value = this.getValue();
+
+		editor.config.setKey( 'exportPrecision', value );
+
+	} );
+
+	exportPrecisionRow.add( new UIText( strings.getKey( 'sidebar/settings/exportPrecision' ) ).setWidth( '90px' ) );
+	exportPrecisionRow.add( exportPrecision );
+
+	container.add( exportPrecisionRow );
+
+	//
+
 	container.add( new SidebarSettingsShortcuts( editor ) );
 	container.add( new SidebarSettingsViewport( editor ) );
 

+ 2 - 0
editor/js/Strings.js

@@ -295,6 +295,7 @@ var Strings = function ( config ) {
 
 			'sidebar/settings': 'Settings',
 			'sidebar/settings/language': 'Language',
+			'sidebar/settings/exportPrecision': 'Export Precision',
 
 			'sidebar/settings/shortcuts/translate': 'Translate',
 			'sidebar/settings/shortcuts/rotate': 'Rotate',
@@ -580,6 +581,7 @@ var Strings = function ( config ) {
 
 			'sidebar/settings': '设置',
 			'sidebar/settings/language': '语言',
+			'sidebar/settings/exportPrecision': 'Export Precision',
 
 			'sidebar/settings/shortcuts/translate': '移动',
 			'sidebar/settings/shortcuts/rotate': '旋转',