2025-07-03 13:54:01 +08:00
|
|
|
/**
|
|
|
|
* 分屏对比
|
|
|
|
* */
|
|
|
|
import Tools from '../../Tools';
|
|
|
|
import { CesiumContainer, closeRotateAround } from '../global'
|
|
|
|
import { FlwStatusSwitch, JwwStatusSwitch, getFlwStatus, getJwwStatus } from "../global"
|
|
|
|
import { off as offMultiViewportMode } from '../MultiViewportMode';
|
|
|
|
import { MouseRightMenu, getMouseRightMenuStatus } from '../mouseRightMenu';
|
|
|
|
import { getLeftClickState, getRightClickState, getMoveState } from '../ClickCallback'
|
|
|
|
import { openLeftClick, openRightClick, openMove } from './ClickCallback'
|
|
|
|
import { SheetIndexStatusSwitch, getStatus } from '../SheetIndex'
|
|
|
|
|
|
|
|
|
|
|
|
let state = false
|
|
|
|
let sdkD // 分屏对象
|
|
|
|
let sdkP // 主屏对象
|
|
|
|
let activeViewer
|
|
|
|
let controlViewer
|
|
|
|
let syncObject = {}
|
|
|
|
let handlers = []
|
|
|
|
let activeIds
|
|
|
|
let statusMap = new Map()
|
|
|
|
// window.statusMap = statusMap
|
|
|
|
// async function init(sdk) {
|
|
|
|
// sdkP = sdk
|
|
|
|
// activeViewer = 0
|
|
|
|
// let tools = new Tools()
|
|
|
|
// let sdk2 = await new YJ.YJEarth(sdk.div_id)
|
|
|
|
// sdk2.viewer._element.className = 'cesium-viewer 2d'
|
|
|
|
// // setTimeout(() => {
|
|
|
|
// // let switchCluster = new YJ.Global.switchCluster(sdk2, true)
|
|
|
|
// // }, 500);
|
|
|
|
// CesiumContainer(sdk2, {
|
|
|
|
// compass: false, // 罗盘
|
|
|
|
// // legend: false, // 比例尺
|
|
|
|
// info: false, // 信息栏
|
|
|
|
// frame: false // 刷新率
|
|
|
|
// })
|
|
|
|
// sdk2.viewer.scene.mode = Cesium.SceneMode.SCENE2D
|
|
|
|
// sdkD = await sdk2
|
|
|
|
// solveBug()
|
|
|
|
// await eventBind(sdk, 0)
|
|
|
|
// await eventBind(sdk2, 1)
|
|
|
|
// syncObject = { sdks: [sdk, sdk2], tools }
|
|
|
|
// await syncData(sdk)
|
|
|
|
// sdk.viewer.scene.preRender.addEventListener(syncViewer, syncObject)
|
|
|
|
|
|
|
|
// sdk.viewer.imageryLayers.layerAdded.addEventListener(syncImageryLayerAdded);
|
|
|
|
// sdk.viewer.imageryLayers.layerMoved.addEventListener(syncImageryLayerMoved);
|
|
|
|
// sdk.viewer.imageryLayers.layerRemoved.addEventListener(syncImageryLayerRemoved);
|
|
|
|
// sdk.viewer.imageryLayers.layerShownOrHidden.addEventListener(syncImageryLayerShownOrHidden);
|
|
|
|
// // sdk.viewer.entities.collectionChanged.addEventListener(syncEntities)
|
|
|
|
// // sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources)
|
|
|
|
// }
|
|
|
|
async function on(sdk) {
|
|
|
|
state = true
|
|
|
|
if (sdkD) {
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
init(sdk)
|
|
|
|
offMultiViewportMode(sdk)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function off() {
|
|
|
|
state = false
|
|
|
|
if (!sdkP) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
setSplitDirection(-1, undefined, true)
|
|
|
|
let sliderElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-slider')[0]
|
|
|
|
let leftElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
let rightElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
if (sliderElm) {
|
|
|
|
sdkP.viewer._element.removeChild(sliderElm)
|
|
|
|
sdkP.viewer._element.removeChild(leftElm)
|
|
|
|
sdkP.viewer._element.removeChild(rightElm)
|
|
|
|
}
|
|
|
|
sdkP.viewer.scene.preRender.removeEventListener(syncViewer, syncObject)
|
|
|
|
sdkP.viewer.imageryLayers.layerAdded.removeEventListener(syncImageryLayerAdded);
|
|
|
|
sdkP.viewer.imageryLayers.layerMoved.removeEventListener(syncImageryLayerMoved);
|
|
|
|
sdkP.viewer.imageryLayers.layerRemoved.removeEventListener(syncImageryLayerRemoved);
|
|
|
|
sdkP.viewer.imageryLayers.layerShownOrHidden.removeEventListener(syncImageryLayerShownOrHidden);
|
|
|
|
// sdk.viewer.entities.collectionChanged.removeEventListener(syncEntities)
|
|
|
|
// sdk.viewer.dataSources.dataSourceAdded.removeEventListener(syncDataSources)
|
|
|
|
|
|
|
|
//primitiveAdded=undefined基元同步设置在add位置
|
|
|
|
// sdk.viewer.scene.primitives.primitiveAdded.removeEventListener(syncPrimitivesAdded)
|
|
|
|
for (let i = 0; i < handlers.length; i++) {
|
|
|
|
handlers[i].destroy()
|
|
|
|
}
|
|
|
|
if (sdkD) {
|
|
|
|
let rightBox = sdkP.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].getElementsByClassName('cesium-widget')[1]
|
|
|
|
sdkP.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].removeChild(rightBox)
|
|
|
|
// sdkD.destroy()
|
|
|
|
handlers = []
|
|
|
|
sdkD = null
|
|
|
|
activeViewer = null
|
|
|
|
syncObject = {}
|
|
|
|
}
|
|
|
|
let leftBox = sdkP.viewer._element.getElementsByClassName('cesium-widget')[0]
|
|
|
|
let leftCanvas = leftBox.getElementsByTagName('canvas')[0]
|
|
|
|
leftBox.style.width = '100%'
|
|
|
|
leftCanvas.style.width = '100%'
|
|
|
|
sdkP = null
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function init(sdk) {
|
|
|
|
sdk.entityMap.forEach((item, key) => {
|
|
|
|
if (item.type && item.type == 'TrajectoryMotion' && item.viewFollow) {
|
|
|
|
item.viewFollow = false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let sliderElm = sdk.viewer._element.getElementsByClassName('YJ-custom-slider')[0]
|
|
|
|
let leftElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
let rightElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
if (sliderElm) {
|
|
|
|
sdk.viewer._element.removeChild(sliderElm)
|
|
|
|
sdk.viewer._element.removeChild(leftElm)
|
|
|
|
sdk.viewer._element.removeChild(rightElm)
|
|
|
|
}
|
|
|
|
sliderElm = document.createElement('div');
|
|
|
|
sliderElm.className = 'YJ-custom-slider'
|
|
|
|
sliderElm.style.position = 'absolute'
|
|
|
|
sliderElm.style.left = '50%'
|
|
|
|
sliderElm.style.top = '0px'
|
|
|
|
|
|
|
|
leftElm = document.createElement('input');
|
|
|
|
leftElm.className = 'YJ-custom-checkbox-left'
|
|
|
|
leftElm.type = 'checkbox'
|
|
|
|
leftElm.style.position = 'absolute'
|
|
|
|
leftElm.style.left = 'calc(50% - 50px)'
|
|
|
|
rightElm = document.createElement('input');
|
|
|
|
rightElm.className = 'YJ-custom-checkbox-right'
|
|
|
|
rightElm.type = 'checkbox'
|
|
|
|
rightElm.style.position = 'absolute'
|
|
|
|
rightElm.style.right = 'calc(50% - 50px)'
|
|
|
|
|
|
|
|
if (!activeIds || activeIds.length == 0) {
|
|
|
|
leftElm.style.display = 'none'
|
|
|
|
rightElm.style.display = 'none'
|
|
|
|
}
|
|
|
|
|
|
|
|
sdk.viewer._element.appendChild(leftElm)
|
|
|
|
sdk.viewer._element.appendChild(rightElm)
|
|
|
|
|
|
|
|
let left = 0
|
|
|
|
let right = 0
|
|
|
|
if (activeIds) {
|
|
|
|
for (let i = 0; i < activeIds.length; i++) {
|
|
|
|
let status = statusMap.get(activeIds[i])
|
|
|
|
if (status) {
|
|
|
|
if (status.P) {
|
|
|
|
left++
|
|
|
|
}
|
|
|
|
if (status.D) {
|
|
|
|
right++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sdkP = sdk
|
|
|
|
|
|
|
|
if (!left && !right) {
|
|
|
|
left++
|
|
|
|
}
|
|
|
|
leftElm.checked = left ? true : false
|
|
|
|
rightElm.checked = right ? true : false
|
|
|
|
leftElm.addEventListener('change', (e) => {
|
|
|
|
if (!e.target.checked) {
|
|
|
|
if (!rightElm.checked) {
|
|
|
|
rightElm.checked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let i = 0; i < activeIds.length; i++) {
|
|
|
|
let status = statusMap.get(activeIds[i])
|
|
|
|
status = status || {}
|
|
|
|
status.P = e.target.checked
|
|
|
|
status.D = rightElm.checked
|
|
|
|
statusMap.set(activeIds[i], status)
|
|
|
|
}
|
|
|
|
changeEntitySplitStatus()
|
|
|
|
})
|
|
|
|
rightElm.addEventListener('change', (e) => {
|
|
|
|
if (!e.target.checked) {
|
|
|
|
if (!leftElm.checked) {
|
|
|
|
leftElm.checked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let i = 0; i < activeIds.length; i++) {
|
|
|
|
let status = statusMap.get(activeIds[i])
|
|
|
|
status = status || {}
|
|
|
|
status.P = leftElm.checked
|
|
|
|
status.D = e.target.checked
|
|
|
|
statusMap.set(activeIds[i], status)
|
|
|
|
}
|
|
|
|
changeEntitySplitStatus()
|
|
|
|
})
|
|
|
|
|
|
|
|
sliderElm.addEventListener('mousedown', () => {
|
|
|
|
sdk.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].style.cursor = 'e-resize'
|
|
|
|
document.body.addEventListener('mousemove', mousemove)
|
|
|
|
sliderElm.addEventListener('mouseup', () => {
|
|
|
|
sdk.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].style.cursor = 'unset'
|
|
|
|
document.body.removeEventListener('mousemove', mousemove)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
sdk.viewer._element.appendChild(sliderElm)
|
|
|
|
|
|
|
|
|
|
|
|
let leftBox = sdk.viewer._element.getElementsByClassName('cesium-widget')[0]
|
|
|
|
let leftCanvas = leftBox.getElementsByTagName('canvas')[0]
|
|
|
|
leftBox.style.width = '50%'
|
|
|
|
leftBox.style.left = '0px'
|
|
|
|
leftBox.style.overflow = 'hidden'
|
|
|
|
leftCanvas.style.width = '200%'
|
|
|
|
|
|
|
|
activeViewer = 0
|
|
|
|
let tools = new Tools()
|
|
|
|
sdkD = await new YJ.YJEarth(sdk.div_id)
|
|
|
|
if (getLeftClickState()) {
|
|
|
|
await new openLeftClick(sdkD)
|
|
|
|
}
|
|
|
|
if (getRightClickState()) {
|
|
|
|
await new openRightClick(sdkD)
|
|
|
|
}
|
|
|
|
if (getMoveState()) {
|
|
|
|
await new openMove(sdkD)
|
|
|
|
}
|
|
|
|
if (getMouseRightMenuStatus(sdk)) {
|
|
|
|
MouseRightMenu(sdkD, true)
|
|
|
|
}
|
|
|
|
sdkD.viewer._element.style.display = 'none'
|
|
|
|
let rightBox = document.createElement('div');
|
|
|
|
rightBox.className = 'cesium-widget cesium-widget-split'
|
|
|
|
rightBox.style.width = '50%'
|
|
|
|
rightBox.style.position = 'absolute'
|
|
|
|
rightBox.style.right = '0px'
|
|
|
|
rightBox.style.overflow = 'hidden'
|
|
|
|
let rightCanvas = sdkD.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].getElementsByTagName('canvas')[0]
|
|
|
|
rightCanvas.style.width = '200%'
|
|
|
|
rightCanvas.style.position = 'absolute'
|
|
|
|
rightCanvas.style.right = '0px'
|
|
|
|
rightBox.appendChild(rightCanvas)
|
|
|
|
sdk.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0].appendChild(rightBox)
|
|
|
|
document.getElementById(sdk.div_id).removeChild(sdkD.viewer._element)
|
|
|
|
|
|
|
|
function mousemove(a) {
|
|
|
|
if (sdk.viewer._element.getElementsByClassName('cesium-viewer-cesiumWidgetContainer')[0] === a.target ||
|
|
|
|
sdk.viewer._element.getElementsByClassName('cesium-widget')[0].getElementsByTagName('canvas')[0] === a.target ||
|
|
|
|
sdk.viewer._element.getElementsByClassName('cesium-widget')[1].getElementsByTagName('canvas')[0] === a.target) {
|
|
|
|
let offsetX = a.offsetX
|
|
|
|
if (a.offsetX < 60) {
|
|
|
|
offsetX = 60
|
|
|
|
}
|
|
|
|
if ((a.target.width - a.offsetX) < 60) {
|
|
|
|
offsetX = a.target.width - 60
|
|
|
|
}
|
|
|
|
sliderElm.style.left = (offsetX / sdk.viewer._element.scrollWidth * 100) + '%'
|
|
|
|
leftBox.style.width = (offsetX / sdk.viewer._element.scrollWidth) * 100 + '%'
|
|
|
|
leftCanvas.style.width = 100 / (offsetX / sdk.viewer._element.scrollWidth) + '%'
|
|
|
|
rightBox.style.width = (1 - (offsetX / sdk.viewer._element.scrollWidth)) * 100 + '%'
|
|
|
|
rightCanvas.style.width = 100 / (1 - (offsetX / sdk.viewer._element.scrollWidth)) + '%'
|
|
|
|
leftElm.style.left = `calc(${(offsetX / sdk.viewer._element.scrollWidth) * 100}% - 50px)`
|
|
|
|
rightElm.style.right = `calc(${(1 - (offsetX / sdk.viewer._element.scrollWidth)) * 100}% - 50px)`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await eventBind()
|
|
|
|
syncObject = { sdks: [sdk, sdkD], tools }
|
|
|
|
|
|
|
|
changeEntitySplitStatus()
|
|
|
|
// await setSplitDirection(-1)
|
|
|
|
sdk.viewer.scene.preRender.addEventListener(syncViewer, syncObject)
|
|
|
|
|
|
|
|
// sdk.viewer.imageryLayers.layerAdded.addEventListener(syncImageryLayerAdded);
|
2025-07-08 16:48:22 +08:00
|
|
|
sdk.viewer.imageryLayers.layerMoved.addEventListener(syncImageryLayerMoved);
|
2025-07-03 13:54:01 +08:00
|
|
|
// sdk.viewer.imageryLayers.layerRemoved.addEventListener(syncImageryLayerRemoved);
|
|
|
|
// sdk.viewer.imageryLayers.layerShownOrHidden.addEventListener(syncImageryLayerShownOrHidden);
|
|
|
|
|
|
|
|
if (getFlwStatus(sdk)) {
|
|
|
|
FlwStatusSwitch(sdkD, true)
|
|
|
|
}
|
|
|
|
if (getJwwStatus(sdk)) {
|
|
|
|
JwwStatusSwitch(sdkD, true)
|
|
|
|
}
|
|
|
|
if (getStatus()) {
|
|
|
|
SheetIndexStatusSwitch(sdkD, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeEntitySplitStatus(v) {
|
|
|
|
let value
|
|
|
|
// if (v === undefined || v === null) {
|
|
|
|
// if (leftElm.checked && rightElm.checked) {
|
|
|
|
// value = 0
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (leftElm.checked) {
|
|
|
|
// value = -1
|
|
|
|
// }
|
|
|
|
// if (rightElm.checked) {
|
|
|
|
// value = 1
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// value = v
|
|
|
|
// }
|
|
|
|
for (let [key, status] of statusMap) {
|
|
|
|
if (!status) {
|
|
|
|
value = -1
|
|
|
|
}
|
|
|
|
else if (status.P && status.D) {
|
|
|
|
value = 0
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (status.P) {
|
|
|
|
value = -1
|
|
|
|
}
|
|
|
|
if (status.D) {
|
|
|
|
value = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else {
|
|
|
|
// value = v
|
|
|
|
// }
|
|
|
|
let entity = sdk.entityMap.get(key)
|
|
|
|
// entity && (entity.splitDirection = value)
|
|
|
|
entity && (setSplitDirection(value, key))
|
|
|
|
}
|
|
|
|
// if (activeIds && activeIds.length > 0) {
|
|
|
|
// for (let i = 0; i < activeIds.length; i++) {
|
|
|
|
// let entity = sdk.entityMap.get(activeIds[i])
|
|
|
|
// // entity && (entity.splitDirection = value)
|
|
|
|
// console.log(entity, activeIds, value)
|
|
|
|
// entity && (setSplitDirection(value, entity.options.id))
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// sdk.entityMap.forEach((item, key) => {
|
|
|
|
// // item.splitDirection = value
|
|
|
|
// setSplitDirection(value, item.options.id)
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// async function syncData(entityId) {
|
|
|
|
// if (!sdkP) {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// let entityMapP = sdkP.entityMap
|
|
|
|
// let entityMapD = (sdkD && sdkD.entityMap)
|
|
|
|
// if (entityId) {
|
|
|
|
// let thatD = entityMapD.get(entityId)
|
|
|
|
// if (thatD) {
|
|
|
|
// let direction = 0
|
|
|
|
// if(thatD.show) {
|
|
|
|
// direction =
|
|
|
|
// }
|
|
|
|
// thatD.remove()
|
|
|
|
// }
|
|
|
|
// setSplitDirection(entityId)
|
|
|
|
// }
|
|
|
|
// // else {
|
|
|
|
// // for (let [key, thatP] of sdkP.entityMap) {
|
|
|
|
// // if (!thatP || !thatP.show) {
|
|
|
|
// // continue
|
|
|
|
// // }
|
|
|
|
// // else {
|
|
|
|
// // setEvent(key)
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
|
|
|
|
async function setSplitDirection(v, id, isoff = false, entityId) {
|
|
|
|
if (!sdkP) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let entityMapP = sdkP.entityMap
|
|
|
|
let entityMapD = (sdkD && sdkD.entityMap)
|
|
|
|
if (id) {
|
|
|
|
let thatP = entityMapP.get(id)
|
|
|
|
if (!thatP || !thatP.show) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
setEvent(id, entityId)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let [key, thatP] of sdkP.entityMap) {
|
|
|
|
if (!thatP || !thatP.show) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setEvent(key, entityId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function setEvent(id, entityId) {
|
|
|
|
let status = {}
|
|
|
|
let thatP = entityMapP.get(id)
|
|
|
|
if (!thatP && !thatP.show) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let thatD = (entityMapD && entityMapD.get(id))
|
|
|
|
if (thatD) {
|
|
|
|
switch (v) {
|
|
|
|
case null:
|
|
|
|
case void 0:
|
|
|
|
case 0:
|
|
|
|
case '0':
|
|
|
|
status.P = true
|
|
|
|
status.D = true
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
if (thatP.entity && thatP.modelShow && !thatP.firstPersonView) {
|
|
|
|
thatP.entity.show = true
|
|
|
|
}
|
|
|
|
if (thatP.line && thatP.lineShow) {
|
|
|
|
thatP.line.show = true
|
|
|
|
}
|
|
|
|
if (thatP.realTimeLine && thatP.realTimeRoute) {
|
|
|
|
thatP.realTimeLine.show = true
|
|
|
|
}
|
|
|
|
if (thatP.TweenAnimate) {
|
|
|
|
let state = thatP.state
|
|
|
|
if (state) {
|
|
|
|
thatPstate(false)
|
|
|
|
}
|
|
|
|
thatD.setMovePositionByDistance(thatP.TweenAnimate._object.distance)
|
|
|
|
thatPstate(state)
|
|
|
|
}
|
|
|
|
|
|
|
|
function thatPstate(v) {
|
|
|
|
thatP.options.state = v
|
|
|
|
cancelAnimationFrame(thatP._requestAnimationFrameEventId)
|
|
|
|
if (thatP.editObj) {
|
|
|
|
thatP.editObj.destroy()
|
|
|
|
thatP.editObj = null
|
|
|
|
}
|
|
|
|
if (thatP.TweenAnimate) {
|
|
|
|
clearTimeout(thatP.TweenAnimate.timeout)
|
|
|
|
if (v) {
|
|
|
|
thatP.lineEdit = false
|
|
|
|
if (thatP.TweenAnimate.isPlaying()) {
|
|
|
|
thatP.TweenAnimate.timeout = setTimeout(() => {
|
|
|
|
thatP.TweenAnimate.resume()
|
|
|
|
}, thatP.options.delay);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.TweenAnimate.delay(thatP.delay).start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let positionCamera = { ...thatP.sdk.viewer.camera._position }
|
|
|
|
thatP._requestAnimationFrameEventId = requestAnimationFrame(function fn() {
|
|
|
|
if (thatP.firstPersonView) {
|
|
|
|
thatP.sdk.viewer.camera.setView({
|
|
|
|
destination: { ...positionCamera },
|
|
|
|
orientation: {
|
|
|
|
heading: thatP.sdk.viewer.camera.heading,
|
|
|
|
pitch: thatP.sdk.viewer.camera.pitch,
|
|
|
|
roll: thatP.sdk.viewer.camera.roll
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
thatP._requestAnimationFrameEventId = requestAnimationFrame(fn)
|
|
|
|
})
|
|
|
|
thatP.TweenAnimate.pause()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (v) {
|
|
|
|
let positions = thatP.renewLinePositions(thatP.options.line.positions)
|
|
|
|
thatP.modelMove(positions)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (thatP.type === 'vector') {
|
|
|
|
if (thatP.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
if (thatP.entity.entities.values[i].id === entityId) {
|
|
|
|
thatP.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
thatP.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.entity && (thatP.entity.show = true)
|
|
|
|
}
|
|
|
|
if (thatP.type === 'PincerArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
thatP.setSpreadProgressByTime(thatP.TweenAnimate._object.distance1 / thatP.TweenAnimate._valuesEnd.distance1 * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thatP.type === 'AttackArrowObject' || thatP.type === 'StraightArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
thatP.setSpreadProgressByTime(thatP.TweenAnimate._object.distance / thatP.TweenAnimate._valuesEnd.distance * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = thatP.textShow
|
|
|
|
thatD.textShow = thatP.textShow
|
|
|
|
}
|
|
|
|
if (thatP.label && thatP.labelShow) {
|
2025-08-12 11:50:47 +08:00
|
|
|
thatP.labelShow = true
|
2025-07-03 13:54:01 +08:00
|
|
|
}
|
|
|
|
if (thatD.label) {
|
|
|
|
thatD.label.options.ground = false
|
|
|
|
}
|
|
|
|
if (thatD.type === 'vector') {
|
|
|
|
if (thatD.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
if (thatD.entity.entities.values[i].id === entityId) {
|
|
|
|
thatD.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
thatD.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatD.show = true
|
|
|
|
}
|
|
|
|
if (thatD.type === 'TrajectoryMotion') {
|
|
|
|
thatD.firstPersonView = thatP.firstPersonView
|
|
|
|
}
|
|
|
|
if (thatD.type === 'Explosion') {
|
|
|
|
thatD.entity.imgIndex = thatP.entity.imgIndex
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case 1:
|
|
|
|
case '1':
|
|
|
|
status.P = false
|
|
|
|
status.D = true
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
thatP.entity && (thatP.entity.show = false)
|
|
|
|
thatP.line && (thatP.line.show = false)
|
|
|
|
thatP.realTimeLine && (thatP.realTimeLine.show = false)
|
|
|
|
}
|
|
|
|
else if (thatP.type === 'vector') {
|
|
|
|
if (thatP.entity) {
|
|
|
|
if (!entityId) {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
thatP.entity.entities.values[i].show = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
if (thatP.entity.entities.values[i].id === entityId) {
|
|
|
|
thatP.entity.entities.values[i].show = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.entity && (thatP.entity.show = false)
|
|
|
|
}
|
|
|
|
if (thatP.type === 'PincerArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
thatP.setSpreadProgressByTime(thatP.TweenAnimate._object.distance1 / thatP.TweenAnimate._valuesEnd.distance1 * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thatP.type === 'AttackArrowObject' || thatP.type === 'StraightArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
thatP.setSpreadProgressByTime(thatP.TweenAnimate._object.distance / thatP.TweenAnimate._valuesEnd.distance * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = false
|
|
|
|
thatD.textShow = thatP.textShow
|
|
|
|
}
|
|
|
|
if (thatP.label) {
|
|
|
|
thatP.label.entity.show = false
|
|
|
|
}
|
|
|
|
if (thatD.label) {
|
|
|
|
thatD.label.options.ground = false
|
|
|
|
}
|
|
|
|
if (thatD.type === 'vector') {
|
|
|
|
if (thatD.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
if (thatD.entity.entities.values[i].id === entityId) {
|
|
|
|
thatD.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
thatD.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatD.show = true
|
|
|
|
}
|
|
|
|
if (thatD.type === 'TrajectoryMotion') {
|
|
|
|
thatD.firstPersonView = thatP.firstPersonView
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case -1:
|
|
|
|
case '-1':
|
|
|
|
status.P = true
|
|
|
|
status.D = false
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
if (thatP.entity && thatP.modelShow && !thatP.firstPersonView) {
|
|
|
|
thatP.entity.show = true
|
|
|
|
}
|
|
|
|
if (thatP.line && thatP.lineShow) {
|
|
|
|
thatP.line.show = true
|
|
|
|
}
|
|
|
|
if (thatP.realTimeLine && thatP.realTimeRoute) {
|
|
|
|
thatP.realTimeLine.show = true
|
|
|
|
}
|
|
|
|
// if (thatP.TweenAnimate) {
|
|
|
|
// let state = thatP.state
|
|
|
|
// if (state) {
|
|
|
|
// thatP.state = false
|
|
|
|
// }
|
|
|
|
// thatD.setMovePositionByDistance(thatP.TweenAnimate._object.distance)
|
|
|
|
// thatP.state = state
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
else if (thatP.type === 'vector') {
|
|
|
|
if (thatP.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
if (thatP.entity.entities.values[i].id === entityId) {
|
|
|
|
thatP.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
thatP.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.entity && (thatP.entity.show = true)
|
|
|
|
}
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = thatP.textShow
|
|
|
|
thatD.textShow = false
|
|
|
|
}
|
|
|
|
if (thatP.label && thatP.labelShow) {
|
|
|
|
thatP.label.entity.show = true
|
|
|
|
}
|
|
|
|
if (thatD.label) {
|
|
|
|
thatD.label.options.ground = false
|
|
|
|
}
|
|
|
|
if (thatP.type === 'terrain') {
|
|
|
|
thatD.show = true
|
|
|
|
}
|
|
|
|
else if (thatD.type === 'vector') {
|
|
|
|
if (thatD.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
if (thatD.entity.entities.values[i].id === entityId) {
|
|
|
|
if (thatD.entity.entities.values[i].id === entityId) {
|
|
|
|
thatD.entity.entities.values[i].show = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < thatD.entity.entities.values.length; i++) {
|
|
|
|
thatD.entity.entities.values[i].show = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
thatD.show = false
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let options = syncObject.tools.deepCopyObj(thatP.options)
|
|
|
|
let target
|
|
|
|
switch (v) {
|
|
|
|
case null:
|
|
|
|
case void 0:
|
|
|
|
case 0:
|
|
|
|
case '0':
|
|
|
|
status.P = true
|
|
|
|
status.D = true
|
|
|
|
options.show = true
|
2025-07-08 16:48:22 +08:00
|
|
|
if(thatP.type==='layer') {
|
|
|
|
options.layer_index = thatP.layer_index
|
|
|
|
}
|
2025-07-03 13:54:01 +08:00
|
|
|
target = await new thatP.constructor(sdkD, options)
|
|
|
|
if (thatP.onClick) {
|
|
|
|
target.onClick = thatP.onClick
|
|
|
|
}
|
|
|
|
if (thatP.onRightClick) {
|
|
|
|
target.onRightClick = thatP.onRightClick
|
|
|
|
}
|
|
|
|
if (thatP.onMouseMove) {
|
|
|
|
target.onMouseMove = thatP.onMouseMove
|
|
|
|
}
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
if (thatP.entity && thatP.modelShow && !thatP.firstPersonView) {
|
|
|
|
thatP.entity.show = true
|
|
|
|
}
|
|
|
|
if (thatP.line && thatP.lineShow) {
|
|
|
|
thatP.line.show = true
|
|
|
|
}
|
|
|
|
if (thatP.realTimeLine && thatP.realTimeRoute) {
|
|
|
|
thatP.realTimeLine.show = true
|
|
|
|
}
|
|
|
|
if (thatP.TweenAnimate) {
|
|
|
|
let state = thatP.state
|
|
|
|
if (state) {
|
|
|
|
thatP.state = false
|
|
|
|
}
|
|
|
|
target.setMovePositionByDistance(thatP.TweenAnimate._object.distance)
|
|
|
|
thatP.state = state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (target.type !== 'glb' && target.on) {
|
|
|
|
if (target.type === 'vector') {
|
|
|
|
target.data = thatP.data
|
|
|
|
}
|
|
|
|
await target.on()
|
|
|
|
}
|
|
|
|
if (target.type === 'Explosion') {
|
|
|
|
target.entity.imgIndex = thatP.entity.imgIndex
|
|
|
|
}
|
|
|
|
if (target.type === 'PincerArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
target.setSpreadProgressByTime(thatP.TweenAnimate._object.distance1 / thatP.TweenAnimate._valuesEnd.distance1 * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (target.type === 'AttackArrowObject' || target.type === 'StraightArrowObject') {
|
|
|
|
if (thatP.TweenAnimate && !thatP.TweenAnimate._isPaused) {
|
|
|
|
target.setSpreadProgressByTime(thatP.TweenAnimate._object.distance / thatP.TweenAnimate._valuesEnd.distance * thatP.spreadTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thatP.type === 'vector') {
|
|
|
|
target.load(() => {
|
|
|
|
if (target.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < target.entity.entities.values.length; i++) {
|
|
|
|
if (target.entity.entities.values[i].id === entityId) {
|
|
|
|
target.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < target.entity.entities.values.length; i++) {
|
|
|
|
target.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
thatP.entity && (thatP.entity.show = true)
|
|
|
|
}
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = thatP.textShow
|
|
|
|
target.textShow = thatP.textShow
|
|
|
|
}
|
|
|
|
if (thatP.label && thatP.labelShow) {
|
|
|
|
thatP.label.entity.show = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case 1:
|
|
|
|
case '1':
|
|
|
|
status.P = false
|
|
|
|
status.D = true
|
|
|
|
options.show = true
|
2025-07-08 16:48:22 +08:00
|
|
|
if(thatP.type==='layer') {
|
|
|
|
options.layer_index = thatP.layer_index
|
|
|
|
}
|
2025-07-03 13:54:01 +08:00
|
|
|
target = await new thatP.constructor(sdkD, options)
|
|
|
|
if (thatP.onClick) {
|
|
|
|
target.onClick = thatP.onClick
|
|
|
|
}
|
|
|
|
if (thatP.onRightClick) {
|
|
|
|
target.onRightClick = thatP.onRightClick
|
|
|
|
}
|
|
|
|
if (thatP.onMouseMove) {
|
|
|
|
target.onMouseMove = thatP.onMouseMove
|
|
|
|
}
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
if (thatP.entity && thatP.modelShow) {
|
|
|
|
thatP.entity.show = false
|
|
|
|
}
|
|
|
|
if (thatP.line && thatP.lineShow) {
|
|
|
|
thatP.line.show = false
|
|
|
|
}
|
|
|
|
if (thatP.realTimeLine && thatP.realTimeRoute) {
|
|
|
|
thatP.realTimeLine.show = false
|
|
|
|
}
|
|
|
|
if (thatP.TweenAnimate) {
|
|
|
|
let state = thatP.state
|
|
|
|
if (state) {
|
|
|
|
thatP.state = false
|
|
|
|
}
|
|
|
|
target.setMovePositionByDistance(thatP.TweenAnimate._object.distance)
|
|
|
|
thatP.state = state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (target.type !== 'glb' && target.on) {
|
|
|
|
if (thatP.type === 'vector') {
|
|
|
|
target.data = thatP.data
|
|
|
|
if (thatP.entity) {
|
|
|
|
for (let i = 0; i < thatP.entity.entities.values.length; i++) {
|
|
|
|
thatP.entity.entities.values[i].show = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await target.on()
|
|
|
|
}
|
|
|
|
if (thatP.type === 'vector') {
|
|
|
|
if (target.entity) {
|
|
|
|
if (entityId) {
|
|
|
|
for (let i = 0; i < target.entity.entities.values.length; i++) {
|
|
|
|
if (target.entity.entities.values[i].id === entityId) {
|
|
|
|
target.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let i = 0; i < target.entity.entities.values.length; i++) {
|
|
|
|
target.entity.entities.values[i].show = thatP.entity.entities.values[i]._customShow === false ? false : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.entity && (thatP.entity.show = false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = false
|
|
|
|
target.textShow = thatP.textShow
|
|
|
|
}
|
|
|
|
if (thatP.label) {
|
|
|
|
thatP.label.entity.show = false
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case -1:
|
|
|
|
case '-1':
|
|
|
|
status.P = true
|
|
|
|
status.D = false
|
|
|
|
if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
if (thatP.entity && thatP.modelShow && !thatP.firstPersonView) {
|
|
|
|
thatP.entity.show = true
|
|
|
|
}
|
|
|
|
if (thatP.line && thatP.lineShow) {
|
|
|
|
thatP.line.show = true
|
|
|
|
}
|
|
|
|
if (thatP.realTimeLine && thatP.realTimeRoute) {
|
|
|
|
thatP.realTimeLine.show = true
|
|
|
|
}
|
|
|
|
// if (thatP.TweenAnimate) {
|
|
|
|
// let state = thatP.state
|
|
|
|
// if (state) {
|
|
|
|
// thatP.state = false
|
|
|
|
// }
|
|
|
|
// target.setMovePositionByDistance(thatP.TweenAnimate._object.distance)
|
|
|
|
// thatP.state = state
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatP.entity && (thatP.entity.show = true)
|
|
|
|
if (thatP.type === 'terrain') {
|
|
|
|
options.show = true
|
|
|
|
target = await new thatP.constructor(sdkD, options)
|
|
|
|
if (thatP.onClick) {
|
|
|
|
target.onClick = thatP.onClick
|
|
|
|
}
|
|
|
|
if (thatP.onRightClick) {
|
|
|
|
target.onRightClick = thatP.onRightClick
|
|
|
|
}
|
|
|
|
if (thatP.onMouseMove) {
|
|
|
|
target.onMouseMove = thatP.onMouseMove
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
|
|
|
thatP.text.show = thatP.textShow
|
|
|
|
target.textShow = false
|
|
|
|
}
|
|
|
|
if (thatP.label && thatP.labelShow) {
|
|
|
|
thatP.label.entity.show = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isoff) {
|
|
|
|
statusMap.set(id, status)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isoff) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// let leftElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
// let rightElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
// if (leftElm && rightElm) {
|
|
|
|
// switch (v) {
|
|
|
|
// case null:
|
|
|
|
// case void 0:
|
|
|
|
// case 0:
|
|
|
|
// case '0':
|
|
|
|
// leftElm.checked = true
|
|
|
|
// rightElm.checked = true
|
|
|
|
// break
|
|
|
|
// case 1:
|
|
|
|
// case '1':
|
|
|
|
// leftElm.checked = false
|
|
|
|
// rightElm.checked = true
|
|
|
|
// break
|
|
|
|
// case -1:
|
|
|
|
// case '-1':
|
|
|
|
// leftElm.checked = true
|
|
|
|
// rightElm.checked = false
|
|
|
|
// break
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncEntities(entities1, entities2) {
|
|
|
|
if (!sdkP) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (sdkD) {
|
|
|
|
if (Array.isArray(entities1) || Array.isArray(entities2)) {
|
|
|
|
entities1 = null
|
|
|
|
entities2 = null
|
|
|
|
}
|
|
|
|
if (!entities1) {
|
|
|
|
entities1 = sdkD.viewer.entities
|
|
|
|
}
|
|
|
|
if (!entities2) {
|
|
|
|
entities2 = sdkP.viewer.entities
|
|
|
|
}
|
|
|
|
let entities2D = entities1
|
|
|
|
let entities3D = entities2
|
|
|
|
for (let i = entities2D.values.length - 1; i >= 0; i--) {
|
|
|
|
let flag = false
|
|
|
|
for (let m = entities3D.values.length - 1; m >= 0; m--) {
|
|
|
|
if (entities2D.values[i].id === entities3D.values[m].id) {
|
|
|
|
flag = true
|
|
|
|
entities2D.values[i] === entities3D.values[m]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!flag) {
|
|
|
|
entities2D.remove(entities2D.values[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let m = entities3D.values.length - 1; m >= 0; m--) {
|
|
|
|
let flag = false
|
|
|
|
for (let i = entities2D.values.length - 1; i >= 0; i--) {
|
|
|
|
if (entities2D.values[i].id === entities3D.values[m].id) {
|
|
|
|
flag = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!flag) {
|
|
|
|
let entity = entities2D.add(entities3D.values[m])
|
|
|
|
// if (entity.rectangle) {
|
|
|
|
// // 设置高度,否则在某些位置无法显示,但色彩会变暗
|
|
|
|
// entity.rectangle.height = 0
|
|
|
|
// console.log('242342354235',entities3D.values[m])
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function syncDataSources(dataSources, type) {
|
|
|
|
if (!sdkP) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (sdkD) {
|
|
|
|
let dataSources2D = sdkD.viewer.dataSources
|
|
|
|
if (dataSources) {
|
|
|
|
for (let i = dataSources2D._dataSources.length - 1; i >= 0; i--) {
|
|
|
|
if (dataSources2D._dataSources[i].name === dataSources.name) {
|
|
|
|
if (type === 'entities') {
|
|
|
|
syncEntities(dataSources2D._dataSources[i].entities, dataSources.entities)
|
|
|
|
}
|
|
|
|
if (type === 'clustering') {
|
|
|
|
dataSources2D._dataSources[i].clustering.enabled = dataSources.clustering.enabled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// for (let m = dataSources3D._dataSources.length - 1; m >= 0; m--) {
|
|
|
|
// let flag = false
|
|
|
|
// for (let i = dataSources2D._dataSources.length - 1; i >= 0; i--) {
|
|
|
|
// console.log(dataSources2D._dataSources[i].name, dataSources3D._dataSources[m].name)
|
|
|
|
// if (dataSources2D._dataSources[i].name === dataSources3D._dataSources[m].name) {
|
|
|
|
// flag = true
|
|
|
|
// break
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (!flag) {
|
|
|
|
// dataSources2D.add(dataSources3D._dataSources[m])
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function syncImageryLayerAdded(layer, index) {
|
|
|
|
sdkD.viewer.imageryLayers.addImageryProvider(layer.imageryProvider, index)
|
|
|
|
}
|
|
|
|
function syncImageryLayerMoved(layer, newindxe, oldindex) {
|
2025-07-08 16:48:22 +08:00
|
|
|
let layerD
|
|
|
|
for (let i = 0; i < sdkD.viewer.imageryLayers._layers.length; i++) {
|
|
|
|
if (sdkD.viewer.imageryLayers._layers[i]._id === layer._id) {
|
|
|
|
layerD = sdkD.viewer.imageryLayers._layers[i]
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2025-07-03 13:54:01 +08:00
|
|
|
if (!layerD) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// 移到最底层
|
|
|
|
if (newindxe === 0) {
|
|
|
|
sdkD.viewer.imageryLayers.lowerToBottom(layerD)
|
|
|
|
}
|
|
|
|
// 移到最高层
|
2025-07-08 16:48:22 +08:00
|
|
|
else if (newindxe === sdkD.viewer.imageryLayers._layers.length - 1) {
|
2025-07-03 13:54:01 +08:00
|
|
|
sdkD.viewer.imageryLayers.raiseToTop(layerD)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (newindxe < oldindex) {
|
2025-07-08 16:48:22 +08:00
|
|
|
if(newindxe<sdkD.viewer.imageryLayers._layers.length-1) {
|
|
|
|
sdkD.viewer.imageryLayers.lower(layerD)
|
|
|
|
}
|
2025-07-03 13:54:01 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
sdkD.viewer.imageryLayers.raise(layerD)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function syncImageryLayerRemoved(layer, index) {
|
|
|
|
let layerD = sdkD.viewer.imageryLayers._layers[index]
|
|
|
|
if (!layerD) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
sdkD.viewer.imageryLayers.remove(layerD)
|
|
|
|
}
|
|
|
|
function syncImageryLayerShownOrHidden(layer, index, state) {
|
|
|
|
let layerD = sdkD.viewer.imageryLayers._layers[index]
|
|
|
|
if (!layerD) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
layerD.show = state
|
|
|
|
}
|
|
|
|
|
|
|
|
async function syncPrimitives(primitive) {
|
|
|
|
if (!sdkP) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (sdkD) {
|
|
|
|
// await sdkD.viewer.scene.primitives.remove(primitive)
|
|
|
|
// await sdkD.viewer.scene.primitives.add(primitive)
|
|
|
|
let primitives2D = sdkD.viewer.scene.primitives._primitives
|
|
|
|
let primitives3D = sdkP.viewer.scene.primitives._primitives
|
|
|
|
// console.log(primitives2D, primitives3D)
|
|
|
|
// setTimeout(() => {
|
|
|
|
// sdkD.viewer.scene.primitives._primitives[1] = sdkP.viewer.scene.primitives._primitives[1]
|
|
|
|
// }, 2000);
|
|
|
|
for (let i = primitives2D.length - 1; i >= 1; i--) {
|
|
|
|
let flag = false
|
|
|
|
for (let m = primitives3D.length - 1; m >= 1; m--) {
|
|
|
|
if (primitives3D[m].id && primitives2D[m].id && (primitives3D[m].id === primitives2D[i].id)) {
|
|
|
|
flag = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!flag) {
|
|
|
|
sdkD.viewer.scene.primitives.remove(primitives2D[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let m = primitives3D.length - 1; m >= 1; m--) {
|
|
|
|
let flag = false
|
|
|
|
for (let i = primitives2D.length - 1; i >= 1; i--) {
|
|
|
|
if (primitives3D[m].id && primitives2D[m].id && (primitives3D[m].id === primitives2D[i].id)) {
|
|
|
|
flag = true
|
|
|
|
primitives2D[i].show = primitives3D[m].show
|
|
|
|
primitives2D[i].startColor = primitives3D[m].startColor
|
|
|
|
primitives2D[i].endColor = primitives3D[m].endColor
|
|
|
|
primitives2D[i].minimumSpeed = primitives3D[m].minimumSpeed
|
|
|
|
primitives2D[i].maximumSpeed = primitives3D[m].maximumSpeed
|
|
|
|
primitives2D[i].minimumParticleLife = primitives3D[m].minimumParticleLife
|
|
|
|
primitives2D[i].maximumParticleLife = primitives3D[m].maximumParticleLife
|
|
|
|
primitives2D[i].startScale = primitives3D[m].startScale
|
|
|
|
primitives2D[i].endScale = primitives3D[m].endScale
|
|
|
|
primitives2D[i].emissionRate = primitives3D[m].emissionRate
|
|
|
|
primitives2D[i].particleSize = primitives3D[m].particleSize
|
|
|
|
primitives2D[i].modelMatrix = primitives3D[m].modelMatrix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!flag) {
|
|
|
|
sdkD.viewer.scene.primitives.add(primitives3D[m])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function eventBind() {
|
|
|
|
let handler0 = new Cesium.ScreenSpaceEventHandler(
|
|
|
|
sdkP.viewer._element.getElementsByClassName('cesium-widget')[0]
|
|
|
|
)
|
|
|
|
handler0.setInputAction(() => {
|
|
|
|
activeViewer = 0
|
|
|
|
}, Cesium.ScreenSpaceEventType.LEFT_DOWN)
|
|
|
|
handler0.setInputAction(() => {
|
|
|
|
activeViewer = 0
|
|
|
|
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN)
|
|
|
|
handler0.setInputAction(() => {
|
|
|
|
activeViewer = 0
|
|
|
|
}, Cesium.ScreenSpaceEventType.WHEEL)
|
|
|
|
handlers.push(handler0)
|
|
|
|
|
|
|
|
let distanceLegendDiv = document.getElementById('distanceLegendDiv')
|
|
|
|
function distanceLegendDivMouseMove(e) {
|
|
|
|
activeViewer = 0
|
|
|
|
}
|
|
|
|
distanceLegendDiv.addEventListener('mousemove', distanceLegendDivMouseMove)
|
|
|
|
handlers.push({
|
|
|
|
destroy: () => {
|
|
|
|
distanceLegendDiv.removeEventListener('mousemove', distanceLegendDivMouseMove)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
let handler1 = new Cesium.ScreenSpaceEventHandler(
|
|
|
|
sdkP.viewer._element.getElementsByClassName('cesium-widget')[1]
|
|
|
|
)
|
|
|
|
handler1.setInputAction(() => {
|
|
|
|
activeViewer = 1
|
|
|
|
closeRotateAround(sdkP)
|
|
|
|
}, Cesium.ScreenSpaceEventType.LEFT_DOWN)
|
|
|
|
handler1.setInputAction(() => {
|
|
|
|
activeViewer = 1
|
|
|
|
closeRotateAround(sdkP)
|
|
|
|
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN)
|
|
|
|
handler1.setInputAction(() => {
|
|
|
|
activeViewer = 1
|
|
|
|
closeRotateAround(sdkP)
|
|
|
|
}, Cesium.ScreenSpaceEventType.WHEEL)
|
|
|
|
handlers.push(handler1)
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncViewer() {
|
|
|
|
let sdk = this.sdks[activeViewer]
|
|
|
|
let sdk2
|
|
|
|
if (activeViewer === 0) {
|
|
|
|
sdk2 = this.sdks[1]
|
|
|
|
}
|
|
|
|
else if (activeViewer === 1) {
|
|
|
|
sdk2 = this.sdks[0]
|
|
|
|
}
|
|
|
|
let destination = sdk.viewer.camera.position
|
|
|
|
// if (this.sdks[0].viewer.trackedEntity) {
|
|
|
|
// // console.log(sdk,sdk2)
|
|
|
|
// // sdk2.viewer.camera.setView({
|
|
|
|
// // orientation: {
|
|
|
|
// // heading: sdk.viewer.camera.heading,
|
|
|
|
// // pitch: sdk.viewer.camera.pitch,
|
|
|
|
// // roll: sdk.viewer.camera.roll
|
|
|
|
// // }
|
|
|
|
// // })
|
|
|
|
// // if(sdk2.viewer.trackedEntity) {
|
|
|
|
// // sdk2.viewer.trackedEntity.position = sdk.viewer.trackedEntity.position
|
|
|
|
// // }
|
|
|
|
// // else {
|
|
|
|
// // let trackedEntity = sdk2.viewer.entities.add(sdk.viewer.trackedEntity)
|
|
|
|
// // sdk2.viewer.trackedEntity = trackedEntity
|
|
|
|
// // }
|
|
|
|
// // sdk2.viewer.camera.position = sdk.viewer.camera.position
|
|
|
|
// if(!sdk.viewer.trackedEntity) {
|
|
|
|
// let id = this.sdks[0].viewer.trackedEntity.id
|
|
|
|
// let trackedEntity = sdk2.viewer.entities.getById(id)
|
|
|
|
// if(trackedEntity) {
|
|
|
|
// trackedEntity.position = this.sdks[0].viewer.trackedEntity.position
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// trackedEntity = sdk2.viewer.entities.add(sdk.viewer.trackedEntity)
|
|
|
|
// }
|
|
|
|
// sdk.viewer.trackedEntity = trackedEntity
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// sdk.viewer.trackedEntity.position = this.sdks[0].viewer.trackedEntity.position
|
|
|
|
// }
|
|
|
|
// let distance = Cesium.Cartesian3.distance(sdk.viewer.trackedEntity.position._value, sdk.viewer.camera.positionWC);
|
|
|
|
// sdk2.viewer.camera.lookAt(
|
|
|
|
// this.sdks[0].viewer.trackedEntity.position._value,
|
|
|
|
// new Cesium.HeadingPitchRange(sdk.viewer.camera.heading, sdk.viewer.camera.pitch, distance)
|
|
|
|
// )
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if(this.sdks[1].viewer.trackedEntity) {
|
|
|
|
// this.sdks[1].viewer.entities.remove(this.sdks[1].viewer.trackedEntity)
|
|
|
|
// this.sdks[1].viewer.trackedEntity = null
|
|
|
|
// destination = sdk.viewer.camera.position
|
|
|
|
// }
|
|
|
|
// sdk2.viewer.camera.setView({
|
|
|
|
// destination: destination,
|
|
|
|
// orientation: {
|
|
|
|
// heading: sdk.viewer.camera.heading,
|
|
|
|
// pitch: sdk.viewer.camera.pitch,
|
|
|
|
// roll: sdk.viewer.camera.roll
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
|
|
|
|
sdk2.viewer.camera.setView({
|
|
|
|
destination: destination,
|
|
|
|
orientation: {
|
|
|
|
heading: sdk.viewer.camera.heading,
|
|
|
|
pitch: sdk.viewer.camera.pitch,
|
|
|
|
roll: sdk.viewer.camera.roll
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function getState() {
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
|
|
|
|
function getActiveId() {
|
|
|
|
return activeIds
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActiveId(ids = []) {
|
|
|
|
// console.log('=================================')
|
|
|
|
if (Array.isArray(ids)) {
|
|
|
|
activeIds = ids
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
activeIds = [ids]
|
|
|
|
}
|
|
|
|
if (!sdkP || !sdkD) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let leftElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
let rightElm = sdkP.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
if (!ids || ids.length === 0) {
|
|
|
|
if (leftElm && rightElm) {
|
|
|
|
leftElm.style.display = 'none'
|
|
|
|
rightElm.style.display = 'none'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (leftElm && rightElm) {
|
|
|
|
let left = 0
|
|
|
|
let right = 0
|
|
|
|
for (let i = 0; i < activeIds.length; i++) {
|
|
|
|
let status = statusMap.get(activeIds[i])
|
|
|
|
if (!status) {
|
|
|
|
status = { P: true, D: false }
|
|
|
|
statusMap.set(activeIds[i], status)
|
|
|
|
}
|
|
|
|
if (status.P) {
|
|
|
|
left++
|
|
|
|
}
|
|
|
|
if (status.D) {
|
|
|
|
right++
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let thatP = sdkP.entityMap.get(activeIds[i])
|
|
|
|
let thatD = sdkD.entityMap.get(activeIds[i])
|
|
|
|
if (!thatP || (thatP.type === 'terrain' || !thatP.show)) {
|
|
|
|
leftElm.style.display = 'none'
|
|
|
|
rightElm.style.display = 'none'
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
leftElm.style.display = 'unset'
|
|
|
|
rightElm.style.display = 'unset'
|
|
|
|
leftElm.checked = false
|
|
|
|
rightElm.checked = false
|
|
|
|
|
|
|
|
|
|
|
|
// if (thatP) {
|
|
|
|
// if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
// if (thatP.entity && (thatP.modelShow || thatP.lineShow || thatP.labelShow || thatP.realTimeRoute) && (thatP.entity.show || thatP.line.show || (thatP.label && thatP.label.entity.show) || thatP.realTimeLine.show)) {
|
|
|
|
// leftElm.checked = true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else if (thatP.type === 'vector') {
|
|
|
|
// leftElm.checked = status.P
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (thatP.entity && thatP.entity.show) {
|
|
|
|
// leftElm.checked = true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (thatD) {
|
|
|
|
// if (thatP.type === 'TrajectoryMotion') {
|
|
|
|
// if (thatD.show && thatD.entity && (thatD.modelShow || thatD.lineShow || thatD.labelShow || thatD.realTimeRoute) && (thatD.entity.show || thatD.line.show || (thatD.label && thatD.label.entity.show) || thatD.realTimeLine.show)) {
|
|
|
|
// rightElm.checked = true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else if (thatP.type === 'vector') {
|
|
|
|
// rightElm.checked = status.D
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (thatD.show) {
|
|
|
|
// rightElm.checked = true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
if (!left && !right) {
|
|
|
|
left++
|
|
|
|
}
|
|
|
|
leftElm.checked = left ? true : false
|
|
|
|
rightElm.checked = right ? true : false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncSplitData(sdk, id, entityId) {
|
|
|
|
if (!sdkP || !sdkD || sdk !== sdkP || !id) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let status = statusMap.get(id)
|
|
|
|
let thatP = sdkP.entityMap.get(id)
|
|
|
|
let thatD = sdkD.entityMap.get(id)
|
|
|
|
if (thatP) {
|
|
|
|
let value
|
|
|
|
if (status) {
|
|
|
|
if (status.P && status.D) {
|
|
|
|
value = 0
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (status.P) {
|
|
|
|
value = -1
|
|
|
|
}
|
|
|
|
if (status.D) {
|
|
|
|
value = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let leftElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
let rightElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
if (leftElm.style.display === 'none' || rightElm.style.display === 'none') {
|
|
|
|
value = -1
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (leftElm.checked && rightElm.checked) {
|
|
|
|
value = 0
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (leftElm.checked) {
|
|
|
|
value = -1
|
|
|
|
}
|
|
|
|
if (rightElm.checked) {
|
|
|
|
value = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thatD) {
|
|
|
|
thatD.options = JSON.parse(JSON.stringify(thatP.options))
|
|
|
|
thatD.originalOptions = JSON.parse(JSON.stringify(thatP.options))
|
|
|
|
if (thatP.oldData) {
|
|
|
|
thatD.oldData = JSON.parse(JSON.stringify(thatP.oldData))
|
|
|
|
}
|
|
|
|
if (thatD.type === 'TrajectoryMotion') {
|
|
|
|
thatD.height = thatD.options.height
|
|
|
|
}
|
|
|
|
thatD.reset && thatD.reset()
|
|
|
|
|
|
|
|
|
|
|
|
if (thatP.show) {
|
|
|
|
setSplitDirection(value, id, false, entityId)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatD.show = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// else {
|
|
|
|
// thatD.show = false
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let value = -1
|
|
|
|
// if (thatP.show) {
|
|
|
|
// let leftElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-left')[0]
|
|
|
|
// let rightElm = sdk.viewer._element.getElementsByClassName('YJ-custom-checkbox-right')[0]
|
|
|
|
// if (leftElm.checked && rightElm.checked) {
|
|
|
|
// value = 0
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (leftElm.checked) {
|
|
|
|
// value = -1
|
|
|
|
// }
|
|
|
|
// if (rightElm.checked) {
|
|
|
|
// value = 1
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
setSplitDirection(value, id, false, entityId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
thatD && thatD.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActiveViewer(v) {
|
|
|
|
activeViewer = v
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSdk() {
|
|
|
|
return {
|
|
|
|
sdkP: sdkP,
|
|
|
|
sdkD: sdkD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export { on, off, setSplitDirection, syncSplitData, getState, getActiveId, setActiveId, setActiveViewer, getSdk }
|