diff --git a/src/jmapNew/shape/Train/index.js b/src/jmapNew/shape/Train/index.js index 0f518405e..4b6da6300 100644 --- a/src/jmapNew/shape/Train/index.js +++ b/src/jmapNew/shape/Train/index.js @@ -18,8 +18,6 @@ export default class Train extends Group { this.z = 40; this.size = 0; this.section = null; - this.nextPointIndex = 1; - this.currentAdd = 0; this.isShowShape = true; this.fontSize = style.Train.common.useSelfText ? style.Train.common.nameFontSize || style.Train.common.trainTextFontSize : model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize; this.newScale = this.fontSize / style.Train.common.trainTextFontSize; @@ -183,19 +181,21 @@ export default class Train extends Group { // } // debugger; // 目标距离 + console.log('2222222222///////////////////////', this.currentAdd); let targetDistance = Math.sqrt( Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) + Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2), ); const right = train.right == 1 ? 0 : 1; let currentDistance = this.lineLength * Math.abs(right - train.offsetp) - this.currentAdd; + console.log('33333333333/////////////////', currentDistance); // 利用运动距离与目标距离, 判断运动的点是否超过下一个目标点, 超过了就重置下一个点 if (currentDistance >= targetDistance) { this.nextPointIndex++; this.currentAdd += targetDistance; if (this.nextPointIndex <= points.length - 1) { currentDistance = this.lineLength * Math.abs(right - train.offsetp) - this.currentAdd; - console.log('///////////////////////////////////', this.currentAdd); + console.log('44444444444///////////////', this.currentAdd); console.log('///////////////////////////////////', currentDistance); targetDistance = Math.sqrt( Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) + @@ -527,6 +527,8 @@ export default class Train extends Group { item.show(); }); this.isShowShape = true; + this.nextPointIndex = 1; + this.currentAdd = 0; this.setState(this.model, this); } else { this.eachChild(item => {