From fb91f3b29795b9ff69a66057c83db18bdb0d3917 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 25 Sep 2018 23:44:26 -0400 Subject: [PATCH 1/4] Update viewer on preUpdate rather than clock tick --- Source/Scene/Scene.js | 4 ++++ Source/Widgets/Viewer/Viewer.js | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 436293542ab2..f5d3a07dde79 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -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; diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 528fddd8f1ad..4c661f9fe9e5 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -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._onUpdate, this); eventHelper.add(scene.morphStart, Viewer.prototype._clearTrackedObject, this); // Selection Indicator @@ -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._onUpdate = function(scene, time) { var isUpdated = this._dataSourceDisplay.update(time); if (this._allowDataSourcesToSuspendAnimation) { this._clockViewModel.canAnimate = isUpdated; From bb57d780bde106ab05a8811cef8e16ce6e11e563 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 26 Sep 2018 09:36:25 -0400 Subject: [PATCH 2/4] Fix test --- Specs/Widgets/Viewer/ViewerSpec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Specs/Widgets/Viewer/ViewerSpec.js b/Specs/Widgets/Viewer/ViewerSpec.js index 6de5697812e3..73edb08eb36f 100644 --- a/Specs/Widgets/Viewer/ViewerSpec.js +++ b/Specs/Widgets/Viewer/ViewerSpec.js @@ -973,7 +973,7 @@ defineSuite([ viewer.selectedEntity = entity; - viewer.clock.tick(); + viewer.scene.render(); expect(viewModel.showInfo).toBe(true); expect(viewModel.titleText).toEqual(entity.id); expect(viewModel.description).toEqual(''); @@ -981,14 +981,14 @@ defineSuite([ entity.name = 'Yes, this is name.'; entity.description = 'tubelcane'; - viewer.clock.tick(); + viewer.scene.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.scene.render(); expect(viewModel.showInfo).toBe(false); expect(viewModel.titleText).toEqual(''); expect(viewModel.description).toEqual(''); From 1dd7250fcd506ceb135377a00a4f8732a9f2f473 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 26 Sep 2018 10:24:26 -0400 Subject: [PATCH 3/4] Rename onUpdate to onPreUpdate --- Source/Widgets/Viewer/Viewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 4c661f9fe9e5..1df07a286ce9 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -457,7 +457,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to var eventHelper = new EventHelper(); - eventHelper.add(scene.preUpdate, Viewer.prototype._onUpdate, this); + eventHelper.add(scene.preUpdate, Viewer.prototype._onPreUpdate, this); eventHelper.add(scene.morphStart, Viewer.prototype._clearTrackedObject, this); // Selection Indicator @@ -1586,7 +1586,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to /** * @private */ - Viewer.prototype._onUpdate = function(scene, time) { + Viewer.prototype._onPreUpdate = function(scene, time) { var isUpdated = this._dataSourceDisplay.update(time); if (this._allowDataSourcesToSuspendAnimation) { this._clockViewModel.canAnimate = isUpdated; From 950fbb568a72af39b3f6dbfec444d5aaba5ce072 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 26 Sep 2018 10:28:08 -0400 Subject: [PATCH 4/4] Use viewer.render instead of viewer.scene.render in tests --- Specs/Widgets/Viewer/ViewerSpec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Specs/Widgets/Viewer/ViewerSpec.js b/Specs/Widgets/Viewer/ViewerSpec.js index 73edb08eb36f..4b6d3271f2e0 100644 --- a/Specs/Widgets/Viewer/ViewerSpec.js +++ b/Specs/Widgets/Viewer/ViewerSpec.js @@ -973,7 +973,7 @@ defineSuite([ viewer.selectedEntity = entity; - viewer.scene.render(); + viewer.render(); expect(viewModel.showInfo).toBe(true); expect(viewModel.titleText).toEqual(entity.id); expect(viewModel.description).toEqual(''); @@ -981,14 +981,14 @@ defineSuite([ entity.name = 'Yes, this is name.'; entity.description = 'tubelcane'; - viewer.scene.render(); + viewer.render(); expect(viewModel.showInfo).toBe(true); expect(viewModel.titleText).toEqual(entity.name); expect(viewModel.description).toEqual(entity.description.getValue()); viewer.selectedEntity = undefined; - viewer.scene.render(); + viewer.render(); expect(viewModel.showInfo).toBe(false); expect(viewModel.titleText).toEqual(''); expect(viewModel.description).toEqual('');