Hi,
Following up on this topic.
With the great help of “slozier” in the mentioned Github issue, who shared a code example with me, I built a wrapper around the default CesiumTerrainProvider.
The wrapper test tiles for intersection (when requestTileGeometry is called) with a defined rectangle region and if matching returns a custom promise.
That promise generates a new tile using HeightmapTerrainData.
This works perfectly and generates valid mesh that renders fine in the viewer.
However, I can see artefacts in the form of flickering imagery tiles: they turn dark and normal again depending on camera movement or Sun position (see screenshot). Also, the issue is only visible when terrain provider is constructed with requestWaterMask=true.
Which leads me to think that vertex normals are not created properly by the HeightmapTerrainData method.
Any idea on that I am doing wrong?
Finally, I also tried to generate Quantized mesh instead but could not get the tiles to display (just get a hole instead)
Here the code I use - anything blatantly wrong in there?
var tileRect = this.baseProvider.tilingScheme.tileXYToRectangle(x, y, level);
var tileCenter = new Cesium.Cartesian3(tileRect.west + tileRect.width / 2, tileRect.north + tileRect.height / 2, height);
var data = new Cesium.QuantizedMeshTerrainData({
minimumHeight : height,
maximumHeight : height,
quantizedVertices : new Uint16Array([// order is SW NW SE NE
// longitude
0, 0, 32767, 32767,
// latitude
0, 32767, 0, 32767,
// heights
0, 0, 0, 0]),
indices : new Uint16Array([0, 3, 1,
0, 2, 3]),
boundingSphere : new Cesium.BoundingSphere(tileCenter, 100000),
orientedBoundingBox : new Cesium.OrientedBoundingBox(tileCenter, Cesium.Matrix3.fromRotationX(Cesium.Math.PI, new Cesium.Matrix3())),
horizonOcclusionPoint : tileCenter,
westIndices : [0, 1],
southIndices : [0, 2],
eastIndices : [2, 3],
northIndices : [1, 3],
westSkirtHeight : 1.0,
southSkirtHeight : 1.0,
eastSkirtHeight : 1.0,
northSkirtHeight : 1.0,
childTileMask: 0
});
Cheers,
Xavier.