import mapServer from '../../../assets/js/mapSdk/mapServe'; const mapWeather = { regionWeather: null, particle: null, closeRegionWeather() { if (this.regionWeather) { this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_NONE; this.regionWeather = null; } if (this.particle) { this.particle.deleteObject(); this.particle = null; } }, setRegionWeatherType(response) { this.closeRegionWeather(); if (!this.regionWeather) { this.getRegionWather(response); } const coord = this.getCoord(response); earthCtrl.camera.flyTo(coord[0], coord[1], 1000, 0, -90, 0, 0); switch (response.type) { case 'rain': this.showRain(); break; case 'fire': this.showFire(response); break; case 'snow': this.showSnow(); break; } }, showFire(res) { const coord = this.getCoord(res); const obj = { x: coord[0], y: coord[1], z: 0, }; this.particle = earthCtrl.factory.createParticleEffect( 'flame', obj, { translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移 particleSize:10 }, function (data) {} ); }, showRain() { if (this.regionWeather) { this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_RAIN; this.regionWeather.regionAlpha = 0.6; this.regionWeather.regionGradientDistance = 300; } }, showSnow() { if (this.regionWeather) { this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_SNOW; this.regionWeather.regionAlpha = 0.9; this.regionWeather.regionGradientDistance = 300; } }, getCoord(res) { const coord = res.point.split(','); return coord; }, getRegionWather(res) { if (res.type == 'fire') return; const coord = this.getCoord(res); const model = mapServer.layerList.filter((item) => { if (item.name == config.baseModel.cnName + '_' + config.baseModel.id) { return item; } }); if (model.length <= 0) return; this.regionWeather = earthCtrl.factory.createRegionWeather({ primitive: model[0].layer.item, position: new SmartEarth.Cesium.Cartesian3.fromDegrees(coord[0], coord[1], 1), radius: 1000, }) }, }; export default mapWeather;