## 繪制點線面
### 方案一:通過entity來添加
### 先來看一個添加立方體的例子
```
var viewer = new Cesium.Viewer('cesiumContainer');
var redBox = viewer.entities.add({
name : 'Red box with black outline',
position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
box : {
dimensions : new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
material : Cesium.Color.RED.withAlpha(0.5),
outline : true,
outlineColor : Cesium.Color.BLACK
}
});
viewer.zoomTo(viewer.entities);
```
效果如圖:

### 方案二:通過CZML添加
通過CZML也可以添加幾何形狀,而且CZML還可以描述動畫(現在先有個印象,動畫以后介紹)
先來看看官網上的說明,CZML是一種JSON格式的字符串,用于描述與時間有關的動畫場景,CZML包含點、線、地標、模型、和其他的一些圖形元素,并指明了這些元素如何隨時間而變化。某種程度上說, Cesium 和 CZML的關系就像 Google Earth 和 KML。
```
var czml = [{
"id" : "document",
"name" : "box",
"version" : "1.0"
},{
"id" : "shape2",
"name" : "Red box with black outline",
"position" : {
"cartographicDegrees" : [-107.0, 40.0, 300000.0]
},
"box" : {
"dimensions" : {
"cartesian": [400000.0, 300000.0, 500000.0]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 0, 0, 128]
}
}
},
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
}];
var viewer = new Cesium.Viewer('cesiumContainer');
var dataSourcePromise = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSourcePromise);
viewer.zoomTo(dataSourcePromise);
```
### 形狀相關描述
>下表來自于官方網站,但是連接改為本地鏈接了
| | | |
|---|---|---|
|Point||entity.point - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/PointGraphics.html)
|Boxes||entity.box - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Box.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/BoxGraphics.html)
|Circles and Ellipses||entity.ellipse - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Circles%20and%20Ellipses.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/EllipseGraphics.html)
|Corridor||entity.corridor - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Corridor.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/CorridorGraphics.html)
|Cylinder and Cones||entity.cylinder - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Cylinders%20and%20Cones.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/CyilnderGraphics.html)
|Polygons||entity.polygon - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Polygon.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/PolygonGraphics.html) [Reference Build/Documentation]
|Polylines||entity.polyline - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Polyline.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/PolylineGraphics.html)
|Polyline Volumes||entity.polylineVolume - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Polyline%20Volume.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/PolylineVolume.html)
|Rectangles||entity.rectangle - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Rectangle.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/Rectangle.html)
|Spheres and Ellipsoids||entity.ellipsoid - [Code example](http://localhost:8080/Apps/Sandcastle/index.html?src=Spheres%20and%20Ellipsoids.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/EllipsoidGraphics.html)
|Walls||entity.wall - (http://localhost:8080/Apps/Sandcastle/index.html?src=Wall.html) - [Reference Build/Documentation](http://localhost:8080/Build/Documentation/WallGraphics.html)
**Cesium學習交流群:593764057(滿),476893082**
- cesium編程入門(一)cesium簡介
- cesium編程入門(二)環境搭建
- cesium編程入門(三)開始使用cesium開發
- cesium編程入門(四)界面介紹及小控件隱藏
- cesium編程入門(五)繪制形狀
- cesium編程入門(六)添加 3D Tiles,并調整位置,貼地
- cesium編程入門(七)3D Tiles,模型旋轉
- cesium編程入門(八)設置材質
- cesium編程入門(九)實體 Entity
- cesium編程入門(十)優秀資源
- cesium編程入門(十一)常見問題
- cesium編程中級開篇
- cesium編程中級(一)添加示例到Sandcastle
- cesium編程中級(二)源碼編譯
- cesium編程中級(三)嘗試添加PBS本地服務
- cesium編程中級(四)使用漸變紋理