Can polygons for a cesium entity have alpha blended colors?

67 views
Skip to first unread message

Shane Thomas

unread,
Oct 12, 2016, 11:00:44 AM10/12/16
to cesium-dev
I was going off this example here:



And realized that all the geometry here was from primitives not cesium entities.  Can entities have alpha blending so I can see some of the earth/map below them?  I am trying this and it seems to be ignoring all my color and fill options:


                    var entitycesium = new Cesium.Entity();
                    entitycesium.name = jsonf.features[i].properties.name;
                    entitycesium.polygon=new Cesium.PolygonGraphics({
                                hierarchy :  Cesium.Cartesian3.fromDegreesArray([
                                        jsonf.features[i].geometry.coordinates[0][0][0],jsonf.features[i].geometry.coordinates[0][0][1],
                                        jsonf.features[i].geometry.coordinates[0][1][0],jsonf.features[i].geometry.coordinates[0][1][1],
                                        jsonf.features[i].geometry.coordinates[0][2][0],jsonf.features[i].geometry.coordinates[0][2][1],
                                        jsonf.features[i].geometry.coordinates[0][3][0],jsonf.features[i].geometry.coordinates[0][3][1],
                                        jsonf.features[i].geometry.coordinates[0][4][0],jsonf.features[i].geometry.coordinates[0][4][1],
                                    ]),
                                outline:true,
                                outLineColor :  Cesium.Color.RED,
                                material : Cesium.Material.fromType('Color', { color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)})
                            });

 

                    entitycesium.description= '<a href=\"' + jsonf.features[i].properties.file_name + '\">Full Resolution Viewer</a>';
                    viewer.entities.add(entitycesium);


Is there anyway to get alpha blending?


Hannah Pinkos

unread,
Oct 12, 2016, 11:27:27 AM10/12/16
to cesium-dev
Hello,

Sorry, but I'm a little confused by what you're asking.
Both the blue and orange polygons have alpha values.  You can use Color.withAlpha to add an alpha value to an existing color.

If this doesn't answer your question, can you elaborate a little bit about what you're trying to do? Thanks!

Best,

Hannah 

Shane Thomas

unread,
Oct 12, 2016, 7:00:49 PM10/12/16
to cesium-dev
I might be over thinking this, but I am just trying to get a georeferenced foot print on the map, but colored semi opaque.   This did do something with the material colorWithAlpha (the foot print is red!)  but it is solid, no matter what
number I use as an alpha value, and I wanted it semi translucent.... no idea why any number from 1 to 0 is solid red

                 var entitycesium = new Cesium.Entity();
                    entitycesium.name = jsonf.features[i].properties.name;
                    entitycesium.polygon=new Cesium.PolygonGraphics({
                                hierarchy :  Cesium.Cartesian3.fromDegreesArray([
                                        jsonf.features[i].geometry.coordinates[0][0][0],jsonf.features[i].geometry.coordinates[0][0][1],
                                        jsonf.features[i].geometry.coordinates[0][1][0],jsonf.features[i].geometry.coordinates[0][1][1],
                                        jsonf.features[i].geometry.coordinates[0][2][0],jsonf.features[i].geometry.coordinates[0][2][1],
                                        jsonf.features[i].geometry.coordinates[0][3][0],jsonf.features[i].geometry.coordinates[0][3][1],
                                        jsonf.features[i].geometry.coordinates[0][4][0],jsonf.features[i].geometry.coordinates[0][4][1],
                                    ]),
                                outline:true,
                                outLineColor :  Cesium.Color.RED,
                                material : Cesium.Color.RED.withAlpha(0.3),

                            });

 

                    entitycesium.description= '<a href=\"' + jsonf.features[i].properties.file_name + '\">Full Resolution Viewer</a>';
                    viewer.entities.add(entitycesium);

Shane Thomas

unread,
Oct 13, 2016, 10:35:09 AM10/13/16
to cesium-dev
Never mind, i changed the color from RED to green and could more easily see what was underneath, I had to give the value to the withAlpha of .1 though   But looks good thanks!
Reply all
Reply to author
Forward
0 new messages