信号机碰撞检测调整
This commit is contained in:
parent
4d82d8d4f2
commit
4f115f4f58
@ -18,6 +18,7 @@ import { FederatedMouseEvent, DisplayObject } from 'pixi.js';
|
||||
import { state } from 'src/protos/device_status';
|
||||
import { mockSignalApi } from 'src/api/PlatformApi';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { SignalGraphicHitArea } from 'src/graphics/signal/SignalDrawAssistant';
|
||||
|
||||
export class SignalData extends GraphicDataBase implements ISignalData {
|
||||
constructor(data?: graphicData.Signal) {
|
||||
@ -331,6 +332,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.selectable = true;
|
||||
g.lampMainBody.hitArea = new SignalGraphicHitArea(g);
|
||||
g.on('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DisplayObject, FederatedPointerEvent, Point } from 'pixi.js';
|
||||
import { DisplayObject, FederatedPointerEvent, IHitArea, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
@ -58,6 +58,22 @@ export class SignalDraw extends GraphicDrawAssistant<
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class SignalGraphicHitArea implements IHitArea {
|
||||
signal: Signal;
|
||||
constructor(signal: Signal) {
|
||||
this.signal = signal;
|
||||
}
|
||||
contains(x: number, y: number): boolean {
|
||||
const bound = this.signal.getLocalBounds();
|
||||
const maxX = bound.x + bound.width;
|
||||
const minX = bound.x;
|
||||
const maxY = bound.y + bound.height;
|
||||
const minY = bound.y;
|
||||
return maxX >= x && x >= minX && maxY >= y && y >= minY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建吸附线
|
||||
* @param signal
|
||||
@ -129,6 +145,7 @@ export class signalInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.lampMainBody.hitArea = new SignalGraphicHitArea(g);
|
||||
g.on('transformstart', this.transformstart, this);
|
||||
g.signalCode.on('transformstart', this.codetransformstart, this);
|
||||
g.signalCode.draggable = true;
|
||||
|
Loading…
Reference in New Issue
Block a user