From 319c2ca9bee80c0ab6d9ed24986deaeb622675f6 Mon Sep 17 00:00:00 2001 From: ggetz Date: Mon, 26 Feb 2018 13:35:31 -0500 Subject: [PATCH] RequestRender when loadQueue is not empty --- CHANGES.md | 1 + Source/Scene/Globe.js | 13 ++++++++++++- Source/Scene/Scene.js | 10 +++++++--- Specs/createGlobe.js | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c34cd441f164..397bc97968b0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ Change Log * Added `preserveQueryParameters` parameter to `getDerivedResource`, to allow us to append query parameters instead of always replacing them. * Added `setQueryParameters` and `appendQueryParameters` to allow for better handling of query strings. * Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198) +* Added `Globe.tilesLoaded` getter property to determine if all terrain and imagery is loaded. [#6194](https://github.com/AnalyticalGraphicsInc/cesium/pull/6194) ##### Fixes :wrench: * Fixed bug where AxisAlignedBoundingBox did not copy over center value when cloning an undefined result. [#6183](https://github.com/AnalyticalGraphicsInc/cesium/pull/6183) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index 2b98a8dd0fa0..3b000b0821a7 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -326,7 +326,18 @@ define([ return this._surface.tileLoadProgressEvent; } }, - + /** + * Returns true when the tile load queue is empty, false otherwise. When the load queue is empty, + * all terrain and imagery for the current view have been loaded. + * @memeberof Globe.prototype + * @type {Boolean} + * @readonly + */ + tilesLoaded: { + get: function() { + return (this._surface._lastTileLoadQueueLength === 0); + } + }, /** * Gets or sets the material appearance of the Globe. This can be one of several built-in {@link Material} objects or a custom material, scripted with * {@link https://github.com/AnalyticalGraphicsInc/cesium/wiki/Fabric|Fabric}. diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index cdc34030f0cd..5f74217bca9b 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -782,7 +782,6 @@ define([ var removeGlobeCallbacks = []; if (defined(globe)) { - removeGlobeCallbacks.push(globe.tileLoadedEvent.addEventListener(requestRenderAfterFrame(scene))); removeGlobeCallbacks.push(globe.imageryLayersUpdatedEvent.addEventListener(requestRenderAfterFrame(scene))); removeGlobeCallbacks.push(globe.terrainProviderChanged.addEventListener(requestRenderAfterFrame(scene))); } @@ -2750,8 +2749,13 @@ define([ updateDebugFrustumPlanes(scene); updateShadowMaps(scene); - if (scene._globe) { - scene._globe.render(frameState); + var globe = scene._globe; + if (defined(globe)) { + globe.render(frameState); + + if (!globe.tilesLoaded) { + scene._renderRequested = true; + } } } diff --git a/Specs/createGlobe.js b/Specs/createGlobe.js index 98fbff04d656..0e28e28a324c 100644 --- a/Specs/createGlobe.js +++ b/Specs/createGlobe.js @@ -26,6 +26,7 @@ define([ }, _surface : {}, tileLoadedEvent : new Event(), + tilesLoaded : true, imageryLayersUpdatedEvent : new Event(), terrainProviderChanged : new Event(), destroy : function() {}