Merge pull request #1319 from MathemanFlo/LightAngle

Add light angle
This commit is contained in:
Lubos Lenco
2022-03-08 15:28:11 +01:00
committed by GitHub
2 changed files with 7 additions and 12 deletions
+1
View File
@@ -90,6 +90,7 @@ class Context {
public static var showEnvmapBlur = false;
public static var showEnvmapBlurHandle = new Handle({ selected: false });
public static var envmapAngle = 0.0;
public static var lightAngle = 0.0;
public static var drawWireframe = false;
public static var wireframeHandle = new Handle({ selected: false });
public static var drawTexels = false;
+6 -12
View File
@@ -158,24 +158,18 @@ class UIMenu {
menuFill(ui);
var light = iron.Scene.active.lights[0];
var lahandle = Id.handle();
if (lahandle.value < 0) {
lahandle.value += (Std.int(-lahandle.value / 360) + 1) * 360;
}
else if (lahandle.value > 360) {
lahandle.value -= Std.int(lahandle.value / 360) * 360;
}
lahandle.value = Context.lightAngle / Math.PI * 180;
menuAlign(ui);
var lightAngle = lahandle.value;
ui.slider(lahandle, tr("Light Angle"), 0.0, 360.0, true, 1);
var ldiff = lahandle.value - lightAngle;
if (ldiff != 0) {
ldiff = (ldiff) / 180.0 * Math.PI;
var newAngle = ui.slider(lahandle, tr("Light Angle"), 0.0, 359.0, true, 1) / 180 * Math.PI;
var ldiff = newAngle - Context.lightAngle;
if (Math.abs(ldiff) > 0.005) {
Context.lightAngle = newAngle % (2*Math.PI);
var m = iron.math.Mat4.identity();
m.self = kha.math.FastMatrix4.rotationZ(ldiff);
light.transform.local.multmat(m);
light.transform.decompose();
Context.ddirty = 2;
}
if (lahandle.changed) Context.ddirty = 2;
menuFill(ui);
var sxhandle = Id.handle();