Polygons with heightReference, perPositionHeight, no extrusion

1. A concise explanation of the problem you're experiencing.

When a polygon has perPositionHeight and is not extruded, attempting to set a heightReference (RELATIVE_TO_GROUND or CLAMP_TO_GROUND) gives the following error:

DeveloperError: Appearance/Geometry mismatch. The appearance requires vertex shader attribute input 'applyOffset', which was not computed as part of the Geometry. Use the appearance's vertexFormat property when constructing the geometry.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

Here is a sandcastle that demonstrates the issue. You can double-click the map to attempt to clamp the polygon to ground:

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I was able to change the heightReference on polygons I'd created in 1.46 without a problem, and I would like to keep using the same workflows I've been using.

4. The Cesium version you're using, your operating system and browser.
1.48
Windows 10
Chrome

I am seeing the same issue as well. Curious to know if there is a fix in the works.

I was able to avoid the error by setting the value via a Callback Property rather than directly. Using a Callback Property will mark that property of the entity as dynamic.

See this updated example.

However in either case I can’t see the polygon, even when turning off depthTestAgainstTerrain, so let me know if that helps or not.

Thanks,

Gabby

Unfortunately I don’t think this solves the problem. The entity wasn’t actually being updated in your example, so I added the line “entity.polygon.heightReference = newHr” and the error reappeared.

Sorry, I see - I went and reset it to a constant property. I’m having trouble getting it working in my own code, but I see how the example works now. Thank you.

So it turns out when I start by setting the heightReference result to CLAMP_TO_GROUND, rather than starting with NONE, the error occurs even when using a callback. Here’s the example; the only difference between this and the last example is in line 18.

So I’m only getting the error if perPositionHeight is enabled. I don’t think you need it for this case. Instead, make sure you specify the height, and use a value that will put the entity above terrain so you can see it.

I am having trouble with the toggling using a CallbackProperty. I went back to setting heightReference directly and it seemed to work fine.

Here’s a working example.

I’ve found a way to get around this in my current code, but it seems like Cesium should support the ability to create a polygon that’s non-extruded, relativeToGround, and has perPositionHeight all at the same time. Does anyone know if there are plans to get this fixed in the future?

It should be supported. I went ahead an opened an issue, #6976. We may not be able to get to this right away, but if you could help by tracking down the error or providing a fix, contributions are greatly appreciated!

Thanks,

Gabby

Hello,

heightReference is currently not compatible with perPositionHeight. I’ve opened this pull request to fix the DeveloperError and print a warning to the console instead: https://github.com/AnalyticalGraphicsInc/cesium/pull/6978

We’ll keep issue #6976 open and notify you when we have a chance to add support for that case.

Best,

Hannah

Thank you both.