Skip to content

Commit e0dc8ef

Browse files
authored
Merge pull request #4007 from AnalyticalGraphicsInc/clockRealtimeMode
Move logic for real-time mode (SYSTEM_CLOCK) into Clock itself.
2 parents d238e98 + 8176ef2 commit e0dc8ef

File tree

8 files changed

+559
-408
lines changed

8 files changed

+559
-408
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Change Log
99
* Fix some large polygon triangulations. [#2788](https://github.com/AnalyticalGraphicsInc/cesium/issues/2788)
1010
* Improved performance and accuracy of polygon triangulation by using the [earcut](https://github.com/mapbox/earcut) library. Loading a GeoJSON with polygons for each country was 2x faster.
1111
* Added CZML support for Box, Corridor and Cylinder
12+
* `Clock` now keeps its configuration settings self-consistent. Previously, this was done by `AnimationViewModel` and could become inconsistent in certain cases. [#4007](https://github.com/AnalyticalGraphicsInc/cesium/pull/4007)
1213

1314
### 1.22 - 2016-06-01
1415

Source/Core/Clock.js

+176-72
Large diffs are not rendered by default.

Source/DataSources/DataSourceClock.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ define([
2020
'use strict';
2121

2222
/**
23-
* Represents CZML document-level clock settings.
23+
* Represents desired clock settings for a particular {@link DataSource}. These settings may be applied
24+
* to the {@link Clock} when the DataSource is loaded.
2425
*
2526
* @alias DataSourceClock
2627
* @constructor
@@ -50,45 +51,48 @@ define([
5051
},
5152

5253
/**
53-
* Gets or sets the start time of the clock to use when looping or clamped.
54+
* Gets or sets the desired start time of the clock.
55+
* See {@link Clock#startTime}.
5456
* @memberof DataSourceClock.prototype
5557
* @type {JulianDate}
5658
*/
5759
startTime : createRawPropertyDescriptor('startTime'),
5860

5961
/**
60-
* Gets or sets the stop time of the clock to use when looping or clamped.
62+
* Gets or sets the desired stop time of the clock.
63+
* See {@link Clock#stopTime}.
6164
* @memberof DataSourceClock.prototype
6265
* @type {JulianDate}
6366
*/
6467
stopTime : createRawPropertyDescriptor('stopTime'),
6568

6669
/**
67-
* Gets or sets the initial time to use when switching to this clock.
70+
* Gets or sets the desired current time when this data source is loaded.
71+
* See {@link Clock#currentTime}.
6872
* @memberof DataSourceClock.prototype
6973
* @type {JulianDate}
7074
*/
7175
currentTime : createRawPropertyDescriptor('currentTime'),
7276

7377
/**
74-
* Gets or sets how the clock should behave when <code>startTime</code> or <code>stopTime</code> is reached.
78+
* Gets or sets the desired clock range setting.
79+
* See {@link Clock#clockRange}.
7580
* @memberof DataSourceClock.prototype
7681
* @type {ClockRange}
7782
*/
7883
clockRange : createRawPropertyDescriptor('clockRange'),
7984

8085
/**
81-
* Gets or sets if clock advancement is frame dependent or system clock dependent.
86+
* Gets or sets the desired clock step setting.
87+
* See {@link Clock#clockStep}.
8288
* @memberof DataSourceClock.prototype
8389
* @type {ClockStep}
8490
*/
8591
clockStep : createRawPropertyDescriptor('clockStep'),
8692

8793
/**
88-
* Gets or sets how much time advances with each tick, negative values allow for advancing backwards.
89-
* If <code>clockStep</code> is set to ClockStep.TICK_DEPENDENT this is the number of seconds to advance.
90-
* If <code>clockStep</code> is set to ClockStep.SYSTEM_CLOCK_MULTIPLIER this value is multiplied by the
91-
* elapsed system time since the last call to tick.
94+
* Gets or sets the desired clock multiplier.
95+
* See {@link Clock#multiplier}.
9296
* @memberof DataSourceClock.prototype
9397
* @type {Number}
9498
*/
@@ -163,10 +167,10 @@ define([
163167
}
164168
result.startTime = this.startTime;
165169
result.stopTime = this.stopTime;
170+
result.currentTime = this.currentTime;
166171
result.clockRange = this.clockRange;
167-
result.clockStep = this.clockStep;
168172
result.multiplier = this.multiplier;
169-
result.currentTime = this.currentTime;
173+
result.clockStep = this.clockStep;
170174
return result;
171175
};
172176

Source/Widgets/Animation/AnimationViewModel.js

+3-23
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ define([
2929
var realtimeShuttleRingAngle = 15;
3030
var maxShuttleRingAngle = 105;
3131

32-
function cancelRealtime(clockViewModel) {
33-
if (clockViewModel.clockStep === ClockStep.SYSTEM_CLOCK) {
34-
clockViewModel.clockStep = ClockStep.SYSTEM_CLOCK_MULTIPLIER;
35-
clockViewModel.multiplier = 1;
36-
}
37-
}
38-
39-
function unpause(clockViewModel) {
40-
cancelRealtime(clockViewModel);
41-
clockViewModel.shouldAnimate = true;
42-
}
43-
4432
function numberComparator(left, right) {
4533
return left - right;
4634
}
@@ -284,10 +272,9 @@ define([
284272
var pauseCommand = createCommand(function() {
285273
var clockViewModel = that._clockViewModel;
286274
if (clockViewModel.shouldAnimate) {
287-
cancelRealtime(clockViewModel);
288275
clockViewModel.shouldAnimate = false;
289276
} else if (that._canAnimate) {
290-
unpause(clockViewModel);
277+
clockViewModel.shouldAnimate = true;
291278
}
292279
});
293280

@@ -300,7 +287,6 @@ define([
300287

301288
var playReverseCommand = createCommand(function() {
302289
var clockViewModel = that._clockViewModel;
303-
cancelRealtime(clockViewModel);
304290
var multiplier = clockViewModel.multiplier;
305291
if (multiplier > 0) {
306292
clockViewModel.multiplier = -multiplier;
@@ -317,7 +303,6 @@ define([
317303

318304
var playForwardCommand = createCommand(function() {
319305
var clockViewModel = that._clockViewModel;
320-
cancelRealtime(clockViewModel);
321306
var multiplier = clockViewModel.multiplier;
322307
if (multiplier < 0) {
323308
clockViewModel.multiplier = -multiplier;
@@ -333,15 +318,12 @@ define([
333318
});
334319

335320
var playRealtimeCommand = createCommand(function() {
336-
var clockViewModel = that._clockViewModel;
337-
clockViewModel.clockStep = ClockStep.SYSTEM_CLOCK;
338-
clockViewModel.multiplier = 1.0;
339-
clockViewModel.shouldAnimate = true;
321+
that._clockViewModel.clockStep = ClockStep.SYSTEM_CLOCK;
340322
}, knockout.getObservable(this, '_isSystemTimeAvailable'));
341323

342324
this._playRealtimeViewModel = new ToggleButtonViewModel(playRealtimeCommand, {
343325
toggled : knockout.computed(function() {
344-
return clockViewModel.shouldAnimate && clockViewModel.clockStep === ClockStep.SYSTEM_CLOCK;
326+
return clockViewModel.clockStep === ClockStep.SYSTEM_CLOCK;
345327
}),
346328
tooltip : knockout.computed(function() {
347329
return that._isSystemTimeAvailable ? 'Today (real-time)' : 'Current time not in range';
@@ -350,7 +332,6 @@ define([
350332

351333
this._slower = createCommand(function() {
352334
var clockViewModel = that._clockViewModel;
353-
cancelRealtime(clockViewModel);
354335
var shuttleRingTicks = that._allShuttleRingTicks;
355336
var multiplier = clockViewModel.multiplier;
356337
var index = getTypicalMultiplierIndex(multiplier, shuttleRingTicks) - 1;
@@ -361,7 +342,6 @@ define([
361342

362343
this._faster = createCommand(function() {
363344
var clockViewModel = that._clockViewModel;
364-
cancelRealtime(clockViewModel);
365345
var shuttleRingTicks = that._allShuttleRingTicks;
366346
var multiplier = clockViewModel.multiplier;
367347
var index = getTypicalMultiplierIndex(multiplier, shuttleRingTicks) + 1;

0 commit comments

Comments
 (0)