页面分离修改

This commit is contained in:
2025-09-05 18:39:00 +08:00
parent 29629b9d43
commit 9e439f5229
14 changed files with 1146 additions and 888 deletions

View File

@ -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

View File

@ -5,7 +5,7 @@
import Dialog from '../../BaseDialog';
import { html } from "./_element";
import Tools from "../../Tools";
import { closeRotateAround, closeViewFollow} from '../../Global/global'
import { closeRotateAround, closeViewFollow } from '../../Global/global'
let _DialogObject = null
let clickHandler
let repeat = 0
@ -13,32 +13,33 @@ let currentRepeat = 0
const open = async (sdk, options = {}, _Dialog = {}) => {
let name = options.name || '漫游路径'
let name = options.name || '飞线漫游'
options.points || (options.points = [])
if(options.repeat) {
if (options.repeat) {
repeat = Number(options.repeat)
}
let viewer = sdk.viewer
let tools = new Tools(sdk)
let active = 0
if (_DialogObject && _DialogObject.close) {
_DialogObject.close()
_DialogObject = null
}
// if (_DialogObject && _DialogObject.close) {
// _DialogObject.close()
// _DialogObject = null
// }
_DialogObject = await new Dialog(viewer._container, {
title: '飞行漫游', left: '180px', top: '100px',
closeCallBack: () => {
cease({ viewer })
},
})
await _DialogObject.init()
let contentElm = document.createElement('div');
contentElm.className = 'fly-roam'
contentElm.innerHTML = html()
_DialogObject.contentAppChild(contentElm)
// _DialogObject = await new Dialog(viewer._container, {
// title: '飞行漫游', left: '180px', top: '100px',
// closeCallBack: () => {
// cease({ viewer })
// },
// })
// await _DialogObject.init()
// let contentElm = document.createElement('div');
// contentElm.className = 'fly-roam'
// contentElm.innerHTML = html()
// _DialogObject.contentAppChild(contentElm)
let contentElm = document.getElementsByClassName('fly-roam')[0]
let all_elm = contentElm.getElementsByTagName("*")
// EventBinding(all_elm)
@ -84,15 +85,15 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
points.map((item) => {
newPoints.push(item)
})
_Dialog.clickSavePath && _Dialog.clickSavePath(
{
name: name,
points: newPoints,
repeat: repeat+''
}
)
// _Dialog.clickSavePath && _Dialog.clickSavePath(
// {
// name: name,
// points: newPoints,
// repeat: repeat + ''
// }
// )
})
_DialogObject.footAppChild(addListBtn)
// _DialogObject.footAppChild(addListBtn)
let endBtn = contentElm.getElementsByClassName('cease')[0]
endBtn.addEventListener('click', () => {
@ -135,7 +136,7 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
pitch: viewer.camera.pitch,
roll: viewer.camera.roll
}
tools.message({text: '操作成功'})
tools.message({ text: '操作成功' })
})
let totalTimeElm = contentElm.querySelector("input[name='totalTime']")
@ -248,7 +249,7 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
for (let m = 0; m < trList.length; m++) {
if (trList[m] === e_delete.parentNode.parentNode) {
points.splice(m, 1)
points[points.length-1] && (points[points.length-1].duration = 0)
points[points.length - 1] && (points[points.length - 1].duration = 0)
tableBody.removeChild(tr)
if (active > m + 1) {
active--
@ -307,10 +308,20 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
}
const close = () => {
if (_DialogObject && _DialogObject.close) {
_DialogObject.close()
_DialogObject = null
// if (_DialogObject && _DialogObject.close) {
// _DialogObject.close()
// _DialogObject = null
// }
let contentElm = document.getElementsByClassName('fly-roam')[0]
let tableBody = contentElm.getElementsByClassName('table-body')[0];
let trList = tableBody.getElementsByClassName('tr')
for (let i = trList.length - 1; i >= 0; i--) {
tableBody.removeChild(trList[i])
}
repeat = 0
currentRepeat = 0
}
const executeFlyTo = (sdk, points = [], index = 0, noStart) => {
@ -387,4 +398,4 @@ const cease = (sdk) => {
}
}
export { open, close, flyTo, setRepeat, cease }
export { open, close, flyTo, setRepeat, cease }