diff --git a/src/BaseDialog/index.js b/src/BaseDialog/index.js index df9aab3..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 @@ -48,6 +51,15 @@ class BaseDialog { ` this._element.body.appendChild(this._element.foot) + let curtain = await document.createElement('div') + curtain.style.position = 'absolute' + curtain.style.top = '0' + curtain.style.left = '0' + curtain.style.width = '100%' + curtain.style.height = '100%' + curtain.style.backdropFilter = 'blur(2px)' + curtain.style.zIndex = '-999999' + this._element.body.appendChild(curtain) // 关闭 let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0]; diff --git a/src/Draw/drawAttackArrow.js b/src/Draw/drawAttackArrow.js index 0cd20a4..c9208e2 100644 --- a/src/Draw/drawAttackArrow.js +++ b/src/Draw/drawAttackArrow.js @@ -59,12 +59,17 @@ export default class DrawAttackArrow extends Draw { return } into = '3D' + let pos84 = this.cartesian3Towgs84(cartesian, this.viewer) + let lastPos84 = cache_positions[cache_positions.length - 1] + if(lastPos84 && (lastPos84.lng === pos84.lng && lastPos84.lat === pos84.lat)) { + return + } if (!this.entityHasCreated) { let polyline_id = DrawAttackArrow.create_arrow_polygon(this) this.points_ids.push(polyline_id) } this.points_ids.push(this.create_point(cartesian)) - cache_positions.push(this.cartesian3Towgs84(cartesian, this.viewer)) + cache_positions.push(pos84) isMove = false }) this.event.mouse_right((movement, cartesian) => { diff --git a/src/Draw/drawPolygon.js b/src/Draw/drawPolygon.js index 84cbb9f..af9780a 100644 --- a/src/Draw/drawPolygon.js +++ b/src/Draw/drawPolygon.js @@ -13,6 +13,7 @@ class DrawPolygon extends Draw { * */ constructor(sdk, options = {}) { super(sdk, options) + this.color = options.color || 'rgba(255,0,0,0.5)' this.polygonHasCreated = false } @@ -34,8 +35,8 @@ class DrawPolygon extends Draw { positions: new Cesium.CallbackProperty((e) => { return that.positions.concat(that.positions[0]) }), - width: 2, - material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5), + width: 3, + material: Cesium.Color.fromCssColorString(that.color).withAlpha(1), clampToGround: true, zIndex: 99999999 }, diff --git a/src/Global/MapPrint/index.js b/src/Global/MapPrint/index.js index dd16630..43ba23c 100644 --- a/src/Global/MapPrint/index.js +++ b/src/Global/MapPrint/index.js @@ -1420,11 +1420,11 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) { const url = URL.createObjectURL(blob); let downloadElement = document.createElement('a'); downloadElement.href = url; - downloadElement.download = `高清出图-${getDateTimeString()}.jpg`; + downloadElement.download = `高清出图-${getDateTimeString()}.png`; document.body.appendChild(downloadElement); downloadElement.click(); document.body.removeChild(downloadElement); - }, 'image/jpeg', 0.95); + }, 'image/png', 0.95); exporting = false; exportBtn.innerHTML = '打印'; // canvas2.toBlob(function (blob) { diff --git a/src/Global/MapX/index.js b/src/Global/MapX/index.js index a96b34f..d16f0cd 100644 --- a/src/Global/MapX/index.js +++ b/src/Global/MapX/index.js @@ -124,7 +124,7 @@ function syncViewer() { if (height > 9000000) { height = 9000000 } - if (height < 100000) { + if (height < 400000) { this.entity.billboard.show = true this.entity.rectangle.show = false } diff --git a/src/Global/MouseCoordinate/index.js b/src/Global/MouseCoordinate/index.js index 0189c67..147f96a 100644 --- a/src/Global/MouseCoordinate/index.js +++ b/src/Global/MouseCoordinate/index.js @@ -4,18 +4,38 @@ import Tools from "../../Tools"; import { getCoordinateSystem } from "../../Global/global"; import MouseEvent from '../../Event/index' +import { getSdk as get2DSdk } from '../../Global/MultiViewportMode' +import { getSdk as getSplitScreenSdk } from "../../Global/SplitScreen"; let event +let event2 let MouseCoordinateElm let requestAnimationFrameEventId +let tmovement +let targetSdk +let sdkD const MouseCoordinate = (sdk, status) => { + if (!sdk || !sdk.viewer) { + return + } + targetSdk = sdk + sdkD = get2DSdk().sdkD + if(!sdkD) { + sdkD = getSplitScreenSdk().sdkD + } + let tools = new Tools(sdk) if (status) { if (event) { event.destroy() } + if (event2) { + event2.destroy() + event2 = undefined + } event = new MouseEvent(sdk) + tmovement = null let position = { x: '', y: '', @@ -40,22 +60,60 @@ const MouseCoordinate = (sdk, status) => { contentElm.style['background-size'] = `200% 200%`; MouseCoordinateElm = contentElm } - sdk.viewer._element.appendChild(contentElm) - let tmovement + sdk.viewer.container.appendChild(contentElm) + event.mouse_move((movement, cartesian) => { - tmovement = { ...movement } + targetSdk = sdk + tmovement = { ...movement.endPosition } }) const getPosition = () => { - if(!tmovement) { + if (!targetSdk) { return } let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0] - let left = tmovement.endPosition.x; - let top = tmovement.endPosition.y; - let cartesian = event.getcartesian(tmovement) - contentElm.style['background-position-x'] = `${-canvas.width + left + 4}px`; - contentElm.style['background-position-y'] = `${-canvas.height + top - 2}px`; + sdkD = get2DSdk().sdkD + if(!sdkD) { + sdkD = getSplitScreenSdk().sdkD + } + if (!event2 && sdkD) { + event2 = new MouseEvent(sdkD) + event2.mouse_move((movement, cartesian) => { + targetSdk = sdkD + tmovement = { x: movement.endPosition.x, y: movement.endPosition.y } + }) + } + if (!tmovement) { + return + } + let left = tmovement.x; + let top = tmovement.y; + let cartesian + if (targetSdk.viewer.scene.mode === 2) { + left = left + canvas.width + cartesian = targetSdk.viewer.camera.pickEllipsoid(tmovement, targetSdk.viewer.scene.globe.ellipsoid) + } + else { + cartesian = targetSdk.viewer.scene.pickPosition(tmovement) + if (!cartesian) { + const ray = targetSdk.viewer.camera.getPickRay(position); //相交的射线 + let pickedObjects = targetSdk.viewer.scene.drillPickFromRay(ray, 10); + let result = {} + for (let i = 0; i < pickedObjects.length; i++) { + if (pickedObjects[i].position) { + result = pickedObjects[i] + break + } + } + cartesian = result.position + if (!cartesian) { + cartesian = targetSdk.viewer.scene.globe.pick(ray, targetSdk.viewer.scene); + } + } + } + contentElm.style['background-position-x'] = `${-sdk.viewer.container.clientWidth + left + 4}px`; + + contentElm.style['background-position-y'] = `${-sdk.viewer.container.clientHeight + top - 2}px`; // this.entity.position = cartesian if (cartesian) { let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer) @@ -97,10 +155,13 @@ const MouseCoordinate = (sdk, status) => { else { if (event) { event.destroy() - event = undefined + } + if (event2) { + event2.destroy() + event2 = undefined } if (MouseCoordinateElm) { - sdk.viewer._element.removeChild(MouseCoordinateElm) + sdk.viewer.container.removeChild(MouseCoordinateElm) MouseCoordinateElm = undefined } if (requestAnimationFrameEventId) { diff --git a/src/Global/MultiViewportMode/index.js b/src/Global/MultiViewportMode/index.js index 0d63e89..9e61089 100644 --- a/src/Global/MultiViewportMode/index.js +++ b/src/Global/MultiViewportMode/index.js @@ -49,7 +49,16 @@ async function init(sdk) { sdk2D.viewer.imageryLayers.removeAll() for (let i = 0; i < imageryLayers.length; i++) { let entity = sdk2D.viewer.imageryLayers.addImageryProvider(imageryLayers[i].imageryProvider, imageryLayers[i]._layerIndex) + if(imageryLayers[i]._id) { + entity._id = imageryLayers[i]._id + } entity.show = imageryLayers[i].show + entity.alpha = imageryLayers[i].alpha + 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 +70,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) { @@ -94,6 +109,11 @@ function off(sdk) { activeViewer = null syncObject = {} } + sdk.entityMap.forEach((item, key) => { + if (item.showView) { + item.show = item.show + } + }) } async function syncData2(sdk, id, entityId) { @@ -119,7 +139,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.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer' && that.type !== 'wallStereoscopic')) { + if (that.showView == 3) { + options.show = false + } let newObject = await new that.constructor(sdk2D, options) newObject.onClick = that.onClick newObject.onRightClick = that.onRightClick @@ -207,8 +231,15 @@ async function syncData2(sdk, id, entityId) { obj.options.heightReference = 1 } let options = syncObject.tools.deepCopyObj(obj.options) - if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer')) { - let target = await new obj.constructor(sdk2D, options) + if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer' && obj.type !== 'wallStereoscopic')) { + if (obj.showView == 3) { + options.show = false + } + let target = await sdk2D.entityMap.get(options.id) + if(target) { + await target.remove() + } + target = await new obj.constructor(sdk2D, options) target.onClick = obj.onClick target.onRightClick = obj.onRightClick target.onMouseMove = obj.onMouseMove @@ -401,11 +432,25 @@ function syncImageryLayerRemoved(layer, index) { sdk2D.viewer.imageryLayers.remove(layer2d) } function syncImageryLayerShownOrHidden(layer, index, state) { + return let layer2d = sdk2D.viewer.imageryLayers._layers[index] + let layer3d = sdk3D.viewer.imageryLayers._layers[index] + console.log('layer2d', layer2d, sdk2D, layer3d) + if (!layer2d) { return } - layer2d.show = state + if (layer3d._objectState) { + if (!layer3d._showView || layer3d._showView == 2) { + layer2d.show = true + } + if (layer3d._showView == 3) { + layer2d.show = false + } + } + else { + layer2d.show = state + } } async function syncPrimitives(primitive) { @@ -535,6 +580,7 @@ function syncViewer() { } + function get2DView() { return sdk2D } diff --git a/src/Global/SplitScreen/index.js b/src/Global/SplitScreen/index.js index 8df76aa..845b6ee 100644 --- a/src/Global/SplitScreen/index.js +++ b/src/Global/SplitScreen/index.js @@ -517,7 +517,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) { thatD.textShow = thatP.textShow } if (thatP.label && thatP.labelShow) { - thatP.label.entity.show = true + thatP.labelShow = true } if (thatD.label) { thatD.label.options.ground = false diff --git a/src/Global/mouseRightMenu/index.js b/src/Global/mouseRightMenu/index.js index 0fd350e..8b9a223 100644 --- a/src/Global/mouseRightMenu/index.js +++ b/src/Global/mouseRightMenu/index.js @@ -121,6 +121,9 @@ function MouseRightMenu(sdk, status, callBack) { + ${addedMenu} ` _element.appendChild(menuElm) @@ -175,6 +178,7 @@ function MouseRightMenu(sdk, status, callBack) { break case '文本框': object.position = position + key = 'textBox' break } eventListener[sdk.div_id].callBack(key, object) diff --git a/src/Measure/MeasureDistance/index.js b/src/Measure/MeasureDistance/index.js index 7bb3749..52755af 100644 --- a/src/Measure/MeasureDistance/index.js +++ b/src/Measure/MeasureDistance/index.js @@ -91,7 +91,7 @@ class MeasureDistance extends Measure { //暂时固定取20个点 - if (d > 20) {//大于20m时,固定取20个点 + if (d > 2) {//大于20m时,固定取20个点 meters = d / 20 await start(meters) } else if (d < 1) { @@ -106,8 +106,8 @@ class MeasureDistance extends Measure { async sampleHeight(p1, index) { - let p2 = await this.sampleHeightMostDetailed([p1]) - p1.alt = p2[0].height + let height = await this.getClampToHeight(p1, [...this.sdk.viewer.entities.values]) + p1.alt = height return {position: p1, index} } diff --git a/src/Obj/Analysis/Contour/index.js b/src/Obj/Analysis/Contour/index.js index 6a246f9..56f8dff 100644 --- a/src/Obj/Analysis/Contour/index.js +++ b/src/Obj/Analysis/Contour/index.js @@ -47,6 +47,11 @@ class ContourAnalysis { YJ.Analysis.AnalysesResults.push(this) this.createNewLine(); } + + get type() { + return 'ContourAnalysis' + } + createNewLine() { ContourAnalysis.interpolatePoint(this); } diff --git a/src/Obj/Analysis/Visibility/index.js b/src/Obj/Analysis/Visibility/index.js index a7e44cd..0f115ce 100644 --- a/src/Obj/Analysis/Visibility/index.js +++ b/src/Obj/Analysis/Visibility/index.js @@ -63,11 +63,15 @@ class VisibilityAnalysis extends Tools { that.tip.set_text("左键创建视角终点,右键结束通视分析") if (!that.resultObject.viewPoint) { let pos84 = that.cartesian3Towgs84(cartesian, that.viewer) - let positions = await Cesium.sampleTerrainMostDetailed( - that.sdk.viewer.terrainProvider, - [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)] - ); - if (positions[0].height > pos84.alt) { + let positions + if(that.sdk.viewer.terrainProvider.availability) + { + positions = await Cesium.sampleTerrainMostDetailed( + that.sdk.viewer.terrainProvider, + [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)] + ); + } + if (positions && positions[0].height > pos84.alt) { pos84.alt = positions[0].height } pos84.alt = pos84.alt + that.viewPointHeight diff --git a/src/Obj/Base/AssembleObject/index.js b/src/Obj/Base/AssembleObject/index.js index e04f065..3ee6ba0 100644 --- a/src/Obj/Base/AssembleObject/index.js +++ b/src/Obj/Base/AssembleObject/index.js @@ -40,7 +40,7 @@ class AssembleObject extends Base { this.options.positions = options.positions || [] this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) diff --git a/src/Obj/Base/AttackArrowObject/index.js b/src/Obj/Base/AttackArrowObject/index.js index c3aaaac..ec83033 100644 --- a/src/Obj/Base/AttackArrowObject/index.js +++ b/src/Obj/Base/AttackArrowObject/index.js @@ -40,7 +40,7 @@ class AttackArrowObject extends Base { this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) diff --git a/src/Obj/Base/BaseSource/BaseLayer/index.js b/src/Obj/Base/BaseSource/BaseLayer/index.js index f4a0a79..083fd74 100644 --- a/src/Obj/Base/BaseSource/BaseLayer/index.js +++ b/src/Obj/Base/BaseSource/BaseLayer/index.js @@ -9,7 +9,7 @@ import Dialog from '../../../Element/Dialog'; import CoordTransform from "../../../../transform/CoordTransform"; import BaseSource from "../index"; -import { syncData } from '../../../../Global/MultiViewportMode' +import { syncData, get2DView } from '../../../../Global/MultiViewportMode' import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen' import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' @@ -244,8 +244,19 @@ class BaseLayer extends BaseSource { this.originalOptions = this.deepCopyObj(this.options) this._DialogObject.close() this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) - syncData(this.sdk, this.options.id) + // syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + let sdk2D = get2DView() + if (sdk2D && sdk2D != this.sdk) { + for(let i=0;i { this.reset() diff --git a/src/Obj/Base/BaseSource/BaseModel/Model/_element.js b/src/Obj/Base/BaseSource/BaseModel/Model/_element.js index 9301b0f..1385d7a 100644 --- a/src/Obj/Base/BaseSource/BaseModel/Model/_element.js +++ b/src/Obj/Base/BaseSource/BaseModel/Model/_element.js @@ -56,7 +56,7 @@ function html(that) {
- 固定大小 + 固定大小
diff --git a/src/Obj/Base/BaseSource/BaseTerrain/index.js b/src/Obj/Base/BaseSource/BaseTerrain/index.js index 0d2336c..9f9a087 100644 --- a/src/Obj/Base/BaseSource/BaseTerrain/index.js +++ b/src/Obj/Base/BaseSource/BaseTerrain/index.js @@ -8,7 +8,7 @@ import Dialog from '../../../Element/Dialog'; import { getHost } from "../../../../on"; import BaseSource from "../index"; -import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' +import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen' class BaseTerrain extends BaseSource { @@ -78,6 +78,11 @@ class BaseTerrain extends BaseSource { close() { this.sdk.viewer.scene.terrainProvider = new Cesium.EllipsoidTerrainProvider({}) + for (let i = 0; i < YJ.Analysis.AnalysesResults.length; i++) { + if (YJ.Analysis.AnalysesResults[i].type === 'ContourAnalysis') { + YJ.Analysis.AnalysesResults[i].destroy() + } + } syncSplitData(this.sdk, this.options.id) clearTimeout(this.#updateModelTimeout) @@ -156,7 +161,7 @@ class BaseTerrain extends BaseSource { } 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/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js index 053a51c..98f8857 100644 --- a/src/Obj/Base/BillboardObject/index.js +++ b/src/Obj/Base/BillboardObject/index.js @@ -40,6 +40,11 @@ import { import { getGoodsList } from '../../../Tools/getGoodsList' class BillboardObject extends Base { + #_postRenderEvent = null + #_destroyMouseEvent = null + #_billboardHeight = 0 + + /** * @constructor * @description 创建点标注 @@ -118,6 +123,7 @@ class BillboardObject extends Base { this.options.positions.alt = Number( Number(options.positions.alt || 0).toFixed(2) ) + this.#_billboardHeight = this.options.positions.alt // this.options.diffuseShow = options.diffuseShow || false // this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10 // this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000 @@ -145,11 +151,18 @@ class BillboardObject extends Base { this.options.attribute.goods.content || [] this.options.attributeType = options.attributeType || 'richText' this.options.coordinate = options.coordinate || '' + this.options.attributeBoxState = options.attributeBoxState || false this.operate = {} this._elms = {} this.previous = { positions: { ...this.options.positions } } + this.options.attributePos = options.attributePos || { + x: 60, + y: 60, + width: 200, + height: 120 + } this.entity this._proj = this.sdk.proj @@ -182,7 +195,108 @@ class BillboardObject extends Base { + this.#_destroyMouseEvent = () => { + this.attributeElm && (this.attributeElm.style.pointerEvents = 'unset') + this.sdk.viewer._element.onmousemove = null + document.removeEventListener('mouseup', this.#_destroyMouseEvent) + document.removeEventListener('mouseleave', this.#_destroyMouseEvent) + } + this.#_postRenderEvent = () => { + let siteInfoPosition = Cesium.Cartesian3.fromDegrees( + this.options.positions.lng, + this.options.positions.lat, + this.#_billboardHeight + ) + if (this.attributeElm && this.entity) { + let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates( + siteInfoPosition + ) + let pixelOffset = this.entity.label.pixelOffset.getValue() + if (winpos) { + let scale = getCurrentBillboardScale(this.entity, this.sdk.viewer.scene) + let height = ((this.entity.billboard.height.getValue() * (this.options.billboard.scale || 0)) + this.options.label.fontSize) * (1 - (scale * scale)) + let flag = false + let lineElm = this.attributeElm.getElementsByClassName('billboard-attribute-box-line')[0] + let leftTopElm = this.attributeElm.getElementsByClassName('left-top')[0] + let rightTopElm = this.attributeElm.getElementsByClassName('right-top')[0] + this.attributeElm.style.left = (winpos.x + this.options.attributePos.x).toFixed(0) + 'px' + this.attributeElm.style.top = (winpos.y + pixelOffset.y - (this.options.label.show ? (this.options.label.fontSize / 2) : -(this.options.label.fontSize / 2)) - this.attributeElm.offsetHeight - this.options.attributePos.y + height).toFixed(0) + 'px' + this.attributeElm.style.width = this.options.attributePos.width + 'px' + this.attributeElm.style.height = this.options.attributePos.height + 'px' + if (this.options.attributePos.x < -this.options.attributePos.width / 2) { + flag = true + lineElm.style.left = 'unset' + lineElm.style.right = '0' + leftTopElm.style.display = 'block' + rightTopElm.style.display = 'none' + } + else { + lineElm.style.left = '0' + lineElm.style.right = 'unset' + leftTopElm.style.display = 'none' + rightTopElm.style.display = 'block' + } + + let lineLength + let lineAngleRad + let lineAngle + let x + let y + if (flag) { + x = this.attributeElm.offsetWidth + this.options.attributePos.x + y = this.options.attributePos.y ? this.options.attributePos.y : 0 + } + else { + x = this.options.attributePos.x + y = this.options.attributePos.y ? this.options.attributePos.y : 0 + } + lineLength = Math.sqrt((x * x) + (y * y)).toFixed(2); + lineAngleRad = Math.atan(x / y); + lineAngle = parseFloat((lineAngleRad * 180 / Math.PI).toFixed(2)); + if (this.options.attributePos.y < 0) { + lineAngle = lineAngle + 180 + } + // if(this.options.attributePos.y<-this.options.attributePos.height/2) { + // lineElm.style.bottom = 'unset' + // lineElm.style.top = '0' + // } + // else { + // lineElm.style.bottom = -lineLength + 'px' + // lineElm.style.top = 'unset' + // } + lineElm.style.height = lineLength + 'px' + lineElm.style.transform = 'rotate(' + lineAngle + 'deg)' + } + } + } + + function getCurrentBillboardScale(entity, scene) { + // 获取相机到Billboard的距离 + const distance = Cesium.Cartesian3.distance( + scene.camera.positionWC, + entity.position.getValue() + ); + // 获取缩放距离配置 + const scaleByDistance = entity.billboard.scaleByDistance ? entity.billboard.scaleByDistance.getValue() : undefined; + + if (!scaleByDistance) { + // 如果没有设置距离缩放,则使用基础缩放值 + return 1.0; + } + + // 解析缩放距离参数 [near, nearScale, far, farScale] + const { near, nearValue, far, farValue } = scaleByDistance; + if (distance <= near) { + return nearValue; + } else if (distance >= far) { + return farValue; + } else { + // 计算中间距离的缩放值(线性插值) + const t = (distance - near) / (far - near); + return Cesium.Math.lerp(nearValue, farValue, t); + } + } this.sdk.addIncetance(this.options.id, this) @@ -243,6 +357,7 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = 0 that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) + that.attributeBoxState && (that.attributeBoxState = true) } return } @@ -267,13 +382,14 @@ class BillboardObject extends Base { return img }, false) addCluster(that.sdk, that.entity) + that.attributeBoxState && (that.attributeBoxState = true) } }) } else { let image = new Image() image.src = - url || + url || that.getSourceRootPath() + '/img/A-ablu-blank.png' switch (that.options.heightMode) { case 2: @@ -298,6 +414,7 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = height that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) + that.attributeBoxState && (that.attributeBoxState = true) } } image.onerror = function (err) { @@ -309,6 +426,7 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = 0 that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) + that.attributeBoxState && (that.attributeBoxState = true) } }; } @@ -465,14 +583,45 @@ 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) + if (this.attributeBoxState && this.options.show) { + this.attributeBoxState = this.options.show + } + else { + // 关闭属性框 + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + if (this.attributeElm) { + this.sdk.viewer._element.removeChild(this.attributeElm) + this.attributeElm = null + } + this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) + } + } + else { + this.entity && (this.entity.show = false) + // 关闭属性框 + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + if (this.attributeElm) { + this.sdk.viewer._element.removeChild(this.attributeElm) + this.attributeElm = null + } + this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) + } 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 @@ -552,6 +701,26 @@ class BillboardObject extends Base { if (this.entity) { this.entity.billboard.heightReference = heightMode this.entity.label.heightReference = heightMode + if(heightMode == Cesium.HeightReference.CLAMP_TO_GROUND) { + if (this.sdk.viewer.scene.terrainProvider.availability) { + Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.positions.lng, + this.options.positions.lat + ) + ] + ).then(position => { + this.#_billboardHeight = position[0].height + }) + } else { + this.#_billboardHeight = 0 + } + } + else { + this.#_billboardHeight = this.options.positions.alt + } } this._elms.heightMode && (this._elms.heightMode.value = heightModeName) } @@ -606,6 +775,7 @@ class BillboardObject extends Base { } set alt(v) { this.options.positions.alt = Number(Number(v).toFixed(2)) + this.#_billboardHeight = this.options.positions.alt // this.scan && (this.scan.alt = v) // this.diffuse && (this.diffuse.alt = v) this.renewPoint() @@ -766,6 +936,8 @@ class BillboardObject extends Base { _this._frameImages = [] superGif.load(function (status) { if (status == 404) { + let width = 31 + let height = 36 canvas = document.createElement('canvas') canvas.width = 0 canvas.height = 0 @@ -855,6 +1027,8 @@ class BillboardObject extends Base { billboardH = height * (31 / width) } image.onerror = function (err) { + let width = 31 + let height = 36 canvas.width = 0 canvas.height = 0 billboardH = 0 @@ -1702,6 +1876,22 @@ class BillboardObject extends Base { this.cameraSelect && this.cameraSelect() this.ISCSelect && this.ISCSelect() this.goodsSelect && this.goodsSelect() + + let col = document.createElement('div') + col.className = 'col' + col.style.flex = '0 0 110px' + col.innerHTML = ` + 属性框 + + ` + + let row = this._DialogObject._element.content.getElementsByClassName('attribute')[0].getElementsByClassName('row')[0] + row.appendChild(col) + let boxSwitch = col.getElementsByClassName('btn-switch')[0] + boxSwitch.checked = this.attributeBoxState + boxSwitch.addEventListener('change', (e) => { + this.attributeBoxState = boxSwitch.checked + }) let tagData = this.attributeSelect let attributeElm = this._DialogObject._element.content.getElementsByClassName( 'attribute-select-box' @@ -2213,6 +2403,7 @@ class BillboardObject extends Base { this.attributeCamera = this.options.attribute.camera.content this.attributeGoods = this.options.attribute.goods.content this.attributeISC = this.options.attribute.ISC.content + this.attributeBoxState = this.options.attributeBoxState this.cameraSelect && this.cameraSelect() this.goodsSelect && this.goodsSelect() } @@ -2220,6 +2411,7 @@ class BillboardObject extends Base { async remove() { await remove_entity_from_cluster(this.sdk.viewer, this.entity) this.entity = null + this.attributeBoxState = false if (!this.sdk.viewer || !this.sdk.viewer.entities) { return } @@ -2344,6 +2536,9 @@ class BillboardObject extends Base { } async updateHeight() { + if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) { + return + } let height let height2 let point1 = new Cesium.Cartesian3.fromDegrees( @@ -2422,6 +2617,7 @@ class BillboardObject extends Base { switch (this._elms.heightMode.value) { case '海拔高度': heightElm.value = this.options.positions.alt + this.#_billboardHeight = this.options.positions.alt break case '相对地表': if (this.sdk.viewer.scene.terrainProvider.availability) { @@ -2437,15 +2633,18 @@ class BillboardObject extends Base { heightElm.value = Number( (this.options.positions.alt - position[0].height).toFixed(2) ) + this.#_billboardHeight = this.options.positions.alt }) } else { heightElm.value = this.options.positions.alt + this.#_billboardHeight = this.options.positions.alt } break case '依附地表': break case '依附模型': heightElm.value = this.options.positions.alt + this.#_billboardHeight = this.options.positions.alt break } } @@ -2719,6 +2918,216 @@ class BillboardObject extends Base { (this.originalOptions.customView = this.options.customView) } } + + get attributeBoxState() { + return this.options.attributeBoxState + } + + set attributeBoxState(state) { + state = state ? true : false + this.options.attributeBoxState = state + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + if (this.attributeElm) { + this.sdk.viewer._element.removeChild(this.attributeElm) + this.attributeElm = null + } + this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) + if (state && this.sdk && this.sdk.viewer && this.sdk.viewer._element && this.show) { + let attributeElm = document.createElement('div') + this.attributeElm = attributeElm + attributeElm.className = 'billboard-attribute-box' + attributeElm.style.top = '0px' + attributeElm.style.left = '0px' + attributeElm.style.width = 0 + attributeElm.style.height = 0 + // attributeElm.innerHTML = this.options.richTextContent + this.sdk.viewer._element.appendChild(attributeElm) + let linkHtml = '' + let goodsHtml = '' + let richTextHtml = '' + for (let i = 0; i < this.options.attribute.link.content.length; i++) { + linkHtml += `` + } + if (this.options.attribute.goods && this.options.attribute.goods.content && this.options.attribute.goods.content.length > 0) { + goodsHtml += ` +
+
+
+
序号
+
名称
+
数量
+
+
+
+ ` + for (let i = 0; i < this.options.attribute.goods.content.length; i++) { + goodsHtml += `
+
${i + 1}
+
${this.options.attribute.goods.content[i].name}
+
${this.options.attribute.goods.content[i].cnt}
+
` + } + goodsHtml += `
` + } + if (this.options.richTextContent) { + richTextHtml = ` + ${this.options.richTextContent} + ` + } + + let boxHtml = ` + + + ` + + if (!linkHtml && !goodsHtml && !richTextHtml) { + boxHtml = boxHtml + '

暂无属性信息

' + } + else { + boxHtml = boxHtml + ` + + ${richTextHtml} + ${goodsHtml} + ${linkHtml} + +
` + } + + attributeElm.innerHTML = boxHtml + + if (attributeElm.getElementsByClassName('tabs')[0]) { + let tabsElm = new cy_tabs(attributeElm.getElementsByClassName('tabs')[0], undefined, this.sdk) + } + + let imgElm = attributeElm.getElementsByTagName('img') + for (let i = 0; i < imgElm.length; i++) { + if (!imgElm[i].style.width) { + imgElm[i].style.width = '100%' + } + } + + this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent) + let leftOnmousedown = (e) => { + if (this.options.attributePos.width < 200) { + this.options.attributePos.width = 200 + } + if (this.options.attributePos.height < 120) { + this.options.attributePos.height = 120 + } + let x = e.x + let y = e.y + let width = this.options.attributePos.width + let height = this.options.attributePos.height + let positionx = this.options.attributePos.x + this.sdk.viewer._element.onmousemove = (e2) => { + this.options.attributePos.width = width + (x - e2.x) + this.options.attributePos.height = height + (y - e2.y) + if (this.options.attributePos.width < 200) { + this.options.attributePos.width = 200 + } + else { + this.options.attributePos.x = positionx - (x - e2.x) + } + if (this.options.attributePos.height < 120) { + this.options.attributePos.height = 120 + } + // this.options.attributePos.y = positiony + (y - e2.y) + } + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + } + let rightOnmousedown = (e) => { + let x = e.x + let y = e.y + if (this.options.attributePos.width < 200) { + this.options.attributePos.width = 200 + } + if (this.options.attributePos.height < 120) { + this.options.attributePos.height = 120 + } + let width = this.options.attributePos.width + let height = this.options.attributePos.height + this.sdk.viewer._element.onmousemove = (e2) => { + this.options.attributePos.width = width + (e2.x - x) + this.options.attributePos.height = height + (y - e2.y) + } + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + } + // leftTopElm.onmousedown = (e) => { + // console.log(1111111111) + // if (this.options.attributePos.width < 200) { + // this.options.attributePos.width = 200 + // } + // if (this.options.attributePos.height < 120) { + // this.options.attributePos.height = 120 + // } + // let x = e.x + // let y = e.y + // let width = this.options.attributePos.width + // let height = this.options.attributePos.height + // let positionx = this.options.attributePos.x + // this.sdk.viewer._element.onmousemove = (e2) => { + // this.options.attributePos.width = width + (x - e2.x) + // this.options.attributePos.height = height + (y - e2.y) + // if (this.options.attributePos.width < 200) { + // this.options.attributePos.width = 200 + // } + // else { + // this.options.attributePos.x = positionx - (x - e2.x) + // } + // if (this.options.attributePos.height < 120) { + // this.options.attributePos.height = 120 + // } + // // this.options.attributePos.y = positiony + (y - e2.y) + // } + // document.addEventListener('mouseup', this.#_destroyMouseEvent); + // document.addEventListener('mouseleave', this.#_destroyMouseEvent); + // } + // rightTopElm.onmousedown = (e) => { + // let x = e.x + // let y = e.y + // if (this.options.attributePos.width < 200) { + // this.options.attributePos.width = 200 + // } + // if (this.options.attributePos.height < 120) { + // this.options.attributePos.height = 120 + // } + // let width = this.options.attributePos.width + // let height = this.options.attributePos.height + // this.sdk.viewer._element.onmousemove = (e2) => { + // this.options.attributePos.width = width + (e2.x - x) + // this.options.attributePos.height = height + (y - e2.y) + // } + // document.addEventListener('mouseup', this.#_destroyMouseEvent); + // document.addEventListener('mouseleave', this.#_destroyMouseEvent); + // } + + attributeElm.onmousedown = (e) => { + attributeElm.style.pointerEvents = 'none' + if (e.target.className.indexOf('left-top') != -1) { + leftOnmousedown(e) + } + else if (e.target.className.indexOf('right-top') != -1) { + rightOnmousedown(e) + } + else { + let x = e.x + let y = e.y + let oldX = this.options.attributePos.x + let oldXY = this.options.attributePos.y + let height = this.options.attributePos.height + this.sdk.viewer._element.onmousemove = (e2) => { + this.options.attributePos.x = oldX + (e2.x - x) + this.options.attributePos.y = oldXY - (e2.y - y) + } + document.addEventListener('mouseup', this.#_destroyMouseEvent); + document.addEventListener('mouseleave', this.#_destroyMouseEvent); + } + } + } + } } export default BillboardObject diff --git a/src/Obj/Base/CircleDiffuse/index.js b/src/Obj/Base/CircleDiffuse/index.js index be4646d..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,16 +223,31 @@ class CircleDiffuse extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - this.entity.show = v + let sdkD = get2DSdk().sdkD + if (!this.isShowView || !sdkD) { + this.options.show = v + } + if (!this.showView || this.showView == 3 || !sdkD) { + 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") } @@ -362,6 +377,7 @@ class CircleDiffuse extends Base { return this.options.circle } set circle(v) { + console.log(v) this.options.circle = v || [{ radius: 10 }] for (let i = 0; i < this.options.circle.length; i++) { if(this.options.circle[i].radius>999999) { @@ -427,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) { + if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { this.label.show = v } else { @@ -1321,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 @@ -1405,7 +1422,7 @@ class CircleDiffuse extends Base { } } this._radius = radius - inputElm.value = value + // inputElm.value = value CircleDiffuse.create(this) } } diff --git a/src/Obj/Base/CircleObject/index.js b/src/Obj/Base/CircleObject/index.js index a6e88d1..d85022b 100644 --- a/src/Obj/Base/CircleObject/index.js +++ b/src/Obj/Base/CircleObject/index.js @@ -45,7 +45,7 @@ class CircleObject extends Base { this.options.center = options.center || {} this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' options.label = options.label || {} this._elms = {}; @@ -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/CurvelineObject/index.js b/src/Obj/Base/CurvelineObject/index.js index aec879c..0f632a0 100644 --- a/src/Obj/Base/CurvelineObject/index.js +++ b/src/Obj/Base/CurvelineObject/index.js @@ -30,7 +30,7 @@ class CurvelineObject extends Base { * @param options.heightMode{number} 高度模式(0:海拔高度;1:相对高度;2:依附模式) * @param options['nose-to-tail']=false {boolean} 首尾相连 * @param options.extend=false {boolean} 线缓冲 - * @param options['extend-width']=1 {number} 线缓冲宽度 + * @param options['extend-width']=10 {number} 线缓冲宽度 * @param options['extend-color']=#ffde00 {number} 线缓冲颜色 * @param options.show=true {boolean} 显隐 * @param {Array.} options.positions 坐标数组 [{lng,lat},...] @@ -66,8 +66,8 @@ class CurvelineObject extends Base { this.options['extend-width'] = options['extend-width'] || options['extend-width'] === 0 ? options['extend-width'] - : 1 - this.options['extend-color'] = options['extend-color'] || '#ffde00' + : 10 + this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' this.options.show = options.show || options.show === false ? options.show : true this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 diff --git a/src/Obj/Base/EllipseObject/index.js b/src/Obj/Base/EllipseObject/index.js index 1ad1c75..7b4631c 100644 --- a/src/Obj/Base/EllipseObject/index.js +++ b/src/Obj/Base/EllipseObject/index.js @@ -24,7 +24,7 @@ class EllipseObject extends Base { * @param options.name {string} 名称 * @param options.show=true {boolean} 显示/隐藏 * @param options.center {object} 位置 - * @param options.color="#ff000080" {string} 颜色 + * @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色 * @param options.center.lng {object} 经度 * @param options.center.lat {object} 维度 * @param options.semiMinorAxis=10 {number} 短半轴长度 @@ -32,14 +32,14 @@ class EllipseObject extends Base { * @param options.bearing=0 {number} 旋转角度 * @param options.line {object} 边框 * @param options.line.width=2 {string} 边框宽 - * @param options.line.color="#ff000080" {string} 边框颜色 + * @param options.line.color="rgba(255, 0, 0, 1)" {string} 边框颜色 * @param options.label {object} 标注 * @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式) */ constructor(sdk, options = {}) { super(sdk, options); this.options.name = options.name || '未命名对象' - this.options.color = options.color || "#ff000080" + this.options.color = options.color || "rgba(255, 0, 0, 0.5)" this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10 this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20 @@ -47,7 +47,7 @@ class EllipseObject extends Base { this.options.center = options.center || {} this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' options.label = options.label || {} this._elms = {}; diff --git a/src/Obj/Base/GeoJson/index.js b/src/Obj/Base/GeoJson/index.js index 43e4b25..02a0bbe 100644 --- a/src/Obj/Base/GeoJson/index.js +++ b/src/Obj/Base/GeoJson/index.js @@ -8,6 +8,8 @@ import { getHost, getToken } from "../../../on"; import Base from '../index' import Tools from '../../../Tools' +import { syncSplitData } from "../../../Global/SplitScreen"; +import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode' import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global' class GeoJson extends Base { @@ -26,6 +28,7 @@ class GeoJson extends Base { this.primitive = undefined this.positions = [] + this.loading = true } @@ -48,6 +51,27 @@ class GeoJson extends Base { return this.options.show } + // set show(status) { + // let sdkD = get2DSdk().sdkD + // if (!this.isShowView || !sdkD) { + // this.options.show = status + // } + // if (this.entity) { + // 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 + // } + // } + // else { + // for (let i = 0; i < this.entity.entities.values.length; i++) { + // this.entity.entities.values[i].show = false + // } + // } + // } + // syncData(this.sdk, this.options.id) + // syncSplitData(this.sdk, this.options.id) + // this.isShowView = false + // } set show(status) { this.options.show = status if (this.entity) { @@ -74,6 +98,7 @@ class GeoJson extends Base { }) let json = await rsp.json() this.geojson = json + // this.sdk.addIncetance(this.options.id, this) return GeoJson.addDataToGlobe(this, json.features) } diff --git a/src/Obj/Base/GroundImage/_element.js b/src/Obj/Base/GroundImage/_element.js index 4f477d7..0edeb1e 100644 --- a/src/Obj/Base/GroundImage/_element.js +++ b/src/Obj/Base/GroundImage/_element.js @@ -1,5 +1,5 @@ function html() { - return ` + return `
@@ -7,13 +7,21 @@ function html() { 名称
-
-
+
+
+ +
+
+ 军标模式 +
+
+
+
旋转角度 @@ -24,16 +32,85 @@ function html() {
-
+
调整大小 - +
- +
+
+
+ 高度模式 +
+
+
+
+ 高度 +
+ + m + +
+
+
+
+ 图标倍数 +
+ + + +
+
+
+
+
+ 视野缩放 + +
+
+ 最近距离 +
+ + m + +
+
+
+ 最远距离 +
+ + m + +
+
+
+

文字设置

+
+
+ 显隐 + +
+
+ 字体选择 +
+
+
+ 文字大小 +
+ + px + +
+
+
+ 文字颜色 +
+
+
` diff --git a/src/Obj/Base/GroundImage/index.js b/src/Obj/Base/GroundImage/index.js index ea98a52..cf53684 100644 --- a/src/Obj/Base/GroundImage/index.js +++ b/src/Obj/Base/GroundImage/index.js @@ -4,10 +4,13 @@ import { html } from "./_element"; import EventBinding from '../../Element/Dialog/eventBinding'; import Base from "../index"; import MouseEvent from '../../../Event/index' +import { legp } from '../../Element/datalist' import { syncData } from '../../../Global/MultiViewportMode' +import { getGroundCover } from '../../../Global/global' import MouseTip from '../../../MouseTip' +import { getFontList, getFontFamily, getFontFamilyName } from '../../Element/fontSelect' 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 { /** @@ -24,7 +27,7 @@ class GroundImage extends Base { * @param options.flipe.x=false {boolean} 绕X轴翻转 * @param options.flipe.y=false {boolean} 绕Y轴翻转 * @param options.url {string} 图片地址 - * @param {Array.} options.positions 经纬度和高度的列表,值交替 [{lon,lat,alt},...] + * @param {Array.} options.position 经纬度和高度的列表,值交替 [{lon,lat,alt},...] * @param _Dialog {object} 弹框事件 * @param _Dialog.confirmCallBack {function} 弹框确认时的回调 * */ @@ -35,11 +38,32 @@ class GroundImage extends Base { this.options.url = options.url this.options.angle = options.angle || 0 this.options.scale = (options.scale || options.scale === 0) ? options.scale : 1 - this.options.positions = options.positions + this.options.position = options.position + this.options.offset = options.offset || { x: 0.5, y: 1 } + this.options.mode = this.options.mode ? 1 : 0 + this.options.billboard = options.billboard || {} + this.options.billboard.scale = this.options.billboard.scale || 1 + this.options.billboard.near = this.options.billboard.near || this.options.billboard.near === 0 ? this.options.billboard.near : 2000 + this.options.billboard.far = this.options.billboard.far || this.options.billboard.far === 0 ? this.options.billboard.far : 100000 + this.options.billboard.scaleByDistance = this.options.billboard.scaleByDistance ? true : false + + options.label = options.label || {} + this.options.label = options.label || {} + this.options.label.text = options.label.text || this.options.name + this.options.name = this.options.label.text + this.options.label.show = + options.label.show || options.label.show === false + ? options.label.show + : true + this.options.label.fontFamily = options.label.fontFamily || 0 + this.options.label.fontSize = options.label.fontSize || 39 + this.options.label.color = options.label.color || '#00ffff' this.options.flipe = options.flipe || {} this.options.flipe.x = this.options.flipe.x || false this.options.flipe.y = this.options.flipe.y || false + this.options.heightMode = + options.heightMode || options.heightMode == 0 ? options.heightMode : 3 this.entity = { id: this.options.id @@ -47,8 +71,9 @@ class GroundImage extends Base { this._positionEditing = false this.Dialog = _Dialog this._elms = {}; + this._proj = this.sdk.proj this.previous = { - positions: { ...this.options.positions } + position: { ...this.options.position } } this._EventBinding = new EventBinding() this.event = new MouseEvent(this.sdk) @@ -56,6 +81,197 @@ class GroundImage extends Base { this.create() } + get name() { + return this.options.name + } + + set name(v) { + super.name = v + this.options.label.text = this.options.name + this.entity && (this.entity.label.text = this.options.label.text) + } + + get mode() { + return this.options.mode + } + set mode(v) { + this.options.mode = v ? 1 : 0 + let modeData = [ + { + name: '贴地', + value: '贴地', + key: 0 + }, + { + name: '立体', + value: '立体', + key: 1 + } + ] + for (let i = 0; i < modeData.length; i++) { + if (modeData[i].key === this.options.mode) { + this._elms.mode && this._elms.mode.forEach((item) => { + item.value = modeData[i].value + }) + break + } + } + if (this._DialogObject && this._DialogObject._element && this._DialogObject._element.body) { + let elms = this._DialogObject._element.body.getElementsByClassName('row') + let elms2 = this._DialogObject._element.foot.getElementsByTagName('button') + let elms3 = this._DialogObject._element.foot.getElementsByTagName('h4') + for (let i = 0; i < elms.length; i++) { + let mode = elms[i].getAttribute('mode') + if (mode !== null) { + if (mode == this.options.mode) { + elms[i].style.display = 'flex' + } + else { + elms[i].style.display = 'none' + } + } + } + for (let i = 0; i < elms2.length; i++) { + let mode = elms2[i].getAttribute('mode') + if (mode !== null) { + if (mode == this.options.mode) { + elms2[i].style.display = 'block' + } + else { + elms2[i].style.display = 'none' + } + } + } + for (let i = 0; i < elms3.length; i++) { + let mode = elms3[i].getAttribute('mode') + if (mode !== null) { + if (mode == this.options.mode) { + elms3[i].style.display = 'block' + } + else { + elms3[i].style.display = 'none' + } + } + } + } + + const img = new Image(); + img.crossOrigin = 'Anonymous'; + img.src = this.replaceHost(this.options.url, this.options.host); + img.onload = () => { + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + if (this.mode) { + // canvas.width = img.width + // canvas.height = img.height; + // let billboardH = img.height * (128 / img.width) + + // if (this.flipeX) { + // ctx.scale(1, -1); + // ctx.translate(0, -canvas.height) + // } + // if (this.flipeY) { + // ctx.scale(-1, 1); + // ctx.translate(-canvas.width, 0); + // } + // ctx.drawImage(img, 0, 0, img.width, img.height) + // this.entity.billboard.image = canvas + // this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * (this.flipeY ? (1-this.options.offset.x) : this.options.offset.x), y: -billboardH * this.billboardScale * (this.flipeX ? (1-this.options.offset.y) : this.options.offset.y) } + let canvas = this.entity.billboard.image.getValue() + let billboardH = canvas.height * (128 / canvas.width) + this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * this.options.offset.x, y: -billboardH * this.billboardScale * this.options.offset.y } + this.entity.billboard.show = true + this.labelShow && (this.entity.label.show = true) + this.entity.rectangle.show = false + } + else { + // 设置画布大小 + canvas.width = img.width * 2; + canvas.height = img.height * 2; + + // 绘制图像 + if (this.flipeX) { + ctx.scale(1, -1); + ctx.translate(0, -canvas.height) + } + if (this.flipeY) { + ctx.scale(-1, 1); + ctx.translate(-canvas.width, 0); + } + ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y)); + this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ + image: canvas, + transparent: true + }) + this.entity.billboard.show = false + this.entity.label.show = false + this.entity.rectangle.show = true + } + } + } + + get offset() { + return this.options.offset + } + set offset(v) { + this.options.offset = v + const img = new Image(); + img.crossOrigin = 'Anonymous'; + img.src = this.replaceHost(this.options.url, this.options.host); + img.onload = () => { + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + if (this.mode) { + // canvas.width = img.width + // canvas.height = img.height; + // let billboardH = img.height * (128 / img.width) + + // if (this.flipeX) { + // ctx.scale(1, -1); + // ctx.translate(0, -canvas.height) + // } + // if (this.flipeY) { + // ctx.scale(-1, 1); + // ctx.translate(-canvas.width, 0); + // } + // ctx.drawImage(img, 0, 0, img.width, img.height) + // this.entity.billboard.image = canvas + // this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * (this.flipeY ? (1-this.options.offset.x) : this.options.offset.x), y: -billboardH * this.billboardScale * (this.flipeX ? (1-this.options.offset.y) : this.options.offset.y) } + let canvas = this.entity.billboard.image.getValue() + let billboardH = canvas.height * (128 / canvas.width) + this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * this.options.offset.x, y: -billboardH * this.billboardScale * this.options.offset.y } + this.entity.billboard.show = true + this.labelShow && (this.entity.label.show = true) + this.entity.rectangle.show = false + } + else { + // 设置画布大小 + canvas.width = img.width * 2; + canvas.height = img.height * 2; + + // 绘制图像 + if (this.flipeX) { + ctx.scale(1, -1); + ctx.translate(0, -canvas.height) + } + if (this.flipeY) { + ctx.scale(-1, 1); + ctx.translate(-canvas.width, 0); + } + ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y)); + this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ + image: canvas, + transparent: true + }) + this.entity.billboard.show = false + this.entity.label.show = false + this.entity.rectangle.show = true + } + } + } + get angle() { return this.options.angle } @@ -78,6 +294,70 @@ class GroundImage extends Base { }) } + get billboardScale() { + return this.options.billboard.scale + } + set billboardScale(v) { + let billboardScale = Number(v.toFixed(2)) + if (billboardScale > 99) { + billboardScale = 99 + } + if (billboardScale < 0.1) { + billboardScale = 0.1 + } + this.options.billboard.scale = billboardScale + this.renewPoint() + this._elms.billboardScale && + this._elms.billboardScale.forEach(item => { + item.value = v + }) + } + + get billboardScaleByDistance() { + return this.options.billboard.scaleByDistance + } + set billboardScaleByDistance(v) { + this.options.billboard.scaleByDistance = v + this.renewPoint() + this._elms.billboardScaleByDistance && + this._elms.billboardScaleByDistance.forEach(item => { + item.checked = v + }) + } + + get billboardNear() { + return this.options.billboard.near + } + set billboardNear(v) { + let near = v + if (near > this.billboardFar) { + near = this.billboardFar + } + this.options.billboard.near = near + this.renewPoint() + this._elms.billboardNear && + this._elms.billboardNear.forEach(item => { + item.value = near + }) + } + + get billboardFar() { + return this.options.billboard.far + } + set billboardFar(v) { + let far = v + if (far < this.billboardNear) { + far = this.billboardNear + } + this.options.billboard.far = far + this.renewPoint() + this._elms.billboardFar && + this._elms.billboardFar.forEach(item => { + item.value = far + }) + } + + get flipeY() { return this.options.flipe.y } @@ -87,30 +367,55 @@ class GroundImage extends Base { if (!this.entity) { return } + const img = new Image(); - img.src = this.options.url; + img.crossOrigin = 'Anonymous'; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); - // 设置画布大小 - canvas.width = img.width; - canvas.height = img.height; + if (this.mode) { + // canvas.width = img.width + // canvas.height = img.height; + // let billboardH = img.height * (128 / img.width) + // if (this.flipeX) { + // ctx.scale(1, -1); + // ctx.translate(0, -canvas.height) + // } + // if (this.flipeY) { + // ctx.scale(-1, 1); + // ctx.translate(-canvas.width, 0); + // } + // ctx.drawImage(img, 0, 0, img.width, img.height) + // this.entity.billboard.image = canvas + // this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * (this.flipeY ? (1-this.options.offset.x) : this.options.offset.x), y: -billboardH * this.billboardScale * (this.flipeX ? (1-this.options.offset.y) : this.options.offset.y) } + // this.entity.billboard.show = true + // this.entity.rectangle.show = false + } + else { + // 设置画布大小 + canvas.width = img.width * 2; + canvas.height = img.height * 2; - // 绘制图像 - if (this.flipeX) { - ctx.scale(1, -1); - ctx.translate(0, -canvas.height) + // 绘制图像 + if (this.flipeX) { + ctx.scale(1, -1); + ctx.translate(0, -canvas.height) + } + if (this.flipeY) { + ctx.scale(-1, 1); + ctx.translate(-canvas.width, 0); + } + ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y)); + this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ + image: canvas, + transparent: true + }) + this.entity.billboard.show = false + this.entity.label.show = false + this.entity.rectangle.show = true } - if (this.flipeY) { - ctx.scale(-1, 1); - ctx.translate(-canvas.width, 0); - } - ctx.drawImage(img, 0, 0); - this.entity && (this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ - image: canvas, - transparent: true - })) } } else { console.error("参数必须为boolean") @@ -125,45 +430,343 @@ class GroundImage extends Base { if (!this.entity) { return } + const img = new Image(); - img.src = this.options.url; + img.crossOrigin = 'Anonymous'; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); - // 设置画布大小 - canvas.width = img.width; - canvas.height = img.height; + if (this.mode) { + // canvas.width = img.width + // canvas.height = img.height; + // let billboardH = img.height * (128 / img.width) + // if (this.flipeX) { + // ctx.scale(1, -1); + // ctx.translate(0, -canvas.height) + // } + // if (this.flipeY) { + // ctx.scale(-1, 1); + // ctx.translate(-canvas.width, 0); + // } + // ctx.drawImage(img, 0, 0, img.width, img.height) + // this.entity.billboard.image = canvas + // this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * (this.flipeY ? (1-this.options.offset.x) : this.options.offset.x), y: -billboardH * this.billboardScale * (this.flipeX ? (1-this.options.offset.y) : this.options.offset.y) } + // this.entity.billboard.show = true + // this.entity.rectangle.show = false + } + else { + // 设置画布大小 + canvas.width = img.width * 2; + canvas.height = img.height * 2; - // 绘制图像 - if (this.flipeX) { - ctx.scale(1, -1); - ctx.translate(0, -canvas.height) + // 绘制图像 + if (this.flipeX) { + ctx.scale(1, -1); + ctx.translate(0, -canvas.height) + } + if (this.flipeY) { + ctx.scale(-1, 1); + ctx.translate(-canvas.width, 0); + } + ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y)); + this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ + image: canvas, + transparent: true + }) + this.entity.billboard.show = false + this.entity.label.show = false + this.entity.rectangle.show = true } - if (this.flipeY) { - ctx.scale(-1, 1); - ctx.translate(-canvas.width, 0); - } - ctx.drawImage(img, 0, 0); - this.entity.rectangle.material = new Cesium.ImageMaterialProperty({ - image: canvas, - transparent: true - }) + + // this.offset = { + // x: this.offset.x, + // y: Math.abs(this.offset.y - 1), + // } } } else { console.error("参数必须为boolean") } } + get heightMode() { + return this.options.heightMode ? this.options.heightMode : 0 + } + set heightMode(v) { + this.options.heightMode = v ? v : 0 + this.options.heightMode = v || v == 0 ? v : 3 + let heightMode + let heightModeName = '' + let altBoxElm + if ( + this._DialogObject && + this._DialogObject._element && + this._DialogObject._element.content + ) { + altBoxElm = this._DialogObject._element.content.getElementsByClassName( + 'alt-box' + )[0] + } + let heightElm + if (this._elms.height) { + heightElm = this._elms.height.getElementsByClassName('input-number')[0] + } + switch (this.options.heightMode) { + case '0': + case 0: + altBoxElm && + (altBoxElm.className = 'input-number input-number-unit-1 alt-box') + // this._elms.height && (this._elms.height.style.display = 'flex') + heightElm && (heightElm.className = 'input-number input-number-unit-1') + heightMode = Cesium.HeightReference.NONE + heightModeName = '海拔高度' + break + case '1': + case 1: + altBoxElm && + (altBoxElm.className = 'input-number input-number-unit-1 alt-box') + // this._elms.height && (this._elms.height.style.display = 'flex') + heightElm && (heightElm.className = 'input-number input-number-unit-1') + heightMode = Cesium.HeightReference.NONE + heightModeName = '相对地表' + break + case '2': + case 2: + altBoxElm && + (altBoxElm.className = + 'input-number input-number-unit-1 alt-box disabled') + heightModeName = '依附地表' + altBoxElm && + (altBoxElm.className = + 'input-number input-number-unit-1 alt-box disabled') + heightModeName = '依附地表' + heightMode = Cesium.HeightReference.CLAMP_TO_GROUND + // this._elms.height && (this._elms.height.style.display = 'none') + heightElm && (heightElm.className = 'input-number input-number-unit-1 disabled') + break + case '3': + case 3: + altBoxElm && + (altBoxElm.className = + 'input-number input-number-unit-1 alt-box disabled') + // this._elms.height && (this._elms.height.style.display = 'none') + heightElm && (heightElm.className = 'input-number input-number-unit-1 disabled') + heightMode = Cesium.HeightReference.NONE + heightModeName = '依附模型' + break + } + if (this.entity && this.entity.billboard) { + this.entity.billboard.heightReference = heightMode + } + this._elms.heightMode && (this._elms.heightMode.value = heightModeName) + } + + get coordinate() { + return this.options.coordinate + } + set coordinate(v) { + this.options.coordinate = v + // let position = this._proj.convert( + // [ + // { + // x: this.options.position.lng, + // y: this.options.position.lat, + // z: this.options.position.alt + // } + // ], + // 'EPSG:4326', + // v + // ).points + // if ( + // this._DialogObject && + // this._DialogObject._element && + // this._DialogObject._element.content && + // position[0] + // ) { + // this._DialogObject._element.content.getElementsByClassName( + // 'convert-x' + // )[0].value = position[0].x + // this._DialogObject._element.content.getElementsByClassName( + // 'convert-y' + // )[0].value = position[0].y + // this._DialogObject._element.content.getElementsByClassName( + // 'convert-z' + // )[0].value = position[0].z + // } + // this._elms.coordinate && + // this._elms.coordinate.forEach(item => { + // item.value = v + // }) + } + + get position() { + return this.options.position + } + + set position(v) { + this.options.position = v + + this.coordinate = this.options.coordinate + + if (this._textToCenter) { + let point = turf.point([this.options.position.lng, this.options.position.lat]) + let targetPoint = turf.destination(point, this._textToCenter.distance, this._textToCenter.angle, { units: 'kilometers' }).geometry.coordinates + this.getClampToHeight({ lng: targetPoint[0], lat: targetPoint[1] }).then((height) => { + let textPosition = [targetPoint[0], targetPoint[1], height] + this.options.text.position = { lng: targetPoint[0], lat: targetPoint[1], alt: height } + this.text && (this.text.position = textPosition) + }) + } + + this._elms.lng && + this._elms.lng.forEach(item => { + item.value = this.options.position.lng + }) + this._elms.lat && + this._elms.lat.forEach(item => { + item.value = this.options.position.lat + }) + + if (this._elms.height) { + let heightElm = this._elms.height.getElementsByClassName('height')[0] + if (heightElm) { + switch (this._elms.heightMode.value) { + case '海拔高度': + heightElm.value = this.options.position.alt + break + case '相对地表': + if (this.sdk.viewer.scene.terrainProvider.availability) { + Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ).then(position => { + heightElm.value = Number( + (this.options.position.alt - position[0].height).toFixed(2) + ) + this._elms.alt && + this._elms.alt.forEach(item => { + item.value = this.options.position.alt + }) + }) + } else { + heightElm.value = Number( + Number(this.options.position.alt).toFixed(2) + ) + this._elms.alt && + this._elms.alt.forEach(item => { + item.value = this.options.position.alt + }) + } + break + case '依附地表': + case '依附地表': + break + case '依附模型': + this.updateHeight() + break + } + } + } + } + + get labelShow() { + return this.options.label.show + } + set labelShow(v) { + this.options.label.show = v + if (this.entity) { + if (this.mode == 1) { + this.entity.label.show = v + } + else { + this.entity.label.show = false + } + } + + this._elms.labelShow && + this._elms.labelShow.forEach(item => { + item.value = v + }) + } + + get labelFontFamily() { + return this.options.label.fontFamily + } + + set labelFontFamily(v) { + this.options.label.fontFamily = v || 0 + this.renewPoint() + + let name = getFontFamilyName(this.labelFontFamily) || '' + this._elms.labelFontFamily && + this._elms.labelFontFamily.forEach(item => { + item.value = name + }) + } + + get labelFontSize() { + return this.options.label.fontSize + } + set labelFontSize(v) { + this.options.label.fontSize = v + this.renewPoint() + this._elms.labelFontSize && + this._elms.labelFontSize.forEach(item => { + item.value = v + }) + } + + get labelColor() { + return this.options.label.color + } + set labelColor(v) { + this.options.label.color = v || '#00ffff' + this.renewPoint() + if (this._elms.labelColor) { + this._elms.labelColor.forEach((item, i) => { + let colorPicker = new YJColorPicker({ + el: item.el, + size: 'mini', //颜色box类型 + alpha: true, //是否开启透明度 + defaultColor: this.options.label.color, + disabled: false, //是否禁止打开颜色选择器 + openPickerAni: 'opacity', //打开颜色选择器动画 + sure: c => { + this.labelColor = c + }, //点击确认按钮事件回调 + clear: () => { + this.labelColor = 'rgba(0,255,255,1)' + } //点击清空按钮事件回调 + }) + this._elms.labelColor[i] = colorPicker + }) + } + } + async create() { - // let gap = Math.abs(Math.cos(Math.PI/180 * this.options.positions.lat)) * (0.0001*this.options.scale) + // let gap = Math.abs(Math.cos(Math.PI/180 * this.options.position.lat)) * (0.0001*this.options.scale) // let fromDegreesArray = [ - // this.options.positions.lng - 0.05, this.options.positions.lat - 0.05, - // this.options.positions.lng + 0.05, this.options.positions.lat - 0.05, - // this.options.positions.lng + 0.05, this.options.positions.lat + 0.05, - // this.options.positions.lng - 0.05, this.options.positions.lat + 0.05, + // this.options.position.lng - 0.05, this.options.position.lat - 0.05, + // this.options.position.lng + 0.05, this.options.position.lat - 0.05, + // this.options.position.lng + 0.05, this.options.position.lat + 0.05, + // this.options.position.lng - 0.05, this.options.position.lat + 0.05, // ] - let response = await fetch(this.options.url, { + let _this = this + let heightMode + let font = getFontFamily(this.labelFontFamily) || 'Helvetica' + switch (this.options.heightMode) { + case 2: + case '2': + heightMode = Cesium.HeightReference.CLAMP_TO_GROUND + break + } + let response = await fetch(this.replaceHost(this.options.url, this.options.host), { method: 'get', headers: { 'Content-Type': 'application/json', @@ -174,14 +777,22 @@ 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.crossOrigin = 'Anonymous'; + img.src = this.replaceHost(this.options.url, this.options.host); img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); + const canvas2 = document.createElement('canvas'); + const ctx2 = canvas2.getContext('2d'); + let width = img.width + let height = img.height + canvas2.width = width + canvas2.height = height; + ctx2.drawImage(img, 0, 0, width, height) // 设置画布大小 - canvas.width = img.width; - canvas.height = img.height; + canvas.width = img.width * 2; + canvas.height = img.height * 2; // 绘制图像 if (this.flipeX) { ctx.scale(1, -1); @@ -191,19 +802,100 @@ class GroundImage extends Base { ctx.scale(-1, 1); ctx.translate(-canvas.width, 0); } - ctx.drawImage(img, 0, 0); + ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y)); + + + let billboardH = height * (128 / width) this.entity = this.sdk.viewer.entities.add({ id: this.options.id, show: this.options.show, + position: new Cesium.CallbackProperty(() => { + return Cesium.Cartesian3.fromDegrees( + this.options.position.lng, + this.options.position.lat, + this.options.position.alt || 0 + ) + }), + billboard: { + show: this.mode ? true : false, + image: canvas2, + scale: this.billboardScale, + disableDepthTestDistance: new Cesium.CallbackProperty(function () { + return getGroundCover() ? undefined : Number.POSITIVE_INFINITY + }, false), + heightReference: heightMode, + width: 128, + height: billboardH, + horizontalOrigin: Cesium.HorizontalOrigin.LEFT, + verticalOrigin: Cesium.VerticalOrigin.TOP, + // pixelOffset: { x: -128 * this.billboardScale * (this.flipeY ? (1-this.options.offset.x) : this.options.offset.x), y: -billboardH * this.billboardScale * (this.flipeX ? (1-this.options.offset.y) : this.options.offset.y) } + pixelOffset: { x: -128 * this.billboardScale * this.options.offset.x, y: -billboardH * this.billboardScale * this.options.offset.y } + }, + label: { + show: this.mode ? _this.options.label.show : false, + text: _this.options.label.text, + disableDepthTestDistance: new Cesium.CallbackProperty(function () { + return getGroundCover() ? undefined : Number.POSITIVE_INFINITY + }, false), + heightReference: heightMode, + font: _this.options.label.fontSize + 'px ' + font, + fillColor: Cesium.Color.fromCssColorString(_this.options.label.color), + // verticalOrigin : Cesium.VerticalOrigin.BOTTOM, + pixelOffset: new Cesium.CallbackProperty(function () { + if (_this.options.show) { + return new Cesium.Cartesian2( + 0, + -billboardH * _this.billboardScale - + _this.options.label.fontSize / 2 - + 5 + ) + } else { + return new Cesium.Cartesian2( + 0, + -_this.options.label.fontSize / 2 - 5 + ) + } + }, false), + outlineColor: Cesium.Color.BLACK, + outlineWidth: 1, + style: Cesium.LabelStyle.FILL_AND_OUTLINE + }, rectangle: { + show: this.mode ? false : true, coordinates: new Cesium.CallbackProperty(() => { - let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.positions.lat)) * (0.0001 * this.options.scale) + let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.position.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 point1 = [this.options.position.lng - offset.lng + 360, this.options.position.lat - offset.lat]; + // let point2 = [(this.options.position.lng - offset.lng) + ((0.0001 * this.options.scale) * 2) + 360, (this.options.position.lat - offset.lat) + (gap * 2)]; + // let midpoint = turf.point([point1[0]+point2[0]/2, point1[1]+point2[1]/2]); + // let rotatedPot = turf.transformRotate(midpoint, -Number(this.options.angle), {pivot: [this.options.position.lng, this.options.position.lat]}); + // console.log(midpoint.geometry.coordinates, rotatedPot.geometry.coordinates, this.options.position) + // let fromDegreesArray = [ + // rotatedPot.geometry.coordinates[0]-(0.0001 * this.options.scale), rotatedPot.geometry.coordinates[1]-(0.0001 * this.options.scale), + // rotatedPot.geometry.coordinates[0]+(0.0001 * this.options.scale), rotatedPot.geometry.coordinates[1]+(0.0001 * this.options.scale), + + // ] 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.position.lng - offset.lng, this.options.position.lat - offset.lat, + // (this.options.position.lng - offset.lng) + ((0.0001 * this.options.scale) * 2), (this.options.position.lat - offset.lat) + (gap * 2), + + + + + + + this.options.position.lng - (0.0001 * this.options.scale), this.options.position.lat - gap, + // this.options.position.lng + 0.05, this.options.position.lat - 0.05, + this.options.position.lng + (0.0001 * this.options.scale), this.options.position.lat + gap, + // this.options.position.lng - 0.05, this.options.position.lat + 0.05, ] return Cesium.Rectangle.fromDegrees(...fromDegreesArray) @@ -220,12 +912,14 @@ class GroundImage extends Base { }, false) }, }) + + this.renewPoint() if (this.sdk.viewer._element.className === 'cesium-viewer 2d') { this.entity.rectangle.height = 0 } syncData(this.sdk, this.options.id) - if(this.options.show) { - + if (this.options.show) { + setSplitDirection(0, this.options.id) } } @@ -247,12 +941,16 @@ class GroundImage extends Base { // 编辑框 async edit(state) { let _this = this - this.originalOptions = { ...this.options } + this.originalOptions = this.deepCopyObj(this.options) if (this._DialogObject && this._DialogObject.close) { this._DialogObject.close() 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) => { @@ -263,8 +961,8 @@ class GroundImage extends Base { this.originalOptions = this.deepCopyObj(this.options) this._DialogObject.close() this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) - syncData(this.sdk, this.options.id) - syncSplitData(this.sdk, this.options.id) + // syncData(this.sdk, this.options.id) + // syncSplitData(this.sdk, this.options.id) }, resetCallBack: () => { this.reset() @@ -274,13 +972,19 @@ class GroundImage extends Base { this.Dialog.removeCallBack && this.Dialog.removeCallBack() }, closeCallBack: () => { + this.previous = null this.reset() // this.entity.style = new Cesium.Cesium3DTileStyle({ // color: "color('rgba(255,255,255," + this.newData.transparency + ")')", // show: true, // }); - this.positionEditing = false + + if (anchorSetDialogObject && anchorSetDialogObject.close) { + anchorSetDialogObject.close() + } this.Dialog.closeCallBack && this.Dialog.closeCallBack() + YJ.Measure.SetMeasureStatus(false) + this.positionEditing = false }, showCallBack: (show) => { this.show = show @@ -315,6 +1019,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 +1027,548 @@ 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) + } + } + + // let coordinateData = [] + // this.epsg_map.forEach((value, key) => { + // coordinateData.push({ + // name: `${value.name}(${value.epsg})`, + // value: key + // }) + // }) + // let coordinateDataLegpObject = legp( + // this._DialogObject._element.content.getElementsByClassName( + // 'coordinate-select-box' + // )[0], + // '.coordinate-select' + // ) + // if (coordinateDataLegpObject) { + // coordinateDataLegpObject.legp_search(coordinateData) + // let coordinateDataLegpElm = this._DialogObject._element.content + // .getElementsByClassName('coordinate-select')[0] + // .getElementsByTagName('input')[0] + // if (!this.coordinate) { + // this.coordinate = coordinateData[0].value + // } else { + // this.coordinate = this.coordinate + // } + // coordinateDataLegpElm.value = this.coordinate + // for (let i = 0; i < coordinateData.length; i++) { + // if (coordinateData[i].value === coordinateData.value) { + // coordinateDataLegpObject.legp_searchActive( + // coordinateData[i].value + // ) + // break + // } + // } + // coordinateDataLegpElm.addEventListener('input', () => { + // for (let i = 0; i < coordinateData.length; i++) { + // if (coordinateData[i].value === coordinateDataLegpElm.value) { + // this.coordinate = coordinateData[i].value + // break + // } + // } + // }) + // } + + let elms = contentElm.getElementsByClassName('row') + let elms2 = contentElm.getElementsByTagName('h4') + for (let i = 0; i < elms.length; i++) { + let mode = elms[i].getAttribute('mode') + if (mode !== null) { + if (mode == this.options.mode) { + elms[i].style.display = 'flex' + } + else { + elms[i].style.display = 'none' + } + } + } + for (let i = 0; i < elms2.length; i++) { + let mode = elms2[i].getAttribute('mode') + if (mode !== null) { + if (mode == this.options.mode) { + elms2[i].style.display = 'block' + } + else { + elms2[i].style.display = 'none' + } + } + } + + // let lng = contentElm.getElementsByClassName("lng")[0] + // let lat = contentElm.getElementsByClassName("lat")[0] + // let alt = contentElm.getElementsByClassName("alt")[0] + // lng.value = this.options.position.lng + // lat.value = this.options.position.lat + // alt.value = this.options.position.alt + // this._elms.lng = [lng] + // this._elms.lat = [lat] + // this._elms.alt = [alt] + // lng.addEventListener('blur', (e) => { + // let value = e.target.value + // if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + // value = Number(value) + // if ((e.target.max) && value > Number(e.target.max)) { + // value = Number(e.target.max) + // } + // if ((e.target.min) && value < Number(e.target.min)) { + // value = Number(e.target.min) + // } + // if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + // value = Number(e.target.dataset.min) + // } + // } + // // this.position = { + // // lng: value, + // // lat: this.position.lat, + // // alt: this.position.alt + // // } + // this.options.position.lng = value + // this.coordinate = this.options.coordinate + // }) + // lat.addEventListener('blur', (e) => { + // let value = e.target.value + // if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + // value = Number(value) + // if ((e.target.max) && value > Number(e.target.max)) { + // value = Number(e.target.max) + // } + // if ((e.target.min) && value < Number(e.target.min)) { + // value = Number(e.target.min) + // } + // if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + // value = Number(e.target.dataset.min) + // } + // } + // // this.position = { + // // lng: this.position.lng, + // // lat: value, + // // alt: this.position.alt + // // } + // this.options.position.lat = value + // this.coordinate = this.options.coordinate + // }) + // alt.addEventListener('blur', (e) => { + // let value = e.target.value + // if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + // value = Number(value) + // if ((e.target.max) && value > Number(e.target.max)) { + // value = Number(e.target.max) + // } + // if ((e.target.min) && value < Number(e.target.min)) { + // value = Number(e.target.min) + // } + // if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + // value = Number(e.target.dataset.min) + // } + // } + // // this.position = { + // // lng: this.position.lng, + // // lat: this.position.lat, + // // alt: value + // // } + // this.options.position.alt = value + // this.coordinate = this.options.coordinate + // }) + + let colorPicker = new YJColorPicker({ + el: contentElm.getElementsByClassName('labelColor')[0], + size: 'mini', //颜色box类型 + alpha: true, //是否开启透明度 + defaultColor: this.labelColor, + disabled: false, //是否禁止打开颜色选择器 + openPickerAni: 'opacity', //打开颜色选择器动画 + sure: color => { + this.labelColor = color + }, //点击确认按钮事件回调 + clear: () => { + this.labelColor = 'rgba(255,255,255,1)' + } //点击清空按钮事件回调 + }) + this._elms.labelColor = [colorPicker] + + setTimeout(async () => { + let flipeOverXBtn = this._DialogObject._element.foot.getElementsByClassName('flipe-over-x')[0] + let flipeOverYBtn = this._DialogObject._element.foot.getElementsByClassName('flipe-over-y')[0] + flipeOverXBtn.setAttribute('mode', 0) + flipeOverYBtn.setAttribute('mode', 0) + if (this.options.mode) { + flipeOverXBtn.style.display = 'none' + flipeOverYBtn.style.display = 'none' + } + else { + flipeOverXBtn.style.display = 'block' + flipeOverYBtn.style.display = 'block' + } + let modeData = [ + { + name: '贴地', + value: '贴地', + key: 0 + }, + { + name: '立体', + value: '立体', + key: 1 + } + ] + let modeDataLegpObject = legp( + this._DialogObject._element.content.getElementsByClassName( + 'mode-box' + )[0], + '.mode' + ) + if (modeDataLegpObject) { + modeDataLegpObject.legp_search(modeData) + let modeDataLegpElm = this._DialogObject._element.content + .getElementsByClassName('mode')[0] + .getElementsByTagName('input')[0] + modeDataLegpElm.value = this.mode + for (let i = 0; i < modeData.length; i++) { + if (modeData[i].key === this.mode) { + modeDataLegpElm.value = modeData[i].value + modeDataLegpObject.legp_searchActive(modeData[i].value) + break + } + } + modeDataLegpElm.addEventListener('input', () => { + for (let i = 0; i < modeData.length; i++) { + if (modeData[i].value === modeDataLegpElm.value) { + this.mode = modeData[i].key + break + } + } + }) + this._elms.mode = [modeDataLegpElm] + } + + + let heightBoxElm = this._DialogObject._element.content.getElementsByClassName('height-box')[0] + let heightElm = heightBoxElm.getElementsByClassName('height')[0] + let heightModeData = [ + { + name: '海拔高度', + value: '海拔高度', + key: '0' + }, + { + name: '相对地表', + value: '相对地表', + key: '1' + }, + { + name: '依附地表', + value: '依附地表', + key: '2' + }, + { + name: '依附模型', + value: '依附模型', + key: '3' + } + ] + let heightMode = this.heightMode + + switch (heightMode) { + case 0: + case '0': + heightElm.value = this.options.position.alt + break + case 1: + case '1': + if (this.sdk.viewer.scene.terrainProvider.availability) { + Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ).then(position => { + heightElm.value = Number( + (this.options.position.alt - Number(position[0].height.toFixed(2))).toFixed(2) + ) + }) + } else { + heightElm.value = Number(this.options.position.alt.toFixed(2)) + } + break + case 2: + case '2': + case 3: + case '3': + let objectsToExclude = [] + for (let [key, value] of this.sdk.entityMap) { + if (value.type === 'RadarScanStereoscopic' && value.entity) { + objectsToExclude.push(value.entity) + } + } + this.getClampToHeight(this.options.position, objectsToExclude).then(h => { + this.options.position.alt = Number(h.toFixed(2)) + this.coordinate = this.options.coordinate + this._elms.alt && + this._elms.alt.forEach(item => { + item.value = this.options.position.alt + }) + heightElm.value = this.options.position.alt + }) + break + } + let heightModeObject = legp( + this._DialogObject._element.content.getElementsByClassName( + 'height-mode-box' + )[0], + '.height-mode' + ) + if (heightModeObject) { + heightModeObject.legp_search(heightModeData) + let heightModeDataLegpElm = this._DialogObject._element.content + .getElementsByClassName('height-mode')[0] + .getElementsByTagName('input')[0] + heightModeDataLegpElm.value = heightModeData[this.heightMode].value + for (let i = 0; i < heightModeData.length; i++) { + if (heightModeData[i].value == heightModeDataLegpElm.value) { + heightModeObject.legp_searchActive(heightModeData[i].value) + break + } + } + heightModeDataLegpElm.addEventListener('input', () => { + for (let i = 0; i < heightModeData.length; i++) { + if (heightModeData[i].value === heightModeDataLegpElm.value) { + heightMode = heightModeData[i].key + switch (heightMode) { + case 0: + case '0': + this.options.position.alt = Number(heightElm.value) + this.heightMode = 0 + // this.position = this.options.position + break + case 1: + case '1': + if (this.sdk.viewer.scene.terrainProvider.availability) { + Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ).then(position => { + this.options.position.alt = + Number(heightElm.value) + + Number(position[0].height.toFixed(2)) + // this.position = this.options.position + }) + } else { + this.options.position.alt = Number(heightElm.value) + // this.position = this.options.position + } + this.heightMode = 1 + break + case 2: + case '2': + this.heightMode = 2 + break + case 3: + case '3': + let objectsToExclude = [] + for (let [key, value] of this.sdk.entityMap) { + if (value.type === 'RadarScanStereoscopic' && value.entity) { + objectsToExclude.push(value.entity) + } + } + this.getClampToHeight(this.options.position, objectsToExclude).then(h => { + this.options.position.alt = Number(h.toFixed(2)) + // this.position = this.options.position + }) + this.heightMode = 3 + break + } + this.position = this.options.position + break + } + } + }) + + heightElm.addEventListener('blur', async () => { + switch (heightMode) { + case 0: + case '0': + this.options.position.alt = Number( + Number(heightElm.value).toFixed(2) + ) + break + case 1: + case '1': + if (this.sdk.viewer.scene.terrainProvider.availability) { + let position = await Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ) + this.options.position.alt = + Number(heightElm.value) + + Number(position[0].height.toFixed(2)) + } else { + this.options.position.alt = Number(heightElm.value) + + } + break + case 2: + case '2': + break + } + this.position = this.options.position + }) + this._elms.height = heightBoxElm + this._elms.heightMode = heightModeDataLegpElm + + this.heightMode = this.heightMode + } + + let fontData = getFontList() + let fontObject = legp( + this._DialogObject._element.content.getElementsByClassName( + 'font-select-box' + )[0], + '.font-select' + ) + if (fontObject) { + fontObject.legp_search(fontData) + let fontDataLegpElm = this._DialogObject._element.content + .getElementsByClassName('font-select')[0] + .getElementsByTagName('input')[0] + fontDataLegpElm.value = fontData[this.labelFontFamily].value + for (let i = 0; i < fontData.length; i++) { + if (fontData[i].value == fontDataLegpElm.value) { + fontObject.legp_searchActive(fontData[i].value) + break + } + } + fontDataLegpElm.addEventListener('input', () => { + for (let i = 0; i < fontData.length; i++) { + if (fontData[i].value === fontDataLegpElm.value) { + this.labelFontFamily = fontData[i].key + break + } + } + }) + this._elms.labelFontFamily = [fontDataLegpElm] + } + }, 0); + } else { if (this._DialogObject && this._DialogObject.remove) { this._DialogObject.remove() @@ -341,17 +1588,17 @@ class GroundImage extends Base { return } this._positionEditing = status - this.previous = { - positions: { ...this.options.positions } - } if (status === true) { + this.previous = { + position: { ...this.options.position } + } this.tip && this.tip.destroy() this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk) this.event.mouse_move((movement, cartesian) => { - let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer) - this.options.positions.lng = positions.lng - this.options.positions.lat = positions.lat - this.options.positions.alt = positions.alt + let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + this.options.position.lng = position.lng + this.options.position.lat = position.lat + this.options.position.alt = position.alt this.tip.setPosition( cartesian, movement.endPosition.x, @@ -359,21 +1606,22 @@ class GroundImage extends Base { ) }) this.event.mouse_left((movement, cartesian) => { - let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer) - this.options.positions.lng = positions.lng - this.options.positions.lat = positions.lat - this.options.positions.alt = positions.alt + let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + this.options.position.lng = position.lng + this.options.position.lat = position.lat + this.options.position.alt = position.alt this.event.mouse_move(() => { }) this.event.mouse_left(() => { }) this.event.mouse_right(() => { }) this.event.gesture_pinck_start(() => { }) this.event.gesture_pinck_end(() => { }) + this.previous = null this.positionEditing = false }) this.event.mouse_right((movement, cartesian) => { - this.options.positions.lng = this.previous.positions.lng - this.options.positions.lat = this.previous.positions.lat - this.options.positions.alt = this.previous.positions.alt + this.options.position.lng = this.previous.position.lng + this.options.position.lat = this.previous.position.lat + this.options.position.alt = this.previous.position.alt this.positionEditing = false }) @@ -383,16 +1631,16 @@ class GroundImage extends Base { let endTime = new Date() if (endTime - startTime >= 500) { // 长按取消 - this.options.positions.lng = this.previous.positions.lng - this.options.positions.lat = this.previous.positions.lat - this.options.positions.alt = this.previous.positions.alt + this.options.position.lng = this.previous.position.lng + this.options.position.lat = this.previous.position.lat + this.options.position.alt = this.previous.position.alt this.positionEditing = false } else { - let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer) - this.options.positions.lng = positions.lng - this.options.positions.lat = positions.lat - this.options.positions.alt = positions.alt + let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + this.options.position.lng = position.lng + this.options.position.lat = position.lat + this.options.position.alt = position.alt this.event.mouse_move(() => { }) this.event.mouse_left(() => { }) this.event.mouse_right(() => { }) @@ -412,9 +1660,12 @@ class GroundImage extends Base { this.event.gesture_pinck_end(() => { }) } this.tip && this.tip.destroy() - this.options.positions.lng = this.previous.positions.lng - this.options.positions.lat = this.previous.positions.lat - this.options.positions.alt = this.previous.positions.alt + if (!this.previous) { + this.previous = { + position: { ...this.options.position } + } + } + this.position = { ...this.previous.position } } } @@ -428,7 +1679,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 = { @@ -446,8 +1697,8 @@ class GroundImage extends Base { if (this.options.position) { position = { ...this.options.position } } - else if (this.options.positions) { - position = { ...this.options.positions[0] } + else if (this.options.position) { + position = { ...this.options.position[0] } } else if (this.options.center) { position = { ...this.options.center } @@ -480,14 +1731,14 @@ class GroundImage extends Base { }) } else { - let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.positions.lat)) * (0.0001 * this.options.scale) + let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.position.lat)) * (0.0001 * this.options.scale) let fromDegreesArray = [ - [this.options.positions.lng - (0.0001 * this.options.scale), this.options.positions.lat - gap], - [this.options.positions.lng + (0.0001 * this.options.scale), this.options.positions.lat + gap], + [this.options.position.lng - (0.0001 * this.options.scale), this.options.position.lat - gap], + [this.options.position.lng + (0.0001 * this.options.scale), this.options.position.lat + gap], ] let positionArray = [] let height = 0 - let position = this.options.positions + let position = this.options.position let point1 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 0); let point2 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 10000000); let direction = Cesium.Cartesian3.subtract(point2, point1, new Cesium.Cartesian3()); @@ -526,13 +1777,183 @@ class GroundImage extends Base { } } + async updateHeight() { + let height + let height2 + let point1 = new Cesium.Cartesian3.fromDegrees( + this.options.position.lng, + this.options.position.lat, + 0 + ) + let point2 = new Cesium.Cartesian3.fromDegrees( + this.options.position.lng, + this.options.position.lat, + 10000000000000 + ) + + let objectsToExclude = [] + for (let [key, value] of this.sdk.entityMap) { + if (value.type === 'RadarScanStereoscopic' && value.entity) { + objectsToExclude.push(value.entity) + } + } + let updatedCartesians = await this.sdk.viewer.scene.clampToHeightMostDetailed([point1], objectsToExclude) + if (updatedCartesians && updatedCartesians[0]) { + height = this.cartesian3Towgs84(updatedCartesians[0], this.sdk.viewer).alt + } + + let direction = Cesium.Cartesian3.subtract( + point1, + point2, + new Cesium.Cartesian3() + ) + let c = Cesium.Cartesian3.normalize(direction, new Cesium.Cartesian3()) + let ray = new Cesium.Ray(point2, c) + let r = {} + let pickedObjects = this.sdk.viewer.scene.drillPickFromRay(ray) + for (let i = pickedObjects.length - 1; i >= 0; i--) { + if (pickedObjects[i].position) { + r = pickedObjects[i] + break + } + } + if (r && r.position) { + height2 = this.cartesian3Towgs84(r.position, this.sdk.viewer).alt + } + let promise + try { + promise = await Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ) + } catch (error) { } + + if ((height2 === void 0 || height2 < promise[0].height) && promise) { + height2 = promise[0].height + } + if (height === void 0 || height < height2) { + height = height2 + } + if (height !== undefined) { + this.options.position.alt = Number(Number(height).toFixed(2)) + this._elms.alt && + this._elms.alt.forEach(item => { + item.value = this.options.position.alt + }) + this.coordinate = this.options.coordinate + + if (this._elms.height) { + let heightElm = this._elms.height.getElementsByClassName('height')[0] + if (heightElm) { + switch (this._elms.heightMode.value) { + case '海拔高度': + heightElm.value = this.options.position.alt + break + case '相对地表': + if (this.sdk.viewer.scene.terrainProvider.availability) { + Cesium.sampleTerrainMostDetailed( + this.sdk.viewer.scene.terrainProvider, + [ + Cesium.Cartographic.fromDegrees( + this.options.position.lng, + this.options.position.lat + ) + ] + ).then(position => { + heightElm.value = Number( + (this.options.position.alt - position[0].height).toFixed(2) + ) + }) + } else { + heightElm.value = this.options.position.alt + } + break + case '依附地表': + break + case '依附模型': + heightElm.value = this.options.position.alt + break + } + } + } + } + + // if (!this.entity.values) { + // this.entity.position = Cesium.Cartesian3.fromDegrees( + // this.options.position.lng, + // this.options.position.lat, + // this.options.position.alt + // ) + // } + } + + renewPoint() { + if (!this.entity.values && this.entity.billboard) { + let font = getFontFamily(this.labelFontFamily) || 'Helvetica' + this.entity.billboard.scale = this.billboardScale + if (this.billboardScaleByDistance) { + this.entity.billboard.scaleByDistance = new Cesium.NearFarScalar( + this.billboardNear, + 1, + this.billboardFar, + 0 + ) + this.entity.billboard.pixelOffsetScaleByDistance = new Cesium.NearFarScalar( + this.billboardNear, + 1, + this.billboardFar, + 0 + ) + this.entity.label.scaleByDistance = new Cesium.NearFarScalar( + this.billboardNear, + 1, + this.billboardFar, + 0 + ) + this.entity.label.pixelOffsetScaleByDistance = new Cesium.NearFarScalar( + this.billboardNear, + 1, + this.billboardFar, + 0 + ) + } else { + this.entity.billboard.scaleByDistance = undefined + this.entity.billboard.pixelOffsetScaleByDistance = undefined + this.entity.label.scaleByDistance = undefined + this.entity.label.pixelOffsetScaleByDistance = undefined + } + this.entity.label.font = this.options.label.fontSize + 'px ' + font + this.entity.label.fillColor = Cesium.Color.fromCssColorString( + this.options.label.color + ) + let canvas = this.entity.billboard.image.getValue() + let billboardH = canvas.height * (128 / canvas.width) + this.entity.billboard.pixelOffset = { x: -128 * this.billboardScale * this.options.offset.x, y: -billboardH * this.billboardScale * this.options.offset.y } + // this.entity.billboard.pixelOffset = { x: -width * this.billboardScale * (this.flipeY ? (1 - this.options.offset.x) : this.options.offset.x), y: -height * this.billboardScale * (this.flipeX ? (1 - this.options.offset.y) : this.options.offset.y) } + } + } + reset() { if (!this.entity) { return } - this.name = this.originalOptions.name - this.angle = this.originalOptions.angle - this.scale = this.originalOptions.scale + this.options = this.deepCopyObj(this.originalOptions) + this.name = this.options.name + this.angle = this.options.angle + this.scale = this.options.scale + this.offset = this.options.offset + this.flipeX = this.options.flipe.x + this.flipeY = this.options.flipe.y + this.show = this.options.show + this.mode = this.options.mode + this.heightMode = this.options.heightMode + this.billboardScale = this.options.billboard.scale + this.labelShow = this.options.label.show } async remove() { @@ -549,9 +1970,9 @@ class GroundImage extends Base { } setPosition(v) { - this.options.positions.lng = v.position.lng - this.options.positions.lat = v.position.lat - this.options.positions.alt = v.position.alt + this.options.position.lng = v.position.lng + this.options.position.lat = v.position.lat + this.options.position.alt = v.position.alt } } diff --git a/src/Obj/Base/GroundSvg/_element.js b/src/Obj/Base/GroundSvg/_element.js index 1f16498..1766d91 100644 --- a/src/Obj/Base/GroundSvg/_element.js +++ b/src/Obj/Base/GroundSvg/_element.js @@ -54,7 +54,7 @@ function html(that) {
文字内容 - +
-
-
- 动画顺向 - -
-
- 流动速率 -
- - -
-
-
- 间距 -
- - - -
-
-
线段缓冲 @@ -129,6 +108,27 @@ function html(that) {
+
+
+ 首尾反向 + +
+
+ 流动速率 +
+ + +
+
+
+ 线条间距 +
+ + + +
+
+
${labelStyleElm1()} diff --git a/src/Obj/Base/PolylineObject/index.js b/src/Obj/Base/PolylineObject/index.js index 308fd13..f85e43f 100644 --- a/src/Obj/Base/PolylineObject/index.js +++ b/src/Obj/Base/PolylineObject/index.js @@ -13,10 +13,12 @@ import MouseTip from '../../../MouseTip' import Controller from '../../../Controller/index' import { syncData, get3DView } from '../../../Global/MultiViewportMode' import { legp } from '../../Element/datalist' +import { getFontList, getFontFamilyName } from '../../Element/fontSelect' import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' class PolylineObject extends Base { + #unitDataLegpObject /** * @constructor * @param sdk @@ -30,8 +32,8 @@ class PolylineObject extends Base { * @param options['nose-to-tail']=false {boolean} 首尾相连 * @param options.smooth=false {boolean} 线段圆滑 * @param options.extend=false {boolean} 线缓冲 - * @param options['extend-width']=1 {number} 线缓冲宽度 - * @param options['extend-color']=#ffde00 {number} 线缓冲颜色 + * @param options['extend-width']=10 {number} 线缓冲宽度 + * @param options['extend-color']=rgba(255,255,80,0.3) {number} 线缓冲颜色 * @param options.show=true {boolean} 显隐 * @param {Array.} options.positions 坐标数组 [{lng,lat},...] * @param options.label {object} 标注 @@ -67,8 +69,8 @@ class PolylineObject extends Base { this.options['extend-width'] = options['extend-width'] || options['extend-width'] === 0 ? options['extend-width'] - : 1 - this.options['extend-color'] = options['extend-color'] || '#ffde00' + : 10 + this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' this.options.show = options.show || options.show === false ? options.show : true this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 @@ -82,6 +84,7 @@ class PolylineObject extends Base { options.label.fontSize || options.label.fontSize === 0 ? options.label.fontSize : 20, + fontFamily: options.label.fontFamily ? options.label.fontFamily : 0, color: options.label.color || '#ffffff', lineWidth: options.label.lineWidth || options.label.lineWidth === 0 @@ -268,6 +271,7 @@ class PolylineObject extends Base { this._elms.lengthUnit.forEach(item => { item.value = v }) + this.#unitDataLegpObject && this.#unitDataLegpObject.legp_searchActive(v) if (this.options.lengthByMeter) { if (this.unitNum > 2) { switch (v) { @@ -715,6 +719,21 @@ class PolylineObject extends Base { }) } + get labelFontFamily() { + return this.options.label.fontFamily + } + + set labelFontFamily(v) { + this.options.label.fontFamily = v || 0 + this.label && (this.label.fontFamily = this.options.label.fontFamily) + + let name = getFontFamilyName(this.labelFontFamily) || '' + this._elms.labelFontFamily && + this._elms.labelFontFamily.forEach(item => { + item.value = name + }) + } + get labelColor() { return this.options.label.color } @@ -825,7 +844,6 @@ class PolylineObject extends Base { set labelLineColor(v) { this.options.label.lineColor = v this.label.lineColor = v - let _this = this if (this._elms.labelLineColor) { this._elms.labelLineColor.forEach((item, i) => { let lineColorPicker = new YJColorPicker({ @@ -840,6 +858,29 @@ class PolylineObject extends Base { }, //点击确认按钮事件回调 clear: () => { this.labelLineColor = 'rgba(0,255,255,0.5)' + } //点击清空按钮事件回调 + }) + this._elms.labelLineColor[i] = lineColorPicker + }) + } + } + + get labelBackgroundColorStart() { + return this.options.label.backgroundColor[0] + } + set labelBackgroundColorStart(v) { + this.options.label.backgroundColor[0] = v + this.label.backgroundColor = [v, this.label.backgroundColor[1]] + if (this._elms.labelBackgroundColorStart) { + this._elms.labelBackgroundColorStart.forEach((item, i) => { + let labelBackgroundColorStartPicker = new YJColorPicker({ + el: item.el, + size: 'mini', //颜色box类型 + alpha: true, //是否开启透明度 + defaultColor: this.labelBackgroundColorStart, + disabled: false, //是否禁止打开颜色选择器 + openPickerAni: 'opacity', //打开颜色选择器动画 + sure: color => { this.labelBackgroundColorStart = color }, //点击确认按钮事件回调 clear: () => { @@ -848,7 +889,7 @@ class PolylineObject extends Base { }) this._elms.labelBackgroundColorStart[ i - ] = _this.labelBackgroundColorStartPicker + ] = labelBackgroundColorStartPicker }) } } @@ -1312,6 +1353,7 @@ class PolylineObject extends Base { ], text: that.options.name, fontSize: that.options.label.fontSize, + fontFamily: that.options.label.fontFamily, color: that.options.label.color, pixelOffset: that.options.label.pixelOffset, backgroundColor: that.options.label.backgroundColor, @@ -1565,6 +1607,9 @@ class PolylineObject extends Base { } this.nodePoints = [] this.positionEditing = false + YJ.Measure.SetMeasureStatus(false) + this.event && this.event.destroy() + this.tip && this.tip.destroy() }, showCallBack: show => { this.options.show = show @@ -1799,6 +1844,7 @@ class PolylineObject extends Base { '.input-select-unit', 1 ) + this.#unitDataLegpObject = unitDataLegpObject if (unitDataLegpObject) { unitDataLegpObject.legp_search(unitData) let unitDataLegpElm = this._DialogObject._element.content @@ -2221,6 +2267,37 @@ class PolylineObject extends Base { this._elms.altInput.push(altInput) tBodyElm.appendChild(tr) } + + + let fontData = getFontList() + let fontObject = legp( + this._DialogObject._element.content.getElementsByClassName( + 'font-select-box' + )[0], + '.font-select' + ) + if (fontObject) { + fontObject.legp_search(fontData) + let fontDataLegpElm = this._DialogObject._element.content + .getElementsByClassName('font-select')[0] + .getElementsByTagName('input')[0] + fontDataLegpElm.value = fontData[this.labelFontFamily].value + for (let i = 0; i < fontData.length; i++) { + if (fontData[i].value == fontDataLegpElm.value) { + fontObject.legp_searchActive(fontData[i].value) + break + } + } + fontDataLegpElm.addEventListener('input', () => { + for (let i = 0; i < fontData.length; i++) { + if (fontData[i].value === fontDataLegpElm.value) { + this.labelFontFamily = fontData[i].key + break + } + } + }) + this._elms.labelFontFamily = [fontDataLegpElm] + } }, 0) } else { if (this._DialogObject && this._DialogObject.close) { @@ -2422,6 +2499,7 @@ class PolylineObject extends Base { this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize + this.labelFontFamily = this.originalOptions.label.fontFamily this.labelLineWidth = this.originalOptions.label.lineWidth this.labelPixelOffset = this.originalOptions.label.pixelOffset this.labelLineColor = this.originalOptions.label.lineColor diff --git a/src/Obj/Base/RadarScan/index.js b/src/Obj/Base/RadarScan/index.js index bd7101c..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,16 +246,29 @@ class RadarScan extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - this.entity.show = v + let sdkD = get2DSdk().sdkD + if (!this.isShowView || !sdkD) { + this.options.show = v + } + 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 + } + } + 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") } @@ -448,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) { + if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { this.label.show = v } else { @@ -1374,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/SectorObject/index.js b/src/Obj/Base/SectorObject/index.js index 8f7a317..66e9c1e 100644 --- a/src/Obj/Base/SectorObject/index.js +++ b/src/Obj/Base/SectorObject/index.js @@ -23,7 +23,7 @@ class SectorObject extends Base { * @param options.id {string} 标注id * @param options.name {string} 名称 * @param options.show=true {boolean} 显示/隐藏 - * @param options.color="#ff000080" {string} 颜色 + * @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色 * @param options.center {object} 位置 * @param options.center.lng {object} 经度 * @param options.center.lat {object} 维度 @@ -39,7 +39,7 @@ class SectorObject extends Base { constructor(sdk, options = {}) { super(sdk, options); this.options.name = options.name || '未命名对象' - this.options.color = options.color || "#ff000080" + this.options.color = options.color || "rgba(255, 0, 0, 0.5)" this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10 this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20 @@ -47,7 +47,7 @@ class SectorObject extends Base { this.options.center = options.center || {} this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' options.label = options.label || {} this._elms = {}; @@ -293,7 +293,7 @@ class SectorObject extends Base { return this.options.line.width } set lineWidth(v) { - this.options.line.width = ((v || v === 0) ? v : 3) + this.options.line.width = ((v || v === 0) ? v : 3) this.entity.polyline.width = this.options.line.width this._elms.lineWidth && this._elms.lineWidth.forEach((item) => { item.value = this.options.line.width @@ -1560,7 +1560,7 @@ class SectorObject extends Base { _addRr() { if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) { this.options.attribute.vr.content.push({ - name: '全景图' , + name: '全景图', url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value }) this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = '' @@ -1573,7 +1573,7 @@ class SectorObject extends Base { addAttributeRr(vr) { this.options.attribute.vr.content.push({ - name: '全景图' , + name: '全景图', url: vr }) this.attributeVr = this.options.attribute.vr.content @@ -1922,6 +1922,19 @@ class SectorObject extends Base { that.cartesian3Towgs84(positions[1], that.sdk.viewer), that.cartesian3Towgs84(positions[positions.length - 4], that.sdk.viewer) ] + let objectsToExclude = [...that.sdk.viewer.entities.values] + that + .getClampToHeight({ + lng: that.options.center.lng, + lat: that.options.center.lat + }, objectsToExclude) + .then(height => { + that.label.position = [ + that.options.center.lng, + that.options.center.lat, + height + ] + }) setTimeout(() => { createNodePoints(positions[1], 'sector-start') createNodePoints(positions[positions.length - 4], 'sector-end') diff --git a/src/Obj/Base/StraightArrowObject/index.js b/src/Obj/Base/StraightArrowObject/index.js index f1c26aa..f4037ef 100644 --- a/src/Obj/Base/StraightArrowObject/index.js +++ b/src/Obj/Base/StraightArrowObject/index.js @@ -40,7 +40,7 @@ class StraightArrowObject extends Base { this.options.positions = options.positions || [] this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) - this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' + this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) diff --git a/src/Obj/Base/TextObject/StandText/index.js b/src/Obj/Base/TextObject/StandText/index.js index ed1ad98..6e2a173 100644 --- a/src/Obj/Base/TextObject/StandText/index.js +++ b/src/Obj/Base/TextObject/StandText/index.js @@ -417,71 +417,11 @@ class StandText extends Base { this.color = 'rgba(255,255,255,1)' },//点击清空按钮事件回调 }) - let labelColorPicker = new YJColorPicker({ - el: contentElm.getElementsByClassName("labelColor")[0], - size: 'mini',//颜色box类型 - alpha: true,//是否开启透明度 - defaultColor: this.labelColor, - disabled: false,//是否禁止打开颜色选择器 - openPickerAni: 'opacity',//打开颜色选择器动画 - sure: (color) => { - this.labelColor = color - },//点击确认按钮事件回调 - clear: () => { - this.labelColor = 'rgba(255,255,255,1)' - },//点击清空按钮事件回调 - }) - let lineColorPicker = new YJColorPicker({ - el: contentElm.getElementsByClassName("labelLineColor")[0], - size: 'mini',//颜色box类型 - alpha: true,//是否开启透明度 - defaultColor: this.labelLineColor, - disabled: false,//是否禁止打开颜色选择器 - openPickerAni: 'opacity',//打开颜色选择器动画 - sure: (color) => { - this.labelLineColor = color - },//点击确认按钮事件回调 - clear: () => { - this.labelLineColor = 'rgba(255,255,255,1)' - },//点击清空按钮事件回调 - }) - let labelBackgroundColorStartPicker = new YJColorPicker({ - el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0], - size: 'mini', - alpha: true, - defaultColor: this.labelBackgroundColorStart, - disabled: false, - openPickerAni: 'opacity', - sure: (color) => { - this.labelBackgroundColorStart = color - }, - clear: () => { - this.labelBackgroundColorStart = 'rgba(255,255,255,1)' - }, - }) - let labelBackgroundColorEndPicker = new YJColorPicker({ - el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0], - size: 'mini', - alpha: true, - defaultColor: this.labelBackgroundColorEnd, - disabled: false, - openPickerAni: 'opacity', - sure: (color) => { - this.labelBackgroundColorEnd = color - }, - clear: () => { - this.labelBackgroundColorEnd = 'rgba(255,255,255,1)' - }, - }) let all_elm = contentElm.getElementsByTagName("*") this._EventBinding.on(this, all_elm) this._elms = this._EventBinding.element this._elms.color = [colorPicker] - this._elms.labelColor = [labelColorPicker] - this._elms.labelLineColor = [lineColorPicker] - this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker] - this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker] } else { if (this._DialogObject && this._DialogObject.remove) { this._DialogObject.remove() diff --git a/src/Obj/Base/TrajectoryMotion/_element.js b/src/Obj/Base/TrajectoryMotion/_element.js index 3303918..81497e3 100644 --- a/src/Obj/Base/TrajectoryMotion/_element.js +++ b/src/Obj/Base/TrajectoryMotion/_element.js @@ -182,6 +182,23 @@ function html() { +
+
+
+ 油耗 +
+ + L/100km + +
+
+
+ 总油耗 + +
+
+
+ ` } diff --git a/src/Obj/Base/TrajectoryMotion/index.js b/src/Obj/Base/TrajectoryMotion/index.js index 888996a..aefb9dc 100644 --- a/src/Obj/Base/TrajectoryMotion/index.js +++ b/src/Obj/Base/TrajectoryMotion/index.js @@ -78,6 +78,7 @@ class TrajectoryMotion extends Base { this.options.line.smooth = options.line.smooth ? options.line.smooth : false this.options.line.noseToTail = options.line.noseToTail ? options.line.noseToTail : false this.positions_smooth = [] + this.options.unitFuelConsumption = options.unitFuelConsumption || 0 this.options.ground = options.ground || false this.options.state = (options.state || options.state === false) ? options.state : true this.options.routeDirection = (options.routeDirection || options.routeDirection === false) ? options.routeDirection : true @@ -99,7 +100,7 @@ class TrajectoryMotion extends Base { color: options.label.color || '#ffffff', lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4, pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20, - backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'], + backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'], lineColor: options.label.lineColor || '#00ffff80', scaleByDistance: options.label.scaleByDistance || false, near: (options.label.near || options.label.near === 0) ? options.label.near : 2000, @@ -144,37 +145,56 @@ class TrajectoryMotion extends Base { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.originalOptions) { - this.originalOptions.show = v + let sdkD = get2DView() + if (!this.isShowView || !sdkD) { + 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 || !sdkD) ? 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 || !sdkD)) { + 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 || !sdkD) ? this.keyPointShow : false } if (this.realTimeRoute) { - this.realTimeLine && (this.realTimeLine.show = true) + this.realTimeLine && (this.realTimeLine.show = (!this.showView || this.showView == 3 || !sdkD) ? 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) + this.fuelLabel && (this.fuelLabel.show = (!this.showView || this.showView == 3) ? this.options.fuelShow : false) } else { - this.model.show = v + this.model.show = (!this.showView || this.showView == 3 || !sdkD) ? this.options.show : false + let show = this.options.show + if ((!this.showView || this.showView == 3 || !sdkD)) { + 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,9 +202,10 @@ 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.fuelLabel && (this.fuelLabel.show = false) this.viewFollow = false } @@ -193,6 +214,7 @@ class TrajectoryMotion extends Base { } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) + this.isShowView = false } else { console.error("参数必须为boolean") } @@ -238,14 +260,17 @@ class TrajectoryMotion extends Base { // Cesium.Matrix4.multiplyByTranslation(this.model.modelMatrix, new Cesium.Cartesian3(0, 0, -difference), this.model.modelMatrix) // Cesium.Matrix4.getTranslation(this.model.modelMatrix, this.model.position) this.label && (this.label.show = this.label.show) + this.fuelLabel && (this.fuelLabel.show = this.fuelLabel.show) if (this.options.label.position) { setTimeout(() => { if (this.options.label.position.alt) { this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) + this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) } else { this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) + this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, height]) }) } }, 0) @@ -636,7 +661,7 @@ class TrajectoryMotion extends Base { }) this.TweenAnimate.pause() setTimeout(() => { - _this.model.isMove = false + _this.model && (_this.model.isMove = false) }, 200); } } @@ -655,9 +680,17 @@ 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 || !sdkD)) { + 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 +756,16 @@ class TrajectoryMotion extends Base { this.realTimeRoute = false } this.options.line.show = v + let show = v + let sdkD = get2DView() + if ((!this.showView || this.showView == 3 || !sdkD)) { + 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({ @@ -941,6 +982,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 @@ -994,7 +1036,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 || !sdkD)) { + 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,19 +1165,30 @@ 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 || !sdkD)) { + show = v + } + else { + show = false + } if (this.show) { - this.label && (this.label.show = v) - if (this.options.label.position) { - setTimeout(() => { - if (this.options.label.position.alt) { - this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) - } - else { - this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { - this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) - }) - } - }, 0); + if (this.label) { + this.label.show = show + this.label.pixelOffset = this.options.label.pixelOffset + (this.fuelShow ? this.labelFontSize + 20 : 0) + if (this.options.label.position) { + setTimeout(() => { + if (this.options.label.position.alt) { + this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) + } + else { + this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { + this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) + }) + } + }, 0); + } } } else { @@ -1146,6 +1206,7 @@ class TrajectoryMotion extends Base { set labelFontFamily(v) { this.options.label.fontFamily = v || 0 this.label && (this.label.fontFamily = this.options.label.fontFamily) + this.fuelLabel && (this.fuelLabel.fontFamily = this.options.label.fontFamily) let name = getFontFamilyName(this.labelFontFamily) || '' this._elms.labelFontFamily && @@ -1160,6 +1221,7 @@ class TrajectoryMotion extends Base { set labelColor(v) { this.options.label.color = v this.label && (this.label.color = v) + this.fuelLabel && (this.fuelLabel.color = v) if (this._elms.labelColor) { this._elms.labelColor.forEach((item, i) => { let labelColorPicker = new YJColorPicker({ @@ -1187,6 +1249,13 @@ class TrajectoryMotion extends Base { set labelFontSize(v) { this.options.label.fontSize = v this.label && (this.label.fontSize = v) + if (this.fuelLabel) { + this.fuelLabel.fontSize = v + this.label.pixelOffset = this.options.label.pixelOffset + v + 20 + } + else { + this.label.pixelOffset = this.options.label.pixelOffset + } this._elms.labelFontSize && this._elms.labelFontSize.forEach((item) => { item.value = v }) @@ -1198,6 +1267,7 @@ class TrajectoryMotion extends Base { set labelScaleByDistance(v) { this.options.label.scaleByDistance = v this.label && (this.label.scaleByDistance = v) + this.fuelLabel && (this.fuelLabel.scaleByDistance = v) this._elms.labelScaleByDistance && this._elms.labelScaleByDistance.forEach((item) => { item.checked = v }) @@ -1213,6 +1283,7 @@ class TrajectoryMotion extends Base { } this.options.label.near = near this.label && (this.label.near = near) + this.fuelLabel && (this.fuelLabel.near = near) this._elms.labelNear && this._elms.labelNear.forEach((item) => { item.value = near }) @@ -1228,11 +1299,66 @@ class TrajectoryMotion extends Base { } this.options.label.far = far this.label && (this.label.far = far) + this.fuelLabel && (this.fuelLabel.far = far) this._elms.labelFar && this._elms.labelFar.forEach((item) => { item.value = far }) } + get unitFuelConsumption() { + return this.options.unitFuelConsumption + } + + set unitFuelConsumption(v) { + this.options.unitFuelConsumption = v + this._elms.unitFuelConsumption && this._elms.unitFuelConsumption.forEach((item) => { + item.value = v + }) + } + + get fuelShow() { + return this.options.fuelShow + } + + set fuelShow(v) { + this.options.fuelShow = v + let show = v + if (this.show && (!this.showView || this.showView == 3)) { + show = v + } + else { + show = false + } + if (this.show) { + if (this.fuelLabel) { + this.fuelLabel.show = show + this.label.pixelOffset = this.options.label.pixelOffset + (show ? this.labelFontSize + 20 : 0) + } + else { + this.label.pixelOffset = this.options.label.pixelOffset + } + if (this.options.label.position) { + setTimeout(() => { + if (this.options.label.position.alt) { + this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) + } + else { + this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { + this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, height]) + }) + } + }, 0); + } + } + else { + this.fuelLabel && (this.fuelLabel.show = false) + this.label.pixelOffset = this.options.label.pixelOffset + } + this._elms.fuelShow && this._elms.fuelShow.forEach((item) => { + item.checked = v + }) + } + // 创建路径 static addLine(that) { let positions_smooth = that.renewLinePositions(that.options.line.positions) @@ -1351,6 +1477,7 @@ class TrajectoryMotion extends Base { } let pos = that.smooth ? that.positions_smooth : Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArrayHeights) TrajectoryMotion.createLabel(that) + TrajectoryMotion.createFuelLabel(that) that.modelMove(pos) @@ -1360,13 +1487,13 @@ class TrajectoryMotion extends Base { static async createLabel(that) { let labelPosition = that.cartesian3Towgs84(that.model.position, that.sdk.viewer) that.label = new LabelObject(that.sdk, { - show: that.options.show ? (that.options.model.show ? that.options.label.show : false) : false, + show: that.options.show ? (that.options.label.show ? true : false) : false, position: [labelPosition.lng, labelPosition.lat, labelPosition.alt], text: that.options.name, fontSize: that.options.label.fontSize, fontFamily: that.options.label.fontFamily, color: that.options.label.color, - pixelOffset: that.options.label.pixelOffset, + pixelOffset: that.options.label.pixelOffset + (that.options.fuelShow ? that.options.label.fontSize + 20 : 0), backgroundColor: that.options.label.backgroundColor, lineColor: that.options.label.lineColor, lineWidth: that.options.label.lineWidth, @@ -1376,6 +1503,26 @@ class TrajectoryMotion extends Base { }, that.model) } + static async createFuelLabel(that) { + let labelPosition = that.cartesian3Towgs84(that.model.position, that.sdk.viewer) + that.fuelLabel = new LabelObject(that.sdk, { + show: that.options.show ? (that.options.fuelShow ? true : false) : false, + // show: true, + position: [labelPosition.lng, labelPosition.lat, labelPosition.alt], + text: '总油耗:', + fontSize: that.options.label.fontSize, + fontFamily: that.options.label.fontFamily, + color: that.options.label.color, + pixelOffset: 0, + backgroundColor: ['#6e6e6e', '#6e6e6e'], + lineColor: '#00ffff00', + lineWidth: 0, + scaleByDistance: that.options.label.scaleByDistance, + near: that.options.label.near, + far: that.options.label.far + }, that.model) + } + // 创建关键点 static async addKeyPoint(that) { for (let i = 0; i < that.options.line.positions.length; i++) { @@ -1481,7 +1628,7 @@ class TrajectoryMotion extends Base { setPosition(startDistance) setTimeout(() => { _this.model.isMove = false - }, 500); + }, 1000); animateUpdate() @@ -1504,6 +1651,8 @@ class TrajectoryMotion extends Base { } async function setPosition(distance) { + _this.totalFuelConsumption = Number((distance / 100 * _this.unitFuelConsumption).toFixed(2)) + _this.fuelLabel.text = '总油耗:' + _this.totalFuelConsumption + ' L' _this.model.isMove = true let sdk2D = get2DView() let splitSdk = getSdk() @@ -1715,6 +1864,7 @@ class TrajectoryMotion extends Base { } let labelPosition = _this.cartesian3Towgs84(position, _this.sdk.viewer) _this.label.position = [labelPosition.lng, labelPosition.lat, labelPosition.alt] + _this.fuelLabel.position = [labelPosition.lng, labelPosition.lat, labelPosition.alt] lastDistance = distance // console.log(position) _this.realTimeRouteArray.push(position) @@ -1888,10 +2038,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) } }, @@ -2036,7 +2186,7 @@ class TrajectoryMotion extends Base { rubricElm.style.color = '#ff5733'; rubricElm.style.display = 'none' - rubricElm.innerHTML = `场景正北方向为轨迹前进正方向
` + rubricElm.innerHTML = `场景正东方向为轨迹前进正方向
` let iconRubric = contentElm.getElementsByClassName('icon-rubric')[0] iconRubric.addEventListener('mouseenter', (e) => { rubricElm.style.display = 'block' @@ -2111,6 +2261,7 @@ class TrajectoryMotion extends Base { this.sdk.viewer.entities.remove(this.line) this.sdk.viewer.entities.remove(this.realTimeLine) this.label && this.label.remove() + this.fuelLabel && this.fuelLabel.remove() for (let i = 0; i < this.keyPointShow.length; i++) { this.sdk.viewer.entities.remove(this.keyPointShow[i]) } @@ -2118,6 +2269,7 @@ class TrajectoryMotion extends Base { this.realTimeLine = null this.model = null this.label = null + this.fuelLabel = null if (this._DialogObject && !this._DialogObject.isDestroy) { this._DialogObject.close() this._DialogObject = null @@ -2164,13 +2316,14 @@ 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 + this.fuelLabelShow = this.originalOptions.fuelShow this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize this.labelFontFamily = this.originalOptions.label.fontFamily @@ -2229,7 +2382,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/WallRealStereoscopic/eventBinding.js b/src/Obj/Base/WallRealStereoscopic/eventBinding.js index 4554edc..22136c8 100644 --- a/src/Obj/Base/WallRealStereoscopic/eventBinding.js +++ b/src/Obj/Base/WallRealStereoscopic/eventBinding.js @@ -21,6 +21,7 @@ class eventBinding { let Event = [] let isEvent = false let removeName = [] + let blurEvent = ()=>{} if (!elements[i] ||!elements[i].attributes) { continue; } @@ -37,14 +38,14 @@ class eventBinding { let value = e.target.value if (e.target.type == 'number') { if (e.data != '.' && (e.data != '-' || e.target.value)) { - value = Number(value) - if((e.target.max) && value>Number(e.target.max)) { + let v = Number(value) + if((e.target.max) && v>Number(e.target.max)) { value = Number(e.target.max) } - if((e.target.min) && value { + let value = e.target.value + if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) { + value = Number(value) + if ((e.target.max) && value > Number(e.target.max)) { + value = Number(e.target.max) + } + if ((e.target.min) && value < Number(e.target.min)) { + value = Number(e.target.min) + } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } + } + that[m.value] = value + } if(elements[i].nodeName=='IMG') { elements[i].src = that[m.value] } @@ -111,6 +128,9 @@ class eventBinding { Event[t](e) } }); + elements[i].addEventListener('blur', (e) => { + blurEvent(e) + }); } } } diff --git a/src/Obj/Base/WallStereoscopic/eventBinding.js b/src/Obj/Base/WallStereoscopic/eventBinding.js index 53d9ed3..4a2f708 100644 --- a/src/Obj/Base/WallStereoscopic/eventBinding.js +++ b/src/Obj/Base/WallStereoscopic/eventBinding.js @@ -21,8 +21,9 @@ class eventBinding { let Event = [] let isEvent = false let removeName = [] - if (!elements[i] ||!elements[i].attributes) { - continue; + let blurEvent = () => { } + if (!elements[i] || !elements[i].attributes) { + continue; } for (let m of elements[i].attributes) { switch (m.name) { @@ -37,11 +38,11 @@ class eventBinding { let value = e.target.value if (e.target.type == 'number') { if (e.data != '.' && (e.data != '-' || e.target.value)) { - value = Number(value) - if((e.target.max) && value>Number(e.target.max)) { + let v = Number(value) + if ((e.target.max) && v > Number(e.target.max)) { value = Number(e.target.max) } - if((e.target.min) && value { + let value = e.target.value + if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) { + value = Number(value) + if ((e.target.max) && value > Number(e.target.max)) { + value = Number(e.target.max) + } + if ((e.target.min) && value < Number(e.target.min)) { + value = Number(e.target.min) + } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } + } + that[m.value] = value + } + + + if (elements[i].nodeName == 'IMG') { elements[i].src = that[m.value] } else { elements[i].value = that[m.value] } } - if(this.element[m.value]) { + if (this.element[m.value]) { this.element[m.value].push(elements[i]) } else { @@ -81,7 +100,7 @@ class eventBinding { isEvent = true Event.push((e) => { let value = e.target.value - if(e.target.type == 'number' && value!='') { + if (e.target.type == 'number' && value != '') { value = Number(value) e.target.value = value } @@ -94,7 +113,7 @@ class eventBinding { } // elements[i].attributes[m] = undefined } - for(let n=0;n { + blurEvent(e) + }); } } } diff --git a/src/Obj/Base/WallStereoscopic/index.js b/src/Obj/Base/WallStereoscopic/index.js index 938f2c1..49a0edf 100644 --- a/src/Obj/Base/WallStereoscopic/index.js +++ b/src/Obj/Base/WallStereoscopic/index.js @@ -88,6 +88,10 @@ class WallStereoscopic extends Base { } } + get type() { + return 'wallStereoscopic' + } + static createLabel(that) { // 标签 that.label = new LabelObject(that.sdk, { diff --git a/src/Obj/Base/WaterSurface/eventBinding.js b/src/Obj/Base/WaterSurface/eventBinding.js index ccbf026..1fe3d17 100644 --- a/src/Obj/Base/WaterSurface/eventBinding.js +++ b/src/Obj/Base/WaterSurface/eventBinding.js @@ -35,7 +35,8 @@ class eventBinding { else { Event.push((e) => { let value = e.target.value - if (e.target.type == 'number') { + let str = e.target.value + '' + if (e.target.type == 'number' && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.'))) { value = Number(value) } that[m.value] = value diff --git a/src/Obj/Base/index.js b/src/Obj/Base/index.js index 319800a..fedb92a 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) { @@ -29,6 +31,7 @@ class Base extends Tools { this.rightClickCallBack = null this.picking = true this.options.host = this.options.host || getHost() + // this.#_showView = this.options.showView || 0 this.setDefaultValue() // this.sdk.addIncetance(this.options.id, this) @@ -55,6 +58,60 @@ class Base extends Tools { // setSplitDirection(this._splitDirection, this.options.id) // } + get showView() { + return this.#_showView + } + + set showView(v) { + + + let sdk2D = get2DSdk().sdkD + if (!sdk2D) { + this.#_showView = v + if(this.entity) { + this.entity._showView = v + } + return + } + if (this.sdk === sdk2D) { + this.#_showView = 0 + return + } + 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 +129,60 @@ class Base extends Tools { set show(v) { if (typeof v === "boolean") { - this.options.show = v - if (this.originalOptions) { - this.originalOptions.show = v + let sdkD = get2DSdk().sdkD + if (!this.isShowView || !sdkD) { + this.options.show = v + if (this.originalOptions) { + this.originalOptions.show = v + } } - this.entity && (this.entity.show = v) + this.entity._showView = this.showView + if (this.type == 'layer') { + if (this.entity) { + this.entity._objectState = this.options.show + } + } + 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 + } + } + 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 + + if (this.type == 'layer' && sdkD) { + let layer2d = sdkD.viewer.imageryLayers._layers[this.layerIndex] + let layer3d = this.entity + + if (!layer2d) { + return + } + if (layer3d._objectState) { + if (!layer3d._showView || layer3d._showView == 2) { + layer2d.show = true + } + if (layer3d._showView == 3) { + layer2d.show = false + } + } + else { + layer2d.show = this.options.show + } + } } else { console.error("参数必须为boolean") } @@ -192,7 +290,7 @@ class Base extends Tools { let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) let position = { lng: 0, lat: 0 } - if (this.options.position) { + if (this.options.position && Object.prototype.toString.call(this.options.position) === '[object Object]') { position = { ...this.options.position } } else if (this.options.positions) { @@ -263,7 +361,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 +384,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 +407,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) } @@ -338,7 +436,7 @@ class Base extends Tools { let position = { lng: 0, lat: 0 } let relativePosition = { ...cameraPosition84 } - if (this.options.position) { + if (this.options.position && Object.prototype.toString.call(this.options.position) === '[object Object]') { position = { ...this.options.position } } else if (this.options.positions) { diff --git a/src/Obj/Element/Dialog/eventBinding.js b/src/Obj/Element/Dialog/eventBinding.js index 96ef856..6bd6b26 100644 --- a/src/Obj/Element/Dialog/eventBinding.js +++ b/src/Obj/Element/Dialog/eventBinding.js @@ -55,6 +55,9 @@ class EventBinding { if ((e.target.min) && value < Number(e.target.min)) { value = Number(e.target.min) } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } that[m.value] = value } } 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/src/Obj/Element/cy_html_tabs.js b/src/Obj/Element/cy_html_tabs.js index 1270e29..464c37b 100644 --- a/src/Obj/Element/cy_html_tabs.js +++ b/src/Obj/Element/cy_html_tabs.js @@ -1,6 +1,13 @@ class cy_tabs { - constructor(id, clickTabCallBack, sdk) { - let elm = document.getElementById(id); + constructor(boxElm, clickTabCallBack, sdk) { + let elm + if(typeof boxElm === 'string') { + elm = document.getElementById(boxElm); + } + else { + elm = boxElm + } + // let elm = document.getElementById(id); let pane = elm.getElementsByTagName('DIV-cy-tab-pane') let tabTop = `
` @@ -37,7 +44,9 @@ tabContent = tabContent + `
` let BoxElm = document.createElement('div'); - BoxElm.setAttribute('id', id) + if(typeof boxElm === 'string') { + BoxElm.setAttribute('id', boxElm) + } BoxElm.setAttribute('class', 'DIV-cy-tabs') BoxElm.innerHTML = tabTop + tabContent elm.parentNode.insertBefore(BoxElm, elm); diff --git a/src/Obj/Element/richText.js b/src/Obj/Element/richText.js index 072a599..c63614c 100644 --- a/src/Obj/Element/richText.js +++ b/src/Obj/Element/richText.js @@ -56,8 +56,8 @@ class richText { MENU_CONF: { uploadImage: { fieldName: 'file', - maxFileSize: 50 * 1024 * 1024, - base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64 + // maxFileSize: 50 * 1024 * 1024, + // base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64 server: this.uploadImageServer, // // 上传之前触发 // onBeforeUpload(file) { // TS 语法 @@ -95,18 +95,18 @@ class richText { // console.log(`${file.name} 上传出错`, err, res) // }, - // // 自定义上传 - // async customUpload(file, insertFn) { // TS 语法 - // // async customUpload(file, insertFn) { // JS 语法 - // // file 即选中的文件 - // // 自己实现上传,并得到图片 url alt href - // // 最后插入图片 - // console.log(file, insertFn) - // insertFn(url, file.name) - // } + // 自定义上传 + async customUpload(file, insertFn) { // TS 语法 + // async customUpload(file, insertFn) { // JS 语法 + // file 即选中的文件 + // 自己实现上传,并得到图片 url alt href + // 最后插入图片 + let url = await _this.upload(file) + insertFn((_this.host = _this.host || getHost()) + '/' + url) + } }, uploadVideo: { - maxFileSize: 500 * 1024 * 1024, + // maxFileSize: 500 * 1024 * 1024, server: this.uploadVideoServer, allowedFileTypes: ['video/mp4', 'video/mp3', 'video/ogg', 'video/webm', 'video/avi'], // 自定义上传 diff --git a/src/Obj/Element/svg.js b/src/Obj/Element/svg.js index 58bbc1e..3580739 100644 --- a/src/Obj/Element/svg.js +++ b/src/Obj/Element/svg.js @@ -1,4 +1,4 @@ -let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross'] +let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross', 'icom-confirm'] function setSvg() { let svgElm = document.createElement('svg'); svgElm.xmlns = 'http://www.w3.org/2000/svg' diff --git a/src/Obj/Element/yj-color-picker.js b/src/Obj/Element/yj-color-picker.js index 0f95080..2703cf6 100644 --- a/src/Obj/Element/yj-color-picker.js +++ b/src/Obj/Element/yj-color-picker.js @@ -1,7 +1,11 @@ class YJColorPicker { constructor(options = {}) { let _this = this - let pickAlphaInput + let RInput + let GInput + let BInput + let AInput + let config = { el: options.el, size: "mini", @@ -12,18 +16,22 @@ class YJColorPicker { hasClear: true, openPickerAni: 'opacity', defaultColor: options.defaultColor, + pickerInputChange: pickerInputChange, startMainCallback: (t) => { - customizeStyle() + _this.colorPicker && (_this.colorPicker.picker.style.opacity = 0) + setTimeout(() => { + customizeStyle() + }, 0); } } this.el = options.el if (options.sure) { config.sure = (color) => { - this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value + // this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value let c = Cesium.Color.fromCssColorString(color) - if (pickAlphaInput) { - c = c.withAlpha(pickAlphaInput.value / 100) - this.pickAlphaInputValue = pickAlphaInput.value + if (AInput) { + c = c.withAlpha(AInput.value) + this.pickAlphaInputValue = AInput.value } color = c.toCssHexString() if (typeof options.sure == 'function') { @@ -34,8 +42,8 @@ class YJColorPicker { } if (options.clear) { config.clear = () => { - if (pickAlphaInput) { - pickAlphaInput.value = this.pickAlphaInputValue = 100 + if (AInput) { + AInput.value = this.pickAlphaInputValue = 1 } this.colorPicker.config.defaultColor = '' customizeStyle() @@ -53,7 +61,7 @@ class YJColorPicker { } } let CesiumColor - if(config.defaultColor) { + if (config.defaultColor) { CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor) } // if (options.predefineColor) { @@ -66,42 +74,172 @@ class YJColorPicker { customizeStyle() function customizeStyle() { - if (!_this.colorPicker) { + if (!_this.colorPicker || !_this.colorPicker.picker) { return } let isSubtract = false let box = _this.colorPicker.box let picker = _this.colorPicker.picker + let x = box.getBoundingClientRect().x + let y = box.getBoundingClientRect().y + let height = 0 + + // if (picker.style.display === 'none') { + // picker.style.display = 'block' + // height = picker.offsetHeight + // console.log('picker.style.display.opacity', picker.style.display.opacity) + // picker.style.display = 'none' + // } + // console.log('===========================================') + // console.log((y + box.offsetHeight + 4), height, window.innerHeight) + // if ((y + box.offsetHeight + 4) + height > window.innerHeight) { + // console.log(y, height) + // picker.style.top = y - height + 'px' + // } + // else { + // picker.style.top = (y + box.offsetHeight + 4) + 'px' + // } + + picker.style.left = x + 'px' picker.style.minWidth = '325px' - let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0] + // let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0] let pickAlphaSliderBar = picker.getElementsByClassName('ew-alpha-slider-bar')[0] if (pickAlphaSliderBar) { pickAlphaSliderBar.parentNode.style.width = '16px' pickAlphaSliderBar.parentNode.removeChild(pickAlphaSliderBar) } - // let customDivider = document.createElement('span') - // customDivider.className = 'custom-divider' - // customDivider.style.margin = '10px 0' - // pickerContent.parentNode.insertBefore(customDivider, pickerContent.nextSibling) + let pickPen = document.createElement('div') pickPen.className = 'icon-pen-box' pickPen.innerHTML = '' + + /** 为完成、暂时隐藏 */////// + pickPen.style.display = 'none' + pickPen.style.cursor = 'unset' + + + let pickerInput = _this.colorPicker.pickerInput pickerInput.parentNode.insertBefore(pickPen, pickerInput) pickerInput.style.width = '188px' + pickerInput.style.display = 'none' + + let colorInputBox = document.createElement('div') + let row1Elm = document.createElement('div') + row1Elm.className = 'row' + row1Elm.style.margin = '6px 0 0 0' + row1Elm.innerHTML = ` +
R
+
G
+
B
+
+ ` + let row2Elm = document.createElement('div') + row2Elm.className = 'row' + row2Elm.innerHTML = ` +
+ +
+
+ +
+
+ +
+ ` + colorInputBox.appendChild(row1Elm) + colorInputBox.appendChild(row2Elm) + let Inputs = row2Elm.getElementsByTagName('input') + Inputs[0].style.width = '72px' + Inputs[1].style.width = '72px' + Inputs[2].style.width = '72px' + RInput = Inputs[0] + GInput = Inputs[1] + BInput = Inputs[2] + + let dropbtns = picker.getElementsByClassName('ew-color-dropbtns')[0] + picker.insertBefore(colorInputBox, dropbtns) + + RInput.addEventListener('blur', (e) => { + let value = e.target.value + if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + value = Number(value) + if ((e.target.max) && value > Number(e.target.max)) { + value = Number(e.target.max) + } + if ((e.target.min) && value < Number(e.target.min)) { + value = Number(e.target.min) + } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } + RInput.value = parseInt(value) + _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) + _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) + } + }) + GInput.addEventListener('blur', (e) => { + let value = e.target.value + if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + value = Number(value) + if ((e.target.max) && value > Number(e.target.max)) { + value = Number(e.target.max) + } + if ((e.target.min) && value < Number(e.target.min)) { + value = Number(e.target.min) + } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } + GInput.value = parseInt(value) + _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) + _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) + } + }) + BInput.addEventListener('blur', (e) => { + let value = e.target.value + if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { + value = Number(value) + if ((e.target.max) && value > Number(e.target.max)) { + value = Number(e.target.max) + } + if ((e.target.min) && value < Number(e.target.min)) { + value = Number(e.target.min) + } + if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { + value = Number(e.target.dataset.min) + } + BInput.value = parseInt(value) + _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) + _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) + } + }) + + + if (options.alpha) { + Inputs[0].style.width = '52px' + Inputs[1].style.width = '52px' + Inputs[2].style.width = '52px' let pickAlpha = document.createElement('div') - pickAlpha.className = 'input-number input-number-unit-1 color-alpha' + pickAlpha.className = 'input-number input-number-unit color-alpha' pickAlpha.innerHTML = ` - - % + ` pickerInput.parentNode.insertBefore(pickAlpha, pickerInput.nextSibling) - pickerInput.style.width = '106px' - pickAlpha.style.width = '80px' - pickAlphaInput = pickAlpha.getElementsByClassName('input')[0] - pickAlphaInput.addEventListener('blur', (e) => { + pickAlpha.style.width = '66px' + pickAlpha.style.margin = '0 6px 0 0' + AInput = pickAlpha.getElementsByClassName('input')[0] + row1Elm.innerHTML = ` +
R
+
G
+
B
+
A
+
+ ` + row2Elm.appendChild(pickAlpha) + AInput.addEventListener('blur', (e) => { let value = e.target.value if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { value = Number(value) @@ -114,23 +252,26 @@ class YJColorPicker { if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { value = Number(e.target.dataset.min) } - pickAlphaInput.value = Number(value.toFixed(2)) + AInput.value = parseInt(value * 100) / 100 } }) if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') { - pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2)) + AInput.value = parseInt(_this.pickAlphaInputValue * 100) / 100 } else { - pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(2)) : 100 + AInput.value = CesiumColor ? parseInt(Number(CesiumColor.alpha.toFixed(2)) * 100) / 100 : 1 } - _this.pickAlphaInputValue = pickAlphaInput.value - box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString() + _this.pickAlphaInputValue = AInput.value + box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(AInput.value).toCssColorString() } else { CesiumColor = CesiumColor ? CesiumColor.withAlpha(1) : '' box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssColorString() } + let btngroup = picker.getElementsByClassName('ew-color-dropbtngroup')[0] + row2Elm.appendChild(btngroup) + let defineColorContainer = picker.getElementsByClassName('ew-pre-define-color-container')[0] if (defineColorContainer) { let colorList = localStorage.getItem('custom-color') @@ -157,8 +298,10 @@ class YJColorPicker { addColorBtn.className = 'yj-pre-collect-color add' let subtractColorBtn = document.createElement('div') - subtractColorBtn.innerHTML = '' + subtractColorBtn.innerHTML = '' subtractColorBtn.className = 'yj-pre-collect-color subtract' + let minusIcon = subtractColorBtn.getElementsByClassName('icon-minus')[0] + let confirmIcon = subtractColorBtn.getElementsByClassName('icon-confirm')[0] collectColorContainer.appendChild(addColorBtn) collectColorContainer.appendChild(subtractColorBtn) @@ -217,8 +360,8 @@ class YJColorPicker { let color = colorRgbaToHex(colorHsbaToRgba(_this.colorPicker.hsba)) let c = Cesium.Color.fromCssColorString(color || '#ffffff') - if (pickAlphaInput) { - c = c.withAlpha(pickAlphaInput.value / 100) + if (AInput) { + c = c.withAlpha(AInput.value) } let colorString = c.toCssHexString() colorItemElm.style.backgroundColor = colorString @@ -252,23 +395,43 @@ class YJColorPicker { subtractColorBtn.addEventListener('click', () => { isSubtract = !isSubtract if (isSubtract) { + minusIcon.style.display = 'none' + confirmIcon.style.display = 'unset' for (let i = 0; i < subtractElmList.length; i++) { subtractElmList[i].style.display = 'block' } } else { + minusIcon.style.display = 'unset' + confirmIcon.style.display = 'none' for (let i = 0; i < subtractElmList.length; i++) { subtractElmList[i].style.display = 'none' } } }) } + + height = picker.offsetHeight + if (picker.style.display === 'none') { + picker.style.display = 'block' + height = picker.offsetHeight + picker.style.display = 'none' + } + if ((y + box.offsetHeight + 4) + height > window.innerHeight) { + picker.style.top = y - height + 'px' + } + else { + picker.style.top = (y + box.offsetHeight + 4) + 'px' + } + _this.colorPicker.pancelTop = parseFloat(picker.style.top) - 2 + + pickerInputChange(Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssHexString()) } function clickDefineColor(color) { - if (pickAlphaInput) { + if (AInput) { let c = Cesium.Color.fromCssColorString(color) - pickAlphaInput.value = Number((c.alpha * 100).toFixed(2)) + AInput.value = parseInt(Number(c.alpha.toFixed(2)) * 100) / 100 } } @@ -321,6 +484,84 @@ class YJColorPicker { "#" + n } } + + function colorHexToRgba(hex, alpha) { + let a = alpha || 1, + hColor = hex.toLowerCase(), + hLen = hex.length, + rgbaColor = []; + hColor = Cesium.Color.fromCssColorString(hColor).toCssHexString().substring(0, 7) + const colorRegExp = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; + if (hex && colorRegExp.test(hColor)) { + //the hex length may be 4 or 7,contained the symbol of # + if (hLen === 4) { + let hSixColor = '#'; + + for (let i = 1; i < hLen; i++) { + let sColor = hColor.slice(i, i + 1); + hSixColor += sColor.concat(sColor); + } + + hColor = hSixColor; + } + + for (let j = 1, len = hColor.length; j < len; j += 2) { + rgbaColor.push(parseInt('0X' + hColor.slice(j, j + 2), 16)); + } + + // return "rgba(" + rgbaColor.join(",") + ',' + a + ")"; + return rgbaColor; + } else { + return; + } + } + + function colorRgbaToHsba(e) { + var t = e.slice(e.indexOf("(") + 1, e.lastIndexOf(")")).split(",") + , r = t.length < 4 ? 1 : Number(t[3]) + , n = Number(t[0]) / 255 + , o = Number(t[1]) / 255 + , i = Number(t[2]) / 255 + , a = void 0 + , s = void 0 + , l = void 0 + , c = Math.min(n, o, i) + , d = l = Math.max(n, o, i) + , u = d - c; + if (d === c) + a = 0; + else { + switch (d) { + case n: + a = (o - i) / u + (o < i ? 6 : 0); + break; + case o: + a = 2 + (i - n) / u; + break; + case i: + a = 4 + (n - o) / u + } + a = Math.round(60 * a) + } + s = 0 === d ? 0 : 1 - c / d; + return s = Math.round(100 * s), + l = Math.round(100 * l), + { + h: a, + s: s, + b: l, + a: r + } + } + + function pickerInputChange(v) { + if (_this.colorPicker && _this.colorPicker.pickerInput) { + let rgbaColor = colorHexToRgba(v || _this.colorPicker.pickerInput.value) + RInput.value = rgbaColor[0] + GInput.value = rgbaColor[1] + BInput.value = rgbaColor[2] + } + } } } diff --git a/src/Obj/Materail/WallMaterialProperty.js b/src/Obj/Materail/WallMaterialProperty.js index b71c889..bda11b0 100644 --- a/src/Obj/Materail/WallMaterialProperty.js +++ b/src/Obj/Materail/WallMaterialProperty.js @@ -70,7 +70,7 @@ function StreamWall1() { fragColor.rgb = color.rgb / 1.0;\n\ fragColor = czm_gammaCorrect(fragColor);\n\ material.alpha = colorImage.a * color.a;\n\ - material.diffuse = (colorImage.rgb+color.rgb)/2.0;\n\ + material.diffuse = color.rgb/20.0;\n\ material.emission = fragColor.rgb;\n\ return material;\n\ }"; @@ -208,6 +208,14 @@ function StreamWall2() { Property.equals(this.repeat, other._repeat) && Property.equals(this.repeats, other._repeats) }; + // let code2 = 'material.diffuse = color.rgb*1.0;' + // if (uniforms.is2D) { + // code2 = ` + // material.diffuse = color.rgb*0.0; + // material.emission = color.rgb * 1.0; + // ` + // } + // console.log(code2, uniforms.is2D) // 将定义的材质对象添加到cesium的材质队列中 Material._materialCache.addMaterial(MaterialType, { fabric: { @@ -230,8 +238,8 @@ function StreamWall2() { else { material.alpha = 1.0; } - material.diffuse = colorImage.rgb*color.rgb*0.0; - material.emission = colorImage.rgb*color.rgb * 1.4; + material.diffuse = color.rgb*0.0; + material.emission = color.rgb * 1.0; return material; }`, components: { diff --git a/static/3rdparty/ewPlugins.min.js b/static/3rdparty/ewPlugins.min.js index 735f08b..2b89a81 100644 --- a/static/3rdparty/ewPlugins.min.js +++ b/static/3rdparty/ewPlugins.min.js @@ -746,6 +746,7 @@ o.colorHsbaToRgba)(e.hsba) : e.pickerInput.value = (0, o.colorRgbaToHex)((0, o.colorHsbaToRgba)(e.hsba)) + e.config.pickerInputChange && e.config.pickerInputChange() } function f(e) { if (this.pickerFlag = !1, @@ -795,6 +796,8 @@ n.isFunction)(e.sure) ? e.sure : null, clear: (0, n.isFunction)(e.clear) ? e.clear : null, + pickerInputChange: (0, + n.isFunction)(e.pickerInputChange) ? e.pickerInputChange : null, startMainCallback: (0, n.isFunction)(e.startMainCallback) ? e.startMainCallback : null, clickDefineColor: (0, @@ -807,8 +810,10 @@ else this.init(o, this.config) } + this.changeColor = g this.close = () => { this.pickerFlag = !this.pickerFlag, + this.picker.style.opacity = 0 this.render(this.box.parentNode, this.config), d(this), g(this, this.panelWidth, this.panelHeight) @@ -890,6 +895,7 @@ var u = i - e.hsba.a * i; c(e.alphaBarThumb, "top", u + "px") } + e.config.pickerInputChange && e.config.pickerInputChange() } function b(e, t) { var r = e.hueBar.offsetHeight @@ -965,6 +971,7 @@ } , f.prototype.startMain = function(e, t) { + // console.log(e,t) var r = this; this.box = l(e, "ew-color-picker-box"), this.box.setAttribute("color-box-id", this.uid), @@ -1002,8 +1009,21 @@ c += s.offsetParent.offsetTop, f += s.offsetParent.offsetLeft, s = s.offsetParent; - this.pancelLeft = f, - this.pancelTop = c + e.offsetHeight, + this.pancelLeft = f; + let defineColorContainer = this.picker.getElementsByClassName('ew-pre-define-color-container')[0] + let customColorHeight = 0 + if(defineColorContainer) { + let colorList = localStorage.getItem('custom-color') || '{}' + colorList = JSON.parse(colorList) + customColorHeight = (Math.floor((Object.keys(colorList).length+2) / 11)+1) * 30 + } + this.picker.style.display = 'block' + this.pancelTop = e.getBoundingClientRect().y + (e.offsetHeight + customColorHeight) + 2 + if((this.picker.offsetHeight + customColorHeight) + this.pancelTop > window.innerHeight) { + this.pancelTop = e.getBoundingClientRect().y - (this.picker.offsetHeight + customColorHeight) + this.picker.style.top = this.pancelTop + 2 + 'px' + } + this.picker.style.display = 'none' this.preDefineItem = l(e, "ew-pre-define-color", !0), this.preDefineItem.length && (0, n.ewObjToArray)(this.preDefineItem).map(function(e) { @@ -1054,7 +1074,7 @@ }, !1), this.pickerClear.addEventListener("click", function() { !function(e, t) { - t.config.defaultColor = "rgba(255,255,255,1)", + t.config.defaultColor = "", t.pickerFlag = !t.pickerFlag, t.render(e, t.config), d(t), @@ -1070,6 +1090,9 @@ o.colorHsbaToRgba)(e.hsba) : (0, o.colorRgbaToHex)((0, o.colorHsbaToRgba)(e.hsba)); + e.config.defaultColor = e.pickerInput.value + e.config.pickerInputChange && e.config.pickerInputChange() + e.render(e.box.parentNode, e.config), e.config.sure(t, e) }(r) }), @@ -1097,6 +1120,7 @@ }(r, e) }, !1), this.bindEvent(this.pickerCursor, function(e, t, r, n) { + // console.log(e) r=r-7 n=n-7 u(e, Math.max(0, Math.min(r - e.pancelLeft, i)), Math.max(0, Math.min(n - e.pancelTop, a)), i, a) @@ -1119,7 +1143,8 @@ a = i, o.moveX = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientX : a.clientX, o.moveY = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientY : a.clientY, - r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY) + r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY); + // console.log('222222', i, t,e, o.moveX, o.moveY) }; document.addEventListener(n.eventType[1], a, { capture: !1, diff --git a/static/custom/css/index.css b/static/custom/css/index.css index 8e8ad55..e27a648 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -68,7 +68,6 @@ z-index: 999999; background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); border: 1.5px solid; - backdrop-filter: blur(2px); border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; text-align: left; font-family: 'sy-boldface'; @@ -1033,16 +1032,31 @@ background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; padding: 5px; + position: fixed !important; } -.YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content { +.YJ-custom-base-dialog>.content .ew-color-picker input { + font-size: 14px; + line-height: 28px; + height: 28px; + padding: 0 8px; + font-weight: 400; +} + +.YJ-custom-base-dialog>.content .ew-color-picker .input-number-unit input[type=number] { + padding: 0 20px 0 8px; + width: 66px; +} + +.YJ-custom-base-dialog.ew-color-picker>.ew-color-picker-content { margin-bottom: 10px; } -.YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content>.ew-color-panel { + +.YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content>.ew-color-panel { width: 302px; } -.YJ-custom-base-dialog .ew-color-picker> .ew-color-input { +.YJ-custom-base-dialog .ew-color-picker>.ew-color-input { margin-top: 1px; font-size: 14px; background-color: rgba(0, 0, 0, 0.5); @@ -1058,13 +1072,16 @@ .YJ-custom-base-dialog .ew-color-picker .icon-pen-box { display: inline-block; /* cursor: pointer; */ - cursor: no-drop; width: 24px; height: 24px; text-align: center; line-height: 24px; } +.YJ-custom-base-dialog>.content>div .ew-color-picker .row>.col { + margin: 0 !important; +} + .YJ-custom-base-dialog .ew-color-picker .icon-pen-box .icon-pen { margin: 0; } @@ -1080,9 +1097,9 @@ } .YJ-custom-base-dialog .ew-color-picker .color-alpha>input { - font-weight: 400; - font-family: Arial; - font-size: 14px; + font-weight: 400 !important; + font-family: Arial !important; + font-size: 14px !important; } .YJ-custom-base-dialog .ew-color-picker>.ew-pre-define-color-container { @@ -1095,6 +1112,7 @@ margin: 0 0 8px 8px; border: 1px solid #9b979b; } + .YJ-custom-base-dialog .ew-color-picker>.ew-pre-define-color-container>.ew-pre-define-color:nth-child(11n+1) { width: 22px; height: 22px; @@ -1124,6 +1142,7 @@ text-align: center; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg=="); } + .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:nth-child(11n+1) { margin: 0 0 8px 0; } @@ -1132,14 +1151,16 @@ .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.subtract { border-color: rgba(var(--color-sdk-base-rgb), 0.2); background: unset; + line-height: 22px; } + .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.add:hover, .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.subtract:hover { border-color: rgba(var(--color-sdk-base-rgb), 0.4); } .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container svg, -.YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container> svg { +.YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>svg { margin: 0; } @@ -1156,10 +1177,12 @@ border-radius: 3px; cursor: pointer; } + .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color>.yj-pre-define-color-item.subtract-btn { position: absolute; top: 0; left: 0; + line-height: 20px; } .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:hover { @@ -1168,11 +1191,15 @@ .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup { display: flex; + position: unset; } .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup button { - padding: 5px 10px 4px 10px; + padding: 0 8px; + height: 28px; + line-height: 28px; } + .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup button.ew-color-clear { margin-right: 8px; } @@ -1180,6 +1207,7 @@ .YJ-custom-base-dialog .ew-color-picker-box { border-width: 4px; border-color: #ffffff; + display: block; } .YJ-custom-base-dialog .ew-color-picker-box>.ew-color-picker-no, @@ -1209,12 +1237,12 @@ transform: rotate(-45deg); } -.YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtns{ +.YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtns { display: flex; align-items: center; } -.YJ-custom-base-dialog .ew-color-picker svg{ +.YJ-custom-base-dialog .ew-color-picker svg { margin: 0; } @@ -1401,6 +1429,24 @@ margin-bottom: 10px; display: flex; position: relative; + overflow-y: auto; +} + +.DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar { + width: 4px; + height: 4px; +} + +.DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar-thumb { + border-radius: 5px; + -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + background-color: rgba(var(--color-sdk-base-rgb)); +} + +.DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + border-radius: 5px; + background-color: rgba(var(--color-sdk-base-rgb), 0.1); } .DIV-cy-tabs .DIV-cy-tab-top::after { @@ -1445,7 +1491,14 @@ border-bottom: 2px solid #dddddd00; position: relative; z-index: 2; + white-space: nowrap; + user-select: none; cursor: pointer; + -webkit-pointer-events: auto; + -moz-pointer-events: auto; + -ms-pointer-events: auto; + -o-pointer-events: auto; + pointer-events: auto; } .DIV-cy-tabs .DIV-cy-tab-pane-title-p span { @@ -1935,6 +1988,7 @@ .YJ-custom-base-dialog.water-surface>.content>div .row .label { flex: 0 0 60px; } + /* 流光飞线 */ .YJ-custom-base-dialog.flow-line-surface>.content { width: 586px; @@ -2104,6 +2158,10 @@ width: 200px; } +.YJ-custom-base-dialog.particle-effects>.content .ew-color-picker .row>.col { + width: auto; +} + .YJ-custom-base-dialog.particle-effects>.content [type="range"] { margin-top: 10px; } @@ -2749,6 +2807,7 @@ .YJ-custom-base-dialog.polyline>.content { width: 580px; } + .YJ-custom-base-dialog.polyline>.content>div #dashTextureDom { display: none; } @@ -2800,6 +2859,7 @@ .YJ-custom-base-dialog.polyline>.content>div .spatial-info-table .table-body { max-height: 185px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-unit-box textarea { border-radius: unset !important; } @@ -2928,34 +2988,37 @@ } .YJ-custom-base-dialog.polyline>.content>div .input-select-unit-box textarea { - border-radius: unset!important; + border-radius: unset !important; } .YJ-custom-base-dialog.polyline>.content>div .input-select-unit .datalist { - background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; + background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; border-radius: 4px 0px 0px 4px !important; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(1) .datalist { - background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; - border-radius: 4px 0px, 0px, 4px!important; + background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; + border-radius: 4px 0px, 0px, 4px !important; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) .datalist { - background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; - border-radius: 0px 4px 4px 0px!important; + background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; + border-radius: 0px 4px 4px 0px !important; } .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(1) input { - border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; -} -.YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) input { - border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; + border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; } -.YJ-custom-base-dialog.polyline>.content input.input-text{ - background-color: rgba(0, 0, 0, 0.5)!important; - border-radius: unset!important; - border-top: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; - border-bottom: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; +.YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) input { + border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; +} + +.YJ-custom-base-dialog.polyline>.content input.input-text { + background-color: rgba(0, 0, 0, 0.5) !important; + border-radius: unset !important; + border-top: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; + border-bottom: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; } .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist input { @@ -2979,65 +3042,78 @@ height: 13px; margin-right: 7px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.line { border: 1px solid rgba(var(--color-sdk-base-rgb), 1); height: 0px; margin-top: 4px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.dash-line { border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); height: 0px; margin-top: 4px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.light-line { border: 1px solid rgba(var(--color-sdk-base-rgb), 1); height: 0px; margin-top: 4px; box-shadow: 0 0 3px #fff } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.tail-line { background: url(../../img/arrow/tail.png) 100% 100% no-repeat; background-size: 100% 100%; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.mult-tail-line { background: url(../../img/arrow/tail.png) 100% 100% no-repeat; background-size: 100% 100%; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.flow-dash-line1 { border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); height: 0px; margin-top: 4px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.flow-dash-line2 { border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); height: 0px; margin-top: 4px; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line1 { background: url(../../img/arrow/1.png); background-size: cover; background-position: center; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line2 { background: url(../../img/arrow/2.png); background-size: cover; background-position: center; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line3 { background: url(../../img/arrow/3.png); background-size: cover; background-position: center; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line4 { - background: url(../../img/arrow/4.png) ; + background: url(../../img/arrow/4.png); background-size: cover; background-position: center; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line5 { background: url(../../img/arrow/5.png); background-size: cover; background-position: center; } + .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line6 { background: url(../../img/arrow/6.png) 100% 100% no-repeat; background-size: 100% 100%; @@ -3083,7 +3159,7 @@ /* 贴地图片 */ .YJ-custom-base-dialog.ground-image>.content { - width: 500px; + width: 560px; } /* 模型 */ @@ -3505,3 +3581,184 @@ .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; +} + +.billboard-attribute-box { + position: absolute; + z-index: 1; + background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); + border: 1.5px solid; + border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; + color: #fff; + min-width: 200px; + min-height: 120px; + box-sizing: border-box; + /* -webkit-pointer-events: none; + -moz-pointer-events: none; + -ms-pointer-events: none; + -o-pointer-events: none; + pointer-events: none; */ +} + +.billboard-attribute-box .DIV-cy-tabs { + height: 100%; + display: flex; + flex-direction: column; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title { + padding: 0 2px; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title:first-child { + padding-left: 0; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title:last-child { + padding-right: 0; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title span { + margin: 0 5px; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content { + padding: 0 5px 5px 5px; + box-sizing: border-box; + flex: 1; + overflow: auto; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar { + width: 8px; + height: 8px; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar-thumb { + border-radius: 5px; + -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + background-color: rgba(var(--color-sdk-base-rgb)); +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + border-radius: 5px; + background-color: rgba(var(--color-sdk-base-rgb), 0.1); +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content-pane { + width: 100%; + height: 100%; +} + +.billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content-pane iframe { + border: none; +} + +.billboard-attribute-box .billboard-attribute-box-line { + position: absolute; + width: 0px; + /* border-left: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); */ + border-left: 1px solid rgba(var(--color-sdk-base-rgb), 1); + /* transform: rotate(45deg); */ + transform-origin: 0px 0px; + -webkit-pointer-events: none; + -moz-pointer-events: none; + -ms-pointer-events: none; + -o-pointer-events: none; + pointer-events: none; +} + +.billboard-attribute-box .drag-nook { + position: absolute; + width: 12px; + height: 12px; + display: block; + user-select: none; + -webkit-pointer-events: auto; + -moz-pointer-events: auto; + -ms-pointer-events: auto; + -o-pointer-events: auto; + pointer-events: auto; + z-index: 3; + clip-path: polygon(0% 100%, 100% 100%, 50% 50%); + background-image: linear-gradient(to top, #ffffff 1px, #00000000 1px); + background-size: 100% 3px; + /* background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAJRJREFUWEftltsJgFAMQ5NNdBJ1Eh3NTdRJdJPIBQXF50/p/WgHSNNDCSGch877EQbyIyCpBtAa/cZEsj9qXwhImgEURgZA8rTzzkAiYGVgITm+ErC6/Ek3vycMAkHAnYCkAUDKAosZSTaeSZiCqIwgCgJBIG8CWyXzKySSZBGBu+afStYBqIxMfJdSo8WPslHJgsAKWjkmIRBy/c8AAAAASUVORK5CYII='); */ +} + +.billboard-attribute-box .drag-nook.left-top { + top: -6px; + left: -6px; + cursor: se-resize; + transform: rotate(-45deg); + display: none; +} + +.billboard-attribute-box .drag-nook.right-top { + top: -6px; + right: -6px; + cursor: ne-resize; + transform: rotate(45deg); + display: none; +} + +.billboard-attribute-box .table { + background-color: #ffffff00; + color: #ffffff; + overflow: hidden; + border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); +} + +.billboard-attribute-box .table .table-head .tr { + border-top: none; + border-left: none; + border-right: none; +} + +.billboard-attribute-box .table .tr { + display: flex; + border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); + border-right: none; +} +.billboard-attribute-box .table .tr .th, .billboard-attribute-box .table .tr .td { + border-right: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); + display: flex; + justify-content: center; +} +.billboard-attribute-box .table .tr .th:last-child, .billboard-attribute-box .table .tr .td:last-child { + border-right: none; +} + + +.billboard-attribute-box .table .table-body .tr { + border-bottom: none; + border-left: none; +} + +.billboard-attribute-box .table .table-body .tr:first-child { + border-top: none; +} \ No newline at end of file diff --git a/static/custom/fonts/PangMenZhengDaoBiaoTiTi-1.ttf b/static/custom/fonts/PangMenZhengDaoBiaoTiTi-1.ttf index 61d491d..cd65b62 100644 Binary files a/static/custom/fonts/PangMenZhengDaoBiaoTiTi-1.ttf and b/static/custom/fonts/PangMenZhengDaoBiaoTiTi-1.ttf differ diff --git a/static/custom/img/icom-confirm.svg b/static/custom/img/icom-confirm.svg new file mode 100644 index 0000000..6ba0d24 --- /dev/null +++ b/static/custom/img/icom-confirm.svg @@ -0,0 +1,4 @@ + + + +