Best Practice for Scripting Camera Views

I’m trying to script specific camera views during playback, so that at certain times during an animation, the camera automatically moves to another location or focuses on another object. I’d like that to also work when scrubbing the timeline as well. However, the camera view should only change during the those specific time points.

My current approach seems a little adhoc and I’m wondering if there’s a better approach. I can’t share the code, but I’ll describe it best I can:

Create a TimeIntervalCollection, within which each TimeInterval is a period of time during which a specific camera view is used. I store the desired camera state is each TimeInterval, along with a flag that indicates whether I have already used that view.

Within the clock tick callback, I look for the corresponding TimeInterval. If that view has not been used, I switch to it, set the “used” flag, and clear the flags for all other views. Otherwise, the code does nothing and the animation continues.

Based on the API docs, that seems like a good enough approach. (?)

Using Cesium 1.55, macOS with latest versions of Chrome/Firefox.

Thanks!

I thought I had responded to this already, apologies for the delay!

I think what you’re doing now is your best bet. It would be nice if the camera was integrated more with the timeline, I posted an issue with some thoughts on this here:

https://github.com/AnalyticalGraphicsInc/cesium/issues/7657