pickPosition only works on 3D tiles if depthTestAgainstTerrain = true
See original GitHub issueThis 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:
- Created 6 years ago
- Comments:12 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m having this bug now - setting
viewer.scene.globe.depthTestAgainstTerrain = falsemakespickPositionon the ellipsoid fail.I want to disable
depthTestAgainstTerrainto stop KMLs from digging into the terrain but in doing so I can’t pick on the ellipsoid anymore.I believe the bug is here https://github.com/CesiumGS/cesium/blob/a02065697660f2ee1960548a5630578a8a11e3d0/Source/Scene/Picking.js#L396-L402