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

pickPosition picks groundPrimitive BoundingVolume on pickTranslucentDepth #7257

Closed
jbo023 opened this issue Nov 12, 2018 · 5 comments · Fixed by #8726
Closed

pickPosition picks groundPrimitive BoundingVolume on pickTranslucentDepth #7257

jbo023 opened this issue Nov 12, 2018 · 5 comments · Fixed by #8726

Comments

@jbo023
Copy link
Contributor

jbo023 commented Nov 12, 2018

Hi,

we have some problems with pickTranslucentDepth and GroundPrimitives. If we call pickPosition and set pickTranslucentDepth to true, pickPosition will pick the BoundingVolume of the GroundPrimitive.

In the Sandcastle, you can reproduce this by left clicking on the polygon and the area around. The logged height should return a value around 100m, but if the boundingvolume of the polygon is hit, the height will get up to 1200m.

Maybe in a pickTranslucent Pickpass the boundingvolume can be skipped ?

Sandcastle example:

var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProvider: Cesium.createWorldTerrain(),
    selectionIndicator : false,
    infoBox : false
});
var handler;
var scene = viewer.scene;
Sandcastle.addToolbarButton('Pick position', function() {     
    var bluePolygon = viewer.entities.add({
        name : 'Bluepolygon',
        polygon : {
            hierarchy : {
                positions : Cesium.Cartesian3.fromDegreesArrayHeights([13.508413568947175, 52.624609203388985,63.489969498150046,
                                                                13.507974260302085,52.62343609585099,62.40131342659079,
                                                                13.512261239882516,52.623435464323194,62.62432512380137,
                                                                13.512411447299176,52.62507247479826,64.79929751403317])
            },
            material : Cesium.Color.BLUE
        }
    });
    viewer.scene.camera.flyTo({
        destination:Cesium.Cartesian3.fromRadians(0.23573022033928406,  0.9180339714130956,2468.1889113351654),
        orientation: {
            direction: new Cesium.Cartesian3(-0.9763134662556562,-0.2010860623885384,-0.07985243340649456),
            up: new Cesium.Cartesian3(-0.08359955704461564,0.010197801592665909,0.996447248430453)
        },
        duration: 0
    });
    handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
    handler.setInputAction(function(movement) {
        var scene = viewer.scene;        
        var pickedObject = scene.pick(movement.position);
        if(pickedObject) {
         pickedObject.primitive.debugShowBoundingVolume = true;   
        }
        if (scene.pickPositionSupported) {
            scene.pickTranslucentDepth = true;
            viewer.scene.render();            
            var cartesian = viewer.scene.pickPosition(movement.position);
            scene.pickTranslucentDepth = false;

            if (Cesium.defined(cartesian)) {
                var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
                console.log(cartographic.height);
            }            
        }
    }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
});


Sandcastle.reset = function() {
    viewer.entities.removeAll();
    handler = handler && handler.destroy();
};
@jbo023
Copy link
Contributor Author

jbo023 commented Nov 13, 2018

I think, i found a possible solution for this problem.

if picking and renderTranslucentDepthForPick are true, we don't need to render classification passes.
At least I think it is not necessary, because the result for position picks don't change if we left out the classification passes. As they should not change the geometry.

For the above sandcastle, the following change fixes the problem, but i am not sure if there are other implications.
virtualcitySYSTEMS@2c92954

@jbo023
Copy link
Contributor Author

jbo023 commented Dec 10, 2018

Do you have any thoughts no this problem, should i open a merge request

@hpinkos
Copy link
Contributor

hpinkos commented Dec 10, 2018

Whoops, sorry we missed this issue @jbo023. @lilleyse @bagnell thoughts on this?

@lilleyse
Copy link
Contributor

@jbo023 that fix works. You should go ahead and open a PR.

Though we should also look at the underlying issue. Because of the required render call before pickPosition the commands that are used in the renderTranslucentDepth pass don't have pickOnly set and depth commands are rendered instead. If we can, we should try to remove the requirement of calling render before pickPosition. I might have an idea for that.

@lilleyse
Copy link
Contributor

@lilleyse lilleyse mentioned this issue Apr 5, 2020
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants