|
|
@ -1,8 +1,11 @@
|
|
|
|
import { observable } from "mobx";
|
|
|
|
import { observable, toJS } from "mobx";
|
|
|
|
import { DirectionalLight as TDirectionalLight, MathUtils, PointLight as TPointLight, SpotLight as TSpotLight } from 'three';
|
|
|
|
import { Color, DirectionalLight as TDirectionalLight, MathUtils, Matrix4, PointLight as TPointLight, SpotLight as TSpotLight, Vector3 } from "three";
|
|
|
|
import { end } from "xaop";
|
|
|
|
import { end } from "xaop";
|
|
|
|
|
|
|
|
import { Entitys2Data } from "../../../Add-on/ExportData";
|
|
|
|
import { app } from "../../../ApplicationServices/Application";
|
|
|
|
import { app } from "../../../ApplicationServices/Application";
|
|
|
|
import { HostApplicationServices } from "../../../ApplicationServices/HostApplicationServices";
|
|
|
|
import { HostApplicationServices } from "../../../ApplicationServices/HostApplicationServices";
|
|
|
|
|
|
|
|
import { EntityUpdateWrap } from "../../../Common/EntityUpdateWrap";
|
|
|
|
|
|
|
|
import { safeEval } from "../../../Common/eval";
|
|
|
|
import { DirLightShadowArea } from "../../../Common/LightUtils";
|
|
|
|
import { DirLightShadowArea } from "../../../Common/LightUtils";
|
|
|
|
import { FixedNotZero } from "../../../Common/Utils";
|
|
|
|
import { FixedNotZero } from "../../../Common/Utils";
|
|
|
|
import { CommandHistoryRecord } from "../../../DatabaseServices/CommandHistoryRecord";
|
|
|
|
import { CommandHistoryRecord } from "../../../DatabaseServices/CommandHistoryRecord";
|
|
|
@ -15,9 +18,14 @@ import { RectAreaLight } from "../../../DatabaseServices/Lights/RectAreaLight";
|
|
|
|
import { SpotLight } from "../../../DatabaseServices/Lights/SpotLight";
|
|
|
|
import { SpotLight } from "../../../DatabaseServices/Lights/SpotLight";
|
|
|
|
import { ObjectId } from "../../../DatabaseServices/ObjectId";
|
|
|
|
import { ObjectId } from "../../../DatabaseServices/ObjectId";
|
|
|
|
import { TemplateRecord } from "../../../DatabaseServices/Template/TemplateRecord";
|
|
|
|
import { TemplateRecord } from "../../../DatabaseServices/Template/TemplateRecord";
|
|
|
|
|
|
|
|
import { CommandWrap } from "../../../Editor/CommandMachine";
|
|
|
|
|
|
|
|
import { DefaultPointLightOption, DefaultRectAreaLightOption, DefaultRightPlaneLightOption, DefaultSpotLightOption } from "../../../Editor/DefaultConfig";
|
|
|
|
|
|
|
|
import { userConfig } from "../../../Editor/UserConfig";
|
|
|
|
import { angle, equalv3, ZeroVec } from "../../../Geometry/GeUtils";
|
|
|
|
import { angle, equalv3, ZeroVec } from "../../../Geometry/GeUtils";
|
|
|
|
import { IConfigOption } from "../../Components/Board/UserConfig";
|
|
|
|
import { IConfigOption } from "../../Components/Board/UserConfig";
|
|
|
|
import { AnyObject } from "../BoardInterface";
|
|
|
|
import { DefaultDist } from "../../Components/RightPanel/ScenePanel";
|
|
|
|
|
|
|
|
import { SunLightStore } from "../../Components/RightPanel/SunLightStore";
|
|
|
|
|
|
|
|
import { AnyObject, PointLightOption, RectAreaLightOption, RightPlaneLightOption, SpotLightOption } from "../BoardInterface";
|
|
|
|
import { IConfigStore } from "../BoardStore";
|
|
|
|
import { IConfigStore } from "../BoardStore";
|
|
|
|
|
|
|
|
|
|
|
|
export interface LightModalState
|
|
|
|
export interface LightModalState
|
|
|
@ -54,6 +62,8 @@ export interface LightModalState
|
|
|
|
AttenuationRadius?: string;//射灯衰减半径
|
|
|
|
AttenuationRadius?: string;//射灯衰减半径
|
|
|
|
BarnDoorAngle?: string;//挡光板角度
|
|
|
|
BarnDoorAngle?: string;//挡光板角度
|
|
|
|
BarnDoorLength?: string;//挡光板长度
|
|
|
|
BarnDoorLength?: string;//挡光板长度
|
|
|
|
|
|
|
|
ShowHelper?: boolean;//灯光助手
|
|
|
|
|
|
|
|
CaseShadow?: boolean;//阴影
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export enum ETime
|
|
|
|
export enum ETime
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -75,6 +85,7 @@ export class LightStore implements IConfigStore
|
|
|
|
InitConfigs?: () => { [key: string]: IConfigOption<AnyObject>; };
|
|
|
|
InitConfigs?: () => { [key: string]: IConfigOption<AnyObject>; };
|
|
|
|
GetOtherConfig?: (conf: any) => AnyObject;
|
|
|
|
GetOtherConfig?: (conf: any) => AnyObject;
|
|
|
|
HandleImportConfig?: (conf: any) => void;
|
|
|
|
HandleImportConfig?: (conf: any) => void;
|
|
|
|
|
|
|
|
@observable IsDrawLight = false; //控制绘制灯时,不更新light实体属性
|
|
|
|
@observable ShowAmbientLight = true;
|
|
|
|
@observable ShowAmbientLight = true;
|
|
|
|
@observable ShowSunLight = true;
|
|
|
|
@observable ShowSunLight = true;
|
|
|
|
@observable ShowHemiLight = true;
|
|
|
|
@observable ShowHemiLight = true;
|
|
|
@ -125,7 +136,7 @@ export class LightStore implements IConfigStore
|
|
|
|
Intensity: app.Database.SunLight.Intensity.toString(),
|
|
|
|
Intensity: app.Database.SunLight.Intensity.toString(),
|
|
|
|
IndirectLightingIntensity: app.Database.SunLight.IndirectLightingIntensity.toString(),
|
|
|
|
IndirectLightingIntensity: app.Database.SunLight.IndirectLightingIntensity.toString(),
|
|
|
|
Rotation: equalv3(vec, ZeroVec) ? "0" : FixedNotZero(MathUtils.radToDeg(angle(vec)), 0),
|
|
|
|
Rotation: equalv3(vec, ZeroVec) ? "0" : FixedNotZero(MathUtils.radToDeg(angle(vec)), 0),
|
|
|
|
Elevation: equalv3(vec, ZeroVec) ? "0" : FixedNotZero(MathUtils.radToDeg(vec.angleTo(vec2)), 0)
|
|
|
|
Elevation: equalv3(vec, ZeroVec) ? "0" : FixedNotZero(MathUtils.radToDeg(vec.angleTo(vec2)), 0),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InitLightData(light: Light)
|
|
|
|
InitLightData(light: Light)
|
|
|
@ -145,6 +156,8 @@ export class LightStore implements IConfigStore
|
|
|
|
IndirectLightingIntensity: light.IndirectLightingIntensity.toString(),
|
|
|
|
IndirectLightingIntensity: light.IndirectLightingIntensity.toString(),
|
|
|
|
SpecularScale: light.SpecularScale.toString(),
|
|
|
|
SpecularScale: light.SpecularScale.toString(),
|
|
|
|
Temperature: light.Temperature.toString(),
|
|
|
|
Temperature: light.Temperature.toString(),
|
|
|
|
|
|
|
|
CaseShadow: light.CaseShadow,
|
|
|
|
|
|
|
|
ShowHelper: light.ShowHelper,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.pars.length = 0;
|
|
|
|
this.pars.length = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -276,3 +289,404 @@ export class LightStore implements IConfigStore
|
|
|
|
DirLightShadowArea(app.Database.SunLight);
|
|
|
|
DirLightShadowArea(app.Database.SunLight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class PointLightStore implements IConfigStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@observable configName = "默认";
|
|
|
|
|
|
|
|
SaveConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
this.m_Option.CaseShadow = lightStore.lightData.CaseShadow;
|
|
|
|
|
|
|
|
this.m_Option.Intensity = parseInt(lightStore.lightData.Intensity);
|
|
|
|
|
|
|
|
this.m_Option.lightColor = lightStore.lightData.Color;
|
|
|
|
|
|
|
|
this.m_Option.temperature = parseInt(lightStore.lightData.Temperature);
|
|
|
|
|
|
|
|
this.m_Option.IndirectLightingIntensity = parseInt(lightStore.lightData.IndirectLightingIntensity);
|
|
|
|
|
|
|
|
this.m_Option.SpecularScale = parseFloat(lightStore.lightData.SpecularScale);
|
|
|
|
|
|
|
|
this.m_Option.SoftSourceRadius = parseInt(lightStore.lightData.SoftSourceRadius);
|
|
|
|
|
|
|
|
this.m_Option.SourceLength = parseInt(lightStore.lightData.SourceLength);
|
|
|
|
|
|
|
|
this.m_Option.SourceRadius = parseInt(lightStore.lightData.SourceRadius);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新的配置
|
|
|
|
|
|
|
|
let newConfig: IConfigOption = {};
|
|
|
|
|
|
|
|
newConfig.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
return newConfig;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//板数据
|
|
|
|
|
|
|
|
@observable m_Option: PointLightOption = { ...DefaultPointLightOption };
|
|
|
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
|
|
|
InitOption()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, DefaultPointLightOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InitConfigs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let config: IConfigOption = {};
|
|
|
|
|
|
|
|
config.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
let configs: { [key: string]: IConfigOption; } = {};
|
|
|
|
|
|
|
|
configs["默认"] = config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return configs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async UpdateOption(cof: IConfigOption<PointLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, cof.option);
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
lightStore.lightData.Intensity = cof.option.Intensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.Color = cof.option.lightColor;
|
|
|
|
|
|
|
|
lightStore.lightData.Temperature = cof.option.temperature.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.IndirectLightingIntensity = cof.option.IndirectLightingIntensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SpecularScale = cof.option.SpecularScale.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SoftSourceRadius = cof.option.SoftSourceRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SourceLength = cof.option.SourceLength.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SourceRadius = cof.option.SourceRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pointLight = lightStore.currentSelectEnt as PointLight;
|
|
|
|
|
|
|
|
if (!lightStore.IsDrawLight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await CommandWrap(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updatePointLight(pointLight, cof);
|
|
|
|
|
|
|
|
if (userConfig.synchronousEnable)
|
|
|
|
|
|
|
|
app.WebSocket.Send(JSON.stringify(Entitys2Data([pointLight])));
|
|
|
|
|
|
|
|
}, "应用点光源配置");
|
|
|
|
|
|
|
|
pointLight.Update();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updatePointLight(pointLight, cof);
|
|
|
|
|
|
|
|
app.Viewer.UpdateRender();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static _SingleInstance: PointLightStore;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static GetInstance(): PointLightStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this._SingleInstance) return this._SingleInstance;
|
|
|
|
|
|
|
|
this._SingleInstance = new PointLightStore;
|
|
|
|
|
|
|
|
return this._SingleInstance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private updatePointLight(pointLight: PointLight, cof: IConfigOption<PointLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EntityUpdateWrap(pointLight, () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pointLight.Intensity = cof.option.Intensity;
|
|
|
|
|
|
|
|
pointLight.Color = new Color(cof.option.lightColor);
|
|
|
|
|
|
|
|
pointLight.Temperature = cof.option.temperature;
|
|
|
|
|
|
|
|
pointLight.IndirectLightingIntensity = cof.option.IndirectLightingIntensity;
|
|
|
|
|
|
|
|
pointLight.SpecularScale = cof.option.SpecularScale;
|
|
|
|
|
|
|
|
pointLight.SoftSourceRadius = cof.option.SoftSourceRadius;
|
|
|
|
|
|
|
|
pointLight.SourceLength = cof.option.SourceLength;
|
|
|
|
|
|
|
|
pointLight.SourceRadius = cof.option.SourceRadius;
|
|
|
|
|
|
|
|
pointLight.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class SpotLightStore implements IConfigStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@observable configName = "默认";
|
|
|
|
|
|
|
|
SaveConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
this.m_Option.CaseShadow = lightStore.lightData.CaseShadow;
|
|
|
|
|
|
|
|
this.m_Option.Intensity = parseInt(lightStore.lightData.Intensity);
|
|
|
|
|
|
|
|
this.m_Option.lightColor = lightStore.lightData.Color;
|
|
|
|
|
|
|
|
this.m_Option.temperature = parseInt(lightStore.lightData.Temperature);
|
|
|
|
|
|
|
|
this.m_Option.IndirectLightingIntensity = parseInt(lightStore.lightData.IndirectLightingIntensity);
|
|
|
|
|
|
|
|
this.m_Option.SpecularScale = parseFloat(lightStore.lightData.SpecularScale);
|
|
|
|
|
|
|
|
this.m_Option.Angle = parseInt(lightStore.lightData.Angle);
|
|
|
|
|
|
|
|
this.m_Option.InnerConeAngle = parseInt(lightStore.lightData.InnerConeAngle);
|
|
|
|
|
|
|
|
this.m_Option.SoftSourceRadius = parseInt(lightStore.lightData.SoftSourceRadius);
|
|
|
|
|
|
|
|
this.m_Option.SourceLength = parseInt(lightStore.lightData.SourceLength);
|
|
|
|
|
|
|
|
this.m_Option.SourceRadius = parseInt(lightStore.lightData.SourceRadius);
|
|
|
|
|
|
|
|
this.m_Option.AttenuationRadius = parseInt(lightStore.lightData.AttenuationRadius);
|
|
|
|
|
|
|
|
this.m_Option.ShowHelper = lightStore.lightData.ShowHelper;
|
|
|
|
|
|
|
|
//新的配置
|
|
|
|
|
|
|
|
let newConfig: IConfigOption = {};
|
|
|
|
|
|
|
|
newConfig.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
return newConfig;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
@observable m_Option: SpotLightOption = { ...DefaultSpotLightOption };
|
|
|
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
|
|
|
InitOption()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, DefaultSpotLightOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InitConfigs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let config: IConfigOption = {};
|
|
|
|
|
|
|
|
config.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
let configs: { [key: string]: IConfigOption; } = {};
|
|
|
|
|
|
|
|
configs["默认"] = config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return configs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async UpdateOption(cof: IConfigOption<SpotLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, cof.option);
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
lightStore.lightData.Intensity = cof.option.Intensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.Color = cof.option.lightColor;
|
|
|
|
|
|
|
|
lightStore.lightData.Temperature = cof.option.temperature.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.IndirectLightingIntensity = cof.option.IndirectLightingIntensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SpecularScale = cof.option.SpecularScale.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.Angle = cof.option.Angle.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.InnerConeAngle = cof.option.InnerConeAngle.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SoftSourceRadius = cof.option.SoftSourceRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SourceLength = cof.option.SourceLength.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SourceRadius = cof.option.SourceRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.AttenuationRadius = cof.option.AttenuationRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
lightStore.lightData.ShowHelper = cof.option.ShowHelper;
|
|
|
|
|
|
|
|
let spotLight = lightStore.currentSelectEnt as SpotLight;
|
|
|
|
|
|
|
|
if (!lightStore.IsDrawLight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await CommandWrap(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updateSpotLight(spotLight, cof);
|
|
|
|
|
|
|
|
if (userConfig.synchronousEnable)
|
|
|
|
|
|
|
|
app.WebSocket.Send(JSON.stringify(Entitys2Data([spotLight])));
|
|
|
|
|
|
|
|
}, "应用射灯配置");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updateSpotLight(spotLight, cof);
|
|
|
|
|
|
|
|
app.Viewer.UpdateRender();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static _SingleInstance: SpotLightStore;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static GetInstance(): SpotLightStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this._SingleInstance) return this._SingleInstance;
|
|
|
|
|
|
|
|
this._SingleInstance = new SpotLightStore;
|
|
|
|
|
|
|
|
return this._SingleInstance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateSpotLight(spotLight: SpotLight, cof: IConfigOption<SpotLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EntityUpdateWrap(spotLight, () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
spotLight.Intensity = cof.option.Intensity;
|
|
|
|
|
|
|
|
spotLight.Color = new Color(cof.option.lightColor);
|
|
|
|
|
|
|
|
spotLight.Temperature = cof.option.temperature;
|
|
|
|
|
|
|
|
spotLight.IndirectLightingIntensity = cof.option.IndirectLightingIntensity;
|
|
|
|
|
|
|
|
spotLight.SpecularScale = cof.option.SpecularScale;
|
|
|
|
|
|
|
|
spotLight.Angle = MathUtils.degToRad(cof.option.Angle);
|
|
|
|
|
|
|
|
spotLight.InnerConeAngle = cof.option.InnerConeAngle;
|
|
|
|
|
|
|
|
spotLight.SoftSourceRadius = cof.option.SoftSourceRadius;
|
|
|
|
|
|
|
|
spotLight.SourceLength = cof.option.SourceLength;
|
|
|
|
|
|
|
|
spotLight.SourceRadius = cof.option.SourceRadius;
|
|
|
|
|
|
|
|
spotLight.AttenuationRadius = cof.option.AttenuationRadius;
|
|
|
|
|
|
|
|
spotLight.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
spotLight.ShowHelper = cof.option.ShowHelper;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class RectAreaLightStore implements IConfigStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@observable configName = "默认";
|
|
|
|
|
|
|
|
SaveConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
this.m_Option.CaseShadow = lightStore.lightData.CaseShadow;
|
|
|
|
|
|
|
|
this.m_Option.Intensity = parseInt(lightStore.lightData.Intensity);
|
|
|
|
|
|
|
|
this.m_Option.lightColor = lightStore.lightData.Color;
|
|
|
|
|
|
|
|
this.m_Option.temperature = parseInt(lightStore.lightData.Temperature);
|
|
|
|
|
|
|
|
this.m_Option.IndirectLightingIntensity = parseInt(lightStore.lightData.IndirectLightingIntensity);
|
|
|
|
|
|
|
|
this.m_Option.SpecularScale = parseFloat(lightStore.lightData.SpecularScale);
|
|
|
|
|
|
|
|
this.m_Option.Width = parseFloat(lightStore.lightData.Width);
|
|
|
|
|
|
|
|
this.m_Option.Height = parseFloat(lightStore.lightData.Height);
|
|
|
|
|
|
|
|
this.m_Option.BarnDoorAngle = parseInt(lightStore.lightData.BarnDoorAngle);
|
|
|
|
|
|
|
|
this.m_Option.BarnDoorLength = parseInt(lightStore.lightData.BarnDoorLength);
|
|
|
|
|
|
|
|
this.m_Option.AttenuationRadius = parseInt(lightStore.lightData.AttenuationRadius);
|
|
|
|
|
|
|
|
this.m_Option.ShowHelper = lightStore.lightData.ShowHelper;
|
|
|
|
|
|
|
|
//新的配置
|
|
|
|
|
|
|
|
let newConfig: IConfigOption = {};
|
|
|
|
|
|
|
|
newConfig.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
return newConfig;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
@observable m_Option: RectAreaLightOption = { ...DefaultRectAreaLightOption };
|
|
|
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
|
|
|
InitOption()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, DefaultRectAreaLightOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InitConfigs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let config: IConfigOption = {};
|
|
|
|
|
|
|
|
config.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
let configs: { [key: string]: IConfigOption; } = {};
|
|
|
|
|
|
|
|
configs["默认"] = config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return configs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async UpdateOption(cof: IConfigOption<RectAreaLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, cof.option);
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
lightStore.lightData.Intensity = cof.option.Intensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.Color = cof.option.lightColor;
|
|
|
|
|
|
|
|
lightStore.lightData.Temperature = cof.option.temperature.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.IndirectLightingIntensity = cof.option.IndirectLightingIntensity.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.SpecularScale = cof.option.SpecularScale.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.BarnDoorAngle = cof.option.BarnDoorAngle.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.BarnDoorLength = cof.option.BarnDoorLength.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.AttenuationRadius = cof.option.AttenuationRadius.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
lightStore.lightData.ShowHelper = cof.option.ShowHelper;
|
|
|
|
|
|
|
|
lightStore.lightData.Height = cof.option.Height.toString();
|
|
|
|
|
|
|
|
lightStore.lightData.Width = cof.option.Width.toString();
|
|
|
|
|
|
|
|
let rectAreaLight = lightStore.currentSelectEnt as RectAreaLight;
|
|
|
|
|
|
|
|
if (!lightStore.IsDrawLight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await CommandWrap(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updateRectAreaLight(rectAreaLight, cof);
|
|
|
|
|
|
|
|
if (userConfig.synchronousEnable)
|
|
|
|
|
|
|
|
app.WebSocket.Send(JSON.stringify(Entitys2Data([rectAreaLight])));
|
|
|
|
|
|
|
|
}, "应用矩形光配置");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.updateRectAreaLight(rectAreaLight, cof);
|
|
|
|
|
|
|
|
app.Viewer.UpdateRender();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static _SingleInstance: RectAreaLightStore;
|
|
|
|
|
|
|
|
static GetInstance(): RectAreaLightStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this._SingleInstance) return this._SingleInstance;
|
|
|
|
|
|
|
|
this._SingleInstance = new RectAreaLightStore;
|
|
|
|
|
|
|
|
return this._SingleInstance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateRectAreaLight(rectAreaLight: RectAreaLight, cof: IConfigOption<RectAreaLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EntityUpdateWrap(rectAreaLight, () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rectAreaLight.Intensity = cof.option.Intensity;
|
|
|
|
|
|
|
|
rectAreaLight.Color = new Color(cof.option.lightColor);
|
|
|
|
|
|
|
|
rectAreaLight.Temperature = cof.option.temperature;
|
|
|
|
|
|
|
|
rectAreaLight.IndirectLightingIntensity = cof.option.IndirectLightingIntensity;
|
|
|
|
|
|
|
|
rectAreaLight.SpecularScale = cof.option.SpecularScale;
|
|
|
|
|
|
|
|
rectAreaLight.Width = cof.option.Width;
|
|
|
|
|
|
|
|
rectAreaLight.Height = cof.option.Height;
|
|
|
|
|
|
|
|
rectAreaLight.BarnDoorAngle = cof.option.BarnDoorAngle;
|
|
|
|
|
|
|
|
rectAreaLight.BarnDoorLength = cof.option.BarnDoorLength;
|
|
|
|
|
|
|
|
rectAreaLight.AttenuationRadius = cof.option.AttenuationRadius;
|
|
|
|
|
|
|
|
rectAreaLight.CaseShadow = cof.option.CaseShadow;
|
|
|
|
|
|
|
|
rectAreaLight.ShowHelper = cof.option.ShowHelper;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class RightPlaneLightStore implements IConfigStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@observable configName = "默认";
|
|
|
|
|
|
|
|
SaveConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
let sunLightStore = SunLightStore.GetInstance();
|
|
|
|
|
|
|
|
this.m_Option.ShowHemiLight = lightStore.ShowHemiLight;
|
|
|
|
|
|
|
|
this.m_Option.ShowSunLight = lightStore.ShowSunLight;
|
|
|
|
|
|
|
|
this.m_Option.SkyLightColor = lightStore.hemisphereLightData.Color;
|
|
|
|
|
|
|
|
this.m_Option.SkyLightIntensity = parseInt(lightStore.hemisphereLightData.Intensity);
|
|
|
|
|
|
|
|
this.m_Option.SkyLightIndirectLightingIntensity = parseInt(lightStore.hemisphereLightData.IndirectLightingIntensity);
|
|
|
|
|
|
|
|
this.m_Option.SunLightIntensity = sunLightStore.sunLightIntensity;
|
|
|
|
|
|
|
|
this.m_Option.SunLightIndirectLightingIntensity = sunLightStore.sunLightIndirectLightingIntensity;
|
|
|
|
|
|
|
|
this.m_Option.SunLightColor = sunLightStore.sunLightColor;
|
|
|
|
|
|
|
|
this.m_Option.SunLightTemperature = sunLightStore.sunLightColorTemperature;
|
|
|
|
|
|
|
|
this.m_Option.SunLightElevationDeg = sunLightStore.sunLightElevationDeg;
|
|
|
|
|
|
|
|
this.m_Option.SunLightRotateDeg = sunLightStore.sunLightRotateDeg;
|
|
|
|
|
|
|
|
this.m_Option.ShowExposure = lightStore.ShowExposure;
|
|
|
|
|
|
|
|
this.m_Option.AutoExposure = lightStore.hemisphereLightData.AutoExposure;
|
|
|
|
|
|
|
|
this.m_Option.ExposureCompensation = parseInt(lightStore.hemisphereLightData.ExposureCompensation);
|
|
|
|
|
|
|
|
//新的配置
|
|
|
|
|
|
|
|
let newConfig: IConfigOption = {};
|
|
|
|
|
|
|
|
newConfig.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
return newConfig;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
@observable m_Option: RightPlaneLightOption = { ...DefaultRightPlaneLightOption };
|
|
|
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
|
|
|
InitOption()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, DefaultRightPlaneLightOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InitConfigs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let config: IConfigOption = {};
|
|
|
|
|
|
|
|
config.option = toJS(this.m_Option);
|
|
|
|
|
|
|
|
let configs: { [key: string]: IConfigOption; } = {};
|
|
|
|
|
|
|
|
configs["默认"] = config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return configs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async UpdateOption(cof: IConfigOption<RightPlaneLightOption>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object.assign(this.m_Option, cof.option);
|
|
|
|
|
|
|
|
let lightStore = LightStore.GetInstance();
|
|
|
|
|
|
|
|
let sunLightStore = SunLightStore.GetInstance();
|
|
|
|
|
|
|
|
lightStore.ShowHemiLight = cof.option.ShowHemiLight;
|
|
|
|
|
|
|
|
lightStore.ShowSunLight = cof.option.ShowSunLight;
|
|
|
|
|
|
|
|
lightStore.hemisphereLightData.Color = cof.option.SkyLightColor;
|
|
|
|
|
|
|
|
lightStore.hemisphereLightData.Intensity = cof.option.SkyLightIntensity.toString();
|
|
|
|
|
|
|
|
lightStore.hemisphereLightData.IndirectLightingIntensity = cof.option.SkyLightIndirectLightingIntensity.toString();
|
|
|
|
|
|
|
|
sunLightStore.sunLightIntensity = cof.option.SunLightIntensity;
|
|
|
|
|
|
|
|
sunLightStore.sunLightIndirectLightingIntensity = cof.option.SunLightIndirectLightingIntensity;
|
|
|
|
|
|
|
|
sunLightStore.sunLightColor = cof.option.SunLightColor;
|
|
|
|
|
|
|
|
sunLightStore.sunLightColorTemperature = cof.option.SunLightTemperature;
|
|
|
|
|
|
|
|
sunLightStore.sunLightElevationDeg = cof.option.SunLightElevationDeg;
|
|
|
|
|
|
|
|
sunLightStore.sunLightRotateDeg = cof.option.SunLightRotateDeg;
|
|
|
|
|
|
|
|
lightStore.ShowExposure = cof.option.ShowExposure;
|
|
|
|
|
|
|
|
lightStore.hemisphereLightData.AutoExposure = cof.option.AutoExposure;
|
|
|
|
|
|
|
|
lightStore.hemisphereLightData.ExposureCompensation = cof.option.ExposureCompensation.toString();
|
|
|
|
|
|
|
|
let sunLight = app.Database.SunLight;
|
|
|
|
|
|
|
|
let skyLight = app.Database.HemisphereLight;
|
|
|
|
|
|
|
|
let pos: Vector3;
|
|
|
|
|
|
|
|
let elevation = MathUtils.degToRad(safeEval(cof.option.SunLightElevationDeg.toString()));
|
|
|
|
|
|
|
|
let rotate = MathUtils.degToRad(safeEval(cof.option.SunLightRotateDeg.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);
|
|
|
|
|
|
|
|
await CommandWrap(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
skyLight.Visible = cof.option.ShowHemiLight;
|
|
|
|
|
|
|
|
sunLight.Visible = cof.option.ShowSunLight;
|
|
|
|
|
|
|
|
skyLight.Color = new Color(cof.option.SkyLightColor);
|
|
|
|
|
|
|
|
skyLight.Intensity = cof.option.SkyLightIntensity;
|
|
|
|
|
|
|
|
skyLight.IndirectLightingIntensity = cof.option.SkyLightIndirectLightingIntensity;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sunLight.Intensity = cof.option.SunLightIntensity;
|
|
|
|
|
|
|
|
sunLight.IndirectLightingIntensity = cof.option.SunLightIndirectLightingIntensity;
|
|
|
|
|
|
|
|
sunLight.Color = new Color(cof.option.SunLightColor);
|
|
|
|
|
|
|
|
sunLight.Temperature = cof.option.SunLightTemperature;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sunLight.Position = pos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LightStore.GetInstance().UpdateDirLightShadowArea();
|
|
|
|
|
|
|
|
app.Viewer.UpdateRender();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userConfig.synchronousEnable)
|
|
|
|
|
|
|
|
app.WebSocket.Send(JSON.stringify(Entitys2Data([sunLight, skyLight])));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, "应用配置");
|
|
|
|
|
|
|
|
sunLight.Update();
|
|
|
|
|
|
|
|
skyLight.Update();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static _SingleInstance: RightPlaneLightStore;
|
|
|
|
|
|
|
|
static GetInstance(): RightPlaneLightStore
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this._SingleInstance) return this._SingleInstance;
|
|
|
|
|
|
|
|
this._SingleInstance = new RightPlaneLightStore;
|
|
|
|
|
|
|
|
return this._SingleInstance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|