question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Picking near Earth sphere border returns pickIds equal to 255, 65535 which is being misinterpreted as object pick

See original GitHub issue

Take a look at the following example:

Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(-40, -40, 40, 40);

var viewer = new Cesium.Viewer('cesiumContainer', {
    selectionIndicator : false,
    infoBox : false
});

var scene = viewer.scene;
var handler;

var i;
for (i = 0; i != 255; ++i) {
    viewer.entities.add({
        id: 'obj_' + i,
        /*
        polyline: {
            positions: Cesium.Cartesian3.fromDegreesArray(
                [Math.random() * 10, Math.random() * 10, Math.random() * 10, Math.random() * 10]),
            followSurface: false,
            material: Cesium.Color.RED,
          },
        */
        point: {
            color: Cesium.Color.RED
        },
        position: Cesium.Cartesian3.fromDegrees(Math.random() * 10, Math.random() * 10)
    });
}

handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    var pickedObject = scene.pick(movement.endPosition);
    if (Cesium.defined(pickedObject)) {
        var cartesian = viewer.camera.pickEllipsoid(movement.endPosition, scene.globe.ellipsoid);
        if (cartesian) {
            var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
            var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
            var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
            
            console.log(pickedObject.id._id + ' ' + movement.endPosition + ' (' + longitudeString + ', ' + latitudeString + ')');
        } else {
            console.log(pickedObject.id._id + ' ' + movement.endPosition);
        }
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

It displays points in [0, 10]x[0, 10] degrees square and on mouse move tries to pick entity under mouse cursor — if there is any, outputs mouse coordinates in the log.

Since all points in [0, 10]x[0, 10] degrees square it is expected that points will be picked only in it, which is not the case — if I move mouse near Earth sphere border I get some points selected:

2016-12-27_19 25 35_1

(notice that last two columns in the log are selected point coordinates, and they are far outside [0, 10]x[0, 10] degrees square).

Same issue with polylines entities picking (and probably other entities types).

If I reduce number of entities to 253 or less I can’t reproduce this issue.

Tested in CesiumJS 1.28 in Firefox Developer Edition 52.0a2 and Chromium 55.0.2883.87 on Ubuntu 16.04 with NVidia GTX 980 with NVidia proprietary drivers 367.57.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rutskycommented, Dec 28, 2016

@pjcozzi done, please review: #4790

0reactions
pjcozzicommented, Jan 4, 2017

Thanks again for the fix, @rutsky. I made a small tweak to also not render the sun, moon, and sky box and merged everything in #4806 since I could not commit to your branch (could have been an issue on my end).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fair Oaks Farms - Science On a Sphere
Science On a Sphere® is a program within the National Oceanic and Atmospheric Administration supported by the Office of Education in partnership with...
Read more >
2005-April.txt - Kitware Inc.
GetPoints() is no solution since this returns all points of the original ImageData object (which are far more than the ones defining the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found