!2810 新增:允许修改场景太阳光 sourceAngle 的值

pull/2811/head
罗春太 4 months ago committed by ChenX
parent ad8df31f96
commit 5d77395163

@ -83,6 +83,7 @@ export class INumericInput extends React.Component<INumericInputProps, {}>
return; return;
} }
this._Value = parseFloat(FixedNotZero(num, this._Float)); this._Value = parseFloat(FixedNotZero(num, this._Float));
this.props.onValueChange(num, value, e);
this._isPopoverOpen = false; this._isPopoverOpen = false;
}} }}
onFocus={(e) => onFocus={(e) =>

@ -193,6 +193,30 @@
} }
} }
.sun-light-angle {
display: flex;
.bp3-numeric-input {
.bp3-button-group {
display: none;
}
}
input {
margin-left: none;
}
.bp3-popover-wrapper {
display: flex;
align-items: center;
button {
position: relative;
left: 151px;
}
}
}
.bp3-button-group.bp3-vertical.bp3-fixed { .bp3-button-group.bp3-vertical.bp3-fixed {
margin-top: 1px; margin-top: 1px;
} }

@ -103,7 +103,7 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore; }, {}
alignIndicator={Alignment.RIGHT} alignIndicator={Alignment.RIGHT}
/> />
<div style={{ display: lightStore.ShowSunLight ? "block" : "none", position: "relative" }}> <div style={{ display: lightStore.ShowSunLight ? "block" : "none", position: "relative" }}>
<div style={{ position: "absolute", right: 30, marginTop: 190, zIndex: 2 }}> <div style={{ position: "absolute", right: 30, marginTop: 225, zIndex: 2 }}>
<HTMLSelect <HTMLSelect
options={[ETime.Default, ETime.Morning, ETime.Noon, ETime.Afternoon, ETime.Evening]} options={[ETime.Default, ETime.Morning, ETime.Noon, ETime.Afternoon, ETime.Evening]}
value={lightStore.sunLightData.time} value={lightStore.sunLightData.time}

@ -11,6 +11,7 @@ import { CalcSunShadowCameraExtents } from '../../../Common/LightUtils';
import { commandMachine } from '../../../Editor/CommandMachine'; import { commandMachine } from '../../../Editor/CommandMachine';
import { CommandState } from '../../../Editor/CommandState'; import { CommandState } from '../../../Editor/CommandState';
import { userConfig } from '../../../Editor/UserConfig'; import { userConfig } from '../../../Editor/UserConfig';
import { INumericInput } from '../INumericInput';
import { AppToaster } from '../Toaster'; import { AppToaster } from '../Toaster';
import { DefaultDist } from './ScenePanel'; import { DefaultDist } from './ScenePanel';
import { SunLightStore } from './SunLightStore'; import { SunLightStore } from './SunLightStore';
@ -181,6 +182,35 @@ export default class SunLightGui extends Component
this.SyncSunLight(); this.SyncSunLight();
}; };
SetSunLightSourceAngle = async (val: number) =>
{
const KEY = '修改太阳光源角度';
if (CommandState.CommandIng)
{
if (app.Database.hm.UndoData.CommandName !== KEY)
{
await app.Editor.ModalManage.EndExecingCmd();
if (CommandState.CommandIng)
{
AppToaster.show({
message: "命令正在执行中!无法修改太阳光源角度!",
timeout: 5000,
intent: Intent.DANGER
});
return;
}
commandMachine.CommandStart(KEY);
}
}
else
{
commandMachine.CommandStart(KEY);
}
app.Database.SunLight.LightSourceAngle = val;
this.store.sunLightSourceAngle = val;
this.SyncSunLight();
};
SetSunLightPosition = (rotate: number, elevation: number): void => SetSunLightPosition = (rotate: number, elevation: number): void =>
{ {
let pos: Vector3; let pos: Vector3;
@ -384,6 +414,67 @@ export default class SunLightGui extends Component
</Tooltip> </Tooltip>
</div> </div>
</FormGroup> </FormGroup>
<FormGroup>
<div className='sun-light-angle'>
<Label>:</Label>
<INumericInput
style={{ marginLeft: "none" }}
min={0}
max={5}
float={4}
stepSize={0.0001}
value={this.store.sunLightSourceAngle}
onValueChange={async (num) =>
{
if (num < 0 || num > 5) return;
this.SetSunLightSourceAngle(num);
app.Viewer.UpdateRender();
}}
onBlur={() =>
{
const KEY = '修改太阳光源角度';
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === KEY)
commandMachine.CommandEnd();
}}
/>
<Slider
min={0}
max={5}
stepSize={.0001}
value={this.store.sunLightSourceAngle}
onChange={async (val) =>
{
await this.SetSunLightSourceAngle(val);
app.Viewer.UpdateRender();
}}
onRelease={() =>
{
const KEY = '修改太阳光源角度';
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === KEY)
commandMachine.CommandEnd();
}}
/>
<Tooltip content='重置太阳光源角度'
minimal
placement='top'
>
<Button
style={{ marginLeft: "auto" }}
minimal small
intent={Intent.PRIMARY}
icon='redo'
onClick={async () =>
{
await this.SetSunLightSourceAngle(0.5357);
app.Viewer.UpdateRender();
const KEY = '修改太阳光源角度';
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === KEY)
commandMachine.CommandEnd();
}}
/>
</Tooltip>
</div>
</FormGroup>
<FormGroup <FormGroup
label='颜色:' label='颜色:'
inline inline

@ -10,6 +10,7 @@ export class SunLightStore
{ {
@observable sunLightIntensity: number = 50; @observable sunLightIntensity: number = 50;
@observable sunLightIndirectLightingIntensity: number = 1; @observable sunLightIndirectLightingIntensity: number = 1;
@observable sunLightSourceAngle: number = 0.5357;
@observable sunLightElevationDeg: number = 45; @observable sunLightElevationDeg: number = 45;
@observable sunLightRotateDeg: number = 235; @observable sunLightRotateDeg: number = 235;
@observable sunLightColor: string = '#FFFFFF'; @observable sunLightColor: string = '#FFFFFF';

Loading…
Cancel
Save