This is the example demo app
https://sandcastle.cesium.com/?src=Google%20Photorealistic%203D%20Tiles.html
I tried to add altitude from this snippet (modified so can onclick instead mousemove)
below the original code and then run (F8) but it shows error that it doesn't have globe object.
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (event) {
let ray = viewer.camera.getPickRay(event.position);
console.log(JSON.stringify(ray));
let mousePosition = viewer.scene.globe.pick(ray, viewer.scene);
// error because globe undefined ^
if (Cesium.defined(mousePosition)) {
let cartographic = Cesium.Cartographic.fromCartesian(mousePosition);
let latStr = Cesium.Math.toDegrees(cartographic.latitude);
let lonStr = Cesium.Math.toDegrees(cartographic.longitude);
let heightStr = cartographic.height;
console.log(latStr, lonStr, heightStr)
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
If I tried to enable the globe: true
, it failed on initialization phase of CesiumJS.
tried also solution from this question but 2nd answer not having globe object if using google tileset, 1st answer only get the land altitude, not click altitude.
How can I get altitude (preferably sea level, or any kind is altitude fine), from a mouse click?
Or alternatively is there any more complete 3d tileset other than google 3d photorealistic 3d tileset that I can use that can get the altitude position of a click?