From 21b66bda2968cd73b370e826ee1154acdc6e3569 Mon Sep 17 00:00:00 2001 From: wangyawei <1796609990@qq.com> Date: 星期五, 18 四月 2025 20:28:27 +0800 Subject: [PATCH] 修改雨的效果 --- src/utils/rain.js | 25 ++ src/components/tools/Rain.vue | 12 src/utils/tools.js | 271 +++++++++++++++++--------------------- src/components/tools/Tools.vue | 87 ++--------- 4 files changed, 163 insertions(+), 232 deletions(-) diff --git a/src/components/tools/Rain.vue b/src/components/tools/Rain.vue index f87598b..25cbcf5 100644 --- a/src/components/tools/Rain.vue +++ b/src/components/tools/Rain.vue @@ -1,12 +1,11 @@ <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-slider :step="0.1" v-model="form.rainSize" :min="0" :max="1"></el-slider> + </el-form-item> + <el-form-item label="瀵嗗害:"> + <el-slider :step="10" :min="10" :max="200" v-model="form.rainDensity"> + </el-slider> </el-form-item> <el-form-item label="閫熷害"> <el-slider v-model="form.rainSpeed" :min="0" :max="150"></el-slider> @@ -22,6 +21,7 @@ const form = reactive({ rainSize: 0.5, rainSpeed: 50, + rainDensity: 30, rainColor: "#99B3CC", }); diff --git a/src/components/tools/Tools.vue b/src/components/tools/Tools.vue index 146a429..c9866b7 100644 --- a/src/components/tools/Tools.vue +++ b/src/components/tools/Tools.vue @@ -4,87 +4,35 @@ <div class="tools-title" @click="toggleCollapse"> 宸ュ叿鏍� <div class="popup-menu" v-if="isPopupVisible"> - <div - class="popup-item" - v-for="(option, idx) in currentToolOptions" - :key="idx" - @click="handleOptionClick(option)" - > - <img - class="popup-icon" - :src=" + <div class="popup-item" v-for="(option, idx) in currentToolOptions" :key="idx" @click="handleOptionClick(option)"> + <img class="popup-icon" :src=" require(`../../assets/img/tools/tools_second/${option.icon}.png`) - " - :alt="option.name" - /> + " :alt="option.name" /> {{ option.name }} </div> </div> <LayerTree class="popup-menu" v-show="showLayerTree" /> <!-- 鍙鍩熷垎鏋� --> - <seeAnalyze - :option="option" - v-show="seeAnalyzeShow" - @update:showConeLine="handleUpdateShowConeLine" - @update-option="onUpdateOption" - @draw="onDraw" - @clear="onClear" - class="popup-menu-see" - /> + <seeAnalyze :option="option" v-show="seeAnalyzeShow" @update:showConeLine="handleUpdateShowConeLine" @update-option="onUpdateOption" @draw="onDraw" @clear="onClear" class="popup-menu-see" /> <!-- 鍓栭潰鎻愬彇 --> - <TopographyDia - @draw="handleDraw" - @clear="handleClear" - class="popup-menu-see" - v-show="topographyShow" - /> + <TopographyDia @draw="handleDraw" @clear="handleClear" class="popup-menu-see" v-show="topographyShow" /> <!-- 鍓栭潰鎻愬彇鐨別charts --> <div v-show="echartsShow" id="sectionCharts" class="sectionChars"> <div id="echartsView1" style="width: 100%; height: 100%"></div> </div> <!-- 鍧″害鍧″悜鍒嗘瀽 --> - <Aspect - v-show="showAspect" - @draw="SlopeArrow" - @clear="SlopeArrowClose" - @handleaspect="handleaspect" - @handleSlope="handleSlope" - class="popup-menu-see" - /> - <SlopeAnalysis - @draw="SlopeAnalysiss" - v-show="isContourLabel" - class="popup-menu-see" - @update-slope="onUpdateSlope" - /> + <Aspect v-show="showAspect" @draw="SlopeArrow" @clear="SlopeArrowClose" @handleaspect="handleaspect" @handleSlope="handleSlope" class="popup-menu-see" /> + <SlopeAnalysis @draw="SlopeAnalysiss" v-show="isContourLabel" class="popup-menu-see" @update-slope="onUpdateSlope" /> <!-- 闆� --> - <Rain - v-show="showRain" - class="popup-menu-see" - @update-rain="onUpdateRain" - /> - <Snow - v-show="showSnow" - class="popup-menu-see" - @update-snow="onUpdateSnow" - /> + <Rain v-show="showRain" class="popup-menu-see" @update-rain="onUpdateRain" /> + <Snow v-show="showSnow" class="popup-menu-see" @update-snow="onUpdateSnow" /> </div> <!-- 宸ュ叿鏍忓唴瀹� --> <transition name="fade"> <div v-if="!isCollapsed" class="tools-content"> - <div - class="tools-item" - v-for="(item, index) in toolList" - :key="index" - @click.stop="handleClick(item)" - > - <img - class="icon" - :src="require(`../../assets/img/tools/${item.icon}.png`)" - :title="item.name" - alt="" - /> + <div class="tools-item" v-for="(item, index) in toolList" :key="index" @click.stop="handleClick(item)"> + <img class="icon" :src="require(`../../assets/img/tools/${item.icon}.png`)" :title="item.name" alt="" /> </div> </div> </transition> @@ -103,7 +51,7 @@ import Snow from "@/components/tools/Snow.vue"; // 鍒囨崲灞曞紑/鏀剁缉鐘舵�� -function toggleCollapse() { +function toggleCollapse () { // isCollapsed.value = !isCollapsed.value; } @@ -198,7 +146,7 @@ ]); // 澶勭悊宸ュ叿鐐瑰嚮浜嬩欢 -function handleClick(tool, event) { +function handleClick (tool, event) { // 閬嶅巻宸ュ叿鍒楄〃锛屾洿鏂版縺娲荤姸鎬� toolList.value.forEach((item) => { item.active = item.name === tool.name && currentToolOptions.value !== tool.options; @@ -240,7 +188,7 @@ const currentOption = ref(null); // 澶勭悊寮圭獥閫夐」鐐瑰嚮浜嬩欢 -function handleOptionClick(option) { +function handleOptionClick (option) { isPopupVisible.value = false; currentOption.value = option.name; console.log("Selected option:", currentOption.value); @@ -344,13 +292,13 @@ }; // 澶勭悊瀛愮粍浠朵紶鏉ョ殑鍙鍩熸樉绀洪敟绾跨殑鍊� -function handleUpdateShowConeLine(value) { +function handleUpdateShowConeLine (value) { showConeLine.value = value; mapUtils.showSyfxViewCone(showConeLine.value); } // 榧犳爣缁樺埗鍙鍩� -function onDraw() { +function onDraw () { // 瀹氫箟鍥炶皟鍑芥暟锛岀敤浜庢帴鏀� res 骞舵洿鏂� option const callback = (res) => { option.heading = res.heading; @@ -361,7 +309,7 @@ } // 娓呴櫎鍙鍩� -function onClear() { +function onClear () { mapUtils.syfxqc(option); } @@ -448,6 +396,7 @@ rainSize: 0.5, rainSpeed: 50, rainColor: "#99B3CC", + rainDensity: 30 // 闆ㄧ殑瀵嗗害 }); const onUpdateRain = (newOption) => { console.log(newOption, "new"); diff --git a/src/utils/rain.js b/src/utils/rain.js index a7499e5..2be1717 100644 --- a/src/utils/rain.js +++ b/src/utils/rain.js @@ -6,6 +6,7 @@ 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.rainDensity = Cesium.defaultValue(options.rainSpeed, 30.0); this.color = Cesium.defaultValue(options.color, new Cesium.Color(0.6, 0.7, 0.8, 1.0)); this.viewer = viewer; this.init(); @@ -28,6 +29,9 @@ rainSpeed: () => { return this.rainSpeed; }, + rainDensity: () => { + return this.rainDensity; + }, }, }); this.viewer.scene.postProcessStages.add(this.rainStage); @@ -49,7 +53,6 @@ show(visible) { this.rainStage.enabled = visible; } - rain() { return "uniform sampler2D colorTexture;\n\ in vec2 v_textureCoordinates;\n\ @@ -57,6 +60,7 @@ uniform vec4 rainColor;\n\ uniform float rainSize;\n\ uniform float rainSpeed;\n\ + uniform float rainDensity;\n\ float hash(float x) {\n\ return fract(sin(x * 133.3) * 13.13);\n\ }\n\ @@ -69,11 +73,20 @@ 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\ + uv *= length(uv + vec2(0, 4.9)) / (rainSize * 3.0 + 0.1) + 0.5;\n\ + // 闄愬埗鏈�澶у瘑搴﹀�硷紝浣跨敤瀵规暟鍑芥暟鏉ュ帇缂╅珮瀵嗗害鑼冨洿\n\ + float cappedDensity = min(rainDensity, 30.0 + (rainDensity - 30.0) * 0.1);\n\ + float densityScale = pow(cappedDensity / 200.0, 0.4); // 浣跨敤0.4娆″箓杩涗竴姝ュ帇缂‐n\ + // 鍑忓皯鍩虹闆ㄦ淮鏁伴噺\n\ + float v = 1. - sin(hash(floor(uv.x * (25.0 + densityScale * 50.0))) * 2.);\n\ + // 浣跨敤鏇翠弗鏍肩殑闃堝�煎嚱鏁帮紝璁╅珮瀵嗗害鏃跺鍔犳洿灏戠殑闆╘n\ + float densityThreshold = 0.96 - (0.15 * log(1.0 + cappedDensity / 50.0));\n\ + float b = clamp(abs(sin(20. * time * v + uv.y * (5. / (2. + v)))) - densityThreshold, 0., 1.) * 20.;\n\ + // 璁$畻闆ㄦ淮棰滆壊\n\ + vec3 finalColor = rainColor.rgb * v * b;\n\ + // 璋冩暣娣峰悎绯绘暟\n\ + float mixFactor = min(b * 0.05, 0.5);\n\ + fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor, 1), mixFactor);\n\ }\n\ "; } diff --git a/src/utils/tools.js b/src/utils/tools.js index a56a9c7..733633f 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -2,8 +2,8 @@ // 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' -import SnowEffect from './snow' +import RainEffect from "./rain"; +import SnowEffect from "./snow"; let layerIsOpen = false; const Cesium = SmartEarth.Cesium; const colorAll = { @@ -32,7 +32,7 @@ return this; }, hexToColor(hexColor) { - const hex = hexColor.replace('#', ''); + 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; @@ -41,8 +41,8 @@ // 娓呴櫎澶╂皵鐗规晥 delRain() { if (this.rainEffect) { - this.rainEffect.destroy() - this.rainEffect = null + this.rainEffect.destroy(); + this.rainEffect = null; } }, delSnow() { @@ -53,22 +53,23 @@ }, // 闆ㄥぉ妯℃嫙 toggleRain(option, show) { - console.log(option, 'option') + console.log(option, "option"); // 鍏堥攢姣佹棫瀹炰緥 if (this.rainEffect) { - this.rainEffect.destroy() - this.rainEffect = null + 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) // 闆ㄧ殑棰滆壊 - }) + rainDensity: option.rainDensity, // 闆ㄧ殑瀵嗗害 + color: this.hexToColor(option.rainColor), // 闆ㄧ殑棰滆壊 + }); }, // 闆ぉ妯℃嫙 toggleSnow(option = {}, show = true) { - console.log(option, 'option'); + console.log(option, "option"); const defaultOption = { snowSize: 0.02, // 榛樿闆殑澶у皬 snowSpeed: 100.0, // 榛樿闆殑閫熷害 @@ -95,14 +96,12 @@ this.regionTerrain = earthCtrl.factory.createRegionTerrain({}); this.polygonPosition = []; - const draw = earthCtrl.shapeTool.createDrawShapeTool((e) => { + const draw = earthCtrl.shapeTool.createDrawShapeTool(e => { const polygonI = []; for (const i of e.result) { const ellipsoid = earthCtrl.coreMap.scene.globe.ellipsoid; const cartographic = ellipsoid.cartesianToCartographic(i); - const lon = SmartEarth.Cesium.Math.toDegrees( - cartographic.longitude - ); // 缁忓害 + const lon = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); // 缁忓害 const lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); // 绾害 polygonI.push(lon, lat, 0); this.polygonPosition.push(lon, lat); @@ -119,7 +118,7 @@ // 鍧″害鍒嗘瀽 pdfx() { if (this.regionTerrain) { - console.log('鍧″害鍒嗘瀽'); + console.log("鍧″害鍒嗘瀽"); this.clearPreviousAnalysis(); // 鍏堟竻闄や箣鍓嶇殑鍒嗘瀽 this.regionTerrain.setType("slope"); this.regionTerrain.update(); @@ -172,7 +171,7 @@ if (show) { earthCtrl.factory.createSimpleGraphic(pic, {}, function (entity) { console.log(entity, "entity"); - window.Viewer = earthCtrl.viewer + window.Viewer = earthCtrl.viewer; //寮�鍚紪杈戝苟鍚敤灞炴�у脊绐� earthCtrl.factory.SimpleGraphic.edit(true, { editProp: true, @@ -188,7 +187,7 @@ // 姘村钩娴嬮噺 spjl() { - earthCtrl.measure.horizontalDistance(colorAll, (e) => { + earthCtrl.measure.horizontalDistance(colorAll, e => { console.log(e); }).onEnd = () => { console.log("姘村钩娴嬭窛宸插畬鎴�"); @@ -196,15 +195,15 @@ }, //鐩寸嚎娴嬮噺 jl() { - earthCtrl.measure.lineDistance(colorAll, (e) => { - console.log(e) + earthCtrl.measure.lineDistance(colorAll, e => { + console.log(e); }).onEnd = () => { console.log("鐩寸嚎娴嬮噺宸插畬鎴�"); }; }, // 鍨傜洿娴嬮噺 czgd() { - earthCtrl.measure.height(colorAll, (e) => { + earthCtrl.measure.height(colorAll, e => { console.log(e); }).onEnd = () => { console.log("鍨傜洿娴嬭窛宸插畬鎴�"); @@ -212,20 +211,22 @@ }, //闈㈢Н娴嬮噺 mjcl() { - earthCtrl.measure.surfaceArea({ - ...colorAll, - tin: true, // 鏄惁鏄剧ずtin涓夎缃� - onlyTerrain: false // 鏄惁鍙祴閲忕簿缁嗗湴褰� - }, (e) => { - console.log(e) - - }).onEnd = () => { - console.log('闈㈢Н娴嬮噺宸插畬鎴�') - } + earthCtrl.measure.surfaceArea( + { + ...colorAll, + tin: true, // 鏄惁鏄剧ずtin涓夎缃� + onlyTerrain: false, // 鏄惁鍙祴閲忕簿缁嗗湴褰� + }, + e => { + console.log(e); + } + ).onEnd = () => { + console.log("闈㈢Н娴嬮噺宸插畬鎴�"); + }; }, // 娓呴櫎娴嬮噺 clear() { - earthCtrl.measure.clearResult() + earthCtrl.measure.clearResult(); }, syfx(option) { this.viewShedTool = earthCtrl.analysis.createViewShed({ @@ -244,7 +245,7 @@ if (!this.viewShedTool) { this.syfx(option); } - this.viewShedTool.mouseCreate().then((res) => { + this.viewShedTool.mouseCreate().then(res => { callback(res); }); }, @@ -299,7 +300,7 @@ polyline: Cesium.Color.fromCssColorString("#ffff0050"), polygon: Cesium.Color.fromCssColorString("#ffff0050"), }, - (e) => { } + e => {} ); }, qxcl() { @@ -309,7 +310,7 @@ polyline: Cesium.Color.fromCssColorString("#ffff0050"), polygon: Cesium.Color.fromCssColorString("#ffff0050"), }, - (e) => { } + e => {} ); }, fwjcl() { @@ -319,7 +320,7 @@ polyline: Cesium.Color.fromCssColorString("#ffff0050"), polygon: Cesium.Color.fromCssColorString("#ffff0050"), }, - (e) => { } + e => {} ); }, // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>鍦烘櫙鎴浘<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -374,14 +375,12 @@ this.earthCtrl.factory.createSimpleGraphic( "polygon", { showSize: false, removeEdit: true }, - (entity) => { - let postitions = entity.polygon.hierarchy - .getValue() - .positions.reduce((obj, cur) => { - let lonlat = this.cartesainToDegrees(cur); - obj.push([lonlat.lng, lonlat.lat]); - return obj; - }, []); + entity => { + let postitions = entity.polygon.hierarchy.getValue().positions.reduce((obj, cur) => { + let lonlat = this.cartesainToDegrees(cur); + obj.push([lonlat.lng, lonlat.lat]); + return obj; + }, []); //澶氬彉褰㈤棴鐜� postitions.push(postitions[0]); let gridRadius = 0.05; @@ -423,7 +422,7 @@ } hexres.features.forEach((item, index) => { if (turf.booleanContains(polygon, item)) { - let newArr = item.geometry.coordinates[0].map((el) => { + let newArr = item.geometry.coordinates[0].map(el => { return Cesium.Cartesian3.fromDegrees(el[0], el[1]); }); //缃戞牸闈� @@ -499,112 +498,87 @@ this.RestrictTheHeight.removeFromMap(); this.RestrictTheHeight = null; } - earthCtrl.factory.createSimpleGraphic( - "polygon", - { showSize: false }, - (entity) => { - let arr = []; - entity.polygon.hierarchy.getValue().positions.forEach((position) => { - let cartographic = - SmartEarth.Cesium.Cartographic.fromCartesian(position); - let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); - let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); - arr.push(lng, lat); - }); - this.earthCtrl.viewer.entities.remove(entity); - if (viewer.terrainProvider) { - Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [ - Cesium.Cartographic.fromDegrees(arr[0], arr[1]), - ]).then((updatedPositions) => { - this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight( - { - positions: arr, - baseHeight: baseHeigh + updatedPositions[0].height, - // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5), - color: - SmartEarth.Cesium.Color.fromCssColorString( - "#ff1515" - ).withAlpha(0.5), - } - ); - }); - } else { + earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => { + let arr = []; + entity.polygon.hierarchy.getValue().positions.forEach(position => { + let cartographic = SmartEarth.Cesium.Cartographic.fromCartesian(position); + let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); + let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); + arr.push(lng, lat); + }); + this.earthCtrl.viewer.entities.remove(entity); + if (viewer.terrainProvider) { + Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [ + Cesium.Cartographic.fromDegrees(arr[0], arr[1]), + ]).then(updatedPositions => { this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({ positions: arr, - baseHeight: baseHeigh, - color: - SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha( - 0.5 - ), + baseHeight: baseHeigh + updatedPositions[0].height, + // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5), + color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5), }); - } + }); + } else { + this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({ + positions: arr, + baseHeight: baseHeigh, + color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5), + }); } - ); + }); }, hcqfxPoint(width) { - const pointGraphic = earthCtrl.factory.createSimpleGraphic( - "point", - {}, - (entity) => { - const position = entity.position.getValue(); - const { lng, lat } = this.transformCartesianToCoord(position); - const pointBuffer = earthCtrl.analysis.createBufferAnalysis({ - position: [lng, lat], - color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), - radius: width / 1000, - }); - pointBuffer.initBuffer(); - this.Buffers.push(pointBuffer); - } - ); + const pointGraphic = earthCtrl.factory.createSimpleGraphic("point", {}, entity => { + const position = entity.position.getValue(); + const { lng, lat } = this.transformCartesianToCoord(position); + const pointBuffer = earthCtrl.analysis.createBufferAnalysis({ + position: [lng, lat], + color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), + radius: width / 1000, + }); + pointBuffer.initBuffer(); + this.Buffers.push(pointBuffer); + }); }, hcqfxLine(width) { - this.earthCtrl.factory.createSimpleGraphic( - "polyline", - { showSize: false }, - (entity) => { - const positions = entity.polyline.positions.getValue(); - let coordinates = []; - for (let i = 0; i < positions.length; i++) { - const { lng, lat } = this.transformCartesianToCoord(positions[i]); - coordinates.push(lng, lat); - } - const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({ - position: coordinates, - color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), - radius: width / 1000, - }); - polulineBuffer.initPolylineBuffer(); - this.Buffers.push(polulineBuffer); + this.earthCtrl.factory.createSimpleGraphic("polyline", { showSize: false }, entity => { + const positions = entity.polyline.positions.getValue(); + let coordinates = []; + for (let i = 0; i < positions.length; i++) { + const { lng, lat } = this.transformCartesianToCoord(positions[i]); + coordinates.push(lng, lat); } - ); + const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({ + position: coordinates, + color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), + radius: width / 1000, + }); + polulineBuffer.initPolylineBuffer(); + this.Buffers.push(polulineBuffer); + }); }, hcqfxPolygon(width) { - this.earthCtrl.factory.createSimpleGraphic( - "polygon", - { showSize: false }, - (entity) => { - let positions = entity.polygon.hierarchy.getValue().positions; - let coordinates = []; - for (let i = 0; i < positions.length; i++) { - const { lng, lat } = this.transformCartesianToCoord(positions[i]); - coordinates.push(lng, lat); - } - const { lng, lat } = this.transformCartesianToCoord(positions[0]); + this.earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => { + let positions = entity.polygon.hierarchy.getValue().positions; + let coordinates = []; + for (let i = 0; i < positions.length; i++) { + const { lng, lat } = this.transformCartesianToCoord(positions[i]); coordinates.push(lng, lat); - const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({ - position: coordinates, - color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), - radius: width / 1000, - }); - polygonBuffer.initPolylineBuffer(); - this.Buffers.push(polygonBuffer); } - ); + const { lng, lat } = this.transformCartesianToCoord(positions[0]); + coordinates.push(lng, lat); + const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({ + position: coordinates, + color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), + radius: width / 1000, + }); + polygonBuffer.initPolylineBuffer(); + this.Buffers.push(polygonBuffer); + }); }, // 鍔ㄦ�佽鍩熷垎鏋� dtsyfxPoint(callback) { - earthCtrl.factory.createSimpleGraphic("point", {}, (entity) => { + earthCtrl.factory.createSimpleGraphic("point", {}, entity => { let position = entity.position.getValue(); let coord = this.transformCartesianToCoord(position); this.earthCtrl.viewer.entities.remove(entity); @@ -707,9 +681,9 @@ polygonArray: [], selectedEntity: null, //閫変腑鐨勫疄浣� addPointToMap(row) { - const filteArr = this.pointsArray.filter((item) => item.type == row.type); + const filteArr = this.pointsArray.filter(item => item.type == row.type); if (filteArr.length > 0) { - filteArr.forEach((item) => { + filteArr.forEach(item => { item.entity.show = true; }); return; @@ -750,9 +724,9 @@ }); }, hidePointByType(row) { - const filteArr = this.pointsArray.filter((item) => item.type == row.type); + const filteArr = this.pointsArray.filter(item => item.type == row.type); if (filteArr.length > 0) { - filteArr.forEach((item) => { + filteArr.forEach(item => { item.entity.show = false; }); } @@ -770,14 +744,14 @@ callback(poiInfo); }, setSelectedEntity(entity) { - this.pointsArray.forEach((item) => { + this.pointsArray.forEach(item => { if (item.id === entity.id) { item.entity.billboard.image = cameraIconSel; } }); }, clearSelectedEntityStyle(entity) { - this.pointsArray.forEach((item) => { + this.pointsArray.forEach(item => { if (item.id === entity.id) { item.entity.billboard.image = cameraIcon; } @@ -791,7 +765,7 @@ } }, createPolygonArea(item) { - const findItem = this.polygonArray.find((row) => row.id === item.id); + const findItem = this.polygonArray.find(row => row.id === item.id); if (findItem) { earthCtrl.viewer.flyTo(findItem.polygon); return; @@ -806,9 +780,7 @@ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, }, }); - var polyPositions = curPolygon.polygon.hierarchy.getValue( - Cesium.JulianDate.now() - ).positions; + var polyPositions = curPolygon.polygon.hierarchy.getValue(Cesium.JulianDate.now()).positions; var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //涓績鐐� polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter); curPolygon.position = polyCenter; @@ -840,7 +812,7 @@ this.polygonArray.push(obj); }, clearPoygon() { - this.polygonArray.forEach((item) => { + this.polygonArray.forEach(item => { earthCtrl.viewer.entities.remove(item.polygon); earthCtrl.viewer.entities.remove(item.polyline); }); @@ -883,7 +855,7 @@ if (graphic) { graphic.clear(); } - this.Buffers.map((item) => { + this.Buffers.map(item => { item.removeFromMap(); }); this.Buffers = []; @@ -927,10 +899,7 @@ GroupID: 0, url: SmartEarthRootUrl + "Workers/image/waterNormals.jpg", }; - this.analysisFlood = earthCtrl.analysis.createSubmergence( - method, - (value) => { } - ); + this.analysisFlood = earthCtrl.analysis.createSubmergence(method, value => {}); }, clearFlood() { this.analysisFlood && this.analysisFlood.endWater(); -- Gitblit v1.9.3