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

View File

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

View File

@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText"; import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index' import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject' import LabelObject from '../LabelObject'
import { syncData } from '../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist'; import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect' import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip' import MouseTip from '../../../MouseTip'
@ -223,10 +223,11 @@ class CircleDiffuse extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
this.entity.show = this.options.show this.entity.show = this.options.show
if (this.options.label.show) { if (this.options.label.show) {
this.label.show = this.options.show this.label.show = this.options.show
@ -442,8 +443,9 @@ class CircleDiffuse extends Base {
return this.options.label.show return this.options.label.show
} }
set labelShow(v) { set labelShow(v) {
let sdkD = get2DSdk().sdkD
this.options.label.show = v this.options.label.show = v
if (this.show && (!this.showView || this.showView == 3)) { if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
this.label.show = v this.label.show = v
} }
else { else {
@ -1336,7 +1338,7 @@ class CircleDiffuse extends Base {
} }
async remove() { async remove() {
this.label.remove() this.label && this.label.remove()
this.entity && this.sdk.viewer.entities.remove(this.entity) this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2) this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null this.entity = null

View File

@ -9,7 +9,7 @@ import { getHost, getToken } from "../../../on";
import Base from '../index' import Base from '../index'
import Tools from '../../../Tools' import Tools from '../../../Tools'
import { syncSplitData } from "../../../Global/SplitScreen"; import { syncSplitData } from "../../../Global/SplitScreen";
import { syncData } from '../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global' import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global'
class GeoJson extends Base { class GeoJson extends Base {
@ -52,11 +52,12 @@ class GeoJson extends Base {
} }
// set show(status) { // set show(status) {
// if (!this.isShowView) { // let sdkD = get2DSdk().sdkD
// if (!this.isShowView || !sdkD) {
// this.options.show = status // this.options.show = status
// } // }
// if (this.entity) { // if (this.entity) {
// if (!this.showView || this.showView == 3) { // if (!this.showView || this.showView == 3 || !sdkD) {
// for (let i = 0; i < this.entity.entities.values.length; i++) { // for (let i = 0; i < this.entity.entities.values.length; i++) {
// this.entity.entities.values[i].show = this.options.show // this.entity.entities.values[i].show = this.options.show
// } // }

View File

@ -7,7 +7,7 @@ import EventBinding from './eventBinding'
import Base from "../../index"; import Base from "../../index";
import MouseEvent from '../../../../Event/index' import MouseEvent from '../../../../Event/index'
import { syncPrimitives } from '../../../../Global/MultiViewportMode' import { syncPrimitives } from '../../../../Global/MultiViewportMode'
import { syncData } from '../../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip' import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@ -82,10 +82,11 @@ class Flame extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
this.entity.show = this.options.show this.entity.show = this.options.show
} }

View File

@ -6,7 +6,7 @@ import { html } from "./_element";
import EventBinding from './eventBinding' import EventBinding from './eventBinding'
import Base from "../../index"; import Base from "../../index";
import MouseEvent from '../../../../Event/index' import MouseEvent from '../../../../Event/index'
import { syncData } from '../../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip' import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@ -83,10 +83,11 @@ class Fountain extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
this.entity.show = this.options.show this.entity.show = this.options.show
} }

View File

@ -6,7 +6,7 @@ import { html, css } from "./_element";
import EventBinding from './eventBinding' import EventBinding from './eventBinding'
import Base from "../../index"; import Base from "../../index";
import MouseEvent from '../../../../Event/index' import MouseEvent from '../../../../Event/index'
import { syncData } from '../../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip' import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@ -81,10 +81,11 @@ class Smoke extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
this.entity.show = this.options.show this.entity.show = this.options.show
} }

View File

@ -5,7 +5,7 @@ import Dialog from '../../../Element/Dialog';
import { html, css } from "./_element"; import { html, css } from "./_element";
import Base from "../../index"; import Base from "../../index";
import MouseEvent from '../../../../Event/index' import MouseEvent from '../../../../Event/index'
import { syncData } from '../../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip' import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
@ -84,10 +84,11 @@ class Spout extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
this.entity.show = this.options.show this.entity.show = this.options.show
} }

View File

