New QuantizedMeshTerrainData causes rejection

When the quantized mesh terrain file finishes loading in CesiumTerrainProvider.js, the attempt to create the QuantizedMeshTerrainData object fails. Upon investigation, the provider.availability member is null and is causing a reject to occur when attempting to call computeChildMaskForTile.

I don’t know if this is the correct question to ask, but it’s the only one I can think of. How do I associate an availability object with my terrain provider?

The provider itself is allocated with the following code

  var terrainProvider = new Cesium.CesiumTerrainProvider({url : urlpath});
  this._viewer.scene.terrainProvider = terrainProvider;

You need to make sure the layer.json at that urlpath is configured with an “availability” array. Unfortunately this functionality is not very well documented by the team but you see some of them discussing it here sampleTerrainMostDetailed problem - #7 by omar

An example of what mine looks like (note the settings are very specific to my map and may not work in your case). The below availability array is configured to load all tiles to z22.

{
  "tilejson":"2.1.0",
  "format":"quantized-mesh-1.0",
  "scheme":"slippyMap",
  "minzoom":0,
  "maxzoom":22,
  "available":[
    [
      {
        "endX":1,
        "endY":0,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":3,
        "endY":1,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":7,
        "endY":3,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":15,
        "endY":7,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":31,
        "endY":15,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":63,
        "endY":31,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":127,
        "endY":63,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":255,
        "endY":127,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":511,
        "endY":255,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":1023,
        "endY":511,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":2047,
        "endY":1023,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":4095,
        "endY":2047,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":8191,
        "endY":4095,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":16383,
        "endY":8191,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":32767,
        "endY":16383,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":65535,
        "endY":32767,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":131071,
        "endY":65535,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":262143,
        "endY":131071,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":524287,
        "endY":262143,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":1048575,
        "endY":524287,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":2097151,
        "endY":1048575,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":4194303,
        "endY":2097151,
        "startX":0,
        "startY":0
      }
    ],
    [
      {
        "endX":8388607,
        "endY":4194303,
        "startX":0,
        "startY":0
      }
    ]
  ],
  "tiles":[
    "/{z}/{x}/{y}.terrain"
  ],
  "extensions":[
    "octvertexnormals"
  ]
}

Thanks so much. I never would have thought of that. The layer.json file is somewhat of a mystery. lol