baseLayerPicker==false breaks Scene.pickPosition

I notice a problem where if you set baseLayerPicker to ‘false’ then Scene.pickPosition seems the return garbage.

checkout the console logging in the following example. Right click on map and it should print lat, lon, height. it all works fine when leaving baseLayerPicker to default to true, but when marked false, the height value gets strange.

Sandcastle Example

any tips?

1 Like

I’m also looking for a solution to the same issue pls send tips if any?

I believe it is a bug introduced in the latest version.
did you try it on a bit old version?

1 Like

Yes, which version it’s working fine pls let me know.

I’ve applied this and it’s working fine for me.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {
baseLayerPicker: true,
terrainProvider: Cesium.createWorldTerrain()
viewer.scene.canvas.addEventListener(‘contextmenu’, (event) => {
const mousePosition = new Cesium.Cartesian2(event.clientX, event.clientY);
const selectedLocation = viewer.scene.pickPosition(mousePosition);

}, false);

function setMarkerInPos(positionCartographic){
//viewer.pickTranslucentDepth = true;

//viewer.terrainProvider = Cesium.createWorldTerrain();
viewer.scene.globe.depthTestAgainstTerrain = true;

var redSphere = viewer.entities.add({
name: ‘Red sphere with black outline’,
position: Cesium.Cartesian3.fromRadians(positionCartographic.longitude, positionCartographic.latitude,10),
ellipsoid: {
radii: new Cesium.Cartesian3(1000, 1000, 1000),
material: Cesium.Color.RED.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
//height: 200000.0,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
//heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
//disableDepthTestDistance: Number.POSITIVE_INFINITY


The bug is somewhere in

specifically this call is the one that returns very different values for “pixels” when “baseLayerPicker” is on vs. off

      PixelDatatype$1.toWebGLConstant(pixelDatatype, this),

this is a WebGL call, and i’m not familiar with it. So looks like somehow baseLayerPicker is having an effect on the WebGL context.

This looks like a regression to me. You should file an issue and include the sandcastle example from your initial post.

1 Like

Well I figured it out.
After creating “viewer”, add

1 Like


Welcome to the community :confetti_ball: :grinning: :rocket: I am so happy to see that you were able to resolve this issue yourself!


1 Like