cesium 地图颜色滤镜

实现地图颜色滤镜

这是cesium提供的更改地图颜色的效果

ImageryLayer提供了修改 brightness图层亮度 contrast对比度 hue色相 saturation饱和度 gamma伽玛校正 这些属性

但是用完你会发现,调不出来我想要的颜色,产品想要的一个颜色效果,用这些配置根本达不到要求,所以需要增加一个颜色属性,然后再配合这些属性进行微调

修改源码实现

仿照ImageryLayer源码的原有属性的代码,在其相关地方加入filterRGB属性用于设置颜色

这里为了使用方便,对颜色值进行一个调整

上面实现了一种滤镜颜色效果,进一步优化,再增加一种灰度反色滤镜效果。

业务端调用

ts 复制代码
  // 部分代码,业务端调用时修改这些属性就可以了
  let layersLength = this.viewerCesium.imageryLayers.length;
  if (layersLength === 0) return false;

  for (let j = 0; j < layersLength; j++) {
    let imageryLayer = this.viewerCesium.imageryLayers.get(j);
    imageryLayer.alpha = mapBottomParam.alpha;
    imageryLayer.brightness = mapBottomParam.brightness;
    imageryLayer.contrast = mapBottomParam.contrast;
    imageryLayer.saturation = mapBottomParam.saturation;

    if (mapBottomParam.filterColor) {
      const color = Color.fromCssColorString(mapBottomParam.filterColor);
      if (mapMode === 1) {
        // @ts-ignore
        imageryLayer.color = new Cartesian3(color.red, color.green, color.blue);
        // @ts-ignore
        imageryLayer.colorEnable = true;
        // @ts-ignore
        imageryLayer.filterColorEnable = false;
        imageryLayer.gamma = 0.3;
      } else if (mapMode === 3) {
        // @ts-ignore
        imageryLayer.filterColor = new Cartesian3(color.red, color.green, color.blue);
        // @ts-ignore
        imageryLayer.filterColorEnable = true;
        // @ts-ignore
        imageryLayer.colorEnable = false;
      }
    }
  }

效果

相关推荐
xiaofeichaichai9 小时前
Webpack
前端·webpack·node.js
问心无愧051310 小时前
ctf show web入门111
android·前端·笔记
唐某人丶10 小时前
模型越来越强,我们还需要 Agent 工程吗?—— 从价值重估到 Harness 实践
前端·agent·ai编程
智码看视界10 小时前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
JS菌10 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
excel12 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia31112 小时前
https连接传输流程
前端·面试
徐小夕12 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab12 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器