riku
2025-09-11 307b17ef15c73a071912a262834f2a5f68e1fa87
src/utils/map/sector.js
@@ -9,6 +9,9 @@
  // 动画轨迹
  _sectorViewsAna = new Map();
var _ptSector = undefined,
  _ptSectorViews = new Map();
const zoomStyleMapping = {
  14: 0,
  15: 0,
@@ -107,7 +110,14 @@
  });
}
function drawSectorMesh(sDeg, eDeg, lnglat, distance, distance2) {
function drawSectorMesh(
  sDeg,
  eDeg,
  lnglat,
  distance,
  distance2,
  isPollutinTrace
) {
  if (distance == 0 || distance2 == 0) {
    return false;
  }
@@ -143,59 +153,77 @@
    geometry.vertices.push(p0.x, p0.y, 0);
    geometry.vertices.push(l3.x, l3.y, 0);
    geometry.vertices.push(l4.x, l4.y, 0);
    // 外侧扇形
    geometry.vertices.push(l3.x, l3.y, 0);
    geometry.vertices.push(l4.x, l4.y, 0);
    geometry.vertices.push(l1.x, l1.y, 0);
    geometry.vertices.push(l2.x, l2.y, 0);
    if (!isPollutinTrace) {
      // 内测扇形颜色
      geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
      geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
      geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
    } else {
      geometry.vertexColors.push(0.25, 0.11, 1, 0.6);
      geometry.vertexColors.push(0.25, 0.11, 1, 0.6);
      geometry.vertexColors.push(0.25, 0.11, 1, 0.6);
    }
    if (!isPollutinTrace) {
      // 外侧扇形
      geometry.vertices.push(l3.x, l3.y, 0);
      geometry.vertices.push(l4.x, l4.y, 0);
      geometry.vertices.push(l1.x, l1.y, 0);
      geometry.vertices.push(l2.x, l2.y, 0);
      //外侧扇形颜色
      geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
      geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
      geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
      geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
    }
    // console.log(l3.x + ',' + l3.y + ' | ' + l1.x + ',' + l1.y);
    // 内测扇形颜色
    geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
    geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
    geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
    //外侧扇形颜色
    geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
    geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
    geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
    geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
    var index = i * 7;
    geometry.faces.push(index, index + 1, index + 2);
    geometry.faces.push(index + 3, index + 4, index + 5);
    geometry.faces.push(index + 4, index + 5, index + 6);
    if (!isPollutinTrace) {
      const index = i * 7;
      geometry.faces.push(index, index + 1, index + 2);
      geometry.faces.push(index + 3, index + 4, index + 5);
      geometry.faces.push(index + 4, index + 5, index + 6);
    } else {
      const index = i * 3;
      geometry.faces.push(index, index + 1, index + 2);
      // geometry.faces.push(index + 3, index + 4, index + 5);
      // geometry.faces.push(index + 4, index + 5, index + 6);
    }
  }
  object3Dlayer.add(sector);
  _sector = sector;
  isPollutinTrace ? (_ptSector = sector) : (_sector = sector);
  return true;
}
function drawTextMaker(list, list2, distance, distance2) {
function drawTextMaker(list, list2, distance, distance2, isPollutinTrace) {
  const _sectorViewsTmp = isPollutinTrace ? _ptSectorViews : _sectorViews;
  //10分钟扇形
  const a = _sectorViews.get('text10-t');
  if (a == undefined) {
    const text10t = textMaker(list[2], '10分钟');
    _sectorViews.set('text10-t', text10t);
    const textM10t = textMaker(list[1], distance + 'm');
    _sectorViews.set('textM10-t', textM10t);
    map.add([text10t, textM10t]);
  } else {
    _sectorViews.get('text10-t').setPosition(list[2]);
    _sectorViews.get('textM10-t').setPosition(list[1]);
    _sectorViews.get('textM10-t').setText(distance + 'm');
  if (!isPollutinTrace) {
    const a = _sectorViewsTmp.get('text10-t');
    if (a == undefined) {
      const text10t = textMaker(list[2], '10分钟');
      _sectorViewsTmp.set('text10-t', text10t);
      const textM10t = textMaker(list[1], distance + 'm');
      _sectorViewsTmp.set('textM10-t', textM10t);
      map.add([text10t, textM10t]);
    } else {
      _sectorViewsTmp.get('text10-t').setPosition(list[2]);
      _sectorViewsTmp.get('textM10-t').setPosition(list[1]);
      _sectorViewsTmp.get('textM10-t').setText(distance + 'm');
    }
  }
  //5分钟扇形
  const b = _sectorViews.get('text5-t');
  const b = _sectorViewsTmp.get('text5-t');
  if (b == undefined) {
    const text5t = textMaker(list2[1], '5分钟');
    _sectorViews.set('text5-t', text5t);
    _sectorViewsTmp.set('text5-t', text5t);
    const textM5t = textMaker(list2[0], distance2 + 'm');
    _sectorViews.set('textM5-t', textM5t);
    _sectorViewsTmp.set('textM5-t', textM5t);
    map.add([text5t, textM5t]);
  } else {
    _sectorViews.get('text5-t').setPosition(list2[1]);
    _sectorViews.get('textM5-t').setPosition(list2[0]);
    _sectorViews.get('textM5-t').setText(distance2 + 'm');
    _sectorViewsTmp.get('text5-t').setPosition(list2[1]);
    _sectorViewsTmp.get('textM5-t').setPosition(list2[0]);
    _sectorViewsTmp.get('textM5-t').setText(distance2 + 'm');
  }
}
@@ -233,6 +261,19 @@
    }
    this.clearSectorMesh();
  },
  clearSectorPt() {
    var list = [];
    for (const iterator of _ptSectorViews) {
      list.push(iterator[1]);
    }
    if (list.length > 0) {
      map.remove(list);
      _ptSectorViews.clear();
    }
    if (_ptSector) {
      object3Dlayer.remove(_ptSector);
    }
  },
  /**
   * 只清空扇形
   */
@@ -241,6 +282,7 @@
      object3Dlayer.remove(_sector);
    }
  },
  sectorParams: sectorParams,
  /**
   * 绘制扇形
   * @param {FactorDatas} fDatas
@@ -271,5 +313,17 @@
    if (drawSectorMesh(sDeg, eDeg, lnglat, distance, distance2)) {
      drawTextMaker(list, list2, distance, distance2);
    }
  },
  drawSectorPt(fDatas, i) {
    if (_ptSector) {
      object3Dlayer.remove(_ptSector);
    }
    const { sDeg, eDeg, lnglat, distance, distance2, list, list2 } =
      sectorParams(fDatas, i);
    if (drawSectorMesh(sDeg, eDeg, lnglat, distance, distance2, true)) {
      drawTextMaker(list, list2, distance, distance2, true);
    }
    return { p: lnglat, r: distance };
  }
};