CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13k stars 3.5k forks source link

Camera orientation problem with sampledPositionProperty and trackedEntity #12293

Closed lukemckinstry closed 6 days ago

lukemckinstry commented 2 weeks ago

What happened?

When we have an Entity with a SampledPositionProperty set as trackedEntity, and change the position by a large distance (ie. > 0.01 degree lon or lat) the orientation of the camera changes during the repositioning.

Reported in the forums https://community.cesium.com/t/camera-position-problem-with-sampledpositionproperty-and-trackedentity/36360

From my own reproduction Screencast from 11-07-2024 12:45:46 PM.webm

Reproduction steps

1. 2. 3. ...

Sandcastle example

https://sandcastle.cesium.com/index.html#c=pVdbU+M2FP4rmrysMzVKAuxuGy5TCuwsLcxSYPuUF2GfEBVZykhyQrqT/96jix3bCVt2CsOMfSR95zvfuchkShpLFhyWoMkJkbAk52B4WdC/vC2Z9DL/fq6kZVyCnvRS8m0iCeFyqn5TL2MyZcJA6kwGBGSWK3klc54xq3RrdcZytTRjYnVZWVQp8jPJC2ahtq/7RxMZfjNPD1l9EvxpZg1S9L4nva/3l3eT3ji8EiKYHZPDQzp8Pzz4OPyQRquSY7I32j+gw4+Hhx9Gv0Q7E7h7tD+Mr2aej0kpc5higHk0Wv28bZwrw11840qlc6YtPjF5QKdaFRfwpAFM0vLZ5OW89j3YGgP1cU5L6TUjMyZzAX/A6kItZQILkLZfxReE4DLTUKAddRjS4eiIDAbkLP+7xDVmUCfIIY+hgyXfnCypUyF1IZN1yHDUkjoJPQOvwZLbbEaCW/oMq9q1d88MkHfLd+ONKepIfjoho6EncuXYuY1o5rbMgTyucA1F5Na0Dz7ixuejLr7Zhb9X41/A/8Q/01otv867XlAkF0Utrnd2oxZApNJ29mZkl7Zd2Hs7sY0qfwD7GqZ2CxtrZjf2Eox9M/Sdq4Zd2Ls1wQz8Bza2DCuxw9q7NNhSS49z+cItmSpNlJ3h2MFii+lbV9UYyr3qNizb77ebr3Bf61ga/UilU+nV6HA/lNLOalotOZT6GWGrZwSunyte0eDa2DNfcokDjrI8v3RddM2NBZyYyTuMMHfFkbZ7PMw516ncfOLauLZ2M7A9FlzRW7hROYik1AIxwPGO/RlGN0V3SAkMxXRhls6ESPqxt39QyxDTjqG5NV0DD/8SNA+eDCvmAvLbjcPGrXLfXrzVag7arpIA0DlKsUaWTOeXL1azucLUoPFhNYdNEFtL9POX64tW5DNgOZdPmzM3zM6oVXdoZtIko4P3TfpzPwdxvjZsWgnRMc3mnfvyc3Bz647f4f4k+k0DYupBmo6U5pg11k7Kg0ZKGHZh6KwD+GeJZaAlbk/qAnQ02nn2hbBCwG5hYFUmsQEkK/C2dbXUvdU6CYjrDabj5ktcLlxpjjfdVWo+xhua0kHI9gWzbOA3mUEI80IrCc1n+iQe8cOiQig4fhKUxS1/AXHP/wF3Wf+8WWUvbvU+YwJX9of4U3ViuFmDylEArI/sGfLLSpcgkN/h/sJY2ljXrc+O+lSzCSc99w3kLvJ2o6LCYaRU8iWBQrpBik0b8Kf1N832pVztwZVGI8UTtEpYnHR8SpI4Qdq3duhHi42+qbDfS4FljzkBKtUy6TcGd1QsEyp7pv7YAy9cs/lnZ5fw+oGs1BplfOVIl9XUsY17t5mhlPeAG3OTvOYjJcO02X+b00m/ybHWvlbNo/vKTGoWaVPpNt/NbPafshF6TbCcYVvttgqvkT/qHkPvbxGjFf/ou/G/UYHo+JX417EhDNgridNnwUSyVebIxLUg2a52j9NLe8fGrgScVpR+5cUcv6zcBEpwSlhAJsjbDB5LbFWsGmOqDB4PmkePc74gPD/Z8U8JyQQzBlempfAzY9I7PR7g/q2jQvm5+mUBWrCV2zYbnV4HI34YHA/wdfdJq5R4ZLqD/C8

Environment

Browser: CesiumJS Version: Operating System:

ggetz commented 2 weeks ago

@lukemckinstry I think there is a chance this is fixed in https://github.com/CesiumGS/cesium/pull/12194. Could be worth trying to reproduce in that branch.

lukemckinstry commented 1 week ago

I can still reproduce the issue in that branch.

ggetz commented 1 week ago

Thanks for trying!

jfayot commented 1 week ago

Hi @lukemckinstry. Have you tried setting entity.trackingReferenceFrame to TrackingReferenceFrame.INERTIAL ?

jfayot commented 1 week ago

@lukemckinstry I've tried your sandcastle in my branch and setting entity.trackingReferenceFrame to TrackingReferenceFrame.INERTIAL, and it behaves correctly! What you're experiencing I guess in this issue is a threshold effect with the auto-detect tracking algorithm: low altitude / low speed objects are tracked into their ENU reference frame, while high speed / high altitude objects are tracked in their VVLH frame. If you decrease the increment in handleKeyDown to 0.001 (which is equivalent to decreasing the entity's velocity) you see the orientation issue disappear... My PR aims at solving this kind of issue by adding different kind of tracking reference...

lukemckinstry commented 1 week ago

@jfayot thanks for following up. You are correct, https://github.com/CesiumGS/cesium/pull/12194 fixes this issue! :+1: