CesiumGS / CesiumGS/cesium

viewer.scene.pick does not work with non-integer width and height on ipad

Open
#8,362 4 comments 0 reactions 0 assignees View on GitHub
category - picking type - bug
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

The function `pick(windowPosition, width, height)` does not work well with non-whole numbers, and this makes it difficult to pick entities on touch devices where PointerEvents contain a width and height that are not whole numbers. Initially I saw this issue on the iPad Pro, but the Sandcastle example I have attached can demonstrate the issue on a PC with a mouse. The `pointerdown` event produced by an iPad Pro has a width/height similar to 30.55859385, and it takes multiple attempts to pick an entity if I use that width and height directly. If I instead pass Math.floor(e.width) and Math.floor(e.height), it works as expected.

Sandcastle example:
I have set up a sandcastle with a point entity, and when the entity is picked, its ID is logged to the console. The picking width/height are hardcoded to 30.55, and you should find it is difficult to pick a point. If you click the 'set to 30' button, it will be very easy to pick the point.

https://sandcastle.cesium.com/#c=jVRhT9swEP0rVr40FZkDY0hTKWhQqoFUWkTZGFIk5MaX1sK1q9hp6Qb/fec4KS3RNCpVupx97969d8mS5WQpYAU5OSEKVqQHRhRz+rPMha20fOxpZZlQkLci8idRBH8GJKRWaHWluEiZ1XmHZEwaiPy5UJk+189VMlGv7eNEJSqOydiy3JKVsDNiZ4ABLyNmCddgVAvPdP6UqCVS84cn5HCfHh0d+9wMxHRmt5IV7hnnZFJYq5VJ1JgpnjJjJVDG+Z3WcsLy8/I0bI3BEqt9PU6UFaqcJGzXw71v63KNttVEH+v0nzbNHsc7khUTk+ZiAg5soYWy6BcsQVkcleu0mGNIp2D7Elx4vr7iTe/ajmDfVQ2EsaCcvxUY1yu1TRHaJUUn91wXBm60Ee5gd0l6aCRGTH0OgeosM2B/RaQOHzx9j1L2wWq/a9Sk2J4uRPoU7uBHXpOoUqJd6uL+IiNhhYEUCinJy4sHpYLXuY2whKS4BRotkXoaJsFQE5xa2DXi5uB3r2zUIUlA9nzsm70SwH39F1BPImXgvqpu7xjsudQbbhN2Y+fWtpacBKCHlSx1whkVVhQEdyTLXgdJUL1di0qvTsOKQ5rlen4B0xzAhJ++HkXkC/7329H2it1ChkKoFDYAl7t52hucXd883o0ev9+OfgwvNn2RRudNnYV4BjkWvxHnMKqTurASF66npfso1ATdE72/vLrrv7947504iN40b1Y+9AeD0f3mykfHGI6GfV9TOxBEQdfYtYRTn/8m5guNH6QilyGlsYX5QjLUMp4UaLWlqTGurBvXRV0ulujKSRK8e8HQ81QyY/Akw210siTBaTfG+ztlUjMu1HS0hFyytbsyOzgd+CSltBvjY7PK+i/LFuJf

Browser / OS:
Google Chrome on Windows 7
Safari on iPad Pro

Contributor guide

Open the contributing guide

Research direction

Start with the viewer.scene.pick(windowPosition, width, height) entry point and reproduce the issue using the linked Sandcastle example with fractional dimensions. Compare picking behavior for 30.55 and 30, then verify that pointer-event width and height values work reliably without flooring; done means the point can be picked consistently on the reported touch and desktop scenarios.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.