ibp灯状态

This commit is contained in:
Yuan 2023-11-02 13:46:16 +08:00
parent ee4a26a36c
commit 8c906a39c4
4 changed files with 19 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import {
} from 'src/jl-graphic';
import { ibpGraphicData } from 'src/protos/ibpGraphics';
import { useIbpStore } from 'src/stores/ibp-store';
import { IbpLightData } from './graphics/IbpLightInteraction';
import { IbpLightData, IbpLightState } from './graphics/IbpLightInteraction';
import {
IBPButtonData,
IbpButtonInteraction,
@ -77,7 +77,7 @@ export function initIbpScene(lineApp: IGraphicApp, sceneName: string) {
const graphicTemplate = [
new IBPButtonTemplate(new IBPButtonData(), new IbpButtonState()),
new IbpLightTempalte(new IbpLightData()),
new IbpLightTempalte(new IbpLightData(), new IbpLightState()),
new IbpAlarmTemplate(new IbpAlarmData()),
new IbpKeyTemplate(new IbpKeyData(), new IbpKeyState()),
new TextContentTemplate(new IbpTextData()),

View File

@ -34,7 +34,7 @@ import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
import { IbpLightDraw } from 'src/graphics/ibpLight/IbpLightDrawAssistant';
import { IbpLightTempalte } from 'src/graphics/ibpLight/IbpLight';
import { IbpLightData } from './graphics/IbpLightInteraction';
import { IbpLightData, IbpLightState } from './graphics/IbpLightInteraction';
let drawApp: IDrawApp | null = null;
const UndoOptions: MenuItemOptions = {
@ -79,7 +79,10 @@ export function initIBPDrawApp() {
new IbpKeyTemplate(new IbpKeyData(), new IbpKeyState())
);
new ArrowDraw(drawApp, new ArrowTemplate(new ArrowData()));
new IbpLightDraw(drawApp, new IbpLightTempalte(new IbpLightData()));
new IbpLightDraw(
drawApp,
new IbpLightTempalte(new IbpLightData(), new IbpLightState())
);
new TextContentDraw(drawApp, new TextContentTemplate(new IbpTextData()));
// 画布右键菜单
drawApp.registerMenu(DefaultCanvasMenu);

View File

@ -1,5 +1,4 @@
import {
GraphicAnimation,
GraphicData,
GraphicState,
JlGraphic,
@ -8,7 +7,7 @@ import {
import Ibp_Key_Assets from './ibp-key-spritesheet.png';
import Ibp_Key_JSON from './ibp-key-data.json';
import { Assets, PI_2, Sprite, Spritesheet, Texture } from 'pixi.js';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
interface IbpKeyTextures {
ibpKey: Texture;

View File

@ -29,7 +29,7 @@ const ibpLightColorMap = {
const ibpLightConsts = {
radius: 20,
offAlpha: 0.6,
offAlpha: 0.5,
onAlpha: 1,
};
@ -44,22 +44,29 @@ export class IbpLight extends JlGraphic {
get datas(): IIbpLightData {
return this.getDatas<IIbpLightData>();
}
get state(): IIbpLightState {
return this.getStates<IIbpLightState>();
}
doRepaint(): void {
this.graphic.clear();
this.graphic
.beginFill(ibpLightColorMap[this.datas.color ?? 0], 0.5)
.beginFill(
ibpLightColorMap[this.datas.color ?? 0],
this.state.active ? ibpLightConsts.onAlpha : ibpLightConsts.offAlpha
)
.drawCircle(0, 0, ibpLightConsts.radius)
.endFill();
}
}
export class IbpLightTempalte extends JlGraphicTemplate<IbpLight> {
constructor(dataTemplate: IIbpLightData) {
super(IbpLight.Type, { dataTemplate });
constructor(dataTemplate: IIbpLightData, stateTemplate?: IIbpLightState) {
super(IbpLight.Type, { dataTemplate, stateTemplate });
}
new(): IbpLight {
const g = new IbpLight();
g.loadData(this.datas);
g.loadState(this.states);
return g;
}
}