| | |
| | | .el-input__inner { |
| | | color: #fff !important; |
| | | } |
| | | .el-slider__bar { |
| | | background-color: #009688 !important; |
| | | border-color: #009688 !important; |
| | | } |
| | | |
| | | .el-slider__button { |
| | | border-color: rgb(0, 150, 136) !important; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-form :model="form" label-width="80px" class="terrain-settings"> |
| | | <el-form-item label="大å°"> |
| | | <el-slider |
| | | :step="0.1" |
| | | v-model="form.rainSize" |
| | | :min="0" |
| | | :max="1" |
| | | ></el-slider> |
| | | </el-form-item> |
| | | <el-form-item label="é度"> |
| | | <el-slider v-model="form.rainSpeed" :min="0" :max="150"></el-slider> |
| | | </el-form-item> |
| | | <el-form-item label="é¢è²"> |
| | | <el-color-picker v-model="form.rainColor" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { reactive, watch } from "vue"; |
| | | const form = reactive({ |
| | | rainSize: 0.5, |
| | | rainSpeed: 50, |
| | | rainColor: "#99B3CC", |
| | | }); |
| | | |
| | | // å®ä¹ props å emit |
| | | const props = defineProps({ |
| | | modelValue: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | }); |
| | | const emit = defineEmits(["update-rain"]); |
| | | |
| | | // çå¬ form çååï¼å¹¶å°ææ°å¼ä¼ éç»ç¶ç»ä»¶ |
| | | watch( |
| | | () => ({ ...form }), // æ·±æ·è´ä»¥ç¡®ä¿ååºå¼è§¦å |
| | | (newVal) => { |
| | | emit("update-rain", newVal); |
| | | }, |
| | | { deep: true } // 深度çå¬ |
| | | ); |
| | | </script> |
| | | <style lang="less" scoped> |
| | | .terrain-settings { |
| | | padding: 20px; |
| | | width: 290px; |
| | | background: url("@/assets/img/tools/plotting_new.png") no-repeat; |
| | | filter: opacity(83%); |
| | | background-size: 100% 100%; |
| | | box-sizing: border-box; |
| | | } |
| | | </style> |
| | |
| | | const form = reactive({ |
| | | terrainRender: 0, |
| | | contourLines: false, |
| | | color: "", |
| | | color: "red", |
| | | spacing: 50, |
| | | lineWidth: 5, |
| | | }); |
| | |
| | | display: flex; |
| | | } |
| | | |
| | | /deep/ .el-slider__bar { |
| | | background-color: #009688; |
| | | border-color: #009688; |
| | | } |
| | | |
| | | /deep/ .el-slider__button { |
| | | border-color: rgb(0, 150, 136); |
| | | } |
| | | |
| | | /deep/ .el-switch.is-checked .el-switch__core { |
| | | background-color: #009688; |
| | |
| | | class="popup-menu-see" |
| | | @update-slope="onUpdateSlope" |
| | | /> |
| | | <!-- é¨ --> |
| | | <Rain |
| | | v-show="showRain" |
| | | class="popup-menu-see" |
| | | @update-rain="onUpdateRain" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- å·¥å
·æ å
容 --> |
| | |
| | | import Aspect from "@/components/tools/Aspect.vue"; |
| | | import SlopeAnalysis from "@/components/tools/SlopeAnalysis.vue"; |
| | | import mapUtils from "@/utils/tools.js"; |
| | | import Rain from "@/components/tools/Rain.vue"; |
| | | |
| | | // 忢å±å¼/æ¶ç¼©ç¶æ |
| | | function toggleCollapse() { |
| | | // isCollapsed.value = !isCollapsed.value; |
| | | } |
| | | |
| | | |
| | | const showLayerTree = ref(false); |
| | | |
| | |
| | | const isflfx = ref(false); |
| | | const isFlood = ref(false); |
| | | const isContourLabel = ref(false); |
| | | const isRain = ref(false); |
| | | const showRain = ref(false); |
| | | const isSnow = ref(false); |
| | | |
| | | // åé¢åæå¼¹çª |
| | |
| | | echartsShow.value = false; //åé¢echarts |
| | | showAspect.value = false; //å¡åç®å¤´ |
| | | showSlope.value = false; //å¡åç®å¤´ |
| | | showRain.value = false; //é¨å¤© |
| | | return; |
| | | } |
| | | |
| | |
| | | echartsShow.value = false; //åé¢echarts |
| | | showAspect.value = false; //å¡åç®å¤´ |
| | | showSlope.value = false; //å¡åç®å¤´ |
| | | showRain.value = false; //é¨å¤© |
| | | } |
| | | |
| | | // å¤çå¼¹çªé项ç¹å»äºä»¶ |
| | |
| | | æ¾ç¤ºå¾å±: () => (showLayerTree.value = true), |
| | | éèå¾å±: () => (showLayerTree.value = false), |
| | | é¨å¤©æ¨¡å¼: () => { |
| | | isRain.value = !isRain.value; |
| | | if (isRain.value === false) { |
| | | mapUtils.toggleRain("rain", false); |
| | | } else { |
| | | mapUtils.toggleRain("rain", true); |
| | | } |
| | | showRain.value = true; |
| | | }, |
| | | éªå¤©æ¨¡å¼: () => { |
| | | isSnow.value = !isSnow.value; |
| | |
| | | Object.assign(formData, newOption); |
| | | mapUtils.pdfx(formData); |
| | | }; |
| | | |
| | | // é¨ |
| | | const rainForm = reactive({ |
| | | rainSize: 0.5, |
| | | rainSpeed: 50, |
| | | rainColor: "#99B3CC", |
| | | }); |
| | | const onUpdateRain = (newOption) => { |
| | | console.log(newOption, "new"); |
| | | Object.assign(rainForm, newOption); |
| | | mapUtils.toggleRain(rainForm, true); |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | class RainEffect { |
| | | constructor(viewer, options) { |
| | | if (!viewer) throw new Error("no viewer object!"); |
| | | options = options || {}; |
| | | //徿è§åº¦ï¼è´æ°åå³ï¼æ£æ°åå·¦ |
| | | this.tiltAngle = Cesium.defaultValue(options.tiltAngle, -0.6); |
| | | this.rainSize = Cesium.defaultValue(options.rainSize, 0.3); |
| | | this.rainSpeed = Cesium.defaultValue(options.rainSpeed, 60.0); |
| | | this.color = Cesium.defaultValue(options.color, new Cesium.Color(0.6, 0.7, 0.8, 1.0)); |
| | | this.viewer = viewer; |
| | | this.init(); |
| | | } |
| | | |
| | | init() { |
| | | this.rainStage = new Cesium.PostProcessStage({ |
| | | name: "czm_rain", |
| | | fragmentShader: this.rain(), |
| | | uniforms: { |
| | | tiltAngle: () => { |
| | | return this.tiltAngle; |
| | | }, |
| | | rainSize: () => { |
| | | return this.rainSize; |
| | | }, |
| | | rainColor: () => { |
| | | return this.color; |
| | | }, |
| | | rainSpeed: () => { |
| | | return this.rainSpeed; |
| | | }, |
| | | }, |
| | | }); |
| | | this.viewer.scene.postProcessStages.add(this.rainStage); |
| | | } |
| | | |
| | | destroy() { |
| | | if (!this.viewer || !this.rainStage) return; |
| | | this.viewer.scene.postProcessStages.remove(this.rainStage); |
| | | const isDestroyed = this.rainStage.isDestroyed(); |
| | | // å
æ£æ¥æ¯å¦è¢«éæ¯è¿ï¼å¦æå·²ç»è¢«éæ¯è¿åè°ç¨destroy伿¥é |
| | | if (!isDestroyed) { |
| | | this.rainStage.destroy(); |
| | | } |
| | | delete this.tiltAngle; |
| | | delete this.rainSize; |
| | | delete this.rainSpeed; |
| | | } |
| | | |
| | | show(visible) { |
| | | this.rainStage.enabled = visible; |
| | | } |
| | | |
| | | rain() { |
| | | return "uniform sampler2D colorTexture;\n\ |
| | | in vec2 v_textureCoordinates;\n\ |
| | | uniform float tiltAngle;\n\ |
| | | uniform vec4 rainColor;\n\ |
| | | uniform float rainSize;\n\ |
| | | uniform float rainSpeed;\n\ |
| | | float hash(float x) {\n\ |
| | | return fract(sin(x * 133.3) * 13.13);\n\ |
| | | }\n\ |
| | | out vec4 fragColor;\n\ |
| | | void main(void) {\n\ |
| | | float time = czm_frameNumber * (rainSpeed / 10000.0);\n\ |
| | | vec2 resolution = czm_viewport.zw;\n\ |
| | | vec2 uv = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);\n\ |
| | | vec3 c = rainColor.rgb;\n\ |
| | | float a = tiltAngle;\n\ |
| | | float si = sin(a), co = cos(a);\n\ |
| | | uv *= mat2(co, -si, si, co);\n\ |
| | | uv *= length(uv + vec2(0, 4.9)) / (rainSize * 3.0 + 0.1) + 0.5;\n\ |
| | | float v = 1. - sin(hash(floor(uv.x * 100.)) * 2.);\n\ |
| | | float b = clamp(abs(sin(20. * time * v + uv.y * (5. / (2. + v)))) - .95, 0., 1.) * 20.;\n\ |
| | | c *= v * b;\n\ |
| | | fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(c, 1), .5);\n\ |
| | | }\n\ |
| | | "; |
| | | } |
| | | } |
| | | |
| | | export default RainEffect; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | class SnowEffect { |
| | | constructor(viewer, options) { |
| | | if (!viewer) throw new Error("no viewer object!"); |
| | | options = options || {}; |
| | | this.snowSize = Cesium.defaultValue(options.snowSize, 0.02); // âï¸å¤§å°ï¼æå¥½å°äº0.02 |
| | | this.snowSpeed = Cesium.defaultValue(options.snowSpeed, 100.0); // é度 |
| | | this.snowColor = Cesium.defaultValue(options.snowColor, new Cesium.Color(1.0, 1.0, 1.0, 1.0)); // é¢è² |
| | | this.viewer = viewer; |
| | | this.init(); |
| | | } |
| | | |
| | | init() { |
| | | this.snowStage = new Cesium.PostProcessStage({ |
| | | name: "czm_snow", |
| | | fragmentShader: this.snow(), |
| | | uniforms: { |
| | | snowSize: () => { |
| | | return this.snowSize; |
| | | }, |
| | | snowSpeed: () => { |
| | | return this.snowSpeed; |
| | | }, |
| | | snowColor: () => { |
| | | return this.snowColor; |
| | | }, |
| | | }, |
| | | }); |
| | | this.viewer.scene.postProcessStages.add(this.snowStage); |
| | | } |
| | | |
| | | destroy() { |
| | | if (!this.viewer || !this.snowStage) return; |
| | | this.viewer.scene.postProcessStages.remove(this.snowStage); |
| | | const isDestroyed = this.snowStage.isDestroyed(); |
| | | // å
æ£æ¥æ¯å¦è¢«éæ¯è¿ï¼å¦æå·²ç»è¢«éæ¯è¿åè°ç¨destroy伿¥é |
| | | if (!isDestroyed) { |
| | | this.snowStage.destroy(); |
| | | } |
| | | delete this.snowSize; |
| | | delete this.snowSpeed; |
| | | } |
| | | show(visible) { |
| | | this.snowStage.enabled = visible; |
| | | } |
| | | |
| | | snow() { |
| | | return "uniform sampler2D colorTexture;\n\ |
| | | in vec2 v_textureCoordinates;\n\ |
| | | uniform float snowSpeed;\n\ |
| | | uniform float snowSize;\n\ |
| | | uniform vec4 snowColor;\n\ |
| | | float snow(vec2 uv,float scale)\n\ |
| | | {\n\ |
| | | float time=czm_frameNumber/snowSpeed;\n\ |
| | | float w=smoothstep(1.,0.,-uv.y*(scale/10.));if(w<.1)return 0.;\n\ |
| | | uv+=time/scale;uv.y+=time*2./scale;uv.x+=sin(uv.y+time*.5)/scale;\n\ |
| | | uv*=scale;vec2 s=floor(uv),f=fract(uv),p;float k=3.,d;\n\ |
| | | p=.5+.35*sin(11.*fract(sin((s+p+scale)*mat2(7,3,6,5))*5.))-f;d=length(p);k=min(d,k);\n\ |
| | | k=smoothstep(0.,k,sin(f.x+f.y)*snowSize);\n\ |
| | | return k*w;\n\ |
| | | }\n\ |
| | | out vec4 fragColor;\n\ |
| | | void main(void){\n\ |
| | | vec2 resolution=czm_viewport.zw;\n\ |
| | | vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y);\n\ |
| | | vec3 finalColor=vec3(0);\n\ |
| | | //float c=smoothstep(1.,0.3,clamp(uv.y*.3+.8,0.,.75));\n\ |
| | | float c=0.;\n\ |
| | | c+=snow(uv,30.)*.0;\n\ |
| | | c+=snow(uv,20.)*.0;\n\ |
| | | c+=snow(uv,15.)*.0;\n\ |
| | | c+=snow(uv,10.);\n\ |
| | | c+=snow(uv,8.);\n\ |
| | | c+=snow(uv,6.);\n\ |
| | | c+=snow(uv,5.);\n\ |
| | | finalColor=(vec3(c) * snowColor.rgb);\n\ |
| | | fragColor=mix(texture(colorTexture,v_textureCoordinates),vec4(finalColor,1),.5);\n\ |
| | | }\n\ |
| | | "; |
| | | } |
| | | } |
| | | export default SnowEffect; |
| | |
| | | // import cameraIcon from "../assets/images/base/è§é¢æµç¹.png" |
| | | // import cameraIconSel from "../assets/images/base/è§é¢æµç¹sel.png" |
| | | import { ElLoading, ElMessage } from "element-plus"; |
| | | import RainEffect from './rain' |
| | | let layerIsOpen = false; |
| | | const Cesium = SmartEarth.Cesium; |
| | | const colorAll = { |
| | |
| | | analysisDXPMRes: [], |
| | | slopeArrow: null, |
| | | elevationTool: null, |
| | | rainEffect: null, |
| | | |
| | | init(earthCtrl) { |
| | | this.earthCtrl = earthCtrl; |
| | | return this; |
| | | }, |
| | | hexToColor(hexColor) { |
| | | const hex = hexColor.replace('#', ''); |
| | | const r = parseInt(hex.substring(0, 2), 16) / 255; |
| | | const g = parseInt(hex.substring(2, 4), 16) / 255; |
| | | const b = parseInt(hex.substring(4, 6), 16) / 255; |
| | | return new Cesium.Color(r, g, b, 1.0); |
| | | }, |
| | | // å¤©æ° |
| | | toggleRain(option, show) { |
| | | console.log(option, 'option') |
| | | // å
鿝æ§å®ä¾ |
| | | if (this.rainEffect) { |
| | | this.rainEffect.destroy() |
| | | this.rainEffect = null |
| | | } |
| | | this.rainEffect = new RainEffect(earthCtrl.viewer, { |
| | | tiltAngle: -0.2, //徿è§åº¦ |
| | | rainSize: option.rainSize, // é¨çå¤§å° |
| | | rainSpeed: option.rainSpeed, // é¨çé度 |
| | | color: this.hexToColor(option.rainColor) // é¨çé¢è² |
| | | }) |
| | | }, |
| | | // å¡åº¦åæ |
| | | pdfx(option) { |
| | |
| | | this.slopeArrow.setPositions(polygonPosition); |
| | | this.slopeArrow.setSlopeType(1); |
| | | this.slopeArrow.setRegionEnabled(true); |
| | | console.log(this.slopeArrow,'slope') |
| | | console.log(this.slopeArrow, 'slope') |
| | | }); |
| | | }, |
| | | // å
³éå¡åç®å¤´ |
| | |
| | | } |
| | | }, |
| | | |
| | | // å¤©æ° |
| | | toggleRain(weather = "rain", show) { |
| | | if (show) { |
| | | earthCtrl.environment.showEffect(weather); |
| | | } else { |
| | | earthCtrl.environment.disableEffect(weather); |
| | | } |
| | | }, |
| | | |
| | | toggleSnow(weather = "snow", show) { |
| | | if (show) { |
| | | earthCtrl.environment.showEffect(weather); |