在 CZML 中创建具有多边形底面的金字塔
Creating a pyramid with polygon base in CZML
我是 Cesium、CZML 和 javascript 的新手,我想在地面上创建一个多边形的金字塔。我有纬度和经度顶点的高度,我有每边的角度。我还找不到任何好的方法来创建它。有什么方法可以在 CZML 文件中创建它?
我不确定这是否可以用一个包来完成。然而,它当然可以用一个单独的 czml 对象来完成。转到此网站:http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html
并粘贴下面的代码。它会给你一个很好的起点。如果您不希望它是透明的,您可能希望更改不透明度。如果您不想让任何人看到您是如何用多个多边形构建金字塔的,您可能希望删除多边形边缘的轮廓。
我给你做的"pyramid"是3面的。您可以扩展它以包括您希望的任意多面。
var czml = [
{
"id" : "document",
"name" : "CZML Geometries: Polygon",
"version" : "1.0"
}, {
"id" : "orangePolygon",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-72.0, 37.0, 0,
-68.0, 35.0, 0
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
},
{
"id" : "orangePolygon2",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-70.0, 33.0, 0,
-68.0, 35.0, 0
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
},
{
"id" : "orangePolygon3",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-70.0, 33.0, 0,
-72.0, 37.0, 0,
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
}
];
var viewer = new Cesium.Viewer('cesiumContainer');
var dataSource = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);
我是 Cesium、CZML 和 javascript 的新手,我想在地面上创建一个多边形的金字塔。我有纬度和经度顶点的高度,我有每边的角度。我还找不到任何好的方法来创建它。有什么方法可以在 CZML 文件中创建它?
我不确定这是否可以用一个包来完成。然而,它当然可以用一个单独的 czml 对象来完成。转到此网站:http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html
并粘贴下面的代码。它会给你一个很好的起点。如果您不希望它是透明的,您可能希望更改不透明度。如果您不想让任何人看到您是如何用多个多边形构建金字塔的,您可能希望删除多边形边缘的轮廓。
我给你做的"pyramid"是3面的。您可以扩展它以包括您希望的任意多面。
var czml = [
{
"id" : "document",
"name" : "CZML Geometries: Polygon",
"version" : "1.0"
}, {
"id" : "orangePolygon",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-72.0, 37.0, 0,
-68.0, 35.0, 0
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
},
{
"id" : "orangePolygon2",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-70.0, 33.0, 0,
-68.0, 35.0, 0
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
},
{
"id" : "orangePolygon3",
"name" : "Orange polygon with per-position heights and outline",
"polygon" : {
"positions" : {
"cartographicDegrees" : [
-70.0, 35.0, 100000,
-70.0, 33.0, 0,
-72.0, 37.0, 0,
]
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 100, 0, 100]
}
}
},
"extrudedHeight" : 0,
"perPositionHeight" : true,
"outline" : true,
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
}
}
}
];
var viewer = new Cesium.Viewer('cesiumContainer');
var dataSource = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);