diff --git a/ShadowEditor.Web/src/controls/ControlsManager.js b/ShadowEditor.Web/src/controls/ControlsManager.js index 700e70ab..d28cf8ab 100644 --- a/ShadowEditor.Web/src/controls/ControlsManager.js +++ b/ShadowEditor.Web/src/controls/ControlsManager.js @@ -21,7 +21,7 @@ class ControlsManager extends BaseControls { this.handleUpdate = this.handleUpdate.bind(this); this.handleEnd = this.handleEnd.bind(this); - const mode = app.storage.get('controlMode'); + const mode = app.storage.controlMode; this.changeMode(mode); // 记录上次控制器,以便按Esc退出第一视角,返回原来的模式。 diff --git a/ShadowEditor.Web/src/editor/assets/ModelPanel.jsx b/ShadowEditor.Web/src/editor/assets/ModelPanel.jsx index 6eb2beda..a1780528 100644 --- a/ShadowEditor.Web/src/editor/assets/ModelPanel.jsx +++ b/ShadowEditor.Web/src/editor/assets/ModelPanel.jsx @@ -145,7 +145,7 @@ class ModelPanel extends React.Component { Server: true }); - if (app.storage.get('addMode') === 'click') { + if (app.storage.addMode === 'click') { this.clickSceneToAdd(obj); } else { this.addToCenter(obj); diff --git a/ShadowEditor.Web/src/editor/menu/OptionsMenu.jsx b/ShadowEditor.Web/src/editor/menu/OptionsMenu.jsx index cee0aea2..882e5f43 100644 --- a/ShadowEditor.Web/src/editor/menu/OptionsMenu.jsx +++ b/ShadowEditor.Web/src/editor/menu/OptionsMenu.jsx @@ -161,12 +161,12 @@ class OptionsMenu extends React.Component { // ---------------------------------- 调试模式 ------------------------------- handleEnableDebugMode() { - app.storage.set('debug', true); + app.storage.debug = true; window.location.reload(); } handleDisableDebugMode() { - app.storage.set('debug', false); + app.storage.debug = false; window.location.reload(); } } diff --git a/ShadowEditor.Web/src/editor/menu/ViewMenu.jsx b/ShadowEditor.Web/src/editor/menu/ViewMenu.jsx index cff8d037..a8230657 100644 --- a/ShadowEditor.Web/src/editor/menu/ViewMenu.jsx +++ b/ShadowEditor.Web/src/editor/menu/ViewMenu.jsx @@ -9,9 +9,9 @@ class ViewMenu extends React.Component { super(props); this.state = { - showStats: app.storage.get('showStats') === undefined ? true : app.storage.get('showStats'), - showGrid: app.storage.get('showGrid') === undefined ? true : app.storage.get('showGrid'), - showViewHelper: app.storage.get('showViewHelper') === undefined ? true : app.storage.get('showViewHelper'), + showStats: app.storage.showStats, + showGrid: app.storage.showGrid, + showViewHelper: app.storage.showViewHelper, enablePhysics: app.options.enablePhysics, isThrowBall: false }; @@ -53,8 +53,8 @@ class ViewMenu extends React.Component { } handleShowStats() { - const showStats = !app.storage.get('showStats'); - app.storage.set('showStats', showStats); + const showStats = !app.storage.showStats; + app.storage.showStats = showStats; Object.assign(app.stats.dom.style, { display: showStats ? 'block' : 'none' @@ -66,8 +66,8 @@ class ViewMenu extends React.Component { } handleShowGrid() { - const showGrid = !app.storage.get('showGrid'); - app.storage.set('showGrid', showGrid); + const showGrid = !app.storage.showGrid; + app.storage.showGrid = showGrid; app.call(`storageChanged`, this, 'showGrid', showGrid); @@ -77,8 +77,8 @@ class ViewMenu extends React.Component { } handleShowViewHelper() { - const showViewHelper = !app.storage.get('showViewHelper'); - app.storage.set('showViewHelper', showViewHelper); + const showViewHelper = !app.storage.showViewHelper; + app.storage.showViewHelper = showViewHelper; app.call(`storageChanged`, this, 'showViewHelper', showViewHelper); diff --git a/ShadowEditor.Web/src/editor/status/EditorStatusBar.jsx b/ShadowEditor.Web/src/editor/status/EditorStatusBar.jsx index 3a06d42c..587af340 100644 --- a/ShadowEditor.Web/src/editor/status/EditorStatusBar.jsx +++ b/ShadowEditor.Web/src/editor/status/EditorStatusBar.jsx @@ -36,8 +36,8 @@ class EditorStatusBar extends React.Component { render() { const { x, y, objects, vertices, triangles } = this.state; - const selectMode = app.storage.get('selectMode'); - const controlMode = app.storage.get('controlMode'); + const selectMode = app.storage.selectMode; + const controlMode = app.storage.controlMode; const isLogin = !app.server.enableAuthority || app.server.isLogin; @@ -138,14 +138,14 @@ class EditorStatusBar extends React.Component { } handleChangeSelectMode(value) { - app.storage.set('selectMode', value); + app.storage.selectMode = value; app.call('storageChanged', this, 'selectMode', value); this.forceUpdate(); } handleChangeControlMode(value) { app.editor.controls.changeMode(value); - app.storage.set('controlMode', value); + app.storage.controlMode = value; app.call('storageChanged', this, 'controlMode', value); this.forceUpdate(); } diff --git a/ShadowEditor.Web/src/editor/toolbar/DrawTools.jsx b/ShadowEditor.Web/src/editor/toolbar/DrawTools.jsx index 3503f674..80861ce4 100644 --- a/ShadowEditor.Web/src/editor/toolbar/DrawTools.jsx +++ b/ShadowEditor.Web/src/editor/toolbar/DrawTools.jsx @@ -41,7 +41,7 @@ class DrawTools extends React.Component { render() { const { isAddingPoint, isAddingLine, isAddingPolygon, isSpraying, isDigging } = this.state; - const addMode = app.storage.get('addMode'); + const addMode = app.storage.addMode; return <> @@ -72,7 +72,7 @@ class DisplayPanel extends React.Component { return; } - app.storage.set(name, value); + app.storage[name] = value; app.call(`storageChanged`, this, name, value); this.handleUpdate(); diff --git a/ShadowEditor.Web/src/editor/window/options/HelperPanel.jsx b/ShadowEditor.Web/src/editor/window/options/HelperPanel.jsx index 54d90312..bfc4c80a 100644 --- a/ShadowEditor.Web/src/editor/window/options/HelperPanel.jsx +++ b/ShadowEditor.Web/src/editor/window/options/HelperPanel.jsx @@ -89,14 +89,14 @@ class HelperPanel extends React.Component { handleUpdate() { this.setState({ - showGrid: app.storage.get('showGrid') === true, - showCamera: app.storage.get('showCamera') === true, - showPointLight: app.storage.get('showPointLight') === true, - showDirectionalLight: app.storage.get('showDirectionalLight') === true, - showSpotLight: app.storage.get('showSpotLight') === true, - showHemisphereLight: app.storage.get('showHemisphereLight') === true, - showRectAreaLight: app.storage.get('showRectAreaLight') === true, - showSkeleton: app.storage.get('showSkeleton') === true + showGrid: app.storage.showGrid, + showCamera: app.storage.showCamera, + showPointLight: app.storage.showPointLight, + showDirectionalLight: app.storage.showDirectionalLight, + showSpotLight: app.storage.showSpotLight, + showHemisphereLight: app.storage.showHemisphereLight, + showRectAreaLight: app.storage.showRectAreaLight, + showSkeleton: app.storage.showSkeleton }); } @@ -113,43 +113,43 @@ class HelperPanel extends React.Component { [name]: value }); - if (showGrid !== app.storage.get('showGrid')) { - app.storage.set('showGrid', showGrid); + if (showGrid !== app.storage.showGrid) { + app.storage.showGrid = showGrid; app.call(`storageChanged`, this, 'showGrid', showGrid); } - if (showCamera !== app.storage.get('showCamera')) { - app.storage.set('showCamera', showCamera); + if (showCamera !== app.storage.showCamera) { + app.storage.showCamera = showCamera; app.call(`storageChanged`, this, 'showCamera', showCamera); } - if (showPointLight !== app.storage.get('showPointLight')) { - app.storage.set('showPointLight', showPointLight); + if (showPointLight !== app.storage.showPointLight) { + app.storage.showPointLight = showPointLight; app.call(`storageChanged`, this, 'showPointLight', showPointLight); } - if (showDirectionalLight !== app.storage.get('showDirectionalLight')) { - app.storage.set('showDirectionalLight', showDirectionalLight); + if (showDirectionalLight !== app.storage.showDirectionalLight) { + app.storage.showDirectionalLight = showDirectionalLight; app.call(`storageChanged`, this, 'showDirectionalLight', showDirectionalLight); } - if (showSpotLight !== app.storage.get('showSpotLight')) { - app.storage.set('showSpotLight', showSpotLight); + if (showSpotLight !== app.storage.showSpotLight) { + app.storage.showSpotLight = showSpotLight; app.call(`storageChanged`, this, 'showSpotLight', showSpotLight); } - if (showHemisphereLight !== app.storage.get('showHemisphereLight')) { - app.storage.set('showHemisphereLight', showHemisphereLight); + if (showHemisphereLight !== app.storage.showHemisphereLight) { + app.storage.showHemisphereLight = showHemisphereLight; app.call(`storageChanged`, this, 'showHemisphereLight', showHemisphereLight); } - if (showRectAreaLight !== app.storage.get('showRectAreaLight')) { - app.storage.set('showRectAreaLight', showRectAreaLight); + if (showRectAreaLight !== app.storage.showRectAreaLight) { + app.storage.showRectAreaLight = showRectAreaLight; app.call(`storageChanged`, this, 'showRectAreaLight', showRectAreaLight); } - if (showSkeleton !== app.storage.get('showSkeleton')) { - app.storage.set('showSkeleton', showSkeleton); + if (showSkeleton !== app.storage.showSkeleton) { + app.storage.showSkeleton = showSkeleton; app.call(`storageChanged`, this, 'showSkeleton', showSkeleton); } diff --git a/ShadowEditor.Web/src/event/GPUPickEvent.js b/ShadowEditor.Web/src/event/GPUPickEvent.js index f5078b5e..e12e5952 100644 --- a/ShadowEditor.Web/src/event/GPUPickEvent.js +++ b/ShadowEditor.Web/src/event/GPUPickEvent.js @@ -35,7 +35,7 @@ GPUPickEvent.prototype.start = function () { app.on(`resize.${this.id}`, this.onResize); app.on(`storageChanged.${this.id}`, this.onStorageChanged); - this.selectMode = app.storage.get('selectMode'); + this.selectMode = app.storage.selectMode; }; GPUPickEvent.prototype.stop = function () { diff --git a/ShadowEditor.Web/src/event/PickEvent.js b/ShadowEditor.Web/src/event/PickEvent.js index 0dc0de3c..2a84fd60 100644 --- a/ShadowEditor.Web/src/event/PickEvent.js +++ b/ShadowEditor.Web/src/event/PickEvent.js @@ -69,7 +69,7 @@ PickEvent.prototype.handleClick = function () { let editor = app.editor; let objects = editor.objects; - const selectMode = app.storage.get('selectMode'); + const selectMode = app.storage.selectMode; if (this.onDownPosition.distanceTo(this.onUpPosition) === 0) { let intersects = this.getIntersects(this.onUpPosition, objects); diff --git a/ShadowEditor.Web/src/helper/CameraHelper.js b/ShadowEditor.Web/src/helper/CameraHelper.js index 1f504f5a..ca3461ca 100644 --- a/ShadowEditor.Web/src/helper/CameraHelper.js +++ b/ShadowEditor.Web/src/helper/CameraHelper.js @@ -27,7 +27,7 @@ CameraHelper.prototype.stop = function () { }; CameraHelper.prototype.update = function () { - var showCamera = app.storage.get('showCamera'); + var showCamera = app.storage.showCamera; if (!this.helper) { this.helper = new THREE.CameraHelper(app.editor.camera); diff --git a/ShadowEditor.Web/src/helper/GridHelper.js b/ShadowEditor.Web/src/helper/GridHelper.js index 3c7b39fa..f728b827 100644 --- a/ShadowEditor.Web/src/helper/GridHelper.js +++ b/ShadowEditor.Web/src/helper/GridHelper.js @@ -27,7 +27,7 @@ GridHelper.prototype.stop = function () { }; GridHelper.prototype.update = function () { - var showGrid = app.storage.get('showGrid'); + var showGrid = app.storage.showGrid; if (!this.helper) { this.helper = new THREE.GridHelper(30, 30, 0x444444, 0x888888); diff --git a/ShadowEditor.Web/src/helper/HoverHelper.js b/ShadowEditor.Web/src/helper/HoverHelper.js index 93630bd4..6744a8f9 100644 --- a/ShadowEditor.Web/src/helper/HoverHelper.js +++ b/ShadowEditor.Web/src/helper/HoverHelper.js @@ -7,8 +7,8 @@ import BaseHelper from './BaseHelper'; function HoverHelper() { BaseHelper.call(this); - this.hoverEnabled = app.storage.get('hoverEnabled'); - this.hoveredColor = app.storage.get('hoveredColor'); + this.hoverEnabled = app.storage.hoverEnabled; + this.hoveredColor = app.storage.hoveredColor; this.onGpuPick = this.onGpuPick.bind(this); this.onObjectRemoved = this.onObjectRemoved.bind(this); diff --git a/ShadowEditor.Web/src/helper/SelectHelper.js b/ShadowEditor.Web/src/helper/SelectHelper.js index 8f66eeed..c9a8ec2b 100644 --- a/ShadowEditor.Web/src/helper/SelectHelper.js +++ b/ShadowEditor.Web/src/helper/SelectHelper.js @@ -97,8 +97,8 @@ SelectHelper.prototype.onObjectSelected = function (obj) { }); } - const selectedColor = app.storage.get('selectedColor'); - const selectedThickness = app.storage.get('selectedThickness'); + const selectedColor = app.storage.selectedColor; + const selectedThickness = app.storage.selectedThickness; if (this.edgeMaterial === undefined) { this.edgeMaterial = new THREE.ShaderMaterial({ diff --git a/ShadowEditor.Web/src/helper/ViewHelper.js b/ShadowEditor.Web/src/helper/ViewHelper.js index 051a5e9b..b694fe21 100644 --- a/ShadowEditor.Web/src/helper/ViewHelper.js +++ b/ShadowEditor.Web/src/helper/ViewHelper.js @@ -16,11 +16,11 @@ ViewHelper.prototype.constructor = ViewHelper; ViewHelper.prototype.start = function () { this.scene = new THREE.Scene(); - let show = app.storage.get('showViewHelper'); + let show = app.storage.showViewHelper; if (show === undefined) { show = true; - app.storage.set('showViewHelper', true); + app.storage.showViewHelper = true; } this.show = show; diff --git a/ShadowEditor.Web/src/helper/light/DirectionalLightHelpers.js b/ShadowEditor.Web/src/helper/light/DirectionalLightHelpers.js index ee6c52db..c24d2539 100644 --- a/ShadowEditor.Web/src/helper/light/DirectionalLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/DirectionalLightHelpers.js @@ -35,7 +35,7 @@ DirectionalLightHelpers.prototype.onObjectAdded = function (object) { var helper = new VolumeDirectionalLightHelper(object, 1); - helper.visible = app.storage.get('showDirectionalLight'); + helper.visible = app.storage.showDirectionalLight; this.helpers.push(helper); diff --git a/ShadowEditor.Web/src/helper/light/HemisphereLightHelpers.js b/ShadowEditor.Web/src/helper/light/HemisphereLightHelpers.js index 65ef3b4c..a0dc9602 100644 --- a/ShadowEditor.Web/src/helper/light/HemisphereLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/HemisphereLightHelpers.js @@ -35,7 +35,7 @@ HemisphereLightHelpers.prototype.onObjectAdded = function (object) { var helper = new VolumeHemisphereLightHelper(object, 1); - helper.visible = app.storage.get('showHemisphereLight'); + helper.visible = app.storage.showHemisphereLight; this.helpers.push(helper); diff --git a/ShadowEditor.Web/src/helper/light/PointLightHelpers.js b/ShadowEditor.Web/src/helper/light/PointLightHelpers.js index 08fbc1d9..c90d106a 100644 --- a/ShadowEditor.Web/src/helper/light/PointLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/PointLightHelpers.js @@ -35,7 +35,7 @@ PointLightHelpers.prototype.onObjectAdded = function (object) { var helper = new VolumePointLightHelper(object, 1); - helper.visible = app.storage.get('showPointLight'); + helper.visible = app.storage.showPointLight; this.helpers.push(helper); diff --git a/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js b/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js index ef811e4c..629356e0 100644 --- a/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js @@ -35,7 +35,7 @@ RectAreaLightHelpers.prototype.onObjectAdded = function (object) { var helper = new VolumeRectAreaLightHelper(object, 0xffffff); - helper.visible = app.storage.get('showRectAreaLight'); + helper.visible = app.storage.showRectAreaLight; this.helpers.push(helper); diff --git a/ShadowEditor.Web/src/helper/light/SpotLightHelpers.js b/ShadowEditor.Web/src/helper/light/SpotLightHelpers.js index 78d4302d..7ee38ca5 100644 --- a/ShadowEditor.Web/src/helper/light/SpotLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/SpotLightHelpers.js @@ -35,7 +35,7 @@ SpotLightHelpers.prototype.onObjectAdded = function (object) { var helper = new VolumeSpotLightHelper(object, 0xffffff); - helper.visible = app.storage.get('showSpotLight'); + helper.visible = app.storage.showSpotLight; this.helpers.push(helper); diff --git a/ShadowEditor.Web/src/utils/Storage.js b/ShadowEditor.Web/src/utils/Storage.js index b49b66ef..37d2a35f 100644 --- a/ShadowEditor.Web/src/utils/Storage.js +++ b/ShadowEditor.Web/src/utils/Storage.js @@ -5,7 +5,12 @@ class Storage { constructor() { // 向本地存储写入默认配置,并提供快捷访问方法 const defaultConfigs = { - showGrid: true, + debug: false, // 调试模式 + + // 帮助器 + showStats: true, // 性能监视器 + showGrid: true, // 网格 + showViewHelper: true, // 视角帮助器 showCamera: false, showPointLight: true, showDirectionalLight: true,