| | |
| | | import AmapMercatorTilingScheme from './cesium/AmapMercatorTilingScheme/index' |
| | | import store from '@/store' |
| | | import { Terrain } from 'cesium' |
| | | import { addBlueFilter } from '@/utils/cesium/common' |
| | | |
| | | // 定义全局的viewer变量防止重复生成 |
| | | let viewer = null |
| | |
| | | curLayer.mapLayer.gamma = 0.3 // 伽马校正(小于1.0使颜色更鲜艳) |
| | | curLayer.invertColor = true // 启用反色 |
| | | // curLayer.filterRGB = [0, 50, 100] |
| | | filterLayer({ |
| | | addBlueFilter({ |
| | | bInvertColor: true, |
| | | bFilterColor: true, |
| | | filterColor: '#4e70a6' |
| | | }) |
| | | },viewer) |
| | | } |
| | | |
| | | if (curLayer.mapLayer) curLayer.mapLayer.show = true |
| | |
| | | }) |
| | | // 2D/3D切换 |
| | | switchModel(store.state.common.mapSetting.visual) |
| | | } |
| | | |
| | | const filterLayer = (options) => { |
| | | const { bInvertColor, bFilterColor, filterColor } = options |
| | | const color = new Cesium.Color.fromCssColorString(filterColor) |
| | | const filterRGB = [ |
| | | Math.round(color.red * 255), |
| | | Math.round(color.green * 255), |
| | | Math.round(color.blue * 255) |
| | | ] |
| | | let fragShader = viewer.scene.globe._surfaceShaderSet.baseFragmentShaderSource.sources |
| | | for (let i = 0; i < fragShader.length; i++) { |
| | | const strS = 'color = czm_saturation(color, textureSaturation);\n#endif\n' |
| | | let strT = 'color = czm_saturation(color, textureSaturation);\n#endif\n' |
| | | if (bInvertColor) { |
| | | strT += ` |
| | | color.r = 1.0 - color.r; |
| | | color.g = 1.0 - color.g; |
| | | color.b = 1.0 - color.b; |
| | | ` |
| | | } |
| | | if (bFilterColor) { |
| | | strT += ` |
| | | color.r = color.r * ${filterRGB[0]}.0/255.0; |
| | | color.g = color.g * ${filterRGB[1]}.0/255.0; |
| | | color.b = color.b * ${filterRGB[2]}.0/255.0; |
| | | ` |
| | | } |
| | | fragShader[i] = fragShader[i].replace(strS, strT) |
| | | } |
| | | } |
| | | |
| | | const addCustomLayers = (layerName, options) => { |