How do I manage extrapolation of multiple cesium entity models in a viewer, using Sampled Position Property?

I could get it to work with a single model but could not figure out how to manage extrapolation of approximately 20 models. The position data is real time for 20 models coming in through websocat server with 2-8 seconds time interval (different for each entity), I want to extrapolate the models between updates in order to give them a smoothing effect and not make them jumpy.

NOTE: New to cesium, if I’m missing something very obvious or more information is needed please let me know.

SampledProperty could help you!

Assume you have the data structure like:

{
  id: 1,
  longitude: 100,
  latitude: 20,
  time: 1887766554433
}

Recommend you use a map to store your entities

const map = new Map<number, Cesium.Entity>()
// ...
const e = viewer.entities.add(/* */)
map.set(id, e)

So you can easily check your data in websocket callback.

Use SampledProperty to make it move smoothly

const e = viewer.entities.add({
  position: new Cesium.SampledPositionProperty()
})

// to update it
const pos = e.position
pos.addSample(/* ... */)