Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Background color scene #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions plugins/default/scene/data/SceneSettingsResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ interface SceneSettingsResourcePub {

defaultCameraMode: string;
defaultVerticalAxis: string;
defaultBackgroundColor: string;
[key: string]: any;
}

Expand All @@ -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;
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion plugins/default/scene/editors/scene/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -89,6 +89,7 @@ function startIfReady() {

setCameraMode(data.sceneSettingsResource.pub.defaultCameraMode);
setCameraVerticalAxis(data.sceneSettingsResource.pub.defaultVerticalAxis);
setBackgroundColor(data.sceneSettingsResource.pub.defaultBackgroundColor);
setupInspectorLayers();
}
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/default/scene/editors/scene/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/default/scene/public/locales/en/settingsEditors.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
7 changes: 7 additions & 0 deletions plugins/default/scene/settingsEditors/SceneSettingsEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down