Setting Primitve Appearance/Material (rectangleGeometry)

Hello,

I recently updated from Cesium 1.0 -> 1.19 and am utilizing DrawHelper to draw some regions on the map. I was using rectanglePrimitive which is now deprecated. I found a solution online that suggested changing to:

extent = new Cesium.Primitive({
               geometryInstances : new Cesium.RectangleGeometry(),
               appearance : new Cesium.EllipsoidSurfaceAppearance({
                    material : Cesium.Color.YELLOW.withAlpha(0.5),
               })
});

I have tried a few different things and nothing seems to change the appearance of the rectangle during drawing. It stays invisible. DrawHelper used to draw a yellow rectangle with markers at each end, and now draws the markers but no material.

Does anyone know a solution to this?

Lets just say for now I am stuck with DrawHelper for now (since I need to be able to draw circles, rectangles, and polygons on the map 'by hand'). I have looked into solutions using entities and found that it would be quite difficult to do, or at least have not found a 'entity drawhelper' type plugin. I would love to use entities in a similar fashion as drawhelper uses primitives but again have not found anything.

Thanks for the information and help,

Andrew

Hello,

Take a look at this tutorial about the entity api: http://cesiumjs.org/tutorials/Visualizing-Spatial-Data/

It’s great for any type of primitives that have changing values. Look at this post for a code example of using a CallbackProperty to update positions for a wall:

https://groups.google.com/d/msg/cesium-dev/nypZFdPLjhs/rRH_NdUvhVIJ

DrawHelper is a third party plugin so we aren’t responsible for developing it. Unfortunately, it doesn’t look like the original developer is actively maintaining it. You could try forking the repo and updating it.

Best,

Hannah

I am thinking I could possibly use DrawHelper as a template and refactor primitives to entites (and their callbacks and api), but cannot afford to waste days on this if its not possible. So fundamentally is it possible to extend the functionality of DrawHelper to Entities: Click to select a starting point, move mouse to create an area, click again to create entity. On paper this sounds easy but I am new to Cesium and do not now its limitations or how daunting a task this would be.

Let me know what you think,

Thanks again,

Andrew

I’m not too familiar with their code, but yes I think that’s a good idea.
If the RectanglePrimitive is the only part of the code that’s not working, it should be an easy fix. You should be able to swap in a rectangle entity and change around attribute names. Just be sure to use a CallbackPropertry for rectangle.positions.

Here’s an example of how to add a rectangle with the entity api: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Rectangle.html&label=Geometries

Let me know if you run into any trouble.

-Hannah