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 doesn't pick ellipsoid in 2D and CV #5076

Open
hpinkos opened this issue Mar 6, 2017 · 7 comments
Open

pickPosition doesn't pick ellipsoid in 2D and CV #5076

hpinkos opened this issue Mar 6, 2017 · 7 comments

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Mar 6, 2017

In 3D, pickPosition will return a position when hovering over the globe. In 2D and CV, it's the result is always undefined

var viewer = new Cesium.Viewer('cesiumContainer', {
    sceneMode: Cesium.SceneMode.SCENE2D
});

// Mouse over the globe to see the cartographic position
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(movement) {
    var cartesian = viewer.scene.pickPosition(movement.endPosition);
    if (!Cesium.defined(cartesian)) {
      console.log('undefined');
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
@thw0rted
Copy link
Contributor

I came to report that 2D picking isn't working for WMS (GetFeatureInfo), and I'm wondering if it's a subset of this issue. Demo: go to the WMS Sandcastle, select a point, watch the info load.
Now, switch to 2D, and click again. You can't select anything. This is because this call to Globe.pick is returning undefined.

(If this is a different issue, I can open a new ticket.)

@hpinkos
Copy link
Contributor Author

hpinkos commented Jul 18, 2017

Hey @thw0rted, that bug you're seeing is related to this issue:#2480
I've made a comment that you ran into this problem too

@thw0rted
Copy link
Contributor

Thanks, @hpinkos ! I didn't see any workarounds mentioned on the other ticket -- do I just need to tell customers that WMS picking won't work in 2D for now?

@hpinkos
Copy link
Contributor Author

hpinkos commented Jul 18, 2017

Yeah, unfortunately I can't think of a good workaround. It's labeled high priority, but I'm not sure when we'll get a chance to look at it. If you'd like to take a stab at a solution, comment in that issue and someone from the team can give you some tips on where to get started.

@thw0rted
Copy link
Contributor

Unfortunately the "hard math" bits are my biggest weakness -- I can usually track what everything is doing but once the vectors start normalizing I have to "step over" in the debugger :D

@OmarShehata
Copy link
Contributor

@vhive-jonathan-carse
Copy link

A very useful workaround for anyone getting here:

var viewer = new Cesium.Viewer("cesiumContainer");

var sseh = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);

sseh.setInputAction(function(event) {
  console.log('x', event.position);
  
  var cartesian = viewer.camera.pickEllipsoid(
    event.position,
    viewer.scene.globe.ellipsoid
  );
  
  //const pp = viewer.scene.pickPosition(event.position);
  
  if (cartesian) {
    const cart = Cesium.Cartographic.fromCartesian(cartesian);
    console.log(cart.longitude * (180 / Cesium.Math.PI));
    console.log(cart.latitude  * (180 / Cesium.Math.PI));
  }
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants