修复:太阳光无法旋转角度

pull/2015/head
ChenX 2 years ago
parent b07b875d6e
commit 4c4526501c

@ -1,6 +1,6 @@
import { DirectionalLight as TDirectionalLight, Group, MathUtils, Matrix3, Matrix4, Object3D, Vector2, Vector3 } from "three";
import { UpdateDraw } from "../../Common/Status";
import { equalv3 } from "../../Geometry/GeUtils";
import { equaln, equalv3 } from "../../Geometry/GeUtils";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { AutoRecord } from "../AutoRecord";
import { Factory } from "../CADFactory";
@ -65,6 +65,32 @@ export class DirectionalLight extends Light
this.Update();
}
}
get SunPosition() { return super.Position; }
set SunPosition(p: Vector3)
{
if (
equaln(p.x, this._Matrix.elements[12])
&& equaln(p.y, this._Matrix.elements[13])
&& equaln(p.z, this._Matrix.elements[14])
)
return;
this.WriteAllObjectRecord();
this._Matrix.setPosition(p);
this.Update(UpdateDraw.Geometry);
}
get Position() { return super.Position; }
set Position(p: Vector3)
{
console.error("不支持的用法! 错误的设计");
let bak = this._Target.toArray();
super.Position = p;
this._Target.fromArray(bak);
this.Update(UpdateDraw.Geometry);
}
get WebIntensity()
{
let x = this._Intensity / 150;
@ -92,7 +118,7 @@ export class DirectionalLight extends Light
if (indexList[0] === 0)
this.Position = this.Position.add(vec);
else
this.Target = this.Target.add(vec);
this._Target.add((vec));
}
protected InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
{

@ -188,7 +188,7 @@ export default class SunLightGui extends Component
rotate = MathUtils.degToRad(safeEval(rotate.toString()));
pos = new Vector3(DefaultDist.dist * Math.cos(elevation), 0, DefaultDist.dist * Math.sin(elevation));
pos.applyMatrix4(new Matrix4().makeRotationZ(rotate)).add(app.Database.SunLight.Target);
app.Database.SunLight.Position = pos;
app.Database.SunLight.SunPosition = pos;
CalcSunShadowCameraExtents(app.Database.SunLight, false);
app.Viewer.UpdateRender();

@ -661,7 +661,7 @@ export class RightPlaneLightStore implements IConfigStore
sunLight.Color = new Color(cof.option.SunLightColor);
sunLight.Temperature = cof.option.SunLightTemperature;
sunLight.Position = pos;
sunLight.SunPosition = pos;
CalcSunShadowCameraExtents(app.Database.SunLight, false);
app.Viewer.UpdateRender();

Loading…
Cancel
Save