diff --git a/src/BaseDialog/index.js b/src/BaseDialog/index.js index de36a50..18b3f3c 100644 --- a/src/BaseDialog/index.js +++ b/src/BaseDialog/index.js @@ -1,5 +1,5 @@ class BaseDialog { - constructor(container, options = {}) { + constructor(container, options = {}, only = true) { this.container = container this.options = { ...options } this.options.ismove = true @@ -9,10 +9,13 @@ class BaseDialog { this.closeCallBack = options.closeCallBack this._element = {} this._element_style = undefined + this.only = only } async init() { - this.closeAll() + if (this.only) { + this.closeAll() + } DialogAll.push(this) this.isDestroy = false // body diff --git a/src/Global/MultiViewportMode/index.js b/src/Global/MultiViewportMode/index.js index 0d63e89..5d3c600 100644 --- a/src/Global/MultiViewportMode/index.js +++ b/src/Global/MultiViewportMode/index.js @@ -94,6 +94,10 @@ function off(sdk) { activeViewer = null syncObject = {} } + sdk.entityMap.forEach((item, key) => { + item.showView = undefined + }) + } async function syncData2(sdk, id, entityId) { @@ -119,7 +123,11 @@ 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 + } let newObject = await new that.constructor(sdk2D, options) newObject.onClick = that.onClick newObject.onRightClick = that.onRightClick diff --git a/src/Obj/Base/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js index dafb8c8..3bd6bfc 100644 --- a/src/Obj/Base/BillboardObject/index.js +++ b/src/Obj/Base/BillboardObject/index.js @@ -433,11 +433,11 @@ class BillboardObject extends Base { value: '链接', key: 'link' }, - { - name: 'IP摄像头', - value: 'IP摄像头', - key: 'camera' - }, + // { + // name: 'IP摄像头', + // value: 'IP摄像头', + // key: 'camera' + // }, // { // name: 'ISC摄像头', // value: 'ISC摄像头', @@ -448,16 +448,16 @@ class BillboardObject extends Base { // value: '传感器', // key: 'sensor' // }, - { - name: '全景图', - value: '全景图', - key: 'vr' - }, - { - name: '物资', - value: '物资', - key: 'goods' - } + // { + // name: '全景图', + // value: '全景图', + // key: 'vr' + // }, + // { + // name: '物资', + // value: '物资', + // key: 'goods' + // } ] } @@ -465,14 +465,24 @@ class BillboardObject extends Base { return this.options.show } set show(v) { - this.options.show = v - this.originalOptions.show = v - this.entity && (this.entity.show = v) + if(!this.isShowView) { + this.options.show = v + this.originalOptions.show = v + } + if(!this.showView || this.showView == 3) { + this.entity && (this.entity.show = this.options.show) + } + else { + this.entity && (this.entity.show = false) + } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + if (this._DialogObject && this._DialogObject.showBtn) { - this._DialogObject.showBtn.checked = v + this._DialogObject.showBtn.checked = this.options.show } + + this.isShowView = false // if (v) { // if (this.diffuseShow) { // this.diffuseShow = true diff --git a/src/Obj/Base/CircleDiffuse/index.js b/src/Obj/Base/CircleDiffuse/index.js index 92b2cfd..d7fe430 100644 --- a/src/Obj/Base/CircleDiffuse/index.js +++ b/src/Obj/Base/CircleDiffuse/index.js @@ -223,16 +223,30 @@ class CircleDiffuse extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - this.entity.show = v + if (!this.isShowView) { + this.options.show = v + } + if (!this.showView || this.showView == 3) { + this.entity.show = this.options.show + if (this.options.label.show) { + this.label.show = this.options.show + } + } + else { + this.entity.show = false + if (this.options.label.show) { + this.label.show = false + } + } + + this.isShowView = false + syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) if (this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label.show) { - this.label.show = v - } + } else { console.error("参数必须为boolean") } @@ -429,7 +443,7 @@ class CircleDiffuse extends Base { } set labelShow(v) { this.options.label.show = v - if (this.show) { + if (this.show && (!this.showView || this.showView == 3)) { this.label.show = v } else { diff --git a/src/Obj/Base/CircleObject/index.js b/src/Obj/Base/CircleObject/index.js index 4126eff..d85022b 100644 --- a/src/Obj/Base/CircleObject/index.js +++ b/src/Obj/Base/CircleObject/index.js @@ -333,7 +333,7 @@ class CircleObject extends Base { } set labelShow(v) { this.options.label.show = v - if (this.show) { + if (this.show && (!this.showView || this.showView == 3)) { this.label.show = v } else { diff --git a/src/Obj/Base/GroundImage/_element.js b/src/Obj/Base/GroundImage/_element.js index 4f477d7..7ca2e92 100644 --- a/src/Obj/Base/GroundImage/_element.js +++ b/src/Obj/Base/GroundImage/_element.js @@ -8,6 +8,7 @@ function html() {
+
@@ -27,9 +28,9 @@ function html() {
调整大小 - +
- +
diff --git a/src/Obj/Base/GroundImage/index.js b/src/Obj/Base/GroundImage/index.js index ea98a52..6cff1c7 100644 --- a/src/Obj/Base/GroundImage/index.js +++ b/src/Obj/Base/GroundImage/index.js @@ -7,7 +7,7 @@ import MouseEvent from '../../../Event/index' import { syncData } from '../../../Global/MultiViewportMode' import MouseTip from '../../../MouseTip' import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' -import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global' +import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' class GroundImage extends Base { /** @@ -36,6 +36,7 @@ class GroundImage extends Base { this.options.angle = options.angle || 0 this.options.scale = (options.scale || options.scale === 0) ? options.scale : 1 this.options.positions = options.positions + this.options.offset = { x: 0.5, y: 0.5 } this.options.flipe = options.flipe || {} this.options.flipe.x = this.options.flipe.x || false @@ -56,6 +57,13 @@ class GroundImage extends Base { this.create() } + get offset() { + return this.options.offset + } + set offset(v) { + this.options.offset = v + } + get angle() { return this.options.angle } @@ -87,8 +95,9 @@ class GroundImage extends Base { if (!this.entity) { return } + const img = new Image(); - img.src = this.options.url; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); @@ -111,6 +120,10 @@ class GroundImage extends Base { image: canvas, transparent: true })) + // this.offset = { + // x: Math.abs(this.offset.x - 1), + // y: this.offset.y, + // } } } else { console.error("参数必须为boolean") @@ -125,8 +138,9 @@ class GroundImage extends Base { if (!this.entity) { return } + const img = new Image(); - img.src = this.options.url; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); @@ -149,6 +163,10 @@ class GroundImage extends Base { image: canvas, transparent: true }) + // this.offset = { + // x: this.offset.x, + // y: Math.abs(this.offset.y - 1), + // } } } else { console.error("参数必须为boolean") @@ -163,7 +181,7 @@ class GroundImage extends Base { // this.options.positions.lng + 0.05, this.options.positions.lat + 0.05, // this.options.positions.lng - 0.05, this.options.positions.lat + 0.05, // ] - let response = await fetch(this.options.url, { + let response = await fetch(this.replaceHost(this.options.url, this.options.host), { method: 'get', headers: { 'Content-Type': 'application/json', @@ -174,7 +192,7 @@ class GroundImage extends Base { // let arrayBuffer = await data.arrayBuffer() // const str = String.fromCharCode(...new Uint8Array(arrayBuffer)); const img = new Image(); - img.src = this.options.url; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); @@ -199,11 +217,27 @@ class GroundImage extends Base { rectangle: { coordinates: new Cesium.CallbackProperty(() => { let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.positions.lat)) * (0.0001 * this.options.scale) + let offset = { + x: this.flipeY ? Math.abs(this.options.offset.x - 1) : this.options.offset.x, + y: this.flipeX ? Math.abs(this.options.offset.y - 1) : this.options.offset.y, + } + offset = { + lng: offset.x * ((0.0001 * this.options.scale) * 2), + lat: Math.abs(offset.y-1) * (gap * 2) + } let fromDegreesArray = [ - this.options.positions.lng - (0.0001 * this.options.scale), this.options.positions.lat - gap, - // this.options.positions.lng + 0.05, this.options.positions.lat - 0.05, - this.options.positions.lng + (0.0001 * this.options.scale), this.options.positions.lat + gap, - // this.options.positions.lng - 0.05, this.options.positions.lat + 0.05, + this.options.positions.lng - offset.lng, this.options.positions.lat - offset.lat, + (this.options.positions.lng - offset.lng) + ((0.0001 * this.options.scale) * 2), (this.options.positions.lat - offset.lat) + (gap * 2), + + + + + + + // this.options.positions.lng - (0.0001 * this.options.scale), this.options.positions.lat - gap, + // // this.options.positions.lng + 0.05, this.options.positions.lat - 0.05, + // this.options.positions.lng + (0.0001 * this.options.scale), this.options.positions.lat + gap, + // // this.options.positions.lng - 0.05, this.options.positions.lat + 0.05, ] return Cesium.Rectangle.fromDegrees(...fromDegreesArray) @@ -224,8 +258,8 @@ class GroundImage extends Base { this.entity.rectangle.height = 0 } syncData(this.sdk, this.options.id) - if(this.options.show) { - + if (this.options.show) { + setSplitDirection(0, this.options.id) } } @@ -253,6 +287,10 @@ class GroundImage extends Base { this._DialogObject = null } if (state) { + let anchorSetDialogObject + let canvas + let point + let billboardAnchorPosition this._DialogObject = await new Dialog(this.sdk, this.originalOptions, { title: '军标属性', left: '180px', top: '100px', confirmCallBack: (options) => { @@ -280,6 +318,9 @@ class GroundImage extends Base { // show: true, // }); this.positionEditing = false + if (anchorSetDialogObject && anchorSetDialogObject.close) { + anchorSetDialogObject.close() + } this.Dialog.closeCallBack && this.Dialog.closeCallBack() }, showCallBack: (show) => { @@ -315,6 +356,7 @@ class GroundImage extends Base { ] }, true) this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' ground-image' + let contentElm = document.createElement('div'); contentElm.innerHTML = html() this._DialogObject.contentAppChild(contentElm) @@ -322,6 +364,114 @@ class GroundImage extends Base { this._EventBinding.on(this, all_elm) this._elms = this._EventBinding.element + let anchorBtn = contentElm.getElementsByClassName('anchor')[0] + anchorBtn.addEventListener('click', async () => { + if (anchorSetDialogObject && anchorSetDialogObject.close) { + anchorSetDialogObject.close() + } + document.body.addEventListener('mouseup', mouseupEvent) + let DialogClientRect = _this._DialogObject._element.body.getBoundingClientRect() + let _DialogObject = await new Dialog(this.sdk, this.originalOptions, { + title: '锚点设置', left: (DialogClientRect.left + 80) + 'px', top: (DialogClientRect.top + 200) + 'px', + confirmCallBack: (options) => { + _this.offset = { x: billboardAnchorPosition.x, y: billboardAnchorPosition.y } + _DialogObject.close() + }, + closeCallBack: () => { + document.body.removeEventListener('mouseup', mouseupEvent) + }, + }, false) + anchorSetDialogObject = _DialogObject + _DialogObject._element.body.className = _DialogObject._element.body.className + ' anchor-point' + let contentElm = document.createElement('div'); + let image = new Image() + image.src = this.replaceHost(this.options.url, this.options.host) + image.onload = function () { + let ratio = image.width / image.height + canvas = document.createElement('canvas') + let width = 150 + let height = 150 / ratio + const ctx = canvas.getContext('2d', { willReadFrequently: true }) + canvas.width = width + canvas.height = height; + canvas.style.display = 'block'; + ctx.drawImage(image, 0, 0, width, height) + contentElm.appendChild(canvas) + _DialogObject.contentAppChild(contentElm) + + point = document.createElement('span') + point.className = 'point' + contentElm.appendChild(point) + billboardAnchorPosition = { x: _this.offset.x, y: _this.offset.y } + point.style.top = `calc(${Number(billboardAnchorPosition.y) * 100}% - 6px)` + point.style.left = `calc(${Number(billboardAnchorPosition.x) * 100}% - 6px)` + + canvas.addEventListener('click', (e) => { + let x = e.offsetX + let y = e.offsetY + let anchor = { x: Number((x / canvas.width).toFixed(2)), y: Number((y / canvas.height).toFixed(2)) } + if (anchor.x < 0) { + anchor.x = 0 + } + if (anchor.x > 1) { + anchor.x = 1 + } + if (anchor.y < 0) { + anchor.y = 0 + } + if (anchor.y > 1) { + anchor.y = 1 + } + billboardAnchorPosition = { x: anchor.x, y: anchor.y } + + point.style.top = `calc(${billboardAnchorPosition.y * 100}% - 5px)` + point.style.left = `calc(${billboardAnchorPosition.x * 100}% - 5px)` + }) + + point.addEventListener('mousedown', (e) => { + _DialogObject._element.body.addEventListener('mousemove', mousemoveEvent) + }) + } + }) + function mousemoveEvent(e) { + getDialogBodyElm(e.target) + function getDialogBodyElm(elm) { + if (!elm) { + return + } + else if (elm === anchorSetDialogObject._element.body) { + let x = e.x - elm.getBoundingClientRect().left + let y = e.y - elm.getBoundingClientRect().top + let anchor = { x: Number(((x - 42) / canvas.width).toFixed(2)), y: Number(((y - 71) / canvas.height).toFixed(2)) } + if (anchor.x < 0) { + anchor.x = 0 + } + if (anchor.x > 1) { + anchor.x = 1 + } + if (anchor.y < 0) { + anchor.y = 0 + } + if (anchor.y > 1) { + anchor.y = 1 + } + billboardAnchorPosition = { x: anchor.x, y: anchor.y } + + point.style.top = `calc(${billboardAnchorPosition.y * 100}% - 5px)` + point.style.left = `calc(${billboardAnchorPosition.x * 100}% - 5px)` + } + else { + getDialogBodyElm(elm.offsetParent) + } + } + } + function mouseupEvent() { + if (anchorSetDialogObject) { + anchorSetDialogObject._element.body.removeEventListener('mousemove', mousemoveEvent) + } + } + + } else { if (this._DialogObject && this._DialogObject.remove) { this._DialogObject.remove() @@ -428,7 +578,7 @@ class GroundImage extends Base { async flyTo(options = {}) { setActiveViewer(0) closeRotateAround(this.sdk) - closeViewFollow(this.sdk) + closeViewFollow(this.sdk) if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { let orientation = { diff --git a/src/Obj/Base/GroundSvg/index.js b/src/Obj/Base/GroundSvg/index.js index d738ae7..d94cce8 100644 --- a/src/Obj/Base/GroundSvg/index.js +++ b/src/Obj/Base/GroundSvg/index.js @@ -159,10 +159,18 @@ class GroundSvg extends Base { set show(v) { if (typeof v === "boolean") { - super.show = v - if (this.options.text && this.options.text.show && this.text) { - this.text.show = v + if (this.options.text && this.options.text.show) { + if(this.text) { + if((!this.showView || this.showView == 3)) { + this.text.show = v + } + else { + this.text.show = false + } + } + } + super.show = v } else { console.error("参数必须为boolean") } @@ -308,7 +316,12 @@ class GroundSvg extends Base { set textShow(v) { this.options.text.show = v if (this.show) { - this.text && (this.text.show = v) + if((!this.showView || this.showView == 3)) { + this.text && (this.text.show = v) + } + else { + this.text && (this.text.show = false) + } if (this.options.text.position) { setTimeout(() => { if (this.options.text.position.alt) { diff --git a/src/Obj/Base/ParticleEffects/Flame/index.js b/src/Obj/Base/ParticleEffects/Flame/index.js index 15a541b..77b66b8 100644 --- a/src/Obj/Base/ParticleEffects/Flame/index.js +++ b/src/Obj/Base/ParticleEffects/Flame/index.js @@ -82,18 +82,33 @@ class Flame extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { - this.entity.show = v + if (!this.isShowView) { + this.options.show = v } + if (!this.showView || this.showView == 3) { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = this.options.show + } + if (this.options.label && this.options.label.show) { + this.label.show = this.options.show + } + } + else { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = false + } + if (this.options.label && this.options.label.show) { + this.label.show = false + } + } + if (this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label && this.options.label.show) { - this.label.show = v - } + syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } diff --git a/src/Obj/Base/ParticleEffects/Fountain/index.js b/src/Obj/Base/ParticleEffects/Fountain/index.js index d14be27..7b2a2a0 100644 --- a/src/Obj/Base/ParticleEffects/Fountain/index.js +++ b/src/Obj/Base/ParticleEffects/Fountain/index.js @@ -83,18 +83,31 @@ class Fountain extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if(this.entity && this.sdk.viewer.camera.positionCartographic.height <10000000) { - this.entity.show = v + if (!this.isShowView) { + this.options.show = v + } + if (!this.showView || this.showView == 3) { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = this.options.show + } + if (this.options.label && this.options.label.show) { + this.label.show = this.options.show + } + } + else { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = false + } + if (this.options.label && this.options.label.show) { + this.label.show = false + } } if(this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label && this.options.label.show) { - this.label.show = v - } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } diff --git a/src/Obj/Base/ParticleEffects/Smoke/index.js b/src/Obj/Base/ParticleEffects/Smoke/index.js index f70311d..f457661 100644 --- a/src/Obj/Base/ParticleEffects/Smoke/index.js +++ b/src/Obj/Base/ParticleEffects/Smoke/index.js @@ -81,18 +81,31 @@ class Smoke extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if(this.entity && this.sdk.viewer.camera.positionCartographic.height <10000000) { - this.entity.show = v + if (!this.isShowView) { + this.options.show = v + } + if (!this.showView || this.showView == 3) { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = this.options.show + } + if (this.options.label && this.options.label.show) { + this.label.show = this.options.show + } + } + else { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = false + } + if (this.options.label && this.options.label.show) { + this.label.show = false + } } if(this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label && this.options.label.show) { - this.label.show = v - } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } diff --git a/src/Obj/Base/ParticleEffects/Spout/index.js b/src/Obj/Base/ParticleEffects/Spout/index.js index e36a639..9e78cd5 100644 --- a/src/Obj/Base/ParticleEffects/Spout/index.js +++ b/src/Obj/Base/ParticleEffects/Spout/index.js @@ -84,18 +84,31 @@ class Spout extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { - this.entity.show = v + if (!this.isShowView) { + this.options.show = v } - if (this._DialogObject && this._DialogObject.showBtn) { + if (!this.showView || this.showView == 3) { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = this.options.show + } + if (this.options.label && this.options.label.show) { + this.label.show = this.options.show + } + } + else { + if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { + this.entity.show = false + } + if (this.options.label && this.options.label.show) { + this.label.show = false + } + } + if(this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label && this.options.label.show) { - this.label.show = v - } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } diff --git a/src/Obj/Base/RadarScan/index.js b/src/Obj/Base/RadarScan/index.js index bd7101c..dd3ec65 100644 --- a/src/Obj/Base/RadarScan/index.js +++ b/src/Obj/Base/RadarScan/index.js @@ -246,16 +246,28 @@ class RadarScan extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - this.entity.show = v + if (!this.isShowView) { + this.options.show = v + } + if (!this.showView || this.showView == 3) { + this.entity.show = this.options.show + if (this.options.label.show && this.label) { + this.label.show = this.options.show + } + } + else { + this.entity.show = false + if (this.options.label.show && this.label) { + this.label.show = false + } + } if (this._DialogObject && this._DialogObject.showBtn) { this._DialogObject.showBtn.checked = v } - if (this.options.label.show && this.label) { - this.label.show = v - } + syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } @@ -449,7 +461,7 @@ class RadarScan extends Base { } set labelShow(v) { this.options.label.show = v - if (this.show) { + if (this.show && (!this.showView || this.showView == 3)) { this.label.show = v } else { diff --git a/src/Obj/Base/TrajectoryMotion/index.js b/src/Obj/Base/TrajectoryMotion/index.js index 0783b99..56a8c6e 100644 --- a/src/Obj/Base/TrajectoryMotion/index.js +++ b/src/Obj/Base/TrajectoryMotion/index.js @@ -144,37 +144,54 @@ class TrajectoryMotion extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.originalOptions) { - this.originalOptions.show = v + if (!this.isShowView) { + this.options.show = v + if (this.originalOptions) { + this.originalOptions.show = v + } } - if (v) { + if (this.options.show) { if (this.firstPersonView) { this.model.show = false } else { - this.model.show = this.modelShow + this.model.show = (!this.showView || this.showView == 3) ? this.modelShow : false } - this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({ - color: new Cesium.Color.fromCssColorString('#00ffff'), - dashLength: 20, - }) : new Cesium.PolylineDashMaterialProperty({ - color: new Cesium.Color.fromCssColorString('#00ffff00'), - dashLength: 20, - }) + if ((!this.showView || this.showView == 3)) { + this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({ + color: new Cesium.Color.fromCssColorString('#00ffff'), + dashLength: 20, + }) : new Cesium.PolylineDashMaterialProperty({ + color: new Cesium.Color.fromCssColorString('#00ffff00'), + dashLength: 20, + }) + } + else { + this.line.polyline.material = new Cesium.PolylineDashMaterialProperty({ + color: new Cesium.Color.fromCssColorString('#00ffff00'), + dashLength: 20, + }) + } for (let i = 0; i < this.keyPoints.length; i++) { - this.keyPoints[i].show = this.keyPointShow + this.keyPoints[i].show = (!this.showView || this.showView == 3) ? this.keyPointShow : false } if (this.realTimeRoute) { - this.realTimeLine && (this.realTimeLine.show = true) + this.realTimeLine && (this.realTimeLine.show = (!this.showView || this.showView == 3) ? true : false) } - this.label && (this.label.show = this.options.label.show) + this.label && (this.label.show = (!this.showView || this.showView == 3) ? this.options.label.show : false) } else { - this.model.show = v + this.model.show = (!this.showView || this.showView == 3) ? this.options.show : false + let show = this.options.show + if ((!this.showView || this.showView == 3)) { + show = this.options.show + } + else { + show = false + } this.realTimeLine && (this.realTimeLine.show = false) - this.line.polyline.material = v ? new Cesium.PolylineDashMaterialProperty({ + this.line.polyline.material = show ? new Cesium.PolylineDashMaterialProperty({ color: new Cesium.Color.fromCssColorString('#00ffff'), dashLength: 20, }) : new Cesium.PolylineDashMaterialProperty({ @@ -182,7 +199,7 @@ class TrajectoryMotion extends Base { dashLength: 20, }) for (let i = 0; i < this.keyPoints.length; i++) { - this.keyPoints[i].show = v + this.keyPoints[i].show = (!this.showView || this.showView == 3) ? show : false } this.label && (this.label.show = false) this.viewFollow = false @@ -193,6 +210,7 @@ class TrajectoryMotion extends Base { } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } @@ -656,8 +674,15 @@ class TrajectoryMotion extends Base { } set modelShow(v) { this.options.model.show = v + let show = v + if (this.show && (!this.showView || this.showView == 3)) { + show = v + } + else { + show = false + } if (this.model && this.show) { - this.model.show = v + this.model.show = show } this._elms.modelShow && this._elms.modelShow.forEach((item) => { item.checked = v @@ -723,8 +748,15 @@ class TrajectoryMotion extends Base { this.realTimeRoute = false } this.options.line.show = v + let show = v + if ((!this.showView || this.showView == 3)) { + show = v + } + else { + show = false + } if (this.line && this.show) { - this.line.polyline.material = v ? new Cesium.PolylineDashMaterialProperty({ + this.line.polyline.material = show ? new Cesium.PolylineDashMaterialProperty({ color: new Cesium.Color.fromCssColorString('#00ffff'), dashLength: 20, //短划线长度 }) : new Cesium.PolylineDashMaterialProperty({ @@ -994,7 +1026,14 @@ class TrajectoryMotion extends Base { else { CameraController(this.sdk, true) if (this.model && this.modelShow && this.show) { - this.model.show = true + let show = true + if (this.show && (!this.showView || this.showView == 3)) { + show = true + } + else { + show = false + } + this.model.show = show } if (this._DialogObject && this._DialogObject._element.content) { let e_firstPerson = this._DialogObject._element.content.querySelectorAll("button[name='firstPerson']") @@ -1116,8 +1155,15 @@ class TrajectoryMotion extends Base { } set labelShow(v) { this.options.label.show = v + let show = v + if (this.show && (!this.showView || this.showView == 3)) { + show = v + } + else { + show = false + } if (this.show) { - this.label && (this.label.show = v) + this.label && (this.label.show = show) if (this.options.label.position) { setTimeout(() => { if (this.options.label.position.alt) { @@ -1888,10 +1934,10 @@ class TrajectoryMotion extends Base { this.tip && this.tip.destroy() this.tip = null this.ControllerObject.destroy() - if(this.firstPersonView !== this.originalOptions.firstPersonView) { + if (this.firstPersonView !== this.originalOptions.firstPersonView) { this.firstPersonView = this.originalOptions.firstPersonView; } - if(this.firstPersonView && this.modelShow) { + if (this.firstPersonView && this.modelShow) { this.model && (this.model.show = false) } }, @@ -2164,10 +2210,10 @@ class TrajectoryMotion extends Base { this.modelAnimate = this.originalOptions.model.animate; this.delay = this.originalOptions.delay; (this.ground !== this.originalOptions.ground) && (this.ground = this.originalOptions.ground); - if(this.firstPersonView !== this.originalOptions.firstPersonView) { + if (this.firstPersonView !== this.originalOptions.firstPersonView) { this.firstPersonView = this.originalOptions.firstPersonView; } - if(this.firstPersonView && this.modelShow) { + if (this.firstPersonView && this.modelShow) { this.model && (this.model.show = false) } this.labelShow = this.originalOptions.label.show @@ -2229,7 +2275,6 @@ class TrajectoryMotion extends Base { this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0].innerHTML = '结束调整' this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0].className = 'btn model-rotate-btn is-active' } - console.log(this._DialogObject._element.content, this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0]) this.state = false this.editObj = new EditGltf(this.sdk, this.model) this.editObj.editRtation() diff --git a/src/Obj/Base/index.js b/src/Obj/Base/index.js index 319800a..28a6fcb 100644 --- a/src/Obj/Base/index.js +++ b/src/Obj/Base/index.js @@ -10,10 +10,12 @@ import { getHost, getToken } from "../../on"; import { regLeftClickCallback, regRightClickCallback, regMoveCallback } from "../../Global/ClickCallback"; import { regLeftClickCallback as regLeftClickCallback2, regRightClickCallback as regRightClickCallback2, regMoveCallback as regMoveCallback2 } from "../../Global/SplitScreen/ClickCallback"; import { setSplitDirection, syncSplitData, getSdk } from "../../Global/SplitScreen"; -import { syncData } from '../../Global/MultiViewportMode' +import { syncData, getSdk as get2DSdk } from '../../Global/MultiViewportMode' import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../Global/global' class Base extends Tools { + #_showView + #_isShowView constructor(sdk, options = {}) { super(sdk, options); if (!sdk || !sdk.viewer) { @@ -55,6 +57,50 @@ class Base extends Tools { // setSplitDirection(this._splitDirection, this.options.id) // } + get showView() { + return this.#_showView + } + + set showView(v) { + let sdk2D = get2DSdk().sdkD + if(!sdk2D) { + v=0 + } + if (!this.#_showView && !this.show) { + return + } + if (this.sdk === sdk2D) { + this.#_showView = 0 + return + } + if (v != 2 && v != 3) { + this.#_showView = 0 + } + else { + this.#_showView = v + } + + this.isShowView = true + + // if(!this.show) { + // return + // } + + if (!this.#_showView) { + this.show = true + } + else { + if (v == 2) { + this.show = false + } + else { + this.show = true + } + } + } + + + get name() { return this.options.name } @@ -72,19 +118,32 @@ class Base extends Tools { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.originalOptions) { - this.originalOptions.show = v + if (!this.isShowView) { + this.options.show = v + if (this.originalOptions) { + this.originalOptions.show = v + } } - this.entity && (this.entity.show = v) + if (!this.showView || this.showView == 3) { + this.entity && (this.entity.show = this.options.show) + if (this.options.label && this.options.label.show && this.label) { + this.label.show = this.options.show + } + } + else { + this.entity && (this.entity.show = false) + if (this.options.label && this.options.label.show && this.label) { + this.label.show = false + } + } + if (this._DialogObject && this._DialogObject.showBtn) { - this._DialogObject.showBtn.checked = v - } - if (this.options.label && this.options.label.show && this.label) { - this.label.show = v + this._DialogObject.showBtn.checked = this.options.show } + syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } @@ -263,7 +322,7 @@ class Base extends Tools { console.error('val:', val, '不是一个function') } else { let sdkD = getSdk().sdkD - if(sdkD && this.sdk === sdkD) { + if (sdkD && this.sdk === sdkD) { if (this.clickCallBack == null && this.options && this.options.id) { regLeftClickCallback2(this.options.id, this.leftClickCB, this) } @@ -286,7 +345,7 @@ class Base extends Tools { console.error('val:', val, '不是一个function') } else { let sdkD = getSdk().sdkD - if(sdkD && this.sdk === sdkD) { + if (sdkD && this.sdk === sdkD) { if (this.rightClickCallBack == null && this.entity && this.entity.id) { regRightClickCallback2(this.entity.id, this.rightClickCB, this) } @@ -309,7 +368,7 @@ class Base extends Tools { console.error('val:', val, '不是一个function') } else { let sdkD = getSdk().sdkD - if(sdkD && this.sdk === sdkD) { + if (sdkD && this.sdk === sdkD) { if (this.mouseMoveCallBack == null && this.entity && this.entity.id) { regMoveCallback2(this.entity.id, this.mouseMoveCB, this) } diff --git a/src/Obj/Element/Dialog/index.js b/src/Obj/Element/Dialog/index.js index ab815f6..aecd327 100644 --- a/src/Obj/Element/Dialog/index.js +++ b/src/Obj/Element/Dialog/index.js @@ -2,13 +2,10 @@ import BaseDialog from '../../../BaseDialog'; class Dialog extends BaseDialog { constructor(sdk, info, options, only) { - super(sdk.viewer._container, options); + super(sdk.viewer._container, options, only); this.sdk = sdk this.viewer = sdk.viewer this.info = info - if (only) { - this.closeAll() - } this._init() } diff --git a/static/custom/css/index.css b/static/custom/css/index.css index 193d824..32cb742 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -3490,3 +3490,27 @@ .YJ-custom-base-dialog.contour>.content .label { flex: unset; } + +/* 锚点设置 */ +.YJ-custom-base-dialog.anchor-point { + user-select: none; +} + +.YJ-custom-base-dialog.anchor-point>.content { + padding: 14px 40px; +} + +.YJ-custom-base-dialog.anchor-point>.content>div { + border: 1px solid #757575; + position: relative; +} + +.YJ-custom-base-dialog.anchor-point>.content>div>.point { + width: 10px; + height: 10px; + position: absolute; + background: #FFDF53; + border-radius: 50%; + border: 1px solid #ff7300; + cursor: pointer; +}