@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText"; import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index' import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject' import LabelObject from '../LabelObject'
import { syncData } from '../../../Global/MultiViewportMode' import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist'; import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect' import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip' import MouseTip from '../../../MouseTip'
@ -246,10 +246,11 @@ class RadarScan extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
this.entity.show = this.options.show this.entity.show = this.options.show
if (this.options.label.show && this.label) { if (this.options.label.show && this.label) {
this.label.show = this.options.show this.label.show = this.options.show
@ -460,8 +461,9 @@ class RadarScan extends Base {
return this.options.label.show return this.options.label.show
} }
set labelShow(v) { set labelShow(v) {
let sdkD = get2DSdk().sdkD
this.options.label.show = v this.options.label.show = v
if (this.show && (!this.showView || this.showView == 3)) { if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
this.label.show = v this.label.show = v
} }
else { else {
@ -1386,7 +1388,7 @@ class RadarScan extends Base {
} }
async remove() { async remove() {
this.label.remove() this.label && this.label.remove()
this.entity && this.sdk.viewer.entities.remove(this.entity) this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2) this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null this.entity = null

View File

@ -144,7 +144,8 @@ class TrajectoryMotion extends Base {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DView()
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
if (this.originalOptions) { if (this.originalOptions) {
this.originalOptions.show = v this.originalOptions.show = v
@ -155,10 +156,10 @@ class TrajectoryMotion extends Base {
this.model.show = false this.model.show = false
} }
else { else {
this.model.show = (!this.showView || this.showView == 3) ? this.modelShow : false this.model.show = (!this.showView || this.showView == 3 || !sdkD) ? this.modelShow : false
} }
if ((!this.showView || this.showView == 3)) { if ((!this.showView || this.showView == 3 || !sdkD)) {
this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({ this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({
color: new Cesium.Color.fromCssColorString('#00ffff'), color: new Cesium.Color.fromCssColorString('#00ffff'),
dashLength: 20, dashLength: 20,
@ -174,17 +175,17 @@ class TrajectoryMotion extends Base {
}) })
} }
for (let i = 0; i < this.keyPoints.length; i++) { for (let i = 0; i < this.keyPoints.length; i++) {
this.keyPoints[i].show = (!this.showView || this.showView == 3) ? this.keyPointShow : false this.keyPoints[i].show = (!this.showView || this.showView == 3 || !sdkD) ? this.keyPointShow : false
} }
if (this.realTimeRoute) { if (this.realTimeRoute) {
this.realTimeLine && (this.realTimeLine.show = (!this.showView || this.showView == 3) ? true : false) this.realTimeLine && (this.realTimeLine.show = (!this.showView || this.showView == 3 || !sdkD) ? true : false)
} }
this.label && (this.label.show = (!this.showView || this.showView == 3) ? this.options.label.show : false) this.label && (this.label.show = (!this.showView || this.showView == 3 || !sdkD) ? this.options.label.show : false)
} }
else { else {
this.model.show = (!this.showView || this.showView == 3) ? this.options.show : false this.model.show = (!this.showView || this.showView == 3 || !sdkD) ? this.options.show : false
let show = this.options.show let show = this.options.show
if ((!this.showView || this.showView == 3)) { if ((!this.showView || this.showView == 3 || !sdkD)) {
show = this.options.show show = this.options.show
} }
else { else {
@ -673,9 +674,10 @@ class TrajectoryMotion extends Base {
return this.options.model.show return this.options.model.show
} }
set modelShow(v) { set modelShow(v) {
let sdkD = get2DView()
this.options.model.show = v this.options.model.show = v
let show = v let show = v
if (this.show && (!this.showView || this.showView == 3)) { if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = v show = v
} }
else { else {
@ -749,7 +751,8 @@ class TrajectoryMotion extends Base {
} }
this.options.line.show = v this.options.line.show = v
let show = v let show = v
if ((!this.showView || this.showView == 3)) { let sdkD = get2DView()
if ((!this.showView || this.showView == 3 || !sdkD)) {
show = v show = v
} }
else { else {
@ -973,6 +976,7 @@ class TrajectoryMotion extends Base {
set firstPersonView(v) { set firstPersonView(v) {
// this.state = true // this.state = true
let sdkD = get2DView()
let splitSdk = getSdk() let splitSdk = getSdk()
if (get2DView() || splitSdk.sdkD || !this.show) { if (get2DView() || splitSdk.sdkD || !this.show) {
v = false v = false
@ -1027,7 +1031,7 @@ class TrajectoryMotion extends Base {
CameraController(this.sdk, true) CameraController(this.sdk, true)
if (this.model && this.modelShow && this.show) { if (this.model && this.modelShow && this.show) {
let show = true let show = true
if (this.show && (!this.showView || this.showView == 3)) { if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = true show = true
} }
else { else {
@ -1155,8 +1159,9 @@ class TrajectoryMotion extends Base {
} }
set labelShow(v) { set labelShow(v) {
this.options.label.show = v this.options.label.show = v
let sdkD = get2DView()
let show = v let show = v
if (this.show && (!this.showView || this.showView == 3)) { if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = v show = v
} }
else { else {

View File

@ -120,7 +120,8 @@ class Base extends Tools {
set show(v) { set show(v) {
if (typeof v === "boolean") { if (typeof v === "boolean") {
if (!this.isShowView) { let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v this.options.show = v
if (this.originalOptions) { if (this.originalOptions) {
this.originalOptions.show = v this.originalOptions.show = v
@ -132,7 +133,7 @@ class Base extends Tools {
this.entity._objectState = this.options.show this.entity._objectState = this.options.show
} }
} }
if (!this.showView || this.showView == 3) { if (!this.showView || this.showView == 3 || !sdkD) {
this.entity && (this.entity.show = this.options.show) this.entity && (this.entity.show = this.options.show)
if (this.options.label && this.options.label.show && this.label) { if (this.options.label && this.options.label.show && this.label) {
this.label.show = this.options.show this.label.show = this.options.show
@ -154,7 +155,6 @@ class Base extends Tools {
syncSplitData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id)
this.isShowView = false this.isShowView = false
let { sdkP, sdkD } = get2DSdk()
if (this.type == 'layer' && sdkD) { if (this.type == 'layer' && sdkD) {
let layer2d = sdkD.viewer.imageryLayers._layers[this.layerIndex] let layer2d = sdkD.viewer.imageryLayers._layers[this.layerIndex]
let layer3d = this.entity let layer3d = this.entity