cesium贴地代码

//贴地
// Cesium.sampleTerrain(
//     cesiumInit.terrainProvider, 
//     0,
//     positions//所有点的arry
// ).then(function (updatedCartographics) {
//     console.log(updatedCartographics);
//     for(var i=0;i<updatedCartographics.length;i++){
//         var cartographic = updatedCartographics[i];
//         entityArr[i].position = Cesium.Cartesian3.fromRadians(
//         cartographic.longitude,
//         cartographic.latitude,
//         cartographic.height
//     ),
//         viewer.entities.add(entityArr[i])
//     }
//     viewer.zoomTo(viewer.entities);
// });    

方法2

var options = {
   camera : viewer.scene.camera,
   canvas : viewer.scene.canvas,
   clampToGround: true //开启贴地
}
var dataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(dataSource,options);

方法3

//贴地
// var position = positionProperty.getValue(viewer.clock.currentTime);
// var objectsToExclude = [vehicleEntity];
// vehicleEntity.position = viewer.scene.clampToHeight(position, vehicleEntity);//贴地
posted @ 2019-08-01 18:30  marvelousone  阅读(2457)  评论(0编辑  收藏  举报