CESIUM 點(diǎn)只顯示一半
問(wèn)題:
小圓點(diǎn)只有一半在地上,一半在地下

背景介紹:
通過(guò)下述代碼往地圖上添加小圓點(diǎn)
備注:此時(shí)沒(méi)有加載地形
//創(chuàng)建點(diǎn)
createPoint(cartesian) {
let $this = this;
let point = this.viewer.entities.add({
position: cartesian,
point: {
pixelSize: 10,
color: $this.Cesium.Color.YELLOW,
}
});
$this._entities_point.push(point);
return point;
}
方案1:調(diào)整深度檢測(cè)值
使用disableDepthTestDistance: Number.POSITIVE_INFINITY,
圓點(diǎn)完全都在地上了
存在問(wèn)題:
圖中間的小圓點(diǎn)可能會(huì)出現(xiàn)在一些建筑的前面,實(shí)際在建筑的后面
這是關(guān)閉深度檢測(cè)的必然結(jié)果!
方案2:抬升高度
下述語(yǔ)句中輸入高度值
let position = Cesium.Cartesian3.fromDegrees(x, y, 10);
相關(guān)解釋:
position中的10,代表圓點(diǎn)的高度,單位是“米”(從圓點(diǎn)的中心抬高10米)
pixelSize中的5,代表圓點(diǎn)的像素大小,單位是“像素”(5代表直徑)
圓不被遮擋的條件:只有position中的高度,比pixelSize換算成米的數(shù)值大
在不同的camera高度下,一個(gè)像素代表的實(shí)際高度(單位為米),是不一樣的
camera越高,一個(gè)像素?fù)Q算成米,就越大
camera越低,一個(gè)像素?fù)Q算成米,就越小
存在問(wèn)題:
position中的height比較?。篶amera高的時(shí)候,小圓點(diǎn)還是有可能有一部分在地球下面
position中的height比較大:camera低的時(shí)候,點(diǎn)會(huì)顯得離地面很遠(yuǎn)
方案3:關(guān)閉深度檢測(cè)
執(zhí)行下述代碼,關(guān)閉深度檢測(cè)
viewer.scene.globe.depthTestAgainstTerrain = false;