Also checkout the Cesium Geometry and Appearances tutorial for how to create outlines. You’ll need to create a second geometry that is just the outline.
But the outline box is still giving me an error. Here is the new sandcastle. I looked at the “Geometry and Appearance” tutorial and went through it a few times, but still could not figure out what I am doing wrong.
The error is:
An error occurred while rendering. Rendering has stopped.
undefined
DeveloperError: Appearance/Geometry mismatch. The appearance requires vertex shader attribute input ‘compressedAttributes’, which was not computed as part of the Geometry. Use the appearance’s vertexFormat property when constructing the geometry.
It looks like the shader is looking for a vertex attribute that isn’t there with the outline. Try setting flat: true in the PerInstanceColorAppearance when drawing the outline. Here’s a working example. Hopefully that fixes your issue!
That is great, thanks! Now I have another small issue. I am trying to get shadows, but they refuse to appear. I have tried various things but the tutorials only describe how to do it with entities, not primitives.
It looks like the shadows are working, you just need to get it to a time of the day when the sun is overhead. You can do that with the timeline scrubber widget at the bottom. Here’s a particular time of day I found where the shadows do appear, that you can set programmatic ally with this line:
viewer.clock.currentTime.secondsOfDay = 62624;
``
(I got this by using the scrubber then outputting that value).
I think your code is completely correct Patrick. This might be a bug in Cesium in how it handles the modelMatrix. The problem with (0,0,0) is that it will throw an exception any time Cesium tries to normalize it (it will try to divide by 0). Even if you wiggle the x to 0.01, it’ll work but you’ll get z fighting since the polygon has the same exact position as the surface. A more robust way in general to put polygons on the ground (especially when it includes terrain) is to use GroundPrimitive instead of Primitive (but I think GroundPrimitve doesn’t support extrudedHeight).
So here’s what I did: I manually multiplied the points for each geometry instance by the matrix (which means you end up creating more geometries but you still have the same efficiency of one primitive rendering many instances). I also used height: 0.01 instead of perPositionHeight: trueto make it easier to position the polygon. I think this should work the way you expect it to. Here’s the example.
Your original design with the modelMatrix should work, and I’ll file a bug for that. Thanks for bringing this up and posting about it on the forum! If you run into anything else please feel free to keep posting here or make a new thread if it’s a sufficiently separate issue.