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); }