camera.pickEllipsoid bug?

I think there is something wrong with camera.pickEllipsoid.

In my script, I continue zooming in and observe the output of camera.pickEllipsoid of the centre of the cesium scene.canvas:

Cartesian3 {x: -4764869.519772489, y: 2726241.3470195886, z: -3236305.1304259636, clone: function, equals: function…}

Cartesian3 {x: -4764869.519772935, y: 2726241.3470195276, z: -3236305.130425362, clone: function, equals: function…}

Cartesian3 {x: -4764869.519773309, y: 2726241.347019476, z: -3236305.1304248576, clone: function, equals: function…}

Cartesian3 {x: -1818555.738240933, y: 282104.6668086974, z: 6086398.279179595, clone: function, equals: function…}

Cartesian3 {x: -1818555.738241348, y: 282104.66680878727, z: 6086398.279179471, clone: function, equals: function…}

There is a massive change in numbers. Is this expected?

I am using the latest version of cesium.

Can you post the code that produces this?

Are you using terrain? If so, you may be running into the same problem I ran into recently.

In some parts of the world, the terrain surface is below the ellipsoid. In an area like that, if you zoom in close to the terrain, the camera will actually be below the ellipsoid. Then, when you invoke pickEllipsoid, you end up picking the back side of the ellipsoid, because the front side is behind you.

The solution is simple, and gives better results, anyway. Instead of using camera.pickEllipsoid, use:

var pickRay = camera.getPickRay(windowPosition);

var pickedPosition = viewer.scene.globe.pick(pickRay, viewer.scene);

That will pick the actual terrain surface instead of picking the ellipsoid.

Kevin

Actually, I looked at the code, and you should follow my advice even if you’re not using terrain, because Camera.pickEllipsoid is currently broken.

Specifically, this logic in pickEllipsoid is wrong:

var t = (Cartesian3.magnitude(ray.origin) < ellipsoid.maximumRadius) ? intersection.stop : intersection.start;

It should be ellipsoid.minimumRadius, not maximumRadius. Better yet, just test if the magnitude of the camera’s position is less than the magnitude of the picked position.

I’ll write a bug.

Kevin

Hi Kevin, I am sorry if I post within this message but I’m facing the same problem now.
But for me, wether I use pickEllipsoid or getPickRay, at the end I got the same positions.
Is there any other solution or it is part of cesium?

When you do pickEllipsoid and getPickRay do you get the same results with terrain on and terrain off?