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.

pickPosition only works on 3D tiles if depthTestAgainstTerrain = true

See original GitHub issue

This picking example only works if you uncomment the third line

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
//scene.globe.depthTestAgainstTerrain = true;

var labelEntity = viewer.entities.add({
    label : {
        text: 'X',
        fillColor: Cesium.Color.RED,
        show: false,
        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM
    }
});

// Mouse over the globe to see the cartographic position
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(click) {
    var foundPosition = false;
    if (scene.mode !== Cesium.SceneMode.MORPHING) {
        var pickedObject = scene.pick(click.position);
        if (scene.pickPositionSupported && Cesium.defined(pickedObject)) {
            var cartesian = viewer.scene.pickPosition(click.position);

            if (Cesium.defined(cartesian)) {
                labelEntity.position = cartesian;
                foundPosition = true;
            }
        }
    }

    labelEntity.label.show = foundPosition;
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
    url : '../../../Specs/Data/Cesium3DTiles/Tilesets/Tileset'
}));

tileset.readyPromise.then(function() {
    var boundingSphere = tileset.boundingSphere;
    viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius * 2));
    viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
JoshuaKahncommented, May 12, 2021

I’m having this bug now - setting viewer.scene.globe.depthTestAgainstTerrain = false makes pickPosition on the ellipsoid fail.

I want to disable depthTestAgainstTerrain to stop KMLs from digging into the terrain but in doing so I can’t pick on the ellipsoid anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pickPosition only works on 3D tiles if depthTestAgainstTerrain ...
depthTestAgainstTerrain = true ;. It works when you select the STK terrain because the BaseLayerPicker enables depthTestAgainstTerrain when you ...
Read more >
Depth plane and depthTestAgainstTerrain - Cesium Community
I have several tilesets where a portion of each tileset is below world terrain, because of this I've set depthTestAgainstTerrain to False.
Read more >
Scene - Cesium Documentation - Agi
It is only used when Scene#logarithmicDepthBuffer is false . ... When true , classified 3D Tile geometry will render normally and ... Scene#pickPosition ......
Read more >
viewer.scene.globe.depthTestAgainstTerrain disturb pick?
The documentation on pickPosition (https://cesiumjs.org/Cesium/Build/Documentation/Scene.html#pickPosition) states that it uses the depth buffer to compute ...
Read more >
Designing a peak experience. Exploring 3D terrain using ...
As it turned out, not only was Cesium a good alternative, it was arguably better in ... For us, in addition to the...
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