页面分离修改
This commit is contained in:
@ -15,7 +15,7 @@ let activeHeightElm = null;
|
||||
let tools
|
||||
let _sdk
|
||||
let secondaryLinesCount = 19
|
||||
let show = false
|
||||
let show = true
|
||||
let equalHeightDistance = 10
|
||||
let activeColor = '#ffd000'
|
||||
let indexContourShow = true
|
||||
@ -86,20 +86,21 @@ async function dialog(sdk) {
|
||||
tools = new Tools(sdk)
|
||||
}
|
||||
|
||||
_DialogObject = await new Dialog(sdk, {}, {
|
||||
title: "全局等高线", left: '180px',
|
||||
top: '100px',
|
||||
closeCallBack: () => {
|
||||
_DialogObject = null
|
||||
}
|
||||
});
|
||||
// _DialogObject = await new Dialog(sdk, {}, {
|
||||
// title: "全局等高线", left: '180px',
|
||||
// top: '100px',
|
||||
// closeCallBack: () => {
|
||||
// _DialogObject = null
|
||||
// }
|
||||
// });
|
||||
|
||||
_DialogObject._element.body.className =
|
||||
_DialogObject._element.body.className + ' contour'
|
||||
let contentElm = document.createElement('div')
|
||||
contentElm.innerHTML = html(this)
|
||||
// _DialogObject._element.body.className =
|
||||
// _DialogObject._element.body.className + ' contour'
|
||||
// let contentElm = document.createElement('div')
|
||||
// contentElm.innerHTML = html(this)
|
||||
|
||||
_DialogObject.contentAppChild(contentElm)
|
||||
// _DialogObject.contentAppChild(contentElm)
|
||||
let contentElm = document.getElementsByClassName('contour')[0]
|
||||
|
||||
sdk.viewer.scene.postRender.removeEventListener(accordingToCameraHeight)
|
||||
sdk.viewer.scene.postRender.addEventListener(accordingToCameraHeight)
|
||||
@ -107,6 +108,21 @@ async function dialog(sdk) {
|
||||
// 显示
|
||||
let showBtn = contentElm.getElementsByClassName('show')[0]
|
||||
showBtn.checked = show
|
||||
if (showBtn.checked) {
|
||||
let height = sdk.viewer.camera.positionCartographic.height
|
||||
if (height > 16360) {
|
||||
let cartographic = sdk.viewer.camera.positionCartographic
|
||||
let options = {
|
||||
position: {
|
||||
lng: Cesium.Math.toDegrees(cartographic.longitude),
|
||||
lat: Cesium.Math.toDegrees(cartographic.latitude),
|
||||
alt: 16360,
|
||||
},
|
||||
}
|
||||
flyTo(sdk, options, 0.5)
|
||||
}
|
||||
showContour(sdk)
|
||||
}
|
||||
showBtn.addEventListener('change', (e) => {
|
||||
if (e.target.checked) {
|
||||
show = true
|
||||
@ -473,7 +489,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||
|
||||
// 主等高线计算
|
||||
float distanceToMainContour = mod(materialInput.height, spacing);
|
||||
|
||||
|
||||
// 抗锯齿计算
|
||||
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
||||
float dxc = abs(dFdx(materialInput.height));
|
||||
@ -493,11 +509,11 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||
// 计算当前高度所属的等高线高度
|
||||
float mainContourHeight = floor(materialInput.height / spacing) * spacing;
|
||||
float secondaryContourHeight = floor(materialInput.height / spacing * (secondaryLinesCount + 1.0)) * spacing / (secondaryLinesCount + 1.0);
|
||||
|
||||
|
||||
// 计算次线在两条主等高线之间的相对位置
|
||||
float relativeHeight = materialInput.height - mainContourHeight;
|
||||
float normalizedPosition = relativeHeight / spacing;
|
||||
|
||||
|
||||
// 计算次线索引(从主等高线开始计数)
|
||||
float lineIndex = floor(normalizedPosition * (secondaryLinesCount + 1.0));
|
||||
|
||||
@ -506,7 +522,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||
float secondaryLinesWidth = supplementaryContourWidth;
|
||||
secondarySpacing = spacing / (secondaryLinesCount + 1.0);
|
||||
float distanceToSecondaryContour = mod(materialInput.height, secondarySpacing);
|
||||
|
||||
|
||||
// 确保次线不会与主线重叠
|
||||
float minDistanceToMain = min(distanceToMainContour, spacing - distanceToMainContour);
|
||||
bool notCloseToMain = minDistanceToMain > dFMain * 2.0; // 2倍线宽缓冲
|
||||
@ -532,7 +548,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
||||
dFSecondary = max(dxc, dyc) * czm_pixelRatio * secondaryLinesWidth;
|
||||
#else
|
||||
|
Reference in New Issue
Block a user