scene.pickPosition returns from time to time incorrect values

Hey guys,

I have experienced some problems with the viewer.scene.pickPosition() functionality when clicking on buildings (b3dm assets). We use the current version of the 3D tiles branch.

Most of the times it returns a correct position, but sometimes it seems that the returned point lies some distance (like 10 meters or something) on the ray in the direction towards the viewer.

See the screenshot where entities (white points) are drawn at the clicked position. I have clicked here a couple of times (from different angles) on the facade of the building. The sceenshots shows the building from above, as you can see most of the points lie on the building facade but two of them a couple of meters away..

This effect seems to be quite random to me, I can't predict when the point is going to be placed correctly and when not..

Has anybody experienced this behavior?

Best,
Lucas

http://hosting.virtualcitysystems.de/demos/berlin/Capture.jpg

Hello Lucas,

I wasn’t able to reproduce this. Here’s the example I was testing with:

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

var modelEntity = viewer.entities.add({
name : ‘milktruck’,
position : Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706),
model : {
uri : ‘…/…/SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.gltf’
}
});
viewer.zoomTo(modelEntity);

// Mouse over the globe to see the cartographic position
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
var foundPosition = false;

var scene = viewer.scene;
var pickedObject = scene.pick(click.position);
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.id === modelEntity) {
    var position = viewer.scene.pickPosition(click.position);

    if (Cesium.defined(position)) {
        viewer.entities.add({
            position : position,
            point : {
                pixelSize : 10,
                color : Cesium.Color.YELLOW
            }
        });
    }
}

}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

``

Maybe it’s related to your models? Or it could be OS or browser specific. What OS and browser are you using?

If you can give me any more information or sample data for me to reproduce the error that would be really helpful.

Thanks!

Hannah

Hi Hannah,

Thanks for your quick reply. I ran your code in the sandcastle and can indeed not reproduce the bug with the truck.

Iam on Windows10 over here with Chrome, modern CPU/GPU etc.

Here is a video of the problem to illustrate:

It seems that sometimes the viewer gets in a state where it returns false positions, no matter where is clicked. I started the video after having clicked around for a while and reaching this state.

Once this state is reached, all points clicked return wrong positions (even those on the ground) as can be seen from the video.

Once the camera is moved around a little, a correct state is reached where newly clicked points again return the correct position as can be seen by the end of the video.

I am currently preparing a dataset which you can use.

Best Lucas

A dataset can be found here: hosting.virtualcitysystems.de/demos/temp/c6c113af-c1dc-4ced-a818-dd5dc7540636.zip

Its a piece of Berlin (lon: 13.43217 - lat: 52.51584).

I reach the invalid state quite fast (max after 20 sec of clicking/rotating) once I rotate the camera (CTRL CLICK DRAG) and put a few test clicks repeatedly.

To be sure: we are on the current 3D tiles branch.

Thanks,
Lucas

Hi Hannah,

We have just tested this dataset in the sandcastle of the 3D tiles branch.

It doesnt seem that the problem exists there. Conclusion: it must be somewhere in our code. Not sure yet whether Iam happy or unhappy about that :wink:

Nonetheless, do you have any ideas perhaps what could lead to such a state?

I will let you know once we find something..

Best,
Lucas

Hi Lucas,

I’m not sure what would be causing the problem, sorry. But I’ve asked around to see if someone else may have an idea.

Thanks for digging into the problem a little more! If you track it down to a Cesium related bug, let me know =)

-Hannah

Hi Hannah,

Indeed, after some more investigations it seems to be a cesium related bug.

1. Please visit http://hosting.virtualcitysystems.de/demos/temp/pickProblem/Apps/Sandcastle/?src=3D%20Tiles.html for a reworked version of the 3d tiles example.

If you click on some buildings you will see that the points are placed correctly.

2. Now click on "open in new window" (blob:http://hosting.virtualcitysystems.de/…) you will see that clicking on the buildings will return erroneous positions.

Strangely enough, once you press the fullscreen button in the lower right corner, the positions from clicked positions are correct again.

The Cesium version which is used: https://github.com/virtualcitySYSTEMS/cesium/tree/pickProblem which uses the latest 3d tiles branch.

Note that the behavior changes between correct/incorrect when the camera is rotated / zoomed ..

By the way, the data which is loaded here is also ran through the b3dm pipeline.

Best,
Lucas

Here is a video which shows the behavior described above: https://youtu.be/9twwwMHbjKU

And here is another video that shows that it has something to do with the size of the screen: https://youtu.be/IbDNwqKVOik

And zooming : https://youtu.be/nJpHGOdTssY

:-/

Best,
Lucas

Hi Hannah,

Could you reproduce the bug with the links I sended? I noticed that at a different computer the bug behaved slightly different.. from the startview I had to zoom in or out by some distance to get to the turning point of "correct placed points" / "incorrect placed points".

Best,
Lucas

Hi Lucas,

Sorry I didn’t follow up on this. I didn’t have time to dig into the problem yet but I’ve bookmarked your post and will try to look at it either later today or first thing Monday.

Thanks,

Hannah

Hi Hannah,

That's great, thanks a lot.

Interested in what you find!

Best,
Lucas

Hi Lucas,

I was able to reproduce the problem with the demo you provided. It’s very interesting that it seems to be dependent on screen size.

Thanks for writing that sandcastle example. That should make it easier for our graphics programmers to track down the problem. I’ve created this issue for us to look into it further: https://github.com/AnalyticalGraphicsInc/cesium/issues/4368

I tried to see if this was a 3D tiles specific problem, but I wasn’t able to reproduce it with any of our sample tilesets. Would you be able to share one of your b3dm tiles with us so we can try to reproduce the problem locally?

Thanks,

Hannah

Hi Hannah,

Thank you very much. The 3D tileset which is used in the sandcastle can be used for this purpose:

Ill watch the issue, and post the link to the data there as well. thanks again!

Best,
Lucas