Doodle3D-Slicer/doodle_app/ui/Config.js

70 lines
1.1 KiB
JavaScript
Executable File

/**
* @author mrdoob / http://mrdoob.com/
*/
var Config = function () {
var name = 'threejs-editor';
var storage = {
'autosave': true,
'project/renderer': 'WebGLRenderer',
'project/renderer/antialias': true,
'project/vr': false,
'camera/position': [ 500, 250, 500 ],
'camera/target': [ 0, 0, 0 ]
};
if ( window.localStorage[ name ] === undefined || true ) {
window.localStorage[ name ] = JSON.stringify( storage );
} else {
var data = JSON.parse( window.localStorage[ name ] );
for ( var key in data ) {
storage[ key ] = data[ key ];
}
}
return {
getKey: function ( key ) {
console.log(storage);
return storage[ key ];
},
setKey: function () { // key, value, 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 );
console.log( '[' + /\d\d\:\d\d\:\d\d/.exec( new Date() )[ 0 ] + ']', 'Saved config to LocalStorage.' );
},
clear: function () {
delete window.localStorage[ name ];
}
}
};