Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scene.drillPick() hangs if picking out of more than 254 items #4784

Closed
rutsky opened this issue Dec 27, 2016 · 2 comments
Closed

scene.drillPick() hangs if picking out of more than 254 items #4784

rutsky opened this issue Dec 27, 2016 · 2 comments

Comments

@rutsky
Copy link
Contributor

rutsky commented Dec 27, 2016

Take 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 pickedObjects = scene.drillPick(movement.endPosition);
    
    var ids = pickedObjects.map(function(obj) {return obj.id._id;});
    
    if (pickedObjects.length > 0) {
        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(movement.endPosition + ' (' + longitudeString + ', ' + latitudeString + ') - ' + ids);
        } else {
            console.log(movement.endPosition + ' - ' + ids);
        }
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
@rutsky
Copy link
Contributor Author

rutsky commented Dec 27, 2016

This is based on example from #4783.
In #4783 points are being incorrectly selected which caused "false positives" in selection.
If same objects are not being picked, but drillPick-ed --- Cesium hangs.

Try to move mouse cursor near Earth sphere edge in the example above --- browser tab will hang.

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.

@rutsky rutsky changed the title scene.drillPack() hangs if picking out of more than 254 items scene.drillPick() hangs if picking out of more than 254 items Dec 27, 2016
@hpinkos
Copy link
Contributor

hpinkos commented Dec 27, 2016

Thanks @rutsky, we'll try to take a look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants