Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-client
This commit is contained in:
commit
4d82d8d4f2
@ -4,7 +4,7 @@ import {
|
||||
GraphicInteractionPlugin,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
linePoint,
|
||||
pointBox,
|
||||
} from 'src/jl-graphic';
|
||||
|
||||
import { IRectData, Rect, RectTemplate } from './Rect';
|
||||
@ -78,18 +78,10 @@ export class RectGraphicHitArea implements IHitArea {
|
||||
this.rect = rect;
|
||||
}
|
||||
contains(x: number, y: number): boolean {
|
||||
const boxRect = this.rect.getLocalBounds();
|
||||
let contains = false;
|
||||
const datas = this.rect.datas;
|
||||
const tolerance = datas.lineWidth;
|
||||
const p1 = new Point(0, 0);
|
||||
const p2 = new Point(p1.x + datas.width, p1.y);
|
||||
const p3 = new Point(p1.x + datas.width, p1.y + datas.height);
|
||||
const p4 = new Point(p1.x, p1.y + datas.height);
|
||||
const p = new Point(x, y);
|
||||
contains = contains || linePoint(p1, p2, p, tolerance);
|
||||
contains = contains || linePoint(p2, p3, p, tolerance);
|
||||
contains = contains || linePoint(p3, p4, p, tolerance);
|
||||
contains = contains || linePoint(p4, p1, p, tolerance);
|
||||
contains = contains || pointBox(p, boxRect);
|
||||
return contains;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,9 @@ export class TrainWindow extends JlGraphic {
|
||||
TrainWindowConsts.lineWidth,
|
||||
new Color(TrainWindowConsts.lineColor)
|
||||
);
|
||||
rectGraphic.beginFill(TrainWindowConsts.lineColor, 0.00001);
|
||||
rectGraphic.drawRect(0, 0, width, TrainWindowConsts.height);
|
||||
rectGraphic.endFill;
|
||||
const rectP = new Rectangle(0, 0, width, TrainWindowConsts.height);
|
||||
rectGraphic.pivot = getRectangleCenter(rectP);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js';
|
||||
import { FederatedPointerEvent, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
@ -7,7 +7,6 @@ import {
|
||||
GraphicInteractionPlugin,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
linePoint,
|
||||
} from 'src/jl-graphic';
|
||||
|
||||
import {
|
||||
@ -218,30 +217,6 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
|
||||
}
|
||||
}
|
||||
|
||||
//碰撞检测
|
||||
export class RectGraphicHitArea implements IHitArea {
|
||||
rect: TrainWindow;
|
||||
constructor(rect: TrainWindow) {
|
||||
this.rect = rect;
|
||||
}
|
||||
contains(x: number, y: number): boolean {
|
||||
const width = TrainWindowConsts.width;
|
||||
let contains = false;
|
||||
const tolerance = TrainWindowConsts.lineWidth;
|
||||
const p1 = new Point(0, 0);
|
||||
const p2 = new Point(width, 0);
|
||||
const p3 = new Point(width, TrainWindowConsts.height);
|
||||
const p4 = new Point(0, TrainWindowConsts.height);
|
||||
const p = new Point(x, y);
|
||||
|
||||
contains = contains || linePoint(p1, p2, p, tolerance);
|
||||
contains = contains || linePoint(p2, p3, p, tolerance);
|
||||
contains = contains || linePoint(p3, p4, p, tolerance);
|
||||
contains = contains || linePoint(p4, p1, p, tolerance);
|
||||
return contains;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建吸附位置
|
||||
* @param polygon
|
||||
@ -284,7 +259,6 @@ export class TrainWindowInteraction extends GraphicInteractionPlugin<TrainWindow
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.rectGraphic.hitArea = new RectGraphicHitArea(g);
|
||||
g.on('transformstart', this.move, this);
|
||||
}
|
||||
unbind(g: TrainWindow): void {
|
||||
|
Loading…
Reference in New Issue
Block a user