CylinderGraphics翻譯過來就是圓柱對象,只是這個圓柱對象比較特別,可分別指定上下圓柱面的半徑,從而可以衍生出圓錐和圓臺對象,下面小編就來講解下CylinderGraphics如何使用。
首先還是老規(guī)矩,先看下對象的所有屬性。

CylinderGraphics屬性
這里小編對幾個比較特別的屬性進(jìn)行講解
length:圓柱的長度,也就是圓柱的上下圓面間的空間距離
topRadius:上圓面半徑
bottomRadius:下圓面半徑
numberOfVerticalLines:邊框豎線數(shù)量
slices:上下圓面切邊數(shù)量
下面小編分別設(shè)置上下圓面的大小來實現(xiàn)圓柱、圓臺、圓錐
//圓柱
var greenCylinder = viewer.entities.add({
name : 'Green cylinder with black outline',
position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 200000.0),
cylinder : {
length : 400000.0,
topRadius : 200000.0,
bottomRadius : 200000.0,
material : Cesium.Color.GREEN.withAlpha(0.5),
outline : true,
outlineColor : Cesium.Color.DARK_GREEN
}
});
//圓臺
var blueCylinder = viewer.entities.add({
name : 'Green cylinder with black outline',
position: Cesium.Cartesian3.fromDegrees(-110.0, 40.0, 200000.0),
cylinder : {
length : 400000.0,
topRadius : 100000.0,
bottomRadius : 200000.0,
material : Cesium.Color.BLUE.withAlpha(0.5),
outline : true,
outlineColor : Cesium.Color.DARK_GREEN
}
});
//圓錐
var redCone = viewer.entities.add({
name : 'Red cone',
position: Cesium.Cartesian3.fromDegrees(-105.0, 40.0, 200000.0),
cylinder : {
length : 400000.0,
topRadius : 0.0,
bottomRadius : 200000.0,
outline : true,
material : Cesium.Color.RED.withAlpha(0.5)
}
});

CylinderGraphics
下面設(shè)置下邊框豎線數(shù)量,是是圓柱對象在顯示邊框的情況下,邊線的數(shù)量。邊框豎線數(shù)量并不會影響對象的形狀。

CylinderGraphics邊框豎線
上下圓面切邊數(shù)量設(shè)置,圓都是由一段段細(xì)線構(gòu)成,小編這里做了一個極限測試,將切邊設(shè)置為4,圓面會不會變成正方形面,下面來看下效果:

CylinderGraphics圓面切邊
果然和預(yù)想效果一樣,切邊數(shù)量設(shè)置為3,也會變成正三角形

CylinderGraphics圓面切邊
CylinderGraphics的使用就先介紹到這里,小節(jié)教程再見。