我正在查看将材质图形应用于矩形的沙堡示例...
var viewer = new Cesium.Viewer('cesiumContainer');
var redRectangle = viewer.entities.add({
name : 'Red translucent rectangle',
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-110.0, 20.0, -80.0, 25.0),
material : Cesium.Color.RED.withAlpha(0.5)
}
});
有人可以提供一个如何使用原语API执行此操作的示例吗?
答案 0 :(得分:0)
Sandcastle Materials Example中有一个广泛的演示。这是一个仅限于一种材料的版本:
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var rectangle = scene.primitives.add(new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0),
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
})
}),
appearance : new Cesium.EllipsoidSurfaceAppearance({
aboveGround : false,
material: Cesium.Material.fromType('Color')
})
}));
// Default color is translucent red.
// We change to translucent yellow here as an example:
rectangle.appearance.material.uniforms.color = Cesium.Color.YELLOW.withAlpha(0.5);