!1980 修复:修改灯光属性部分情况报错

pull/1987/head
林三 2 years ago committed by ChenX
parent 12a26a7f96
commit cc5f945d5c

@ -7,6 +7,7 @@ import { Color, MathUtils } from "three";
import { begin } from "xaop"; import { begin } from "xaop";
import { Entitys2Data } from "../../../Add-on/ExportData"; import { Entitys2Data } from "../../../Add-on/ExportData";
import { app } from "../../../ApplicationServices/Application"; import { app } from "../../../ApplicationServices/Application";
import { CoolDownTime } from "../../../Common/CoolDownTime";
import { ResourcesCDN_HOST } from "../../../Common/HostUrl"; import { ResourcesCDN_HOST } from "../../../Common/HostUrl";
import { KeyBoard } from "../../../Common/KeyEnum"; import { KeyBoard } from "../../../Common/KeyEnum";
import { UpdateDraw } from "../../../Common/Status"; import { UpdateDraw } from "../../../Common/Status";
@ -32,7 +33,7 @@ export class LightConfigModel extends React.Component<{ store: LightStore; confi
@observable _Target: string = this.props.lightType === BoardModalType.PointLight ? "" : (this.props.store.currentSelectEnt as SpotLight | RectAreaLight).Target.sub(this.props.store.currentSelectEnt.Position).normalize().ceil().toArray().toString(); @observable _Target: string = this.props.lightType === BoardModalType.PointLight ? "" : (this.props.store.currentSelectEnt as SpotLight | RectAreaLight).Target.sub(this.props.store.currentSelectEnt.Position).normalize().ceil().toArray().toString();
@observable _Position: string = this.props.store.currentSelectEnt.Position.ceil().toArray().toString(); @observable _Position: string = this.props.store.currentSelectEnt.Position.ceil().toArray().toString();
private removeFuncs: Function[] = []; //移除注入 private removeFuncs: Function[] = []; //移除注入
private coolTime = new CoolDownTime;
componentDidMount() componentDidMount()
{ {
if (this.props.isNotModify) if (this.props.isNotModify)
@ -102,7 +103,10 @@ export class LightConfigModel extends React.Component<{ store: LightStore; confi
private SyncLight() private SyncLight()
{ {
if (userConfig.synchronousEnable) if (userConfig.synchronousEnable)
app.WebSocket.Send(JSON.stringify(Entitys2Data([this.props.store.currentSelectEnt]))); this.coolTime.Debounce(() =>
{
app.WebSocket.Send(JSON.stringify(Entitys2Data([this.props.store.currentSelectEnt])));
}, 10);
} }
render() render()
@ -333,8 +337,7 @@ export class LightConfigModel extends React.Component<{ store: LightStore; confi
commandMachine.CommandStart(KEY); commandMachine.CommandStart(KEY);
} }
this.props.store.currentSelectEnt.Temperature = val; this.props.store.currentSelectEnt.Temperature = val;
if (userConfig.synchronousEnable) this.SyncLight();
app.WebSocket.Send(JSON.stringify(Entitys2Data([this.props.store.currentSelectEnt])));
} }
else else
{ {
@ -450,6 +453,17 @@ export class LightConfigModel extends React.Component<{ store: LightStore; confi
export class InputAndSlider extends React.Component<{ pars: string[], store: LightStore; max: number; isFloat: boolean; min: number; noLim: boolean; isNotModify: boolean; }, {}> export class InputAndSlider extends React.Component<{ pars: string[], store: LightStore; max: number; isFloat: boolean; min: number; noLim: boolean; isNotModify: boolean; }, {}>
{ {
OldData: number = 0; OldData: number = 0;
private coolTime = new CoolDownTime;
private SyncLight()
{
if (userConfig.synchronousEnable)
this.coolTime.Debounce(() =>
{
app.WebSocket.Send(JSON.stringify(Entitys2Data([this.props.store.currentSelectEnt])));
}, 10);
}
async SetValue(value: string) async SetValue(value: string)
{ {
@ -505,8 +519,7 @@ export class InputAndSlider extends React.Component<{ pars: string[], store: Lig
this.props.store.currentSelectEnt[this.props.pars[0]] = parseFloat(value); this.props.store.currentSelectEnt[this.props.pars[0]] = parseFloat(value);
break; break;
} }
if (userConfig.synchronousEnable) this.SyncLight();
app.WebSocket.Send(JSON.stringify(Entitys2Data([this.props.store.currentSelectEnt])));
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();
} }
@ -587,7 +600,7 @@ export class InputAndSlider extends React.Component<{ pars: string[], store: Lig
} }
if (this.props.store.lightData[this.props.pars[0]] < this.props.min) if (this.props.store.lightData[this.props.pars[0]] < this.props.min)
{ {
if (this.OldData = this.props.store.currentSelectEnt[this.props.pars[0]]) if (this.OldData === this.props.store.currentSelectEnt[this.props.pars[0]])
{ {
this.props.store.lightData[this.props.pars[0]] = this.props.store.currentSelectEnt[this.props.pars[0]]; this.props.store.lightData[this.props.pars[0]] = this.props.store.currentSelectEnt[this.props.pars[0]];
return; return;
@ -615,18 +628,26 @@ export class InputAndSlider extends React.Component<{ pars: string[], store: Lig
value={parseFloat(this.props.store.lightData[this.props.pars[0]]) >= this.props.max ? this.props.max : parseFloat(this.props.store.lightData[this.props.pars[0]])} value={parseFloat(this.props.store.lightData[this.props.pars[0]]) >= this.props.max ? this.props.max : parseFloat(this.props.store.lightData[this.props.pars[0]])}
onChange={(e) => onChange={(e) =>
{ {
this.props.isNotModify ? this.SetLightData((FixedNotZero(e, this.props.isFloat ? 1 : 0))) : this.SetValue((FixedNotZero(e, this.props.isFloat ? 1 : 0))); let coolTime = new CoolDownTime;
coolTime.Debounce(() =>
{
this.props.isNotModify ? this.SetLightData((FixedNotZero(e, this.props.isFloat ? 1 : 0))) : this.SetValue((FixedNotZero(e, this.props.isFloat ? 1 : 0)));
}, 0);
}} }}
onRelease={() => onRelease={() =>
{ {
if (!this.props.isNotModify) let coolTime = new CoolDownTime;
coolTime.Debounce(() =>
{ {
const KEY = '修改灯光' + this.props.pars[1]; if (!this.props.isNotModify)
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === KEY)
{ {
commandMachine.CommandEnd(); const KEY = '修改灯光' + this.props.pars[1];
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === KEY)
{
commandMachine.CommandEnd();
}
} }
} }, 50);
}} }}
/> />
</div> </div>

Loading…
Cancel
Save