本文主要是介绍cesium暗色地图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
效果图
调用方式
import modifyMap from './filterColor'modifyMap(viewer, {//反色?invertColor: true,//滤色值filterRGB: [60, 145, 172],
});
./filterColor文件
import * as Cesium from 'cesium'//根据自己的实际路径修改export default function modifyMap(viewer, options) {const baseLayer = viewer.imageryLayers.get(0)//以下几个参数根据实际情况修改,目前我是参照火星科技的参数,个人感觉效果还不错baseLayer.brightness = options.brightness || 0.6baseLayer.contrast = options.contrast || 1.8baseLayer.gamma = options.gamma || 0.3baseLayer.hue = options.hue || 1baseLayer.saturation = options.saturation || 0const baseFragShader = (viewer.scene.globe)._surfaceShaderSet.baseFragmentShaderSource.sourcesfor (let i = 0; i < baseFragShader.length; i++) {const strS = 'color = czm_saturation(color, textureSaturation);\n#endif\n'let strT = 'color = czm_saturation(color, textureSaturation);\n#endif\n'if (options.invertColor) {strT += `color.r = 1.0 - color.r;color.g = 1.0 - color.g;color.b = 1.0 - color.b;`}if (options.filterRGB.length > 0) {strT += `color.r = color.r * ${options.filterRGB[0]}.0/255.0;color.g = color.g * ${options.filterRGB[1]}.0/255.0;color.b = color.b * ${options.filterRGB[2]}.0/255.0;`}baseFragShader[i] = baseFragShader[i].replace(strS, strT)}
}//调用
// import modifyMap from './filterColor'
// modifyMap(viewer, {
// //反色?
// invertColor: true,
// //滤镜值
// filterRGB: [60, 145, 172],
// });
// viewer是什么不用我说了吧
这篇关于cesium暗色地图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!