cesium icon indicating copy to clipboard operation
cesium copied to clipboard

scene.pick get wrong result at same position

Open QianWu184 opened this issue 4 years ago • 9 comments

I‘m trying to get entity by scene.pick。 I found that sometimes it get wrong result. i use code like: setInputAction(function(event) { console.log(event.position) let model = viewer.scene.pick(event.position); if (model && model.id) { console.log(model.id.id) } }, ScreenSpaceEventType.LEFT_DOWN) In the map, i clicked green position three times image

then i got three different entity: image

Is there something I did wrong?

QianWu184 avatar May 22 '21 13:05 QianWu184

Hi @QianWu184 - are you able to share a Sandcastle that reproduces this issue?

ebogo1 avatar May 24 '21 23:05 ebogo1

Hi @QianWu184 - are you able to share a Sandcastle that reproduces this issue?

Thanks your attention,but i'm afraid i can't provid Sandcastle to you(It's too long. Basically, it's building 100 entities, arranging them like a grid, and trying to get one of them by LEFT_DOWN).And is there any possible reason for this problem?

QianWu184 avatar May 25 '21 01:05 QianWu184

@QianWu184 This doesn't seem like correct behavior but it's tough to diagnose the issue.. I was unable to reproduce the behavior in this Sandcastle with multiple models arranged in a line.

Are you able to identify which entities are being picked when you are clicking?

ebogo1 avatar May 25 '21 23:05 ebogo1

@QianWu184 This doesn't seem like correct behavior but it's tough to diagnose the issue.. I was unable to reproduce the behavior in this Sandcastle with multiple models arranged in a line.

Are you able to identify which entities are being picked when you are clicking?

In fact, each Entity is just a polygon geometry. I just want to click and drag the Entity where the green dot is located. But the results obtained through viewer.scene.pick the previous few times are always wrong. For example, in the image above, I want to get the corresponding Entity by clicking on the green position. But these three numbers indicate the three different results when I clicked on the green dot.The yellow background is just the effect I made to confirm the current actual selected result。

QianWu184 avatar May 26 '21 03:05 QianWu184

@QianWu184 This doesn't seem like correct behavior but it's tough to diagnose the issue.. I was unable to reproduce the behavior in this Sandcastle with multiple models arranged in a line.

Are you able to identify which entities are being picked when you are clicking?

This problem does not seem to exist when the Entity has only one row or I click on the edge of the Entity. But if you arrange them into multiple rows and click on the Entity in the middle, this problem seems to occur.

QianWu184 avatar May 26 '21 03:05 QianWu184

Here's a different Sandcastle that has 100 entities in a 10 x 10 grid. What are you doing differently? I'm testing on Windows 10 using Chrome.

GatorScott avatar May 26 '21 13:05 GatorScott

Thanks @GatorScott - in macOS/Chrome your Sandcastle works for me as well.

ebogo1 avatar May 26 '21 14:05 ebogo1

Here's a different Sandcastle that has 100 entities in a 10 x 10 grid. What are you doing differently? I'm testing on Windows 10 using Chrome.

This can also run successfully here. Maybe I should check if my code has offset the coordinates

QianWu184 avatar May 27 '21 02:05 QianWu184

Hi @QianWu184. In my work, i encounter the same problem which you stated. Have you solved this problem yet?

robert6757 avatar Dec 18 '23 08:12 robert6757