Skip to content

Commit

Permalink
Point light component gui connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Praccen committed Oct 1, 2023
1 parent c8e27e1 commit 42959e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions code/src/Engine/ECS/Components/PointLightComponent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import ObjectPlacer from "../../../Game/ObjectPlacer";
import Div from "../../GUI/Div";
import PointLight from "../../Lighting/PointLight";
import Vec3 from "../../Maths/Vec3";
import { OverlayRendering } from "../../Rendering/OverlayRendering";
import { Component, ComponentTypeEnum } from "./Component";

export default class PointLightComponent extends Component {
Expand All @@ -11,4 +14,26 @@ export default class PointLightComponent extends Component {
this.pointLight = pointLight;
this.posOffset = new Vec3();
}

addToGui(
overlayRendering: OverlayRendering,
parentDiv: Div,
objectPlacer: ObjectPlacer
) {
let addTextEdit = (label: string, vec: Vec3, index: number) => {
let propEditText = overlayRendering.getNewEditText(parentDiv);
propEditText.textString = label;
propEditText.textSize = 20;
propEditText.scaleWithWindow = true;
propEditText.getInputElement().value = vec[index].toString();
propEditText.getInputElement().onchange = (ev) => {
vec[index] = parseFloat(propEditText.getInputElement().value);
};
objectPlacer.makeCheckpoint();
};

addTextEdit("R", this.pointLight.colour, 0);
addTextEdit("G", this.pointLight.colour, 1);
addTextEdit("B", this.pointLight.colour, 2);
}
}
2 changes: 1 addition & 1 deletion code/src/Game/States/DebugMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class DebugMode extends State {
edited = true;
this.actionString = "Rotating";
}
if (input.keys["T"] || input.keys["G"]) {
if ((input.keys["T"] || input.keys["G"]) && this.game.objectPlacer.currentlyEditingEntityId != 0) {
let ray = MousePicking.GetRay(this.game.rendering.camera);
let dist: number = Infinity;

Expand Down

0 comments on commit 42959e0

Please sign in to comment.