cesium 解决带高度的polygon 材质不能透明的问题

问题描述:创建一个带高度的polygon,用一个带透明度的图片做材质,画出来的多边形没有透明效果,图片的透明通道没有用上。

一、创建不带高度polygon

不带高度的polygon,使用带透明度的图片是有效果的,但是不带高度的话,polygon是自动贴模型的,如果在polygon的上面还有模型,那么这个多边形也会贴到上面的模型上去。

复制代码
let coors = [
                113.296373, 38.189969,
                113.29641, 38.189979,
                113.296289, 38.190231,
                113.296252, 38.190222,                
            ]
            viewer.entities.add({
                polygon: {
                    hierarchy: Cesium.Cartesian3.fromDegreesArray(coors),
                    material: new Cesium.ImageMaterialProperty({
                        image: './image/fence.png'
                    })
                },
            });

二、创建带高度的polygon

复制代码
let coors = [
                113.296373, 38.189969,
                113.29641, 38.189979,
                113.296289, 38.190231,
                113.296252, 38.190222,                
            ]
            viewer.entities.add({
                polygon: {
                    hierarchy: Cesium.Cartesian3.fromDegreesArray(coors),
                    material: new Cesium.ImageMaterialProperty({
                        image: './image/fence.png'
                    }),
                    height: 1
                },
            });

三、创建带高度的polygon+设置material的color:即可解决此问题

复制代码
let coors = [
                113.296373, 38.189969,
                113.29641, 38.189979,
                113.296289, 38.190231,
                113.296252, 38.190222,                
            ]
            viewer.entities.add({
                polygon: {
                    hierarchy: Cesium.Cartesian3.fromDegreesArray(coors),
                    material: new Cesium.ImageMaterialProperty({
                        image: './image/fence.png',
                        color: Cesium.Color.fromCssColorString('rgba(255, 255, 255,0.6)')
                    }),
                    height: 1
                },
            });

1、如果不想改变图片的颜色,那么color的rgb必须是(255, 255, 255)

2、color的透明度a必须小于1,原图片的透明效果才能看到

相关推荐
整点可乐1 天前
关于cesium的primitive的modelMatrix的应用
前端·javascript·cesium
GIS遥遥2 天前
Cesium进阶教程(2)|基于 Cesium 后处理Post Processing的图形绘制(上)
cesium·gis开发·webgis开发
幸会同学3 天前
在Cesium中实现飘动的红旗
javascript·three.js·cesium
落霞的思绪3 天前
Cesium里的postProcessStages实现暗黑样式的天地图
前端·gis·cesium
GIS兵墩墩6 天前
C1 ——cesium加载天地图瓦片
cesium·天地图
我是ed.7 天前
vue2 使用 cesium 展示 TLE 星历数据
vue.js·cesium
GisCoder11 天前
Cesium教程(9)---编辑Entity图形控制点、拖拽Entity移动、删除Entity
webgl·cesium
GISBox11 天前
BIM+GIS协同:RVT文件转3DTiles的技术路径与场景落地
cesium·3dtiles·gisbox·服务分发·gis server·切片转换·rvt
GISBox12 天前
高斯泼溅转3DTiles:GISBox高效转换全流程指南
免费·cesium·ply·3dtiles·高斯泼溅·gisbox·切片转换
王将近14 天前
Cesium 山洪流体模拟
前端·cesium