How can I control viewer time and ticks?

Hey guys!

What I'd like to do is control the clock ticks for a non-realtime application. Imagine there's expensive code running, plus I want to give the viewer time to load the tiles before continuing. So how do I disable automatic ticking, and then call tick() when my code is ready for it?

Docs for Cesium.Clock say "The clock will only tick when both Clock#canAnimate and Clock#shouldAnimate are true." but that's not what I'm getting.
What I currently see:

viewer.clock.canAnimate = false;
viewer.clock.shouldAnimate = false;
viewer.clock.onTick.addEventListener(function(clock){
    console.log("Tick");
});

Tick
Tick
Tick
Tick
...

What I'd like to do:

viewer.clock.stopTicking(); // or whatever that command would be...
while (someCondition){
    // run expensive code
    tick(); // issue manual tick
}

Thanks for your help!
Max

Hi Max,

According to the documentation, the tick event should be called every frame, regardless of whether animation is taking place or not. It advances the clock from the current time based on the current configuration options.

Do you want to run your code between the frames, or just before the time advances? If the latter, you should be able to do so by toggling shouldAnimate accordingly.

Hope that clears things up.

Thanks,

Gabby