在之前的博文中,已經(jīng)講過如何在Cesium中加載3dTiles格式的傾斜攝影模型(Cesium加載3D Tiles模型)。最近發(fā)現(xiàn)一個問題,新加載的傾斜攝影模型,都漂浮在空中,無法很好的貼合地面。分析了一些這個問題,可能是由于以下原因造成的:
- 飛行器的精度
- 傾斜攝影的參數(shù)問題
- Cesium自帶的DEM精度問題
剛剛加載效果圖
解決辦法
最簡單的解決方式就是,讓3DTiles模型進(jìn)行一定程度的平移變換。構(gòu)建平移變換相關(guān)代碼如下圖所示:文章來源:http://www.zghlxwxcb.cn/news/detail-532918.html
let tileSetModel = new Cesium.Cesium3DTileset({
url: "http://localhost:9003/model/tkBZRQBVc/tileset.json",
preferLeaves: true,
//【重要】內(nèi)存建議顯存大小的50%左右,內(nèi)存分配變小有利于傾斜攝影數(shù)據(jù)回收,提升性能體驗(yàn)
maximumMemoryUsage: 1500,
cullWithChildrenBounds: true,
skipLevelOfDetail: true,
});
tileSetModel.readyPromise.then(tileset => {
console.log("加載完成")
//
let surface = Cesium.Cartesian3.fromRadians(0, 0, 0);
//模型改變的位置
let offset = Cesium.Cartesian3.fromRadians(0, 0, 193);
//定義模型的改變狀態(tài)
let translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix= Cesium.Matrix4.fromTranslation(translation)
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.5, -0.2, tileset.boundingSphere.radius * 1.0));
}).catch(function (error) {
console.log(error);
});
修正之后加載效果
文章來源地址http://www.zghlxwxcb.cn/news/detail-532918.html
到了這里,關(guān)于Cesium.js加載3dTiles格式傾斜攝模型影懸浮空中的解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!