Clock Multiplier Inconsistencies

Background: I need to modify the Cesium Clock / Timeline widget to match my datasets. My datasets consist of weather forecast models which are comprised of “forecast hours,” which are generally released for 60-minute or 180-minute intervals.

Problem: I set the Clock widget constraints based on the weather forecast model’s parameters which give me the startTime and stopTime. currentTime is startTime. multiplier is 1800x, as I wish to move forward 30-minutes per second by default. However, when I click the play button, the clock moves forward at a ridiculous rate. If I pause, adjust the shuttle ring to a different multiplier and then back to the default multiplier, the animation works as expected.

Other notes: I modify the AnimationViewModel with pre-defined Shuttle Ring Ticks and snapToTicks set to true. This does not seem to have any impact on the problem.

Code:

var start = ‘2016-10-25T18:00:00.000Z’;

var startTime = Cesium.JulianDate.fromIso8601(start);

var stopTime = Cesium.JulianDate.fromIso8601(start);

Cesium.JulianDate.addSeconds(stopTime, 108000, stopTime);

viewer.clock.currentTime = startTime.clone();

viewer.clock.startTime = startTime.clone();

viewer.clock.stopTime = stopTime.clone();

viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;

viewer.clock.clockStep = Cesium.ClockStep.TICK_DEPENDENT;

viewer.clock.multiplier = 1800.0;

viewer.clock.shouldAnimate = false;

viewer.timeline.updateFromClock();

if(stopTime > startTime) {

viewer.timeline.zoomTo(startTime.clone(), stopTime.clone());

}

viewer.clock.onTick.addEventListener(function(clock) {

// likely irrelevant code here which references other
// functions used for changing the WMS parameters.

});

viewer.animation.viewModel.snapToTicks = true;

viewer.animation.viewModel.setShuttleRingTicks([1800.0, 3600.0, 7200.0, 9000.0]);

``

I have created a video to describe this but I was actually able to reproduce the issue in Sandcastle as well.

Steps to Reproduce:

  1. Copy the code above to Sandcastle. http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html

  2. Hit play. Notice the time is moving way too fast.

  3. Hit pause. Move the Shuttle Ring to a different multiplier.

  4. Move the multiplier back to the default of 1800x.

  5. Hit play again. Notice time is moving at ~30 seconds per real second, as is the expected behavior.

Re-arranging the code has not fixed the problem for me. I appreciate any insight into what might be the cause of these inconsistencies and if there is anything I can change in my code to fix them.

Thanks for your time.

Hello,

The problem seems to be caused by using viewer.clock.clockStep = Cesium.ClockStep.TICK_DEPENDENT;

If you omit this line, your code works as expected. Do you have a reason for using TICK_DEPENDENT?

I think as soon as you move the animation pointer it sets the clockStep to SYSTEM_CLOCK_MULTIPLIER, which is why the animation works after you move the shuttle ring.

Best,

Hannah

The error was my misunderstanding of the TICK_DEPENDENT option.

The description says…
Clock#tick advances the current time by a fixed step, which is the number of seconds specified by Clock#multiplier.

And my broken comprehension focused on everything but the first word / reference to Clock#tick.

This makes a lot more sense now. Thanks for taking the time to assist me with a seemingly obvious error.