Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What to do when loading irregular shapes in Cesium

Shulou Source: shulou.com Published: 2022-06-01 03:40:34 09月28日 Update

This article mainly shows you "how to load irregular shapes in Cesium", the content is simple and clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "how to load irregular shapes in Cesium" this article.

In the development of Cesium map system, the range of background map is an irregular polygon in longitude and latitude, and the shape of the picture is not regular. If you want to paste this picture on the map, the range of the picture should be in line with the actual map location.

Picture effect:

To find the interface of Cesium, the first thing that comes to mind is to use the polygon to draw a polygon according to the range of longitude and latitude, and then paste the picture as a material material, but after the code is written, the map found is deformed in polygon and has not been posted to the corresponding map location.

After testing, it is found that the Rectangle solid object of Cesium can be used to calculate the coordinates of the upper left corner and the lower right corner of the irregular polygon range, and then paste the picture material on the map, the position on the map is also right.

The specific code is as follows:

/ / add an entity of rectangle

Viewer.entities.add ({

Name: 'irregular mapping'

Rectangle: {

/ / set the four coordinate ranges of rectangle

Coordinates: Cesium.Rectangle.fromDegrees (- 92.0,30.0,-76.0,40.0)

/ / set the picture to material

Material: 'data/wind_500_2018030616_True.png'

/ / Image display style type, with terrain, model or both, this effect can achieve the effect that the map is along the

/ / of the curved surface of the map

ClassificationType: Cesium.ClassificationType.TERRAIN

}

After the addition is completed, the effect is close to the ground and the shape is rectangular, but the blank space is black. To set it separately in the material, change the material properties to the following: black is gone.

Material: new Cesium.ImageMaterialProperty ({

Image:'data/wind_500_2018030616_True.png'

Transparent:true

})

/ / set a height property by the way, which can be displayed off the ground.

Height:70000

Finish the effect picture:

These are all the contents of the article "what to do when loading irregular shapes in Cesium". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Pictures irregularities maps shapes materials ranges drawings effects how to add position content coordinates articles maps code entities attributes longitude and latitude black Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple OPPO Reno Redmi NVidia