cesium 加载的矢量数据或模型会在地面漂移
2021-06-21 本文已影响0人
ME88
解决方法:
function changeHeight(tileset, height) {height = Number(height);
if (isNaN(height)) {
return;
}
var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude,
cartographic
.height);
var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
}
1.开启深度监测 viewer.scene.globe.depthTestAgainstTerrain=true;
2.关闭深度监测 viewer.scene.globe.depthTestAgainstTerrain=false;