interpolateMeshHeight and interpolateMeshHeight

1. A concise explanation of the problem you’re experiencing.

What’s the different between interpolateHeight function and interpolateMeshHeight function in QuantizedMeshTerrainData,the two function get different results in my code.

the interpolateHeight function return 2496.909550352688

the interpolateMeshHeight function return undefined

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var cartographic = Cesium.Cartographic.fromDegrees(104.931, 33.387);

var height=terrainData.interpolateHeight(terrainRectangle, cartographic.longitude, cartographic.latitude);

//terrainData level 3 ,x 12 ,y 2

//the source code from cesium

QuantizedMeshTerrainData.prototype.interpolateHeight = function(rectangle, longitude, latitude) {

var u = CesiumMath.clamp((longitude - rectangle.west) / rectangle.width, 0.0, 1.0);

u *= maxShort;

var v = CesiumMath.clamp((latitude - rectangle.south) / rectangle.height, 0.0, 1.0);

v *= maxShort;

if (!defined(this._mesh)) {

return interpolateHeight(this, u, v);

}

return interpolateMeshHeight(this, u, v);

};

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.53

Finally,I think this is a bug in Cesium,the source code should be modify like this:

QuantizedMeshTerrainData.prototype.interpolateHeight = function(rectangle, longitude, latitude) {

var u = CesiumMath.clamp((longitude - rectangle.west) / rectangle.width, 0.0, 1.0);

var v = CesiumMath.clamp((latitude - rectangle.south) / rectangle.height, 0.0, 1.0);

if (!defined(this._mesh)) {

u *= maxShort;

        v *= maxShort; 

return interpolateHeight(this, u, v);

}

return interpolateMeshHeight(this, u, v);

};

在 2019年6月26日星期三 UTC+8下午7:00:33,pollux写道:

Thanks for pointing this out! Any chance you have a full Sandcastle (https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html) example recreating the issue? That way we can open a GitHub issue with all the details required.

Opening a pull request to contribute this fix back into CesiumJS would be great as well! The contributing guide is a great place to start for that: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#opening-a-pull-request