I have a dynamic gltf model on 3d tiles, and I want the model to stick on the ground
this is my code to get tiles’s height
//longitude,latitude is position of vehicle
function getGroundHeight(longitude,latitude) {
var modelPosition = Cesium.Cartesian3.fromDegrees(Number(longitude),Number(latitude));
var windowPosition = viewer.scene.cartesianToCanvasCoordinates(modelPosition,new Cesium.Cartesian2());
var tilesCartesian = viewer.scene.pickPosition(windowPosition);
var tilesPosition = viewer.scene.globe.ellipsoid.cartesianToCartographic(tilesCartesian);
var groundHeight = tilesPosition.height;
return groundHeight;
}
``
but when I move the perspective,the window position is changed,so the height of the return is not correct.
Have any ideas to solve the problem?