Camera position problem with sampledPositionProperty and trackedEntity

Hi I was referring to the following sandcastle to animate an entity while changing its position based on a real-time changing position.

However, I noticed that when the position changes a lot (maybe when moving fast?), the camera orientation becomes weird. What could this be related to?

I’m attaching a sandcastle (3D model and keyboard arrow events added) that I created for testing.
If the increment of the handleKeyDown function is smaller (like 0.0001), the problem does not occur.

Test Sandcastle

Thanks.

2024-11-06 12-24-39-VEED

Hi @Leafmire ,
Thanks for your post and being a part of the Cesium community.

Thanks as well for providing a clear description of you objective and working sandcastle of your current code.

it certainly seems to be the case that the orientation of the camera is changing when changing positions over larger distances.

I do think you are on the right track when you note the orientation becomes weird “maybe when moving fast”. SampledPositionProperty is intended to represent a position that can change at each time step according to some logic. This sabndcastle demonstrates Cesium Sandcastle

You also note that when you move in small increments, the camera orientation holds steady as intended. It might be the case moving such large distances in a single time step is problematic. One possible immediate solution is you could interpolate moves over several timesteps buy adding multiple incremental new time and positions to the SampledPositionProperty with the addSample function in response to a user move event.

I went ahead and opened an issue for this issue with the info you provided here in addition to some of my own screenshots. Camera orientation problem with sampledPositionProperty and trackedEntity · Issue #12293 · CesiumGS/cesium · GitHub. Feel free to follow along the issue, comment on it further, or investigate and start a fix.

I hope the solution I suggested is helpful and please let us know if you have more issues or questions.
Best,
Luke

1 Like

This PR Added Entity.trackingReferenceFrame by jfayot · Pull Request #12194 · CesiumGS/cesium · GitHub will fix the observed issue when it is released (hopefully next release on December 2, 2024). You will need to add
entity.trackingReferenceFrame = Cesium.TrackingReferenceFrame.INERTIAL;

Thanks,
Luke