**Resolved** CylinderGraphics Entity Render Error with heightReference Set to Anything But 'None'

I’m attempting to place cylinders at various locations on the globe. The cylinder heights are specified in meters MSL, and I’m needing to place the cylinders immediately as the scene loads… so I’m using sampleTerrainMostDetailed to get the ground elevation at the locations. I’m then calculating the ground MSL for each location using the data from EGM96.

I calculate the above ground height of the cylinder based on the MSL calculations mentioned above. However, when I attempt to draw the cylinders with
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
or
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
I get an error that states “An error occurred while rendering. Rendering has stopped. Cannot read property ‘clone’ of undefined”.

If I allow the heightReference to be Cesium.HeightReference.NONE then I don’t get the error. However, I’m having a hard time figuring out how to position the cylinder so that the bottom of the cylinder is at the terrain/surface.

What is preventing me from using a heightReference of Cesium.HeightReference.CLAMP_TO_GROUND?

If the heightReference is NONE how do I position the bottom of the cylinder at the ground’s surface? It seems like I would set the entity’s position using the height returned from the call to sampleTerrainMostDetailed, but this doesn’t position the bottom of the cylinder at ground/surface level.

I’ve put together a Sandcastle example to show what I’m doing…
Note: If you comment out the cylinder heightReference on line 254 the scene will load, but the cylinders are not being positioned at the correct height.

It dawned on me that I was thinking the cylinder was positioned from the bottom… which is wrong. Once I realized the cylinder is being positioned from its center… and that objects are by default positioned above the WGS84Ellipsoid… I was able to position the cylinders correctly.

I worked through my calculations again and discovered I had made some mistakes. I’ve modified the calculations, and everything is working well now.

I updated the Sandcastle example with the corrections…

1 Like