[help] Added entities do not render until after time animation stops


I have provided Cesium time series data, and when I scrub the timeline it animates.

I’m am trying to transition to realtime data (not a giant list of time data).

So, during time animation, some new data is added with dataSource.entities.add(thing) on each time change.

It seems to work, except that the added things do not appear on screen until after I stop scrubbing the timeline bar, as if their rendering is queued/deferred/debounced until I stop changing time.

How do I fix this?

Also asked on StackOverflow (I will sync the answers)

EDIT: Note, on each time change, I remove the previous entities, and add new ones (not efficient I suppose, but it should at least work, it is only a handful of objects). I haven’t tried mutating the entities each time change, rather than recreating them, yet.

Ok, there are two problems.

Problem 1

One of them is that a polyline worker is created only when lines are added, and immediately disposed when no lines remain, based on the following threads plus the behavior that I observe:

The following code is needed once, initially, in order to ensure that a line worker exists all of the time, by making an invisible dummy line, in order to ensure that things stay on screen when removing then adding new lines:

				new Cesium.Entity({
					name: 'dummy line to keep polyline web worker alive',
					polyline: {
						positions: [new Cesium.Cartesian3(0, 0, 0), new Cesium.Cartesian3(1, 1, 1)],
						arcType: Cesium.ArcType.NONE, // required, or runtime error
						material: new Cesium.PolylineDashMaterialProperty({color: Cesium.Color.CYAN}), // required, or else no worker!

You can’t see the line, but it causes the worker to be around all the time because the line is around all the time, added only once during initialization.

Before adding this dummy line to keep a worker alive, here’s what it looks like each time that time is animated:

After adding the dummy line and keeping a worker alive, lines no longer disappear while animating time:

Problem 2

Although the dummy line trick keeps lines visible in the rendering during time animation, only the last lines visible before time animation started are visible, and any new lines added during time animation are not rendered until time animation stops.

Note, as I described above, I am adding new lines whenever time changes (during time animation), however they don’t show until time stops. Old lines (the ones still visible during time animation) should no longer be visible, however they remain erroneously visible.

TLDR, two problems: without workers, no lines show at all during time animation. With workers, only the last lines before time animation started are visible during time animation but some other problem prevents the rendering to be fully updated.

Overall, this API is very confusing for end users; I’ve no idea how to change this undesirable behavior.

I tried mutating an existing set of lines, rather than removing and adding new ones every time change, but the behavior remains the same: rendering doesn’t update until after time animation is stopped.

Cesium team, can you please make the API intuitive?

I was able to work around the problem by using Cesium.CallbackProperty (on persisted line objects) for the position updates (as opposed to removing old lines and adding new lines).

I believe this shouldn’t be required. Adding and removing entities should always re-draw with the new set of entities.

1 Like

Hello there,

Thanks for the detailed breakdown! Additionally, would you mind providing a sandcastle code example that replicates the problem? It’ll help troubleshoot in case any particular scene option or other behavior is contributing to this.

We do generally recommend mutating a pool of geometries rather than adding and removing them for the sake of performance. Here’s some info on the design philosophy behind the entity API that may help.