1.材质
可以在创建时赋值材质,也可以构造后赋值材质
//方法一,构造时赋材质
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(-103.0, 40.0),
ellipse : {
semiMinorAxis : 250000.0,
semiMajorAxis : 400000.0,
material : Cesium.Color.BLUE.withAlpha(0.5)//可设置不同的MaterialProperty
}
});
//方法二,构造后赋材质
var ellipse = entity.ellipse;
ellipse.material = Cesium.Color.RED;
(1)颜色材质:
Cesium.Color.BLUE.withAlpha(0.5)
(2)图片材质
//完整的这么写
ellipse.material = new Cesium.ImageMaterialProperty({
image:'../images/cats.jpg',
color: Cesium.Color.BLUE,
repeat : new Cesium.Cartesian2(4, 4)
});
//也可以简单的写成
ellipse.material = '../images/cats.jpg';
image的值可以使url或者video或者canvas
repeat的值为两个数,分别代表x和y方向图片重复次数
color设置的话会在图片上加一层颜色
transparent是否透明,png的话可以设置
(3)棋盘
ellipse.material = new Cesium.CheckerboardMaterialProperty({
evenColor : Cesium.Color.WHITE,//第一个颜色
oddColor : Cesium.Color.BLACK,//第二个颜色
repeat : new Cesium.Cartesian2(4, 4)//重复次数
});
(4)条纹
ellipse.material = new Cesium.StripeMaterialProperty({
evenColor : Cesium.Color.WHITE,//第一个颜色
oddColor : Cesium.Color.BLACK,//第二个颜色
repeat : 32,//重复次数
offset:20,//偏移量
orientation:Cesium.StripeOrientation.VERTICAL //水平还是垂直,默认水平
});
(5)网格
ellipse.material = new Cesium.GridMaterialProperty({
color : Cesium.Color.YELLOW,//网格颜色
cellAlpha : 0.2,//单元格透明度
lineCount : new Cesium.Cartesian2(8, 8),//行列个数
lineThickness : new Cesium.Cartesian2(2.0, 2.0)//线的粗细
});
还有一个lineOffset线的偏移量
(6)polyline
var entity = viewer.entities.add({
polyline : {
positions : Cesium.Cartesian3.fromDegreesArray([-77, 35,
-77.1, 35]),
width : 5,
material : Cesium.Color.RED
}});
viewer.zoomTo(viewer.entities);
polyline.material = new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.2,//发光的长度,值为现款的百分比(0~1)
color : Cesium.Color.BLUE//发光的颜色(中心为白色)
});
polyline.material = new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.ORANGE,//线的颜色
outlineWidth : 3,//线文理宽度
outlineColor : Cesium.Color.BLACK//线颜色
});