From b33e28bc2843555355ecad59a80c83e3c26445a3 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 01 九月 2025 17:29:36 +0800 Subject: [PATCH] 走航季度报告模块(待完成) --- src/utils/map/animation.js | 75 +++++++++++++++++++++++++------------ 1 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/utils/map/animation.js b/src/utils/map/animation.js index ab13719..4180e7d 100644 --- a/src/utils/map/animation.js +++ b/src/utils/map/animation.js @@ -3,7 +3,7 @@ import Layer from '@/utils/map/3dLayer'; import sector from '@/utils/map/sector'; import { map } from '@/utils/map/index_old'; -import util from "@/utils/map/util"; +import util from '@/utils/map/util'; import car_driving from '@/assets/mipmap/car_driving.png'; import boat_driving from '@/assets/mipmap/boat_driving.png'; @@ -11,7 +11,7 @@ // 闈炶繛缁潗鏍囩偣鏈�澶ц窛绂�(绫�) this.maxD = 500; // 褰撳墠缁樺埗鐨勭洃娴嬪洜瀛愮被鍨� - this.factorType = 0; + this.factorType; this.factorDatas; // 杞藉叿绫诲瀷 this.vehicleType = 0; // 0: 杞﹁締锛�1锛氭棤浜烘満锛�2锛氭棤浜鸿埞 @@ -21,6 +21,7 @@ this._fps = this.frameAnimation.fps; // 缁樺埗鍥惧舰缂撳瓨 this.moveViews = {}; + this.clear = true; } MapAnimation.prototype = { @@ -82,7 +83,7 @@ if (i == endIndex || i == factorDatas.length() - 1) { break; } - // 鍔ㄧ敾杞ㄨ抗 + // 鍔ㄧ敾杞ㄨ抗锛堝凡缁樺埗閮ㄥ垎锛� var animationData = factorDatas.getByIndex(0, i + 1); // 璺緞鐐� @@ -104,19 +105,19 @@ 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); // 璁$畻鍔ㄧ敾杞ㄨ抗 - for (let i = 0; i < count - 1; i++) { + for (let i = 0; i < count; i++) { // path var length = d * (i + 1); if (isNaN(angle)) { @@ -134,7 +135,7 @@ } 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); @@ -149,26 +150,25 @@ animationData, function (data, index, count) { var length = data.length(); - var start = length - count + 1; + var start = length - count; // 1.鑾峰彇鏁版嵁 var d = data.getByIndex(0, start + index + 1); - var f = d.factor[that.factorType + 1 + '']; + var f = d.factor[that.factorType]; // 2.缁樺埗鍥惧舰 if (length > count || index > 0) { // 3d鍥惧舰 - // var lnglat = d.lnglats_GD[d.lnglats_GD.length - 1]; Layer.drawMesh(d, f); - // MapUtil.drawLine(lnglat) - // 椋庡悜椋庨�� - sector.drawSector(d, start + index); - // if (d.factor['17'] != undefined && d.factor['16'] != undefined) { - // var windDir = d.factor['17'].datas; - // windDir = windDir[windDir.length - 1].factorData; - // var windSpeed = d.factor['16'].datas; - // windSpeed = windSpeed[windSpeed.length - 1].factorData; - // MapUtil.drawSector4(lnglat, windDir, windSpeed); - // } + 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]; @@ -210,9 +210,27 @@ 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) { @@ -224,12 +242,14 @@ 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) ); @@ -252,6 +272,8 @@ /*******************************鍔ㄧ敾浠诲姟閫昏緫 -end ******************************/ _clearMap: function () { + if (!this.clear) return; + var list = []; for (const key in this.moveViews) { list.push(this.moveViews[key]); @@ -396,4 +418,9 @@ } }; -export { MapAnimation }; +const realTimeMapAnimation = new MapAnimation(); +// 寮�鍚姩鎬佺粯鍒堕�熷害 +realTimeMapAnimation.setDynamicSpeed(true, 4); +// realTimeMapAnimation.clear = false; + +export { realTimeMapAnimation, MapAnimation }; -- Gitblit v1.9.3