mirror of https://gitee.com/cf-fz/WebCAD.git
!1978 功能:矩形灯切换配置可锁定长宽和批量修改灯光功能
parent
c6f3359a1b
commit
04f1e79218
@ -0,0 +1,109 @@
|
||||
import { app } from "../../ApplicationServices/Application";
|
||||
import { EntitysUpdateWrap } from "../../Common/EntityUpdateWrap";
|
||||
import { PointLight } from "../../DatabaseServices/Lights/PointLight";
|
||||
import { RectAreaLight } from "../../DatabaseServices/Lights/RectAreaLight";
|
||||
import { SpotLight } from "../../DatabaseServices/Lights/SpotLight";
|
||||
import { Command } from "../../Editor/CommandMachine";
|
||||
import { PromptStatus } from "../../Editor/PromptResult";
|
||||
import { BoardModalType } from "../../UI/Components/Board/BoardModalType";
|
||||
import { ModalState } from "../../UI/Components/Modal/ModalInterface";
|
||||
import { IConfigStore } from "../../UI/Store/BoardStore";
|
||||
import { LightConfigModel } from "../../UI/Store/RightPanelStore/LightConfigModel";
|
||||
import { LightStore, PointLightStore, RectAreaLightStore, SpotLightStore } from "../../UI/Store/RightPanelStore/LightStore";
|
||||
|
||||
export class BatchModifyLights implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let lightType: BoardModalType;
|
||||
let configStore: IConfigStore;
|
||||
let enRes = await app.Editor.GetEntity({
|
||||
Msg: "请选择第一个灯(需要修改的灯类型)",
|
||||
NotNone: true,
|
||||
Filter: { filterTypes: [RectAreaLight, SpotLight, PointLight] }
|
||||
});
|
||||
if (enRes.Status !== PromptStatus.OK) return;
|
||||
let currentLight = enRes.Entity as RectAreaLight | SpotLight | PointLight;
|
||||
|
||||
app.Editor.SetSelection([currentLight]);
|
||||
let lightStore = new LightStore().InitLightData(currentLight);
|
||||
lightStore.IsDrawLight = true;
|
||||
|
||||
if (currentLight instanceof SpotLight)
|
||||
{
|
||||
lightType = BoardModalType.SpotLight;
|
||||
configStore = SpotLightStore.GetInstance();
|
||||
(configStore as SpotLightStore).lightStore = lightStore;
|
||||
}
|
||||
else if (currentLight instanceof RectAreaLight)
|
||||
{
|
||||
lightType = BoardModalType.RectAreaLight;
|
||||
configStore = RectAreaLightStore.GetInstance();
|
||||
(configStore as RectAreaLightStore).lightStore = lightStore;
|
||||
}
|
||||
else if (currentLight instanceof PointLight)
|
||||
{
|
||||
lightType = BoardModalType.PointLight;
|
||||
configStore = PointLightStore.GetInstance();
|
||||
(configStore as PointLightStore).lightStore = lightStore;
|
||||
}
|
||||
|
||||
let ssRes = await app.Editor.GetSelection({
|
||||
Msg: "请选择需要修改的灯",
|
||||
Filter: { filterTypes: lightType === BoardModalType.RectAreaLight ? [RectAreaLight] : lightType === BoardModalType.SpotLight ? [SpotLight] : [PointLight] },
|
||||
});
|
||||
if (ssRes.Status !== PromptStatus.OK) return;
|
||||
let lights = ssRes.SelectSet.SelectEntityList as (RectAreaLight | SpotLight | PointLight)[];
|
||||
|
||||
app.Editor.ModalManage.RenderModal(LightConfigModel,
|
||||
{
|
||||
store: lightStore,
|
||||
lightType,
|
||||
type: lightType + "Config",
|
||||
configStore: configStore,
|
||||
isNotModify: true,
|
||||
}, { IsLightModal: true });
|
||||
|
||||
let state = await app.Editor.ModalManage.Wait();
|
||||
if (state.Status !== ModalState.Ok) return;
|
||||
|
||||
EntitysUpdateWrap(lights, () =>
|
||||
{
|
||||
for (const light of lights)
|
||||
{
|
||||
light.Color = currentLight.Color;
|
||||
light.Temperature = currentLight.Temperature;
|
||||
light.Intensity = currentLight.Intensity;
|
||||
light.IndirectLightingIntensity = currentLight.IndirectLightingIntensity;
|
||||
light.SpecularScale = currentLight.SpecularScale;
|
||||
light.ShowHelper = currentLight.ShowHelper;
|
||||
if (currentLight instanceof RectAreaLight && light instanceof RectAreaLight)
|
||||
{
|
||||
light.Width = currentLight.Width;
|
||||
light.Height = currentLight.Height;
|
||||
light.BarnDoorAngle = currentLight.BarnDoorAngle;
|
||||
light.BarnDoorLength = currentLight.BarnDoorLength;
|
||||
light.AttenuationRadius = currentLight.AttenuationRadius;
|
||||
light.CaseShadow = currentLight.CaseShadow;
|
||||
}
|
||||
else if (currentLight instanceof SpotLight && light instanceof SpotLight)
|
||||
{
|
||||
light.Angle = currentLight.Angle;
|
||||
light.InnerConeAngle = currentLight.InnerConeAngle;
|
||||
light.SoftSourceRadius = currentLight.SoftSourceRadius;
|
||||
light.SourceLength = currentLight.SourceLength;
|
||||
light.SourceRadius = currentLight.SourceRadius;
|
||||
light.AttenuationRadius = currentLight.AttenuationRadius;
|
||||
light.CaseShadow = currentLight.CaseShadow;
|
||||
light.Update();
|
||||
}
|
||||
else if (currentLight instanceof PointLight && light instanceof PointLight)
|
||||
{
|
||||
light.SoftSourceRadius = currentLight.SoftSourceRadius;
|
||||
light.SourceLength = currentLight.SourceLength;
|
||||
light.SourceRadius = currentLight.SourceRadius;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in new issue