From 2ef707a5bb68e71e5c927c9bf54335cbb2efcacb Mon Sep 17 00:00:00 2001 From: Yann Dubois Date: Tue, 6 Sep 2016 00:36:23 +0200 Subject: [PATCH 1/2] Add setting option to change scene background color in the editor --- npm-debug.log | 24 +++++++++++++++++++ .../scene/data/SceneSettingsResource.ts | 7 ++++-- .../default/scene/editors/scene/network.ts | 3 ++- plugins/default/scene/editors/scene/ui.ts | 4 ++++ .../public/locales/en/settingsEditors.json | 3 ++- .../settingsEditors/SceneSettingsEditor.ts | 7 ++++++ 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 npm-debug.log diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 000000000..b2f86e9bb --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,24 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ] +2 info using npm@3.3.12 +3 info using node@v5.3.0 +4 verbose stack Error: missing script: build +4 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:147:19) +4 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:57:5 +4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 +4 verbose stack at checkBinReferences_ (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) +4 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) +4 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) +4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:300:12 +4 verbose stack at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16 +4 verbose stack at tryToString (fs.js:414:3) +4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12) +5 verbose cwd /home/dubois/Dev/superpowers/core/systems/game +6 error Linux 4.4.0-36-generic +7 error argv "/usr/bin/node" "/usr/bin/npm" "run" "build" +8 error node v5.3.0 +9 error npm v3.3.12 +10 error missing script: build +11 error If you need help, you may report this error at: +11 error +12 verbose exit [ 1, true ] diff --git a/plugins/default/scene/data/SceneSettingsResource.ts b/plugins/default/scene/data/SceneSettingsResource.ts index 5d7a5c2b8..a0a6ce46a 100644 --- a/plugins/default/scene/data/SceneSettingsResource.ts +++ b/plugins/default/scene/data/SceneSettingsResource.ts @@ -3,6 +3,7 @@ interface SceneSettingsResourcePub { defaultCameraMode: string; defaultVerticalAxis: string; + defaultBackgroundColor: string; [key: string]: any; } @@ -13,7 +14,8 @@ export default class SceneSettingsResource extends SupCore.Data.Base.Resource { formatVersion: { type: "integer" }, defaultCameraMode: { type: "enum", items: [ "3D", "2D" ], mutable: true }, - defaultVerticalAxis: { type: "enum", items: [ "Y", "Z" ], mutable: true } + defaultVerticalAxis: { type: "enum", items: [ "Y", "Z" ], mutable: true }, + defaultBackgroundColor: { type: "string", mutable: true } }; pub: SceneSettingsResourcePub; @@ -27,7 +29,8 @@ export default class SceneSettingsResource extends SupCore.Data.Base.Resource { formatVersion: SceneSettingsResource.currentFormatVersion, defaultCameraMode: "3D", - defaultVerticalAxis: "Y" + defaultVerticalAxis: "Y", + defaultBackgroundColor: "#000000" }; super.init(callback); diff --git a/plugins/default/scene/editors/scene/network.ts b/plugins/default/scene/editors/scene/network.ts index 4be916833..d47e679a5 100644 --- a/plugins/default/scene/editors/scene/network.ts +++ b/plugins/default/scene/editors/scene/network.ts @@ -3,7 +3,7 @@ import ui, { setCameraMode, setCameraVerticalAxis, createNodeElement, setupSelectedNode, createComponentElement, setInspectorPosition, setInspectorOrientation, setInspectorScale, setInspectorVisible, setInspectorLayer, setInspectorPrefabScene, - setupInspectorLayers } from "./ui"; + setupInspectorLayers, setBackgroundColor } from "./ui"; import engine, { start as engineStart, setupHelpers } from "./engine"; import * as async from "async"; @@ -89,6 +89,7 @@ function startIfReady() { setCameraMode(data.sceneSettingsResource.pub.defaultCameraMode); setCameraVerticalAxis(data.sceneSettingsResource.pub.defaultVerticalAxis); + setBackgroundColor(data.sceneSettingsResource.pub.defaultBackgroundColor); setupInspectorLayers(); } } diff --git a/plugins/default/scene/editors/scene/ui.ts b/plugins/default/scene/editors/scene/ui.ts index 4b8f62156..885b253e5 100644 --- a/plugins/default/scene/editors/scene/ui.ts +++ b/plugins/default/scene/editors/scene/ui.ts @@ -747,6 +747,10 @@ function onChangeCameraVerticalAxis(event: any) { setCameraVerticalAxis(ui.cameraVerticalAxis === "Y" ? "Z" : "Y"); } +export function setBackgroundColor(color: string) { + engine.gameInstance.threeRenderer.setClearColor(color); +} + function onChangeCameraSpeed() { engine.cameraControls.movementSpeed = ui.cameraSpeedSlider.value; } diff --git a/plugins/default/scene/public/locales/en/settingsEditors.json b/plugins/default/scene/public/locales/en/settingsEditors.json index 8bc254b9b..cc2af1c3d 100644 --- a/plugins/default/scene/public/locales/en/settingsEditors.json +++ b/plugins/default/scene/public/locales/en/settingsEditors.json @@ -2,6 +2,7 @@ "Scene": { "label": "Scene", "defaultCameraMode": "Default camera mode", - "defaultCameraVerticalAxis": "Default camera vertical axis" + "defaultCameraVerticalAxis": "Default camera vertical axis", + "defaultBackgroundColor": "Default background color" } } \ No newline at end of file diff --git a/plugins/default/scene/settingsEditors/SceneSettingsEditor.ts b/plugins/default/scene/settingsEditors/SceneSettingsEditor.ts index 6afb43990..327d59b13 100644 --- a/plugins/default/scene/settingsEditors/SceneSettingsEditor.ts +++ b/plugins/default/scene/settingsEditors/SceneSettingsEditor.ts @@ -26,6 +26,13 @@ export default class SceneSettingsEditor { this.projectClient.editResource("sceneSettings", "setProperty", "defaultVerticalAxis", event.target.value); }); + let defaultBackgroundColorRow = SupClient.table.appendRow(tbody, SupClient.i18n.t("settingsEditors:Scene.defaultBackgroundColor")); + this.fields["defaultBackgroundColor"] = SupClient.table.appendColorField(defaultBackgroundColorRow.valueCell, "0x000000").pickerField; + + this.fields["defaultBackgroundColor"].addEventListener("change", (event: any) => { + this.projectClient.editResource("sceneSettings", "setProperty", "defaultBackgroundColor", event.target.value); + }); + this.projectClient.subResource("sceneSettings", this); } From d389df9278f5a663317b962d4253ec0e21a1c5b8 Mon Sep 17 00:00:00 2001 From: Yann Dubois Date: Tue, 6 Sep 2016 00:46:59 +0200 Subject: [PATCH 2/2] Remove log file --- npm-debug.log | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 npm-debug.log diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index b2f86e9bb..000000000 --- a/npm-debug.log +++ /dev/null @@ -1,24 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ] -2 info using npm@3.3.12 -3 info using node@v5.3.0 -4 verbose stack Error: missing script: build -4 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:147:19) -4 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:57:5 -4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 -4 verbose stack at checkBinReferences_ (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) -4 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) -4 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) -4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:300:12 -4 verbose stack at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16 -4 verbose stack at tryToString (fs.js:414:3) -4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12) -5 verbose cwd /home/dubois/Dev/superpowers/core/systems/game -6 error Linux 4.4.0-36-generic -7 error argv "/usr/bin/node" "/usr/bin/npm" "run" "build" -8 error node v5.3.0 -9 error npm v3.3.12 -10 error missing script: build -11 error If you need help, you may report this error at: -11 error -12 verbose exit [ 1, true ]