How to add a MaterialAppearance to a DynamicPolygon

Hello everyone,
I am using Cesium b26 & Firefox. I am creating DynamicPolygons in the following manner:

   var do1 = new Cesium.DynamicObject();
   var dynamicPolygon = new Cesium.DynamicPolygon();
   dynamicPolygon.material = Cesium.ColorMaterialProperty.fromColor(Cesium.Color.YELLOW);
   do1.polygon = dynamicPolygon;
   var propArray = new Cesium.PositionPropertyArray(.. Get Positions ...);
   do1.vertexPositions = propArray;
   czmlDataSource.getDynamicObjectCollection().add(do1);

I would like to add a MaterialAppearance to the DynamicPolygon. Something like this:
   var materailAppearance = new Cesium.MaterialAppearance({
                  material : Cesium.Material.fromType('Color'),
                  flat : true
               });
   dynamicPolygon.appearance = materailAppearance;

But this does not work. I want to add the MaterialAppearance because in the the 2D view, the yellow polygons become dark gray, like they are in the shade, the more south they are. I am hoping that "flat : true" will make them look bright yellow no matter where they are on the globe.
Thanks.
Marshall

Forgot to mention in the original post that the DynamicPolygon does use a time interval. So this should also be part of code:

   do1.availability = // Create TimeIntervalCollection ...

DynamicPolygon has a material property that you can set to the desired material; however you don’t create/use materials directly with anything in DynamicScene, instead you assign the material property to one of the DynamicScene equivalents. This allows you to define materials that change over simulation time. Currently, only 4 materials are supported:

ColorMaterialProperty

GridMaterialProperty

ImageMaterialProperty

CompositeMaterialProperty (different materia types at different times).

If you are still having problems, let me know and I can throw together a quick sample. We will also add new material types as needed and if you are doing custom materials, we should be able to easily take care of that too.

Matthew,
Thanks for the reply. I think I understand the material property - in the original example I made the DynamicPolygon yellow using a ColorMaterialProperty.

What I am really trying to do is set its Appearance value of 'flat' to true. In the 3D view the DynamicPolygon is always bright yellow, regardless of where it is on the globe. In the 2D view, the DynamicPolygon is yellow on certain parts of the map and it become gray/shaded in other parts of the map. I want it be yellow, regardless of where it is on the 2D map.

I figure if I can set its 'flat' value to true, it will always appear as yellow on the 2D map.
The problem is I can't find a way to add an MaterialAppearance (or any other Appearance) to a DynamicPolygon.
Thanks.

So there’s good news and bad news. The bad news is that DynamicScene doesn’t actually expose a way to set appearance options, like “flat”. So there’s no way to actually do what you are asking. It makes sense so I added an item to our roadmap (https://github.com/AnalyticalGraphicsInc/cesium/issues/1045). The good news is I think this is easy, so I’m going to try and do this right now. I’ll send out an update once I’m done (whether I’m successful or not).

As an aside, there are lighting issues with all 3 scene modes that result in inconsistency. We plan on fixing this with a completely revamped lighting system in the near-ish fugure. Keep your eye on https://github.com/AnalyticalGraphicsInc/cesium/issues/1578. I think having flat set will negate this issue for your use case, but I just wanted to point it out in case you see other issues.

I think #1578 is one of the real culprits here. Even if I hard-coded flat to true, lighting in 2D and Columbus View is still shaded incorrectly. I’ll have to talk to some of the other devs and figure out what is going on.