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:
-
Copy the code above to Sandcastle. http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html
-
Hit play. Notice the time is moving way too fast.
-
Hit pause. Move the Shuttle Ring to a different multiplier.
-
Move the multiplier back to the default of 1800x.
-
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.