Config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. var Config = function () {
  2. var name = 'threejs-editor';
  3. var storage = {
  4. 'theme': 'css/light.css',
  5. 'camera/position': [ 500, 250, 500 ],
  6. 'camera/target': [ 0, 0, 0 ],
  7. 'ui/sidebar/animation/collapsed': true,
  8. 'ui/sidebar/geometry/collapsed': true,
  9. 'ui/sidebar/material/collapsed': true,
  10. 'ui/sidebar/object3d/collapsed': false,
  11. 'ui/sidebar/renderer/collapsed': true,
  12. 'ui/sidebar/scene/collapsed': false,
  13. 'ui/sidebar/script/collapsed': true
  14. };
  15. if ( window.localStorage[ name ] === undefined ) {
  16. window.localStorage[ name ] = JSON.stringify( storage );
  17. } else {
  18. var data = JSON.parse( window.localStorage[ name ] );
  19. for ( var key in data ) {
  20. storage[ key ] = data[ key ];
  21. }
  22. }
  23. return {
  24. getKey: function ( key ) {
  25. return storage[ key ];
  26. },
  27. setKey: function ( key, value ) {
  28. storage[ key ] = value;
  29. window.localStorage[ name ] = JSON.stringify( storage );
  30. console.log( '[' + /\d\d\:\d\d\:\d\d/.exec( new Date() )[ 0 ] + ']', 'Saved config to LocalStorage.' );
  31. },
  32. clear: function () {
  33. delete window.localStorage[ name ];
  34. }
  35. }
  36. };