Using external source to feed TerrainProvider

Hi all,

1. A concise explanation of the problem you're experiencing.
I'm trying to feed ArcGIS LERCs to TerrainProvider. I've followed the old ArcGisImageServerTerrainProvider logic as reference and this thread:!msg/cesium-dev/zhJgvO4U3Vk/A3yvKnQRMA8J

The LERC part is easy; After decoding the LERC format I have a 257x257 terrain tile containing the altitudes in MSL (geoid, not ellipsoid).

Following ArcGisImageServerTerrainProvider logic, I've tried to feed a downscaled image to HeightmapTerrainData, but as far as I can see there's no terrain data at all in my scene.
Cesium does call requestTileGeometry for the whole pyramid (from zoom 0 to the max zoom defined by childTileMask - I've put logging to verify this).

I'm not sure how to progress from here. Is this the right way to load terrain data to Cesium? Is there a better way?

Is there reference code for something like this?

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
This is the code that actually loads the terrain data:

                // Load LERC
                let lerc =;
                let image = Lerc.decode(lerc);
                let imageData = image.pixels[0];

                // Limit pyramid depth
                let childrenAvailable = 15;
                if (level >= 13) {
                    childrenAvailable = 0;

                // Load the LERC data into a heightmap buffer
                let terrainBuffer = this.getImagePixels(imageData, image.width, image.height);
                let result = new Cesium.HeightmapTerrainData({
                    buffer : terrainBuffer,
                    width : 65,
                    height : 65,
                    childTileMask : childrenAvailable, // all children present
                    structure : this._terrainDataStructure

                console.log('LERC Loaded [Level: ' + level + ' X: ' + x + ' Y: ' + y);

                return result;

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


Yeah I think your best bet here is looking at the other terrain providers to see how they work. If you’re not already using it, you might find the inspector tool useful for debugging:

If you make progress on this please post what worked for you here! I can imagine it’ll be useful for other community members in the same situation.