属性框位置高度计算
This commit is contained in:
@ -42,6 +42,7 @@ import { getGoodsList } from '../../../Tools/getGoodsList'
|
|||||||
class BillboardObject extends Base {
|
class BillboardObject extends Base {
|
||||||
#_postRenderEvent = null
|
#_postRenderEvent = null
|
||||||
#_destroyMouseEvent = null
|
#_destroyMouseEvent = null
|
||||||
|
#_billboardHeight = 0
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,6 +123,7 @@ class BillboardObject extends Base {
|
|||||||
this.options.positions.alt = Number(
|
this.options.positions.alt = Number(
|
||||||
Number(options.positions.alt || 0).toFixed(2)
|
Number(options.positions.alt || 0).toFixed(2)
|
||||||
)
|
)
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
// this.options.diffuseShow = options.diffuseShow || false
|
// this.options.diffuseShow = options.diffuseShow || false
|
||||||
// this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10
|
// this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10
|
||||||
// this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000
|
// this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000
|
||||||
@ -203,7 +205,8 @@ class BillboardObject extends Base {
|
|||||||
this.#_postRenderEvent = () => {
|
this.#_postRenderEvent = () => {
|
||||||
let siteInfoPosition = Cesium.Cartesian3.fromDegrees(
|
let siteInfoPosition = Cesium.Cartesian3.fromDegrees(
|
||||||
this.options.positions.lng,
|
this.options.positions.lng,
|
||||||
this.options.positions.lat
|
this.options.positions.lat,
|
||||||
|
this.#_billboardHeight
|
||||||
)
|
)
|
||||||
if (this.attributeElm && this.entity) {
|
if (this.attributeElm && this.entity) {
|
||||||
let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates(
|
let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates(
|
||||||
@ -698,6 +701,26 @@ class BillboardObject extends Base {
|
|||||||
if (this.entity) {
|
if (this.entity) {
|
||||||
this.entity.billboard.heightReference = heightMode
|
this.entity.billboard.heightReference = heightMode
|
||||||
this.entity.label.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)
|
this._elms.heightMode && (this._elms.heightMode.value = heightModeName)
|
||||||
}
|
}
|
||||||
@ -752,6 +775,7 @@ class BillboardObject extends Base {
|
|||||||
}
|
}
|
||||||
set alt(v) {
|
set alt(v) {
|
||||||
this.options.positions.alt = Number(Number(v).toFixed(2))
|
this.options.positions.alt = Number(Number(v).toFixed(2))
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
// this.scan && (this.scan.alt = v)
|
// this.scan && (this.scan.alt = v)
|
||||||
// this.diffuse && (this.diffuse.alt = v)
|
// this.diffuse && (this.diffuse.alt = v)
|
||||||
this.renewPoint()
|
this.renewPoint()
|
||||||
@ -2387,6 +2411,7 @@ class BillboardObject extends Base {
|
|||||||
async remove() {
|
async remove() {
|
||||||
await remove_entity_from_cluster(this.sdk.viewer, this.entity)
|
await remove_entity_from_cluster(this.sdk.viewer, this.entity)
|
||||||
this.entity = null
|
this.entity = null
|
||||||
|
this.attributeBoxState = false
|
||||||
if (!this.sdk.viewer || !this.sdk.viewer.entities) {
|
if (!this.sdk.viewer || !this.sdk.viewer.entities) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2592,6 +2617,7 @@ class BillboardObject extends Base {
|
|||||||
switch (this._elms.heightMode.value) {
|
switch (this._elms.heightMode.value) {
|
||||||
case '海拔高度':
|
case '海拔高度':
|
||||||
heightElm.value = this.options.positions.alt
|
heightElm.value = this.options.positions.alt
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
break
|
break
|
||||||
case '相对地表':
|
case '相对地表':
|
||||||
if (this.sdk.viewer.scene.terrainProvider.availability) {
|
if (this.sdk.viewer.scene.terrainProvider.availability) {
|
||||||
@ -2607,15 +2633,18 @@ class BillboardObject extends Base {
|
|||||||
heightElm.value = Number(
|
heightElm.value = Number(
|
||||||
(this.options.positions.alt - position[0].height).toFixed(2)
|
(this.options.positions.alt - position[0].height).toFixed(2)
|
||||||
)
|
)
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
heightElm.value = this.options.positions.alt
|
heightElm.value = this.options.positions.alt
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case '依附地表':
|
case '依附地表':
|
||||||
break
|
break
|
||||||
case '依附模型':
|
case '依附模型':
|
||||||
heightElm.value = this.options.positions.alt
|
heightElm.value = this.options.positions.alt
|
||||||
|
this.#_billboardHeight = this.options.positions.alt
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2979,11 +3008,7 @@ class BillboardObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent)
|
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) => {
|
let leftOnmousedown = (e) => {
|
||||||
console.log(1111111111)
|
|
||||||
if (this.options.attributePos.width < 200) {
|
if (this.options.attributePos.width < 200) {
|
||||||
this.options.attributePos.width = 200
|
this.options.attributePos.width = 200
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user