工具
This commit is contained in:
@ -30,6 +30,7 @@ let halfIntervalContourColor = '#64b6d9'
|
||||
let supplementaryContourShow = false
|
||||
let supplementaryContourWidth = 1.0
|
||||
let supplementaryContourColor = '#d084d1'
|
||||
let paramData = {}
|
||||
|
||||
|
||||
activeHeightElm = document.createElement('div')
|
||||
@ -72,6 +73,55 @@ function accordingToCameraHeight() {
|
||||
// console.log(cameraHeight)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function startDraw(sdk, showData) {
|
||||
show = showData
|
||||
|
||||
Object.keys(paramData).forEach(item => {
|
||||
material.uniforms[item] = paramData[item]
|
||||
})
|
||||
|
||||
if (show) {
|
||||
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)
|
||||
} else {
|
||||
hideContour(sdk)
|
||||
}
|
||||
}
|
||||
function reset() {
|
||||
// if (handler) {
|
||||
// handler.destroy()
|
||||
// }
|
||||
secondaryLinesCount = 19
|
||||
// show = true
|
||||
equalHeightDistance = 10
|
||||
activeColor = '#ffd000'
|
||||
indexContourShow = true
|
||||
indexContourWidth = 2.5
|
||||
indexContourColor = '#43cf7c'
|
||||
intermediateContourShow = true
|
||||
intermediateContourWidth = 1.8
|
||||
intermediateContourColor = '#ff0000'
|
||||
halfIntervalContourShow = false
|
||||
halfIntervalContourWidth = 1.0
|
||||
halfIntervalContourColor = '#64b6d9'
|
||||
supplementaryContourShow = false
|
||||
supplementaryContourWidth = 1.0
|
||||
supplementaryContourColor = '#d084d1'
|
||||
|
||||
|
||||
}
|
||||
async function dialog(sdk) {
|
||||
_sdk = sdk
|
||||
@ -106,44 +156,44 @@ async function dialog(sdk) {
|
||||
sdk.viewer.scene.postRender.addEventListener(accordingToCameraHeight)
|
||||
|
||||
// 显示
|
||||
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
|
||||
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)
|
||||
} else {
|
||||
show = false
|
||||
hideContour(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
|
||||
// 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)
|
||||
// } else {
|
||||
// show = false
|
||||
// hideContour(sdk)
|
||||
// }
|
||||
// })
|
||||
// 等高距
|
||||
let equalHeightDistanceInput = contentElm.getElementsByClassName('equal-height-distance')[0]
|
||||
equalHeightDistanceInput.value = equalHeightDistance
|
||||
@ -152,7 +202,8 @@ async function dialog(sdk) {
|
||||
equalHeightDistance = value
|
||||
equalHeightDistanceInput.value = value
|
||||
if (material) {
|
||||
material.uniforms.spacing = equalHeightDistance * 5
|
||||
// material.uniforms.spacing = equalHeightDistance * 5
|
||||
paramData.spacing = equalHeightDistance * 5
|
||||
}
|
||||
})
|
||||
|
||||
@ -188,13 +239,15 @@ async function dialog(sdk) {
|
||||
sure: color => {
|
||||
activeColor = color
|
||||
if (material) {
|
||||
material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
// material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
paramData.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
}
|
||||
},
|
||||
clear: () => {
|
||||
activeColor = 'rgba(255,255,255,1)'
|
||||
if (material) {
|
||||
material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
// material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
paramData.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -205,7 +258,8 @@ async function dialog(sdk) {
|
||||
indexContourSwitch.addEventListener('change', (e) => {
|
||||
indexContourShow = e.target.checked
|
||||
if (material) {
|
||||
material.uniforms.indexContourShow = indexContourShow
|
||||
// material.uniforms.indexContourShow = indexContourShow
|
||||
paramData.indexContourShow = indexContourShow
|
||||
}
|
||||
})
|
||||
// 计曲线颜色
|
||||
@ -219,13 +273,15 @@ async function dialog(sdk) {
|
||||
sure: color => {
|
||||
indexContourColor = color
|
||||
if (material) {
|
||||
material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
// material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
paramData.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
}
|
||||
},
|
||||
clear: () => {
|
||||
indexContourColor = 'rgba(255,255,255,1)'
|
||||
if (material) {
|
||||
material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
// material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
paramData.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -237,7 +293,8 @@ async function dialog(sdk) {
|
||||
indexContourWidth = value
|
||||
indexContourWidthInput.value = value
|
||||
if (material) {
|
||||
material.uniforms.indexContourWidth = indexContourWidth
|
||||
// material.uniforms.indexContourWidth = indexContourWidth
|
||||
paramData.indexContourWidth = indexContourWidth
|
||||
}
|
||||
})
|
||||
|
||||
@ -247,7 +304,8 @@ async function dialog(sdk) {
|
||||
intermediateContourSwitch.addEventListener('change', (e) => {
|
||||
intermediateContourShow = e.target.checked
|
||||
if (material) {
|
||||
material.uniforms.intermediateContourShow = intermediateContourShow
|
||||
// material.uniforms.intermediateContourShow = intermediateContourShow
|
||||
paramData.intermediateContourShow = intermediateContourShow
|
||||
}
|
||||
})
|
||||
// 首曲线颜色
|
||||
@ -261,13 +319,15 @@ async function dialog(sdk) {
|
||||
sure: color => {
|
||||
intermediateContourColor = color
|
||||
if (material) {
|
||||
material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
// material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
paramData.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
}
|
||||
},
|
||||
clear: () => {
|
||||
intermediateContourColor = 'rgba(255,255,255,1)'
|
||||
if (material) {
|
||||
material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
// material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
paramData.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -279,7 +339,8 @@ async function dialog(sdk) {
|
||||
intermediateContourWidth = value
|
||||
intermediateContourWidthInput.value = value
|
||||
if (material) {
|
||||
material.uniforms.intermediateContourWidth = intermediateContourWidth
|
||||
// material.uniforms.intermediateContourWidth = intermediateContourWidth
|
||||
paramData.intermediateContourWidth = intermediateContourWidth
|
||||
}
|
||||
})
|
||||
|
||||
@ -289,7 +350,8 @@ async function dialog(sdk) {
|
||||
halfIntervalContourSwitch.addEventListener('change', (e) => {
|
||||
halfIntervalContourShow = e.target.checked
|
||||
if (material) {
|
||||
material.uniforms.halfIntervalContourShow = halfIntervalContourShow
|
||||
// material.uniforms.halfIntervalContourShow = halfIntervalContourShow
|
||||
paramData.halfIntervalContourShow = halfIntervalContourShow
|
||||
}
|
||||
})
|
||||
// 间曲线颜色
|
||||
@ -303,13 +365,15 @@ async function dialog(sdk) {
|
||||
sure: color => {
|
||||
halfIntervalContourColor = color
|
||||
if (material) {
|
||||
material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
// material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
paramData.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
}
|
||||
},
|
||||
clear: () => {
|
||||
halfIntervalContourColor = 'rgba(255,255,255,1)'
|
||||
if (material) {
|
||||
material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
// material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
paramData.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -321,7 +385,8 @@ async function dialog(sdk) {
|
||||
halfIntervalContourWidth = value
|
||||
halfIntervalContourWidthInput.value = value
|
||||
if (material) {
|
||||
material.uniforms.halfIntervalContourWidth = halfIntervalContourWidth
|
||||
// material.uniforms.halfIntervalContourWidth = halfIntervalContourWidth
|
||||
paramData.halfIntervalContourWidth = halfIntervalContourWidth
|
||||
}
|
||||
})
|
||||
|
||||
@ -331,7 +396,8 @@ async function dialog(sdk) {
|
||||
supplementaryContourSwitch.addEventListener('change', (e) => {
|
||||
supplementaryContourShow = e.target.checked
|
||||
if (material) {
|
||||
material.uniforms.supplementaryContourShow = supplementaryContourShow
|
||||
// material.uniforms.supplementaryContourShow = supplementaryContourShow
|
||||
paramData.supplementaryContourShow = supplementaryContourShow
|
||||
}
|
||||
})
|
||||
// 助曲线颜色
|
||||
@ -345,13 +411,15 @@ async function dialog(sdk) {
|
||||
sure: color => {
|
||||
supplementaryContourColor = color
|
||||
if (material) {
|
||||
material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
// material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
paramData.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
}
|
||||
},
|
||||
clear: () => {
|
||||
supplementaryContourColor = 'rgba(255,255,255,1)'
|
||||
if (material) {
|
||||
material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
// material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
paramData.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -363,7 +431,8 @@ async function dialog(sdk) {
|
||||
supplementaryContourWidth = value
|
||||
supplementaryContourWidthInput.value = value
|
||||
if (material) {
|
||||
material.uniforms.supplementaryContourWidth = supplementaryContourWidth
|
||||
// material.uniforms.supplementaryContourWidth = supplementaryContourWidth
|
||||
paramData.supplementaryContourWidth = supplementaryContourWidth
|
||||
}
|
||||
})
|
||||
|
||||
@ -638,4 +707,4 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||
});
|
||||
}
|
||||
|
||||
export { dialog }
|
||||
export { dialog, startDraw, reset }
|
||||
|
Reference in New Issue
Block a user