| | |
| | | this._fps = this.frameAnimation.fps; |
| | | // 绘制图形缓存 |
| | | this.moveViews = {}; |
| | | this.clear = true; |
| | | } |
| | | |
| | | MapAnimation.prototype = { |
| | |
| | | if (i == endIndex || i == factorDatas.length() - 1) { |
| | | break; |
| | | } |
| | | // 动画轨迹 |
| | | // 动画轨迹(已绘制部分) |
| | | var animationData = factorDatas.getByIndex(0, i + 1); |
| | | |
| | | // 路径点 |
| | |
| | | var d = distance / count; |
| | | // 每个fps对应的实际时长(默认1秒) |
| | | var t = 1; |
| | | // 两点间不连续时 |
| | | // 两点间不连续时,使用默认时长,避免 |
| | | if (distance > this.maxD) { |
| | | count = 4 * this._fps; |
| | | count = this.frameAnimation.taskPeriod * this._fps; |
| | | d = distance / count; |
| | | t = duration / (count / this._fps); |
| | | } |
| | | |
| | | // 监测数据 |
| | | // 监测数据(待绘制数据点,在已绘制部分和该数据点之间,插入动画帧数据点) |
| | | // var fData1 = factorDatas.getByIndex(i, i + 1) |
| | | var fData2 = factorDatas.getByIndex(i + 1, i + 2); |
| | | |
| | |
| | | } |
| | | animationData.times.push(time); |
| | | } |
| | | // factor |
| | | // 给每个监测因子进行插帧 |
| | | for (const key in animationData.factor) { |
| | | var factor = animationData.factor[key]; |
| | | factor.insertFrame(fData2.factor[key], count, distance <= this.maxD); |
| | |
| | | Layer.drawMesh(d, f); |
| | | // 风向风速 |
| | | sector.drawSectorAna(d, start + index); |
| | | // 执行监听函数 |
| | | if (typeof that.OnEachFrameCallback === 'function') { |
| | | that.OnEachFrameCallback(d, start + index); |
| | | } |
| | | // 绘制3D图形时,最少需要2个点才可绘制图形 |
| | | // 因此此处索引只到倒数第二个点就结束,此时执行这段任务结束的监听回调 |
| | | if (typeof that.OnEachTaskEndCallback === 'function') { |
| | | that.OnEachTaskEndCallback(d); |
| | | } |
| | | } |
| | | |
| | | var pos = d.lnglats_GD[d.lnglats_GD.length - 1]; |
| | |
| | | this.start(); |
| | | }, |
| | | |
| | | /** |
| | | * 设置每一帧的监听函数 |
| | | * @param {Function} callback |
| | | */ |
| | | setOnEachFrameCallback(callback) { |
| | | this.OnEachFrameCallback = callback; |
| | | }, |
| | | |
| | | /** |
| | | * 设置每一段任务结束的监听函数 |
| | | * @param {Function} callback |
| | | */ |
| | | setOnEachTaskEndCallback(callback) { |
| | | this.OnEachTaskEndCallback = callback; |
| | | }, |
| | | |
| | | /*******************************动画任务逻辑 -start ******************************/ |
| | | start: function () { |
| | | sector.clearSector(); |
| | | if (this.frameAnimation.isStop) { |
| | | sector.clearSector(); |
| | | } |
| | | this.frameAnimation.start(); |
| | | }, |
| | | changeSpeed: function (speed) { |
| | |
| | | stop: function () { |
| | | this.factorDatas = undefined; |
| | | this.frameAnimation.addOnNextTasks(undefined); |
| | | // this.OnEachFrameCallback = undefined; |
| | | // this.OnEachTaskEndCallback = undefined; |
| | | this.frameAnimation.stop(); |
| | | this._clearMap(); |
| | | }, |
| | | setOnStopCallback: function (callback) { |
| | | this.frameAnimation.setOnStopCallback( |
| | | function () { |
| | | this._clearMap(); |
| | | callback(); |
| | | }.bind(this) |
| | | ); |
| | |
| | | /*******************************动画任务逻辑 -end ******************************/ |
| | | |
| | | _clearMap: function () { |
| | | if (!this.clear) return; |
| | | |
| | | var list = []; |
| | | for (const key in this.moveViews) { |
| | | list.push(this.moveViews[key]); |
| | |
| | | } |
| | | }; |
| | | |
| | | export { MapAnimation }; |
| | | const realTimeMapAnimation = new MapAnimation(); |
| | | // 开启动态绘制速度 |
| | | realTimeMapAnimation.setDynamicSpeed(true, 4); |
| | | // realTimeMapAnimation.clear = false; |
| | | |
| | | export { realTimeMapAnimation, MapAnimation }; |