From fff8041faa0fd764f830d9f839cc4cabe7a72fed Mon Sep 17 00:00:00 2001
From: zh <972939975@qq.com>
Date: Wed, 13 Aug 2025 11:51:39 +0800
Subject: [PATCH] =?UTF-8?q?showView=E7=8A=B6=E6=80=81=E4=BF=9D=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Global/MultiViewportMode/index.js | 33 ++++++++++++++-----
src/Global/mouseRightMenu/index.js | 16 ++++-----
src/Obj/Base/CircleDiffuse/index.js | 12 ++++---
src/Obj/Base/GeoJson/index.js | 7 ++--
src/Obj/Base/ParticleEffects/Flame/index.js | 7 ++--
.../Base/ParticleEffects/Fountain/index.js | 7 ++--
src/Obj/Base/ParticleEffects/Smoke/index.js | 7 ++--
src/Obj/Base/ParticleEffects/Spout/index.js | 7 ++--
src/Obj/Base/RadarScan/index.js | 12 ++++---
src/Obj/Base/TrajectoryMotion/index.js | 29 +++++++++-------
src/Obj/Base/index.js | 6 ++--
11 files changed, 86 insertions(+), 57 deletions(-)
diff --git a/src/Global/MultiViewportMode/index.js b/src/Global/MultiViewportMode/index.js
index a05fd63..f5531be 100644
--- a/src/Global/MultiViewportMode/index.js
+++ b/src/Global/MultiViewportMode/index.js
@@ -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
}
}
diff --git a/src/Global/mouseRightMenu/index.js b/src/Global/mouseRightMenu/index.js
index 818271b..891623f 100644
--- a/src/Global/mouseRightMenu/index.js
+++ b/src/Global/mouseRightMenu/index.js
@@ -100,14 +100,14 @@ function MouseRightMenu(sdk, status, callBack) {
that = sdk.entityMap.get(entityId)
}
- if (that && that.picking) {
- addedMenu = `
-
-
- `
- }
+ // if (that && that.picking) {
+ // addedMenu = `
+ //
+ //
+ // `
+ // }
let position = tools.cartesian3Towgs84(cartesian, sdk.viewer)
menuElm = document.createElement('div')
menuElm.id = 'custom-menu'
diff --git a/src/Obj/Base/CircleDiffuse/index.js b/src/Obj/Base/CircleDiffuse/index.js
index d7fe430..36acfa4 100644
--- a/src/Obj/Base/CircleDiffuse/index.js
+++ b/src/Obj/Base/CircleDiffuse/index.js
@@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject'
-import { syncData } from '../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip'
@@ -223,10 +223,11 @@ class CircleDiffuse extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
this.options.show = v
}
- if (!this.showView || this.showView == 3) {
+ if (!this.showView || this.showView == 3 || !sdkD) {
this.entity.show = this.options.show
if (this.options.label.show) {
this.label.show = this.options.show
@@ -442,8 +443,9 @@ class CircleDiffuse extends Base {
return this.options.label.show
}
set labelShow(v) {
+ let sdkD = get2DSdk().sdkD
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
}
else {
@@ -1336,7 +1338,7 @@ class CircleDiffuse extends Base {
}
async remove() {
- this.label.remove()
+ this.label && this.label.remove()
this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null
diff --git a/src/Obj/Base/GeoJson/index.js b/src/Obj/Base/GeoJson/index.js
index 795785e..02a0bbe 100644
--- a/src/Obj/Base/GeoJson/index.js
+++ b/src/Obj/Base/GeoJson/index.js
@@ -9,7 +9,7 @@ import { getHost, getToken } from "../../../on";
import Base from '../index'
import Tools from '../../../Tools'
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'
class GeoJson extends Base {
@@ -52,11 +52,12 @@ class GeoJson extends Base {
}
// set show(status) {
- // if (!this.isShowView) {
+ // let sdkD = get2DSdk().sdkD
+ // if (!this.isShowView || !sdkD) {
// this.options.show = status
// }
// 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++) {
// this.entity.entities.values[i].show = this.options.show
// }
diff --git a/src/Obj/Base/ParticleEffects/Flame/index.js b/src/Obj/Base/ParticleEffects/Flame/index.js
index 77b66b8..08fe7bb 100644
--- a/src/Obj/Base/ParticleEffects/Flame/index.js
+++ b/src/Obj/Base/ParticleEffects/Flame/index.js
@@ -7,7 +7,7 @@ import EventBinding from './eventBinding'
import Base from "../../index";
import MouseEvent from '../../../../Event/index'
import { syncPrimitives } from '../../../../Global/MultiViewportMode'
-import { syncData } from '../../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@@ -82,10 +82,11 @@ class Flame extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
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) {
this.entity.show = this.options.show
}
diff --git a/src/Obj/Base/ParticleEffects/Fountain/index.js b/src/Obj/Base/ParticleEffects/Fountain/index.js
index 7b2a2a0..893eb47 100644
--- a/src/Obj/Base/ParticleEffects/Fountain/index.js
+++ b/src/Obj/Base/ParticleEffects/Fountain/index.js
@@ -6,7 +6,7 @@ import { html } from "./_element";
import EventBinding from './eventBinding'
import Base from "../../index";
import MouseEvent from '../../../../Event/index'
-import { syncData } from '../../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@@ -83,10 +83,11 @@ class Fountain extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
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) {
this.entity.show = this.options.show
}
diff --git a/src/Obj/Base/ParticleEffects/Smoke/index.js b/src/Obj/Base/ParticleEffects/Smoke/index.js
index f457661..3d367f7 100644
--- a/src/Obj/Base/ParticleEffects/Smoke/index.js
+++ b/src/Obj/Base/ParticleEffects/Smoke/index.js
@@ -6,7 +6,7 @@ import { html, css } from "./_element";
import EventBinding from './eventBinding'
import Base from "../../index";
import MouseEvent from '../../../../Event/index'
-import { syncData } from '../../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
@@ -81,10 +81,11 @@ class Smoke extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
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) {
this.entity.show = this.options.show
}
diff --git a/src/Obj/Base/ParticleEffects/Spout/index.js b/src/Obj/Base/ParticleEffects/Spout/index.js
index 9e78cd5..ed2863d 100644
--- a/src/Obj/Base/ParticleEffects/Spout/index.js
+++ b/src/Obj/Base/ParticleEffects/Spout/index.js
@@ -5,7 +5,7 @@ import Dialog from '../../../Element/Dialog';
import { html, css } from "./_element";
import Base from "../../index";
import MouseEvent from '../../../../Event/index'
-import { syncData } from '../../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
import MouseTip from '../../../../MouseTip'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
@@ -84,10 +84,11 @@ class Spout extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
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) {
this.entity.show = this.options.show
}
diff --git a/src/Obj/Base/RadarScan/index.js b/src/Obj/Base/RadarScan/index.js
index dd3ec65..3959c72 100644
--- a/src/Obj/Base/RadarScan/index.js
+++ b/src/Obj/Base/RadarScan/index.js
@@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject'
-import { syncData } from '../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip'
@@ -246,10 +246,11 @@ class RadarScan extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
this.options.show = v
}
- if (!this.showView || this.showView == 3) {
+ if (!this.showView || this.showView == 3 || !sdkD) {
this.entity.show = this.options.show
if (this.options.label.show && this.label) {
this.label.show = this.options.show
@@ -460,8 +461,9 @@ class RadarScan extends Base {
return this.options.label.show
}
set labelShow(v) {
+ let sdkD = get2DSdk().sdkD
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
}
else {
@@ -1386,7 +1388,7 @@ class RadarScan extends Base {
}
async remove() {
- this.label.remove()
+ this.label && this.label.remove()
this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null
diff --git a/src/Obj/Base/TrajectoryMotion/index.js b/src/Obj/Base/TrajectoryMotion/index.js
index 56a8c6e..f561a70 100644
--- a/src/Obj/Base/TrajectoryMotion/index.js
+++ b/src/Obj/Base/TrajectoryMotion/index.js
@@ -144,7 +144,8 @@ class TrajectoryMotion extends Base {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DView()
+ if (!this.isShowView || !sdkD) {
this.options.show = v
if (this.originalOptions) {
this.originalOptions.show = v
@@ -155,10 +156,10 @@ class TrajectoryMotion extends Base {
this.model.show = false
}
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({
color: new Cesium.Color.fromCssColorString('#00ffff'),
dashLength: 20,
@@ -174,17 +175,17 @@ class TrajectoryMotion extends Base {
})
}
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) {
- 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 {
- 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
- if ((!this.showView || this.showView == 3)) {
+ if ((!this.showView || this.showView == 3 || !sdkD)) {
show = this.options.show
}
else {
@@ -673,9 +674,10 @@ class TrajectoryMotion extends Base {
return this.options.model.show
}
set modelShow(v) {
+ let sdkD = get2DView()
this.options.model.show = v
let show = v
- if (this.show && (!this.showView || this.showView == 3)) {
+ if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = v
}
else {
@@ -749,7 +751,8 @@ class TrajectoryMotion extends Base {
}
this.options.line.show = v
let show = v
- if ((!this.showView || this.showView == 3)) {
+ let sdkD = get2DView()
+ if ((!this.showView || this.showView == 3 || !sdkD)) {
show = v
}
else {
@@ -973,6 +976,7 @@ class TrajectoryMotion extends Base {
set firstPersonView(v) {
// this.state = true
+ let sdkD = get2DView()
let splitSdk = getSdk()
if (get2DView() || splitSdk.sdkD || !this.show) {
v = false
@@ -1027,7 +1031,7 @@ class TrajectoryMotion extends Base {
CameraController(this.sdk, true)
if (this.model && this.modelShow && this.show) {
let show = true
- if (this.show && (!this.showView || this.showView == 3)) {
+ if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = true
}
else {
@@ -1155,8 +1159,9 @@ class TrajectoryMotion extends Base {
}
set labelShow(v) {
this.options.label.show = v
+ let sdkD = get2DView()
let show = v
- if (this.show && (!this.showView || this.showView == 3)) {
+ if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
show = v
}
else {
diff --git a/src/Obj/Base/index.js b/src/Obj/Base/index.js
index 4cee908..7439d37 100644
--- a/src/Obj/Base/index.js
+++ b/src/Obj/Base/index.js
@@ -120,7 +120,8 @@ class Base extends Tools {
set show(v) {
if (typeof v === "boolean") {
- if (!this.isShowView) {
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
this.options.show = v
if (this.originalOptions) {
this.originalOptions.show = v
@@ -132,7 +133,7 @@ class Base extends Tools {
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)
if (this.options.label && this.options.label.show && this.label) {
this.label.show = this.options.show
@@ -154,7 +155,6 @@ class Base extends Tools {
syncSplitData(this.sdk, this.options.id)
this.isShowView = false
- let { sdkP, sdkD } = get2DSdk()
if (this.type == 'layer' && sdkD) {
let layer2d = sdkD.viewer.imageryLayers._layers[this.layerIndex]
let layer3d = this.entity