This commit is contained in:
joylink_fanyuhong 2024-08-29 17:40:37 +08:00
commit 94607edcfe
2 changed files with 22 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import Tcc_Handle_JSON from './tcc-handle-data.json';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
export const zeroOffset = 9;
interface TccHandleTextures {
tccHandle: Texture;
handleBackground: Texture;
@ -54,7 +55,14 @@ export class TccHandle extends JlGraphic {
return this.getStates<ITccHandleState>();
}
doRepaint(): void {
this._tccHandle.y = -(this.state.gear * 144) / 100;
const pos = -(this.state.gear * (144 - zeroOffset)) / 100;
if (pos > 0) {
this._tccHandle.y = pos + zeroOffset;
} else if (pos < 0) {
this._tccHandle.y = pos - zeroOffset;
} else {
this._tccHandle.y = 0;
}
this._tccHandle.texture = this.tccHandleTextures.tccHandle;
}
}

View File

@ -5,7 +5,7 @@ import { useLineStore } from './line-store';
import { tccOperation } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
import { request } from 'src/protos/request';
import { TccHandle } from 'src/graphics/tccHandle/TccHandle';
import { TccHandle, zeroOffset } from 'src/graphics/tccHandle/TccHandle';
import { TccKey } from 'src/graphics/tccKey/TccKey';
import { IGraphicApp } from 'jl-graphic';
@ -47,8 +47,19 @@ export const useTccStore = defineStore('tcc', {
.getScene(`tcc${this.tccId}`)
.queryStore.queryById<TccHandle>(this.tccHandleId);
if (!simulationId) return;
let transFormHandleVal = 0;
if (
tccHandle._tccHandle.y >= -zeroOffset &&
tccHandle._tccHandle.y <= zeroOffset
) {
tccHandle._tccHandle.y = 0;
} else if (tccHandle._tccHandle.y < -zeroOffset) {
transFormHandleVal = tccHandle._tccHandle.y + zeroOffset;
} else {
transFormHandleVal = tccHandle._tccHandle.y - zeroOffset;
}
const handleVal = Number(
(-(tccHandle._tccHandle.y / 144) * 100).toFixed()
(-(transFormHandleVal / (144 - zeroOffset)) * 100).toFixed()
);
tccOperation({
simulationId,