[beginner] I'd like to move my camera along the user position on the smartphone

Hello guys and thanks in advance for your help.

I'm a student and for my stage I have to create more or less a 3D Waze for pilotes on smartphones, but I'm kinda lost with all the Cesium/Cordova environments and APIs.

I'd like to create an entity on our position so the camera follows it and mostly update its position along the position of the smartphone at the time being, every second if that's possible.

My problem is that I have no idea how to get our current position variable and mostly update it while we move with the smartphone.

I know this is very general but I'd like a least a good lead or some code examples, because I've search a lot on the Internet and every examples I find don't fit with my code and break it so I have no idea what's supposed to work.

I've linked my index.html so you can see my project atm and especially my 2 viewers containers which seem to complicate my whole problem.

Thanks a lot for your ideas !

index.html (10.8 KB)

4:14 PM (less than a minute ago)
Let me reformulate because my confusion is visible :

I know I have more or less to create a loop to update any model position but I'm really confused on the method to have it permanent and according to our constant and fast speed update in this case.
I find coordinates management really confusing on Cesium ^^'

You should be able to just query the device location (get the longitude and latitude) and then add it to a SampledProperty with a timestamp. You could then use Cesium’s built-in interpolation or extrapolation to smooth between the time samples. This is a good code example on how sampled properties work. Both the vehicle’s position as well as the wheel’s angle are all controlled by these sampled properties. So even though it’s not taking data in real time, it would be the same idea for your application. Instead of adding the sample all at once at the beginning, you could add samples as often as you can query the device for:

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=Time Dynamic Wheels.html

Let me know if that helps!

Thanks for your help !

I already saw this code and I will dig into it to test, but I don't feel like it will solve my main problem.

I already have my smartphone location initialized but I need to update it while the application is on the run.
In this case, it is "just" a pre-defined trajectory while I'd like to see my model move along the position of the smartphone, which I can't manage to update properly after the initialization.

Thank you if you may guide me a little more !

You should be able to create a sampled property, and instead of adding all the samples to it upfront, add the samples as you get them from your device.

If that still doesn’t work, please create a code example of what you have so far and I’d be happy to take a look.