showView状态保存

This commit is contained in:
zh
2025-08-13 11:51:39 +08:00
parent 20ae03cc5e
commit fff8041faa
11 changed files with 86 additions and 57 deletions

View File

@ -50,6 +50,11 @@ async function init(sdk) {
for (let i = 0; i < imageryLayers.length; i++) {
let entity = sdk2D.viewer.imageryLayers.addImageryProvider(imageryLayers[i].imageryProvider, imageryLayers[i]._layerIndex)
entity.show = imageryLayers[i].show
if (imageryLayers[i]._objectState) {
if (imageryLayers[i]._showView == 3) {
entity.show = false
}
}
}
// sdk.viewer.entities.collectionChanged.addEventListener(syncEntities)
// sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources)
@ -61,6 +66,12 @@ async function init(sdk) {
JwwStatusSwitch(sdk2, true)
}
sdk.entityMap.forEach((item, key) => {
if (item.showView == 2) {
item.showView = 2
}
})
}
async function on(sdk) {
if (sdk2D) {
@ -95,9 +106,10 @@ function off(sdk) {
syncObject = {}
}
sdk.entityMap.forEach((item, key) => {
item.showView = undefined
if (item.showView) {
item.show = item.show
}
})
}
async function syncData2(sdk, id, entityId) {
@ -123,10 +135,10 @@ async function syncData2(sdk, id, entityId) {
options.heightMode = 0
options.height = 0
}
if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer')) {
if(that.showView==3) {
options.show=false
if (that.showView == 3) {
options.show = false
}
let newObject = await new that.constructor(sdk2D, options)
newObject.onClick = that.onClick
@ -216,6 +228,9 @@ async function syncData2(sdk, id, entityId) {
}
let options = syncObject.tools.deepCopyObj(obj.options)
if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer')) {
if (obj.showView == 3) {
options.show = false
}
let target = await new obj.constructor(sdk2D, options)
target.onClick = obj.onClick
target.onRightClick = obj.onRightClick
@ -413,15 +428,15 @@ function syncImageryLayerShownOrHidden(layer, index, state) {
let layer2d = sdk2D.viewer.imageryLayers._layers[index]
let layer3d = sdk3D.viewer.imageryLayers._layers[index]
console.log('layer2d', layer2d, sdk2D, layer3d)
if (!layer2d) {
return
}
if(layer3d._objectState) {
if(!layer3d._showView || layer3d._showView==2) {
if (layer3d._objectState) {
if (!layer3d._showView || layer3d._showView == 2) {
layer2d.show = true
}
if(layer3d._showView==3) {
if (layer3d._showView == 3) {
layer2d.show = false
}
}

View File

@ -100,14 +100,14 @@ function MouseRightMenu(sdk, status, callBack) {
that = sdk.entityMap.get(entityId)
}
if (that && that.picking) {
addedMenu = `
<span class="divider" style="display: block;border-top: 1px solid #ddd;margin: 5px;"></span>
<ul class="added" style="list-style: none;padding: 0;margin: 0;font-size: 12px;">
<li style="padding: 3px 10px;cursor: pointer;">属性</li>
</ul>
`
}
// if (that && that.picking) {
// addedMenu = `
// <span class="divider" style="display: block;border-top: 1px solid #ddd;margin: 5px;"></span>
// <ul class="added" style="list-style: none;padding: 0;margin: 0;font-size: 12px;">
// <li style="padding: 3px 10px;cursor: pointer;">属性</li>
// </ul>
// `
// }
let position = tools.cartesian3Towgs84(cartesian, sdk.viewer)
menuElm = document.createElement('div')
menuElm.id = 'custom-menu'