Skip to content

Commit

Permalink
Merge pull request #7069 from AnalyticalGraphicsInc/update-entities
Browse files Browse the repository at this point in the history
Update Viewer on preUpdate instead of clock tick
  • Loading branch information
mramato authored Sep 26, 2018
2 parents c448444 + 950fbb5 commit 19b6914
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -3249,6 +3249,10 @@ define([
var us = context.uniformState;
var frameState = this._frameState;

// Update with previous frame's time, assuming that render is called before picking.
this._preUpdate.raiseEvent(this, frameState.time);
this._postUpdate.raiseEvent(this, frameState.time);

var view = this._defaultView;
this._view = view;

Expand Down
6 changes: 2 additions & 4 deletions Source/Widgets/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to

var eventHelper = new EventHelper();

eventHelper.add(clock.onTick, Viewer.prototype._onTick, this);
eventHelper.add(scene.preUpdate, Viewer.prototype._onPreUpdate, this);
eventHelper.add(scene.morphStart, Viewer.prototype._clearTrackedObject, this);

// Selection Indicator
Expand Down Expand Up @@ -1586,9 +1586,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to
/**
* @private
*/
Viewer.prototype._onTick = function(clock) {
var time = clock.currentTime;

Viewer.prototype._onPreUpdate = function(scene, time) {
var isUpdated = this._dataSourceDisplay.update(time);
if (this._allowDataSourcesToSuspendAnimation) {
this._clockViewModel.canAnimate = isUpdated;
Expand Down
6 changes: 3 additions & 3 deletions Specs/Widgets/Viewer/ViewerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,22 +973,22 @@ defineSuite([

viewer.selectedEntity = entity;

viewer.clock.tick();
viewer.render();
expect(viewModel.showInfo).toBe(true);
expect(viewModel.titleText).toEqual(entity.id);
expect(viewModel.description).toEqual('');

entity.name = 'Yes, this is name.';
entity.description = 'tubelcane';

viewer.clock.tick();
viewer.render();
expect(viewModel.showInfo).toBe(true);
expect(viewModel.titleText).toEqual(entity.name);
expect(viewModel.description).toEqual(entity.description.getValue());

viewer.selectedEntity = undefined;

viewer.clock.tick();
viewer.render();
expect(viewModel.showInfo).toBe(false);
expect(viewModel.titleText).toEqual('');
expect(viewModel.description).toEqual('');
Expand Down

0 comments on commit 19b6914

Please sign in to comment.