问题描述
在开启 viewer.scene.globe.depthTestAgainstTerrain = true //开启地形深度检测
后加载3dtiles数据会导致被地形遮挡,导致3d tiles数据看不见文章来源:https://www.toymoban.com/news/detail-780999.html
解决办法
使用矩阵将模型高度提升文章来源地址https://www.toymoban.com/news/detail-780999.html
const tilesets = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: `${BASE_URL}/3DTiles/building/tileset.json`,
}),
)
tilesets.readyPromise.then(function (tileset) {
const offsetHeight = 100
const boundingSphere = tileset.boundingSphere
const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center)
const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0)
const offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, offsetHeight)
const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3())
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation)
viewer.flyTo(tileset)
})
到了这里,关于cesium 3dtiles地形遮挡、设置离地高度的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!