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

1,202 views
Skip to first unread message

Alberto Acevedo

unread,
Aug 21, 2015, 3:37:46 PM8/21/15
to cesium-dev
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

Alberto Acevedo

unread,
Aug 21, 2015, 3:51:07 PM8/21/15
to cesium-dev
See attached snapshot for a better description of my issue. 
polygon_no_outline.png

Matthew Amato

unread,
Aug 21, 2015, 9:41:28 PM8/21/15
to cesiu...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alberto Acevedo

unread,
Sep 1, 2015, 3:55:31 PM9/1/15
to cesium-dev
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

On Friday, August 21, 2015 at 3:37:46 PM UTC-4, Alberto Acevedo wrote:
Reply all
Reply to author
Forward
0 new messages