This commit is contained in:
zyy 2020-12-09 15:03:59 +08:00
commit a984e6b4ed
2 changed files with 13 additions and 7 deletions

View File

@ -71,7 +71,8 @@ export default class ETriangle extends Group {
zlevel: model.zlevel,
z: model.z,
shape: {
points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]]
// points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]]
points:[[model.point.x, model.point.y], [model.point.x - 10 * right, model.point.y - 6], [model.point.x - 10 * right, model.point.y + 6]]
},
style: {
stroke:'#00FF00',
@ -88,9 +89,12 @@ export default class ETriangle extends Group {
if (this.angle) {
const trainRight = right == 1 ? 1 : -1;
let data = [
[model.x + 10 * trainRight, model.y],
[model.x, model.y - 6],
[model.x, model.y + 6]
// [model.x + 10 * trainRight, model.y],
// [model.x, model.y - 6],
// [model.x, model.y + 6]
[model.x, model.y],
[model.x - 10 * trainRight, model.y - 6],
[model.x - 10 * trainRight, model.y + 6]
];
if (this.style.Section.trainPosition.specialShow) {
data = [

View File

@ -143,7 +143,7 @@ export default class Train extends Group {
});
oldPoint = 0;
this.pointList.forEach(point => {
point.percentStart = oldPoint / this.lineLength;
point.percentStart = (oldPoint / this.lineLength) < 0.001 ? 0 : (oldPoint / this.lineLength);
oldPoint += point.length;
point.percentEnd = oldPoint / this.lineLength;
});
@ -190,8 +190,10 @@ export default class Train extends Group {
if (train.physicalCode && train.offsetp && this.triangle) {
this.pointList.forEach(point => {
if (train.offsetp > point.percentStart && train.offsetp <= point.percentEnd) {
this.startX = point.pointStart.x + (point.pointEnd.x - point.pointStart.x) * (train.offsetp - point.percentStart);
this.startY = point.pointStart.y + (point.pointEnd.y - point.pointStart.y) * (train.offsetp - point.percentStart);
let offsetp = train.offsetp;
if (train.offsetp > 0.99) { offsetp = 1; }
this.startX = point.pointStart.x + (point.pointEnd.x - point.pointStart.x) * (offsetp - point.percentStart);
this.startY = point.pointStart.y + (point.pointEnd.y - point.pointStart.y) * (offsetp - point.percentStart);
}
});
const point = { x: this.startX, y: this.startY };