How to set outline color of polygon geometry when using Cesium.MaterialAppearance

I need your guidance. I’m rendering 3d polygon primitives but I’m not able to find a way to see the delineation of corners or joints of the walls of the polygon. Is there a way to set an outline color for the polygon? I tried to see the delineation of the walls by setting translucent to true but the rendered shape doesn’t look translucent.

I’m using Cesium.MaterialAppearance instead of the PerInstanceColorAppearance because MaterialAppearance allows me to
easily change the color of the shape (material.uniforms.color) after it is already created.

My code is below:

var geometryInstance = new Cesium.GeometryInstance({
geometry: Cesium.PolygonGeometry.fromPoints({
positions: positions,
vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
perPositionHeight: true})
attributes: { color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.Yellow)}
});

var material = new Cesium.Material.fromType(“Color”);
material.uniforms.color = Cesium.Color.Yellow;

var appearance = new Cesium.MaterialAppearance({
material: material,
translucent: true,
closed: true,
renderState: { lineWidth: Math.min(2.0, this.scene.maximumAliasedLineWidth), lineColor: Cesium.Color.Black},
faceForward: true});

var primitive = new Cesium.Primitive({
geometryInstances: geometryInstance,
allowPicking: pickable,
interleave: true,
appearance: appearance,
releaseGeometryInstances: false});

Thanks,

Alberto

See attached snapshot for a better description of my issue.

polygon_no_outline.png

When using the Primitive API, you need to create a separate geometry with separate batching in order to handle outlines. In polygon’s case that’s PolygonOutlineGeometry. Using Primitives is much more verbose and requires more code because it more accurately reflects what’s going on in the engine. Unless you have a specific reason not to, I recommend you use the Entity API instead, which you can read about in the Visualizing Spatial Data tutorial

Matthew,

I was able to improve the outline by adding the wall Geometry to the primitive.
I will follow your advice and start migrating the primitives into entities.

Thanks,

Alberto