Переглянути джерело

Editor: Config.setKey() now allows more than one key.

Mr.doob 11 роки тому
батько
коміт
980d842ef5
3 змінених файлів з 18 додано та 8 видалено
  1. 7 3
      editor/js/Config.js
  2. 7 3
      editor/js/Menubar.File.js
  3. 4 2
      editor/js/Viewport.js

+ 7 - 3
editor/js/Config.js

@@ -40,9 +40,13 @@ var Config = function () {
 
 		},
 
-		setKey: function ( key, value ) {
+		setKey: function () { // key, value, key, value ...
 
-			storage[ key ] = value;
+			for ( var i = 0, l = arguments.length; i < l; i += 2 ) {
+
+				storage[ arguments[ i ] ] = arguments[ i + 1 ];
+
+			}
 
 			window.localStorage[ name ] = JSON.stringify( storage );
 
@@ -58,4 +62,4 @@ var Config = function () {
 
 	}
 
-};
+};

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

@@ -21,7 +21,11 @@ Menubar.File = function ( editor ) {
 
 		if ( confirm( 'Are you sure?' ) ) {
 
-			editor.config.clear();
+			editor.config.setKey(
+				'camera/position', [ 500, 250, 500 ],
+				'camera/target', [ 0, 0, 0 ]
+			);
+
 			editor.storage.clear( function () {
 
 				location.href = location.pathname;
@@ -67,7 +71,7 @@ Menubar.File = function ( editor ) {
 	option.setClass( 'option' );
 	option.setTextContent( 'Export Geometry' );
 	option.onClick( function () {
-		
+
 		var object = editor.selected;
 
 		if ( object === null ) {
@@ -229,4 +233,4 @@ Menubar.File = function ( editor ) {
 
 	return container;
 
-};
+};

+ 4 - 2
editor/js/Viewport.js

@@ -295,8 +295,10 @@ var Viewport = function ( editor ) {
 
 		saveTimeout = setTimeout( function () {
 
-			editor.config.setKey( 'camera/position', camera.position.toArray() );
-			editor.config.setKey( 'camera/target', controls.center.toArray() );
+			editor.config.setKey(
+				'camera/position', camera.position.toArray(),
+				'camera/target', controls.center.toArray()
+			);
 
 		}, 1000 );