【超图+CESIUM】【基础API使用示例】07、超图|CESIUM - 场景颜色设置和校正
作者:互联网
前言
缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.csdn.net/weixin_44402694/article/details/123110136)
以下示例使用到的公共静态资料,不建议下载,建议官网自行下载超图Build资源,示例所涉及图片会在示例使用到时提供出来。如有需要可下载:[https://download.csdn.net/download/weixin_44402694/82180350](https://download.csdn.net/download/weixin_44402694/82180350)。
场景颜色设置和校正。
设置
-
效果
-
完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>颜色设置 - 场景颜色设置和校正</title>
<link href="./public/Build/Cesium/Widgets/widgets.css" rel="stylesheet" />
<script
type="text/javascript"
src="./public/Build/Cesium/Cesium.js"
></script>
<style>
* {
margin: 0;
padding: 0;
}
html,
body,
#cesium-container {
width: 100%;
height: 100%;
}
.input-group {
width: 220px;
display: flex;
flex-direction: column;
position: fixed;
left: 10px;
top: 10px;
box-sizing: border-box;
padding: 10px;
border: 1px solid #fff;
background-color: #fff;
z-index: 1;
}
.input-group p {
display: flex;
justify-content: space-between;
}
</style>
</head>
<body>
<div id="cesium-container" />
<div class="input-group">
<p>
<span>亮度</span>
<input
type="range"
min="0"
max="1"
step="0.02"
data-cate="brightness"
/>
</p>
<p>
<span>对比度</span>
<input type="range" min="0" max="1" step="0.02" data-cate="contrast" />
</p>
<p>
<span>色调</span>
<input type="range" min="0" max="1" step="0.02" data-cate="hue" />
</p>
<p>
<span>饱和度</span>
<input
type="range"
min="0"
max="1"
step="0.02"
data-cate="saturation"
/>
</p>
</div>
<script>
let viewer = null,
correction = null
window.onload = function () {
viewer = new Cesium.Viewer('cesium-container')
viewer.imageryLayers.get(0).alpha = 0 // 默认的地图的透明度直接设置为0
correction = viewer.scene.colorCorrection // 创建颜色校正对象
correction.show = true // 开启颜色校正
setS3MServiceHandler()
}
// 添加由supermap iserver上发布的s3m服务 并设置其相关的颜色参数
function setS3MServiceHandler() {
const promise = viewer.scene.open(
'http://{s}/realspace/services/3D-NewCBD/rest/realspace',
undefined,
{
subdomains: ['www.supermapol.com'],
}
)
Cesium.when(promise, () => {
listenInputChangeHandler()
})
}
// input的监听事件,触发手动设置layer图层当前变化的这一项参数
function listenInputChangeHandler() {
const inps = document.querySelectorAll('.input-group p input')
Array.from(inps).forEach((inp) => {
const currentCate = inp.getAttribute('data-cate')
inp.value = correction[currentCate]
inp.addEventListener('input', () => {
correction[currentCate] = parseFloat(inp.value)
})
})
}
</script>
</body>
</html>
标签:示例,viewer,correction,inp,超图,设置,CESIUM,input 来源: https://blog.csdn.net/weixin_44402694/article/details/123114703