rt-sim-training-client/src/jmapNew/shape/Train/ETriangle.js
joylink_cuiweidong 56126bdbf3 列车精确定位代码调整
列车的状态信息调整
去掉仿真里的拖动鼠标生成包围框
2020-03-12 14:41:53 +08:00

52 lines
1.6 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import Polygon from 'zrender/src/graphic/shape/Polygon';
/** 创建三角形*/
export default class ETriangle extends Group {
constructor(model) {
super();
this.model = model;
this.zlevel = model.zlevel;
this.z = model.z;
this.create(model);
}
create(model) {
if (model && model.point) {
const right = model.right == 1 ? 1 : -1;
this.angle = new Polygon({
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]]
},
style: {
stroke:'#00FF00',
lineWidth: 0.5,
fill: '#00FF00'
}
});
this.add(this.angle);
}
}
updateTriangle(model, right) {
const trainRight = right == 1 ? 1 : -1;
const data = [[model.x + 10 * trainRight, model.y], [model.x, model.y - 6], [model.x, model.y + 6]];
// this.angle.shape.points.push([model.x + 10 * trainRight, model.y]);
// this.angle.attr('shape', { points: this.angle.shape.points });
this.angle.attr({
shape: {
points:data
}
});
this.angle.animateTo({
shape: {
points:data
}
}, 10, 0, 'elasticOut', function () {
});
this.dirty();
}
}