!1751 功能:模型旋转重置功能,输入框输入功能

pull/1722/MERGE
黄诗津 3 years ago committed by ChenX
parent b5feedce96
commit 904d460d6c

@ -198,6 +198,43 @@ export default class ModifyModelStore
ent.Position = p; ent.Position = p;
app.Viewer.UpdateRender(); app.Viewer.UpdateRender();
}; };
UpdatePosition = async (ents: Entity[], move: number, axis: ModuleAxis) =>
{
if (!ents) return;
let m = new Matrix4;
for (let ent of ents)
{
switch (axis)
{
case (ModuleAxis.x):
{
m.setPosition(new Vector3(move, 0, 0));
ent.ApplyMatrix(m);
break;
}
case (ModuleAxis.y):
{
m.setPosition(new Vector3(0, move, 0));
ent.ApplyMatrix(m);
break;
}
case (ModuleAxis.z):
{
m.setPosition(new Vector3(0, 0, move));
ent.ApplyMatrix(m);
break;
}
default:
AppToaster.show({
message: "出错啦!",
timeout: 5000,
intent: Intent.DANGER,
});
break;
}
app.Viewer.UpdateRender();
}
};
UpdateModuleRotate = (ent: Entity, x: number, y: number, z: number) => UpdateModuleRotate = (ent: Entity, x: number, y: number, z: number) =>
{ {
let eu = new Euler(x * MathUtils.DEG2RAD, y * MathUtils.DEG2RAD, z * MathUtils.DEG2RAD, 'ZYX'); let eu = new Euler(x * MathUtils.DEG2RAD, y * MathUtils.DEG2RAD, z * MathUtils.DEG2RAD, 'ZYX');

@ -205,10 +205,62 @@ export default class ModuleBaseParams extends Component<{}, {}>
targetEl.onmousemove = null; targetEl.onmousemove = null;
}; };
}; };
ChangeRotate = async (e: number, ModifyModelStore: ModifyModelStore, axis: ModuleAxis) =>
{
if (!app.Editor.SelectCtrl.SelectSet.SelectEntityList.length) return;
const Command_KEY = '修改模型角度';
if (CommandState.CommandIng)
{
await app.Editor.ModalManage.EndExecingCmd();
if (CommandState.CommandIng)
{
AppToaster.show({
message: "命令正在执行中!无法修改模型角度!",
timeout: 5000,
intent: Intent.DANGER,
});
return;
}
commandMachine.CommandStart(Command_KEY);
} else
{
commandMachine.CommandStart(Command_KEY);
}
switch (axis)
{
case ModuleAxis.x: {
ModifyModelStore.rotateX = e;
break;
}
case ModuleAxis.y: {
ModifyModelStore.rotateY = e;
break;
}
case ModuleAxis.z: {
ModifyModelStore.rotateZ = e;
break;
}
default:
break;
}
for (let e of app.Editor.SelectCtrl.SelectSet.SelectEntityList)
{
ModifyModelStore.UpdateModuleRotate(e,
ModifyModelStore.rotateX,
ModifyModelStore.rotateY,
ModifyModelStore.rotateZ
);
}
if (CommandState.CommandIng && app.Database.hm.UndoData.CommandName === Command_KEY)
{
commandMachine.CommandEnd();
}
};
ChangePosition = async (e: string, axis: ModuleAxis) => ChangePosition = async (e: string, axis: ModuleAxis) =>
{ {
if (!app.Editor.SelectCtrl.SelectSet.SelectEntityList.length) return; if (!app.Editor.SelectCtrl.SelectSet.SelectEntityList.length) return;
const ent = app.Editor.SelectCtrl.SelectSet.SelectEntityList[0]; let ents = app.Editor.SelectCtrl.SelectSet.SelectEntityList;
const Command_KEY = '修改模型位置'; const Command_KEY = '修改模型位置';
if (CommandState.CommandIng) if (CommandState.CommandIng)
{ {
@ -234,21 +286,25 @@ export default class ModuleBaseParams extends Component<{}, {}>
{ {
v = 0; v = 0;
} }
let move: number;
switch (axis) switch (axis)
{ {
case ModuleAxis.x: { case ModuleAxis.x: {
move = v - ModifyModelStore.positionX;
ModifyModelStore.positionX = v; ModifyModelStore.positionX = v;
ModifyModelStore.UpdateModulePosition(ent, ModifyModelStore.positionX, ModuleAxis.x); ModifyModelStore.UpdatePosition(ents, move, ModuleAxis.x);
break; break;
} }
case ModuleAxis.y: { case ModuleAxis.y: {
move = v - ModifyModelStore.positionY;
ModifyModelStore.positionY = v; ModifyModelStore.positionY = v;
ModifyModelStore.UpdateModulePosition(ent, ModifyModelStore.positionY, ModuleAxis.y); ModifyModelStore.UpdatePosition(ents, move, ModuleAxis.y);
break; break;
} }
case ModuleAxis.z: { case ModuleAxis.z: {
move = v - ModifyModelStore.positionZ;
ModifyModelStore.positionZ = v; ModifyModelStore.positionZ = v;
ModifyModelStore.UpdateModulePosition(ent, ModifyModelStore.positionZ, ModuleAxis.z); ModifyModelStore.UpdatePosition(ents, move, ModuleAxis.z);
break; break;
} }
default: default:
@ -561,7 +617,7 @@ export default class ModuleBaseParams extends Component<{}, {}>
}} /> }} />
</div> </div>
<div className='ParamsItem'> <div className='ParamsItem'>
<div className='ParamsPosition'> <div className='ParamsPosition' style={{ width: 220 }}>
<span style={{ lineHeight: "24px" }}></span> <span style={{ lineHeight: "24px" }}></span>
<div> <div>
<InputGroup <InputGroup
@ -571,6 +627,10 @@ export default class ModuleBaseParams extends Component<{}, {}>
this.ChangePosition(e.target.value, ModuleAxis.x); this.ChangePosition(e.target.value, ModuleAxis.x);
}} }}
onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.x); }} onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.x); }}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/> />
</div> </div>
<div> <div>
@ -581,6 +641,10 @@ export default class ModuleBaseParams extends Component<{}, {}>
this.ChangePosition(e.target.value, ModuleAxis.y); this.ChangePosition(e.target.value, ModuleAxis.y);
}} }}
onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.y); }} onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.y); }}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/> />
</div> </div>
<div> <div>
@ -591,11 +655,12 @@ export default class ModuleBaseParams extends Component<{}, {}>
this.ChangePosition(e.target.value, ModuleAxis.z); this.ChangePosition(e.target.value, ModuleAxis.z);
}} }}
onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.z); }} onPointerDown={(e) => { this.LetsMove(e, ModuleAxis.z); }}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/> />
</div> </div>
<Tooltip minimal placement='top' content='重置'>
<Button minimal small intent={Intent.PRIMARY} icon='redo' />
</Tooltip>
</div> </div>
</div> </div>
<div className='ParamsItem' style={{ marginTop: "10px" }}> <div className='ParamsItem' style={{ marginTop: "10px" }}>
@ -611,13 +676,20 @@ export default class ModuleBaseParams extends Component<{}, {}>
<Icon icon='record' size={8} style={{ color: "#FF0000" }} /> <Icon icon='record' size={8} style={{ color: "#FF0000" }} />
</div> </div>
<NumericInput <NumericInput
selectAllOnFocus={true}
min={min} min={min}
max={max} max={max}
value={ModifyModelStore.rotateX.toFixed(0)} value={ModifyModelStore.rotateX.toFixed(0)}
onValueChange={(e: number) => onValueChange={(e: number) =>
{ {
ModifyModelStore.rotateX = e; if (isNaN(e) || e < 0 || e > 360) return;
}} /> this.ChangeRotate(e, ModifyModelStore, ModuleAxis.x);
}}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/>
</div> </div>
</div> </div>
<div className='RotateY'> <div className='RotateY'>
@ -630,13 +702,20 @@ export default class ModuleBaseParams extends Component<{}, {}>
<Icon icon='record' size={8} style={{ color: "#00FF00" }} /> <Icon icon='record' size={8} style={{ color: "#00FF00" }} />
</div> </div>
<NumericInput <NumericInput
selectAllOnFocus={true}
min={min} min={min}
max={max} max={max}
value={ModifyModelStore.rotateY.toFixed(0)} value={ModifyModelStore.rotateY.toFixed(0)}
onValueChange={(e: number) => onValueChange={(e: number) =>
{ {
ModifyModelStore.rotateY = e; if (isNaN(e) || e < 0 || e > 360) return;
}} /> this.ChangeRotate(e, ModifyModelStore, ModuleAxis.y);
}}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/>
</div> </div>
</div> </div>
<div className='RotateZ'> <div className='RotateZ'>
@ -649,17 +728,55 @@ export default class ModuleBaseParams extends Component<{}, {}>
<Icon icon='record' size={8} style={{ color: "#0000FF" }} /> <Icon icon='record' size={8} style={{ color: "#0000FF" }} />
</div> </div>
<NumericInput <NumericInput
selectAllOnFocus={true}
min={min} min={min}
max={max} max={max}
value={ModifyModelStore.rotateZ.toFixed(0)} value={ModifyModelStore.rotateZ.toFixed(0)}
onValueChange={(e: number) => onValueChange={(e: number) =>
{ {
ModifyModelStore.rotateZ = e; if (isNaN(e) || e < 0 || e > 360) return;
}} /> this.ChangeRotate(e, ModifyModelStore, ModuleAxis.z);
}}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/>
</div> </div>
</div> </div>
<Tooltip minimal placement='top' content='重置'> <Tooltip minimal placement='top' content='重置'>
<Button minimal small intent={Intent.PRIMARY} icon='redo' /> <Button minimal small intent={Intent.PRIMARY} icon='redo'
onClick={async (e: React.MouseEvent) =>
{
e.stopPropagation();
if (app.Editor.SelectCtrl.SelectSet.SelectEntityList.length !== 1) return;
if (CommandState.CommandIng)
{
await app.Editor.ModalManage.EndExecingCmd();
if (CommandState.CommandIng)
{
AppToaster.show({
message: "命令正在执行中!无法修改模型角度!",
timeout: 5000,
intent: Intent.DANGER,
});
return;
}
}
const Command_KEY = '修改模型角度';
commandMachine.CommandStart(Command_KEY);
for (let ent of app.Editor.SelectCtrl.SelectSet.SelectEntityList as EntityRef[])
{
ModifyModelStore.UpdateModuleRotate(ent, 0, 0, 0);
app.Viewer.UpdateRender();
}
commandMachine.CommandEnd();
}}
onKeyDown={(e: React.KeyboardEvent) =>
{
e.stopPropagation();
}}
/>
</Tooltip> </Tooltip>
</div> </div>
</div> </div>

Loading…
Cancel
Save