|  | @@ -2,6 +2,13 @@ const Nightscape = {
 | 
	
		
			
				|  |  |    GeoJsonLayerList: [],
 | 
	
		
			
				|  |  |    liudongGntities: [],
 | 
	
		
			
				|  |  |    routesGroupByAirline: {},
 | 
	
		
			
				|  |  | +  tiyuchangdg: [],
 | 
	
		
			
				|  |  | +  tiyuchangdg1: [],
 | 
	
		
			
				|  |  | +  tiyuchangdg2: [],
 | 
	
		
			
				|  |  | +  tiyuchangdg3: [],
 | 
	
		
			
				|  |  | +  dgdsq: null,
 | 
	
		
			
				|  |  | +  tycindex: 0,
 | 
	
		
			
				|  |  | +  t: 0,
 | 
	
		
			
				|  |  |    //打开夜景
 | 
	
		
			
				|  |  |    openNightSwitch() {
 | 
	
		
			
				|  |  |      store.state.isNightSwitch = true;
 | 
	
	
		
			
				|  | @@ -21,6 +28,9 @@ const Nightscape = {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // 是否开启夜景
 | 
	
		
			
				|  |  |      if (!isNight) {
 | 
	
		
			
				|  |  | +      if (this.dgdsq) {
 | 
	
		
			
				|  |  | +        clearTimeout(this.dgdsq);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        if (scene.layers.find("白天")) scene.layers.find("白天").visible = true;
 | 
	
		
			
				|  |  |        if (scene.layers.find("夜晚")) scene.layers.find("夜晚").visible = false;
 | 
	
		
			
				|  |  |        scene.sun.show = true;
 | 
	
	
		
			
				|  | @@ -111,7 +121,7 @@ const Nightscape = {
 | 
	
		
			
				|  |  |        // 体育场灯光
 | 
	
		
			
				|  |  |        Cesium.loadJson(window.NightLightUrl.tycdg).then((response) => {
 | 
	
		
			
				|  |  |          let features = response.features;
 | 
	
		
			
				|  |  | -        features.forEach((element) => {
 | 
	
		
			
				|  |  | +        features.forEach((element, indx) => {
 | 
	
		
			
				|  |  |            let p = element.geometry.coordinates;
 | 
	
		
			
				|  |  |            var SpotLightPos3 = new Cesium.Cartesian3.fromDegrees(
 | 
	
		
			
				|  |  |              p[0],
 | 
	
	
		
			
				|  | @@ -131,8 +141,13 @@ const Nightscape = {
 | 
	
		
			
				|  |  |              // SpotLightPos32,
 | 
	
		
			
				|  |  |              SpotLightOptions3
 | 
	
		
			
				|  |  |            );
 | 
	
		
			
				|  |  | +          that.tiyuchangdg.push(SpotLight33);
 | 
	
		
			
				|  |  |            scene.addLightSource(SpotLight33);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | +        let sd = that.splitArray(that.tiyuchangdg);
 | 
	
		
			
				|  |  | +        that.tiyuchangdg1 = sd[0];
 | 
	
		
			
				|  |  | +        that.tiyuchangdg2 = sd[1];
 | 
	
		
			
				|  |  | +        that.tiyuchangdg3 = sd[2];
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |        // // 道路灯光
 | 
	
		
			
				|  |  |        Cesium.loadJson(window.NightLightUrl.dldg).then((response) => {
 | 
	
	
		
			
				|  | @@ -142,7 +157,7 @@ const Nightscape = {
 | 
	
		
			
				|  |  |            var SpotLightPos3 = new Cesium.Cartesian3.fromDegrees(
 | 
	
		
			
				|  |  |              p[0],
 | 
	
		
			
				|  |  |              p[1],
 | 
	
		
			
				|  |  | -            p[2] + 20
 | 
	
		
			
				|  |  | +            p[2] + 40
 | 
	
		
			
				|  |  |            );
 | 
	
		
			
				|  |  |            var SpotLightOptions3 = {
 | 
	
		
			
				|  |  |              cutoffDistance: 110,
 | 
	
	
		
			
				|  | @@ -197,6 +212,49 @@ const Nightscape = {
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |        );
 | 
	
		
			
				|  |  |        this.imageLayer.alpha = 0.5;
 | 
	
		
			
				|  |  | +      if (this.dgdsq) {
 | 
	
		
			
				|  |  | +        clearTimeout(dgdsq);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this.dgdsq = setInterval(function () {
 | 
	
		
			
				|  |  | +        that.tycindex += 1;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        that.t += 0.2;
 | 
	
		
			
				|  |  | +        if (that.t > 1) {
 | 
	
		
			
				|  |  | +          that.t = 0;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        let rgb = that.lerpColor("5,33,232", "232,222,5", that.t);
 | 
	
		
			
				|  |  | +        let isch = false;
 | 
	
		
			
				|  |  | +        if (that.tiyuchangdg1.length > that.tycindex) {
 | 
	
		
			
				|  |  | +          that.tiyuchangdg1[that.tycindex].color = new Cesium.Color(
 | 
	
		
			
				|  |  | +            rgb.r / 255,
 | 
	
		
			
				|  |  | +            rgb.g / 255,
 | 
	
		
			
				|  |  | +            rgb.b / 255,
 | 
	
		
			
				|  |  | +            0.51
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +          isch = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (that.tiyuchangdg2.length > that.tycindex) {
 | 
	
		
			
				|  |  | +          that.tiyuchangdg2[that.tycindex].color = new Cesium.Color(
 | 
	
		
			
				|  |  | +            rgb.r / 255,
 | 
	
		
			
				|  |  | +            rgb.g / 255,
 | 
	
		
			
				|  |  | +            rgb.b / 255,
 | 
	
		
			
				|  |  | +            0.51
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +          isch = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (that.tiyuchangdg3.length > that.tycindex) {
 | 
	
		
			
				|  |  | +          that.tiyuchangdg3[that.tycindex].color = new Cesium.Color(
 | 
	
		
			
				|  |  | +            rgb.r / 255,
 | 
	
		
			
				|  |  | +            rgb.g / 255,
 | 
	
		
			
				|  |  | +            rgb.b / 255,
 | 
	
		
			
				|  |  | +            0.51
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +          isch = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!isch) {
 | 
	
		
			
				|  |  | +          that.tycindex = 0;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      }, 1000 * 1);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -568,6 +626,51 @@ const Nightscape = {
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  lerpColor(startColor, endColor, t) {
 | 
	
		
			
				|  |  | +    // 解析颜色字符串为数组
 | 
	
		
			
				|  |  | +    let start = startColor.split(",").map(Number);
 | 
	
		
			
				|  |  | +    let end = endColor.split(",").map(Number);
 | 
	
		
			
				|  |  | +    // 计算渐变后的颜色值
 | 
	
		
			
				|  |  | +    let r = start[0] + (end[0] - start[0]) * t;
 | 
	
		
			
				|  |  | +    let g = start[1] + (end[1] - start[1]) * t;
 | 
	
		
			
				|  |  | +    let b = start[2] + (end[2] - start[2]) * t;
 | 
	
		
			
				|  |  | +    // 返回结果为字符串格式
 | 
	
		
			
				|  |  | +    return { r, g, b };
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  splitArray(arr) {
 | 
	
		
			
				|  |  | +    let chunkSize = Math.ceil(arr.length / 3); // 计算每个子数组应该有的元素数量
 | 
	
		
			
				|  |  | +    let result = [];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    for (let i = 0; i < arr.length; i += chunkSize) {
 | 
	
		
			
				|  |  | +      let chunk = arr.slice(i, i + chunkSize); // 使用slice方法获取子数组
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      // 如果需要,可以将子数组中的元素按特定顺序重新排列
 | 
	
		
			
				|  |  | +      // 例如,如果你想保持每组的元素顺序与原始数组中的顺序相同,但分成三个子数组
 | 
	
		
			
				|  |  | +      // 则不需要额外的逻辑,因为slice已经按照顺序返回了元素
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      result.push(chunk); // 将子数组添加到结果数组中
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 如果需要,你可以对结果数组中的每个子数组进行额外的处理
 | 
	
		
			
				|  |  | +    // 例如,按照你给出的例子,我们需要将每个子数组的元素重新排序
 | 
	
		
			
				|  |  | +    result = result.map((chunk, index) => {
 | 
	
		
			
				|  |  | +      // 根据索引确定每个子数组中元素的最终位置
 | 
	
		
			
				|  |  | +      return chunk
 | 
	
		
			
				|  |  | +        .map((value, i) => {
 | 
	
		
			
				|  |  | +          // 使用模运算来确定元素在最终数组中的位置
 | 
	
		
			
				|  |  | +          let finalIndex = (i + index) % 3;
 | 
	
		
			
				|  |  | +          // 如果最终索引小于子数组的长度,则返回当前值,否则返回undefined(但在这个例子中,不会有undefined)
 | 
	
		
			
				|  |  | +          return finalIndex < chunkSize ? value : undefined;
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        .filter((value) => value !== undefined); // 过滤掉undefined值(如果有的话)
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 但是,在这个特定的例子中,我们不需要上面的重新排序步骤
 | 
	
		
			
				|  |  | +    // 因为我们只需要简单地按照原始数组的顺序将元素分配给三个子数组
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    return result;
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export default Nightscape;
 |