Globe transparency and picking

Hi,

Is there any way to have picking on the globe working through viewer.scene.pickPosition() normally if you turn viewer.scene.globe.translucency.enabled = true? I know I can use viewer.camera.pickEllipsoid(), but it doesn’t pick properly for anything that might be on the map, like terrains. Right now it simply picks through the globe to the underside of the opposite pole, not quite where I wanted to go. :slight_smile:

I’ve tried using viewer.scene.pickTranslucentDepth = true, and I’m able to pick 3D tilesets some of the time, it seems almost at random whether it picks it or falls through to the other side of the planet. But terrain models not at all. I’m using viewer.scene.preRender.addEventListener() to be the first thing that picks, as I read there are some oddities with situations where you use different pickers, and pickPosition() needs to be first. It’s the only preRender I’ve got that picks. Anything else I should be looking at? Any way to pick the height of a translucent terrain?

Cheers,

Alex

I didn’t quite understand everything, but here are some of my thoughts:

  1. I would use entity (point) with Cesium.HeightReference.CLAMP_TO_GROUND.
  2. If you want to hit the relief, then use pickEllipsoid with sampleTerrainMostDetailed. This will give you the height and will be able to raise the point above the ellipsoid. Don’t forget about startPosition and endPosition.
  3. There are also IntersectionTests, you can create a Ray in the desired direction and find an intersection with an ellipsoid or other geometric shapes. You can fill the same relief with small triangles and use rayTriangle.

Hi there,

Those things are fine for when the globe is normal, but don’t work when the globe is translucent. It’s especially picking on a translucent terrain that’s proving tricky.

Cheers,

Alex

Could using a Ray help? Something like:

let scratchDropConversion;
let rayScratch;
let pickPos = new Cesium.Cartesian2(mousePos.clientX, mousePos.clientY);
scene.camera.getPickRay(pickPos , rayScratch);
scene.globe.pick(rayScratch, scene, scratchDropConversion);

Hi there,

Well, it’s interesting, it can actually pick on a transparent terrain, just nothing else. :slight_smile: I guess I could check for transparency, and if I can’t pick any models/entities the normal way, throw this one in at the end as a penalty to make sure I’m hitting the terrain. I could even compare it’s height to the pickEllipsoid() to figure out if needed.

Great, I’ll see if I can combine them. The issue will always be speed in the end, but that just might be the penalty of transparent terrains. Thanks, man!

Cheers,

Alex