信号机调整

This commit is contained in:
fan 2023-06-06 17:07:39 +08:00
parent dad537cf47
commit bf4847e1ab
2 changed files with 34 additions and 2 deletions

View File

@ -27,6 +27,12 @@ enum directionSelect {
向上 = 'up',
向下 = 'down',
}
enum directionMap {
left = '向左',
right = '向右',
up = '向上',
down = '向下',
}
drawStore.$subscribe;
watch(
@ -34,7 +40,7 @@ watch(
(val) => {
if (val && val.type == Signal.Type) {
signalModel.copyFrom(val.saveData() as SignalData);
signalDirection.value = (directionSelect as never)[signalModel.direction];
signalDirection.value = (directionMap as never)[signalModel.direction];
}
}
);
@ -43,7 +49,7 @@ onMounted(() => {
const signal = drawStore.selectedGraphic as Signal;
if (signal) {
signalModel.copyFrom(signal.saveData());
signalDirection.value = (directionSelect as never)[signalModel.direction];
signalDirection.value = (directionMap as never)[signalModel.direction];
}
});

View File

@ -134,6 +134,32 @@ export class Signal extends JlGraphic {
codeGraph.anchor.set(0.5);
codeGraph.style.fill = this.datas.codeColor;
codeGraph.position.set(0, signalConsts.nameOffsetY);
if (this.datas.direction === 'left') {
this.lampPost.rotation = Math.PI;
this.circularLamp.rotation = Math.PI;
this.humanControl.rotation = Math.PI;
this.fleetMode.rotation = Math.PI;
this.logicMode.rotation = Math.PI;
} else if (this.datas.direction === 'up') {
this.lampPost.rotation = (Math.PI / 2) * 3;
this.circularLamp.rotation = (Math.PI / 2) * 3;
this.humanControl.rotation = (Math.PI / 2) * 3;
this.fleetMode.rotation = (Math.PI / 2) * 3;
this.logicMode.rotation = (Math.PI / 2) * 3;
} else if (this.datas.direction === 'down') {
this.lampPost.rotation = Math.PI / 2;
this.circularLamp.rotation = Math.PI / 2;
this.humanControl.rotation = Math.PI / 2;
this.fleetMode.rotation = Math.PI / 2;
this.logicMode.rotation = Math.PI / 2;
} else {
this.lampPost.rotation = 0;
this.circularLamp.rotation = 0;
this.humanControl.rotation = 0;
this.fleetMode.rotation = 0;
this.logicMode.rotation = 0;
}
this.position.set(this.datas.point.x, this.datas.point.y);
}
}