Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position) result undefined

Hello!
Use Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position) with position camera result undefined.

I change the camera angle middle mouse button, result Ok.

I need to get the coordinates of the mouse click, to accommodate infobox.

Sandcastl:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

viewer.camera.lookAt(Cesium.Cartesian3.fromDegrees(20.5, 54.7),

new Cesium.Cartesian3(35000.0, -200000.0, 100000.0));

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

var scene = viewer.scene;

var ellipsoid = scene.globe.ellipsoid;

var position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(function(movement) {

console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));

}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

What am I doing wrong?

Thanks.

Hello,

You’re not doing anything wrong. If you read the documentation for wgs84ToWindowCoordinates it says that it may return undefined. Every once in a while, the math to compute the window position doesn’t quite work out.

I know this is supposed to be the case for a position close to the center of the earth, but it should be able to find the position in the example you gave. I created this issue so that we can look into why it isn’t working: https://github.com/AnalyticalGraphicsInc/cesium/issues/4098

Best,

Hannah

Additonally, SceneTransforms.wgs84WithEyeOffsetToWindowCoordinates can return undefined here:

if (positionCC.z < 0 && frameState.mode !== SceneMode.SCENE2D) { return undefined; }

Which is not handled in Billboard._computeScreenSpacePosition, there is not undefined or null check, throwing an error when retriveing the x/y properties here:

positionWC.x += po.x; positionWC.y += po.y;

Cheers

Bryce