From 1a1aa9f6a5f4e302ceafdc4cadd569487d3f2996 Mon Sep 17 00:00:00 2001 From: zh <972939975@qq.com> Date: Fri, 22 Aug 2025 17:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=A1=86=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Obj/Base/BillboardObject/index.js | 35 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Obj/Base/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js index 9f37bdc..98f8857 100644 --- a/src/Obj/Base/BillboardObject/index.js +++ b/src/Obj/Base/BillboardObject/index.js @@ -42,6 +42,7 @@ import { getGoodsList } from '../../../Tools/getGoodsList' class BillboardObject extends Base { #_postRenderEvent = null #_destroyMouseEvent = null + #_billboardHeight = 0 /** @@ -122,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 @@ -203,7 +205,8 @@ class BillboardObject extends Base { this.#_postRenderEvent = () => { let siteInfoPosition = Cesium.Cartesian3.fromDegrees( this.options.positions.lng, - this.options.positions.lat + this.options.positions.lat, + this.#_billboardHeight ) if (this.attributeElm && this.entity) { let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates( @@ -698,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) } @@ -752,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() @@ -2387,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 } @@ -2592,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) { @@ -2607,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 } } @@ -2979,11 +3008,7 @@ class BillboardObject extends Base { } this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent) - - let leftTopElm = attributeElm.getElementsByClassName('left-top')[0] - let rightTopElm = attributeElm.getElementsByClassName('right-top')[0] let leftOnmousedown = (e) => { - console.log(1111111111) if (this.options.attributePos.width < 200) { this.options.attributePos.width = 200 }