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..
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 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.
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.
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.
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".
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.
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?