visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.14k stars 2.08k forks source link

[Bug] Inconsistent world coordinates returned by pickObject method #8994

Open Danon29 opened 3 months ago

Danon29 commented 3 months ago

Description

When using the pickObject method to transform screen coordinates to world coordinates, the resulting coordinates (x, y, z) vary slightly and seem to be influenced by the position of the camera. This inconsistency makes it difficult to accurately interact with 3D objects on the map.

I have a 3D object with a fixed height of 15. However, the unproject method returns slightly different z values for the same point, even though the height should consistently be 15.

Here are some example coordinates that were obtained when hovering over a 3D object on the map. The object has a fixed height of 15, but the z values returned are slightly different each time:

Expected height: 15

Unprojected coordinates:

(3) [14.967373591089833, 55.215464098258174, 15.006034213629] (3) [14.967371362548931, 55.21546726508324, 15.00713966500024] (3) [14.96737136262501, 55.215467265098205, 15.00713966500024] (3) [14.967368298183448, 55.21547185649847, 15.008745031010902] (3) [14.967368298269019, 55.215471856518064, 15.008745031010902] (3) [14.967366348143466, 55.2154759730605, 15.009797201422398] (3) [14.967366348237713, 55.21547597308487, 15.009797201422398]

Flavors

Expected Behavior

The (x, y, z) coordinates should be consistent for the same point on the object, and the z value should be exactly 15 regardless of the camera's position.

Steps to Reproduce

Move the camera to different positions. Use the unproject method to convert screen coordinates back to world coordinates. Observe the variation in the (x, y, z) coordinates for the same point on the object.

Environment

Logs

No response

Pessimistress commented 3 months ago

Use the unproject method to convert screen coordinates back to world coordinate

Which "unproject method" are you taking about?

Danon29 commented 2 months ago

Use the unproject method to convert screen coordinates back to world coordinate

Which "unproject method" are you taking about?

Sorry, I meant the pickObject method

Pessimistress commented 2 months ago

pickObject performs unprojection from the screen space, so some precision loss is expected. There was a similar discussion in https://github.com/visgl/deck.gl/issues/7698#issuecomment-1450645228