Cesium-GeoJSON数据源多边形材质为白色,尽管指定了图像



我无法找到从GeoJsonDataSource更改多边形实体材质的方法。我想应用一个图像。

这里有一个使用颜色的例子,因为我不知道如何在在线沙堡上嵌入图像:

var viewer = new Cesium.Viewer("cesiumContainer");
const poly = {
"type": "FeatureCollection",
"name": "MyPolygon",
"crs": {"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}},
"features": [
{"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[[ 10.746500009923748, 48.314700009648320, 500 ],
[ 10.747500009924019, 48.315700009648104, 500 ],
[ 10.747038310965864, 48.315905422444722, 550 ],
[ 10.746038315853207, 48.314905418639555, 550 ],
[ 10.746500009923748, 48.314700009648320, 500 ]] 
]}}]};
const Promise0 = async () => {
try {
const dataSource = await Cesium.GeoJsonDataSource.load(poly, {
stroke: Cesium.Color.BLUE,
strokeWidth: 3
});
const Promise1 = async () => {
try {
const polygonalFrame = await viewer.dataSources.add(dataSource);
viewer.zoomTo(polygonalFrame);
const entities = polygonalFrame.entities.values;
for (var i = 0; i < entities.length; i++) {
const entity = entities[i];
entity.polygon.material = new Cesium.Material({
fabric : {
type : 'Color',
uniforms : {
color : new Cesium.Color(1.0, 0.0, 0.4, 0.5)
}
}
});
}
}
catch (err) {
console.log("Error: ", err);
}
};
Promise1();
}
catch (e) {
console.log("Error:", e);
}
};
Promise0();

多边形保持黄色,这是我认为的默认颜色。

对于图像材料,我在本地使用这个定义:

new Cesium.Material({
fabric : {
type : 'Image',
uniforms : {
image : './image.png'
}
}
});

我用这种方式在我的实体中定义PolygonGraphics的材料来修复它:

new Cesium.ImageMaterialProperty({
image: './image.png',
alpha: 0.5
});

但我注意到,当我试图将alpha混合应用于我的整个图像时,它不起作用。。。

最新更新