一、画矩形,每个点不带高度,距离地表500米
viewer.entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArray(
[
113.34742631368005, 38.1066616874903,
113.34779274419935, 38.1022786524791,
113.35862863192612, 38.1029782894311,
113.35717374940154, 38.10801627463857
]
)
),
material: Cesium.Color.fromCssColorString('#f00'),
height: 500
}
});
- height:距离地表距离
二、画带高度的矩形,每个点都带高度,距离地表的高度取自每个点的高度
viewer.entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArrayHeights(
[
113.3695158066395, 38.10294013762673, 100,
113.36754792663295, 38.09536196679693, 200,
113.3800395556131, 38.095568014125725, 300,
113.38035000390059, 38.10236754677722, 400
]
)
),
material: Cesium.Color.fromCssColorString('#f00'),
perPositionHeight: true,
}
});
- perPositionHeight:取每个点的高度,设置了perPositionHeight之后,height属性就无效
三:特殊应用:竖起来的面
viewer.entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArrayHeights(
[
113.35355684432594, 38.088067028328254, 100,
113.36490826822829, 38.088193587605545, 100,
113.36490826822829, 38.088193587605545, 600,
113.35355684432594, 38.088067028328254, 600
]
)
),
material: Cesium.Color.fromCssColorString('#f00'),
perPositionHeight: true,
}
});
- 原理:取两组点,底下一组,上面一组,这两组点的经纬度相同,高度不同
其他参考:
- 竖起来的圆:cesium实现竖立的圆-CSDN博客
- polygon高度:ceisum polygon 高度有关的参数_cesium中polygon的坐标高程值和height值有什么关系-CSDN博客