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.

Mouse over picking when polygons switch between batches causes errors

See original GitHub issue

I get the following error message:

Uncaught RuntimeError: An entity with id 26912e0a-e73c-4b55-ac1b-f1bfed18bd22 already exists in this collection.
Error
    at new RuntimeError (http://localhost:8080/Source/Core/RuntimeError.js:43:19)
    at EntityCollection.add (http://localhost:8080/Source/DataSources/EntityCollection.js:283:19)
    at <anonymous>:58:32
    at handleMouseMove (http://localhost:8080/Source/Core/ScreenSpaceEventHandler.js:251:13)
    at HTMLDocument.listener (http://localhost:8080/Source/Core/ScreenSpaceEventHandler.js:68:13) (on line 283 of http://localhost:8080/Source/DataSources/EntityCollection.js)

when I run the following sandcastle examples

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

var scene = viewer.scene;
var handler;

var pickedEntities = new Cesium.EntityCollection();
var pickColor = Cesium.Color.YELLOW;
function makeProperty(entity, color) {
    var colorProperty = new Cesium.CallbackProperty(function(time, result) {
        if (pickedEntities.contains(entity)) {
            return pickColor.clone(result);
        }
        return color.clone(result);
    }, false);

    entity.polygon.material = new Cesium.ColorMaterialProperty(colorProperty);
}

var red = viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-70.0, 30.0,
                                                        -60.0, 30.0,
                                                        -60.0, 40.0,
                                                        -70.0, 40.0]),
        height : 0
    }
});
makeProperty(red, Cesium.Color.RED.withAlpha(0.5));

var blue = viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-75.0, 34.0,
                                                        -63.0, 34.0,
                                                        -63.0, 40.0,
                                                        -75.0, 40.0]),
        height : 0
    }
});
makeProperty(blue, Cesium.Color.BLUE.withAlpha(0.5));

// Move the primitive that the mouse is over to the top.
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    // get an array of all primitives at the mouse position
    var pickedObjects = scene.drillPick(movement.endPosition);
    if (Cesium.defined(pickedObjects)) {
        //Update the collection of picked entities.
        pickedEntities.removeAll();
        for (var i = 0; i < pickedObjects.length; ++i) {
            var entity = pickedObjects[i].id;
            pickedEntities.add(entity);
        }
    }

}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

This occurs using Primitives. If you remove the height : 0 from both entities the same thing will occur with GroundPrimitives. It only happens when you force the entity to switch batches during the pick. For Primitive it has to switch between opaque and translucent, for GroundPrimitive it just has to switch color.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tfilicommented, Jan 4, 2017

@pjcozzi It looks like this is fixed for GroundPrimitives, but is still an issue with regular Primitives (with height:0 in the code).

image

I suspect that the GroundPrimitives were fixed in 203bdf3c6671a4e6fea6b0fd43b77d62605b497b

0reactions
pjcozzicommented, Jan 2, 2017

@tfili:

The above code worked for me, do you need to remove height : 0 to reproduce this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Altium Bugs And Things To Watch Out For - mbedded.ninja
If you are finding that when you draw polygons that Altium is not staying the correct distance away from zones you draw on...
Read more >
Slowness in specific areas | Altium Designer | Knowledge Base
Sometimes there are settings or things about your documents that can cause unusual slowness. Here are some things to look for.
Read more >
AutoCAD Hatch Problems & Tips | 2 Minute Tuesday - YouTube
AutoCAD Hatch Problems & Tips - Boundary Errors + Time Saving ... how to fix any unclosed areas or boundary issues with hatches...
Read more >
Help - iTOL
To switch the display mode, click the corresponding button in the Mode section on the top of the Basic controls tab. Trees which...
Read more >
BD FACSDiva Software 6.0 Reference Manual
The information in this guide is subject to change without notice. ... to ensure accuracy, BD Biosciences assumes no liability for any errors...
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