Skip to content

Commit

Permalink
Merge pull request #6194 from AnalyticalGraphicsInc/fix-imagery-reque…
Browse files Browse the repository at this point in the history
…stRender

Fix imagery request render
  • Loading branch information
Hannah authored Feb 27, 2018
2 parents d1e5471 + a4d7754 commit 57061f0
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 28 deletions.
6 changes: 3 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ Change Log
* Added `put`, `patch`, `delete`, `options` and `head` methods, so it can be used for all XHR requests.
* 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)
* Fixed a bug where imagery stops loading when changing terrain in request render mode. [#6193](https://github.com/AnalyticalGraphicsInc/cesium/issues/6193)
* Fixed bug where KmlDataSource did not use Ellipsoid to convert coordinates. Use `options.ellipsoid` to pass the ellipsoid to KmlDataSource constructors / loaders. [#6176] (https://github.com/AnalyticalGraphicsInc/cesium/pull/6176)
* Fixed `Resource.fetch` when called with no arguments [#6206](https://github.com/AnalyticalGraphicsInc/cesium/issues/6206)
* Fixed `Resource.clone` to clone the `Request` object, so resource can be used in parallel. [#6208](https://github.com/AnalyticalGraphicsInc/cesium/issues/6208)
Expand All @@ -42,9 +45,6 @@ Change Log
* Fixed an issue causing the Bing Maps key to be sent unnecessarily with every tile request. [#6250](https://github.com/AnalyticalGraphicsInc/cesium/pull/6250)
* Fixed documentation issue for the `Cesium.Math` class. [#6233](https://github.com/AnalyticalGraphicsInc/cesium/issues/6233)

##### Additions :tada:
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198)

### 1.42.1 - 2018-02-01
_This is an npm-only release to fix an issue with using Cesium in Node.js.__
* Fixed a bug where Cesium would fail to load under Node.js. [#6177](https://github.com/AnalyticalGraphicsInc/cesium/pull/6177)
Expand Down
15 changes: 15 additions & 0 deletions Source/Scene/Globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ define([
return this._surface.tileProvider.tileLoadedEvent;
}
},
/**
* Returns <code>true</code> when the tile load queue is empty, <code>false</code> otherwise. When the load queue is empty,
* all terrain and imagery for the current view have been loaded.
* @memberof Globe.prototype
* @type {Boolean}
* @readonly
*/
tilesLoaded: {
get: function() {
if (!defined(this._surface)) {
return true;
}
return (this._surface.tileProvider.ready && this._surface._tileLoadQueueHigh.length === 0 && this._surface._tileLoadQueueMedium.length === 0 && this._surface._tileLoadQueueLow.length === 0);
}
},
/**
* Gets or sets the color of the globe when no imagery is available.
* @memberof Globe.prototype
Expand Down
27 changes: 19 additions & 8 deletions Source/Scene/QuadtreePrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ define([
this._tileReplacementQueue = new TileReplacementQueue();
this._levelZeroTiles = undefined;
this._loadQueueTimeSlice = 5.0;
this._tilesInvalidated = false;

this._addHeightCallbacks = [];
this._removeHeightCallbacks = [];
Expand Down Expand Up @@ -167,16 +168,20 @@ define([
* @memberof QuadtreePrimitive
*/
QuadtreePrimitive.prototype.invalidateAllTiles = function() {
this._tilesInvalidated = true;
};

function invalidateAllTiles(primitive) {
// Clear the replacement queue
var replacementQueue = this._tileReplacementQueue;
var replacementQueue = primitive._tileReplacementQueue;
replacementQueue.head = undefined;
replacementQueue.tail = undefined;
replacementQueue.count = 0;

clearTileLoadQueue(this);
clearTileLoadQueue(primitive);

// Free and recreate the level zero tiles.
var levelZeroTiles = this._levelZeroTiles;
var levelZeroTiles = primitive._levelZeroTiles;
if (defined(levelZeroTiles)) {
for (var i = 0; i < levelZeroTiles.length; ++i) {
var tile = levelZeroTiles[i];
Expand All @@ -186,17 +191,17 @@ define([
for (var j = 0; j < customDataLength; ++j) {
var data = customData[j];
data.level = 0;
this._addHeightCallbacks.push(data);
primitive._addHeightCallbacks.push(data);
}

levelZeroTiles[i].freeResources();
}
}

this._levelZeroTiles = undefined;
primitive._levelZeroTiles = undefined;

this._tileProvider.cancelReprojections();
};
primitive._tileProvider.cancelReprojections();
}

/**
* Invokes a specified function for each {@link QuadtreeTile} that is partially
Expand Down Expand Up @@ -335,7 +340,7 @@ define([
function updateTileLoadProgress(primitive, frameState) {
var currentLoadQueueLength = primitive._tileLoadQueueHigh.length + primitive._tileLoadQueueMedium.length + primitive._tileLoadQueueLow.length;

if (currentLoadQueueLength !== primitive._lastTileLoadQueueLength) {
if (currentLoadQueueLength !== primitive._lastTileLoadQueueLength || primitive._tilesInvalidated) {
frameState.afterRender.push(Event.prototype.raiseEvent.bind(primitive._tileLoadProgressEvent, currentLoadQueueLength));
primitive._lastTileLoadQueueLength = currentLoadQueueLength;
}
Expand Down Expand Up @@ -371,10 +376,16 @@ define([
return;
}

if (this._tilesInvalidated) {
invalidateAllTiles(this);
}

// Load/create resources for terrain and imagery. Prepare texture re-projections for the next frame.
processTileLoadQueue(this, frameState);
updateHeights(this, frameState);
updateTileLoadProgress(this, frameState);

this._tilesInvalidated = false;
};

/**
Expand Down
6 changes: 5 additions & 1 deletion Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ 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)));
}
scene._removeGlobeCallbacks = removeGlobeCallbacks;
}
Expand Down Expand Up @@ -3010,6 +3010,10 @@ define([

if (defined(scene.globe)) {
scene.globe.endFrame(frameState);

if (!scene.globe.tilesLoaded) {
scene._renderRequested = true;
}
}

frameState.creditDisplay.endFrame();
Expand Down
1 change: 1 addition & 0 deletions Specs/DataSources/EntityClusterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ defineSuite([
}
},
tileLoadedEvent : new Event(),
terrainProviderChanged : new Event(),
imageryLayersUpdatedEvent : new Event(),
beginFrame : function() {},
update : function() {},
Expand Down
4 changes: 2 additions & 2 deletions Specs/DataSources/PointVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ defineSuite([
ellipsoid : Ellipsoid.WGS84,
_surface : {},
tileLoadedEvent : new Event(),
imageryLayersUpdatedEvent : new Event()
imageryLayersUpdatedEvent : new Event(),
terrainProviderChanged : new Event()
};

scene.globe.getHeight = function() {
Expand All @@ -65,7 +66,6 @@ defineSuite([
scene.globe._surface.updateHeight = function() {
};

scene.globe.terrainProviderChanged = new Event();
defineProperties(scene.globe, {
terrainProvider : {
set : function(value) {
Expand Down
50 changes: 38 additions & 12 deletions Specs/Scene/GlobeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defineSuite([
return pollToPromise(function() {
globe._surface._debug.enableDebugOutput = true;
scene.render();
return globe._surface.tileProvider.ready && globe._surface._tileLoadQueueHigh.length === 0 && globe._surface._tileLoadQueueMedium.length === 0 && globe._surface._tileLoadQueueLow.length === 0 && globe._surface._debug.tilesWaitingForChildren === 0;
return globe.tilesLoaded;
});
}

Expand Down Expand Up @@ -148,6 +148,37 @@ defineSuite([
expect(spyListener).toHaveBeenCalledWith(terrainProvider);
});

it('tilesLoaded return true when tile load queue is empty', function() {
expect(globe.tilesLoaded).toBe(true);

globe._surface._tileLoadQueueHigh.length = 2;
expect(globe.tilesLoaded).toBe(false);

globe._surface._tileLoadQueueHigh.length = 0;
expect(globe.tilesLoaded).toBe(true);

globe._surface._tileLoadQueueMedium.length = 2;
expect(globe.tilesLoaded).toBe(false);

globe._surface._tileLoadQueueMedium.length = 0;
expect(globe.tilesLoaded).toBe(true);

globe._surface._tileLoadQueueLow.length = 2;
expect(globe.tilesLoaded).toBe(false);

globe._surface._tileLoadQueueLow.length = 0;
expect(globe.tilesLoaded).toBe(true);

var terrainProvider = new CesiumTerrainProvider({
url : 'made/up/url',
requestVertexNormals : true
});

globe.terrainProvider = terrainProvider;
scene.render();
expect(globe.tilesLoaded).toBe(false);
});

it('renders terrain with enableLighting', function() {
globe.enableLighting = true;

Expand All @@ -167,18 +198,13 @@ defineSuite([
});

globe.terrainProvider = terrainProvider;
scene.camera.setView({ destination : new Rectangle(0.0001, 0.0001, 0.0025, 0.0025) });

return pollToPromise(function() {
return terrainProvider.ready;
}).then(function() {
scene.camera.setView({ destination : new Rectangle(0.0001, 0.0001, 0.0025, 0.0025) });

return updateUntilDone(globe).then(function() {
scene.globe.show = false;
expect(scene).toRender([0, 0, 0, 255]);
scene.globe.show = true;
expect(scene).notToRender([0, 0, 0, 255]);
});
return updateUntilDone(globe).then(function() {
expect(scene).notToRender([0, 0, 0, 255]);

scene.globe.show = false;
expect(scene).toRender([0, 0, 0, 255]);
});
});
}, 'WebGL');
4 changes: 4 additions & 0 deletions Specs/Scene/GlobeSurfaceTileProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ defineSuite([
expect(replacementQueue.count).toBeGreaterThan(0);

surface.tileProvider.terrainProvider = new EllipsoidTerrainProvider();

scene.renderForSpecs();

expect(replacementQueue.count).toBe(0);
});
});
Expand All @@ -691,6 +694,7 @@ defineSuite([

surface.tileProvider.terrainProvider = new EllipsoidTerrainProvider();

scene.renderForSpecs();
scene.renderForSpecs();

levelZeroTiles = surface._levelZeroTiles;
Expand Down
33 changes: 31 additions & 2 deletions Specs/Scene/SceneSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1463,12 +1463,13 @@ defineSuite([
var ellipsoid = Ellipsoid.UNIT_SPHERE;
var globe = new Globe(ellipsoid);
scene.globe = globe;
globe.tileLoadedEvent.raiseEvent();

scene.requestRender();
Object.defineProperty(globe, 'tilesLoaded', { value: false });
scene.renderForSpecs();
lastRenderTime = JulianDate.clone(scene.lastRenderTime, scratchTime);

expect(scene._renderRequested).toBe(true);

scene.renderForSpecs();
expect(scene.lastRenderTime).not.toEqual(lastRenderTime);

Expand Down Expand Up @@ -1502,6 +1503,34 @@ defineSuite([
scene.destroyForSpecs();
});

it('Globe changing terrain providers triggers a new frame to be rendered in requestRenderMode', function() {
var scene = createScene();

scene.renderForSpecs();

var lastRenderTime = JulianDate.clone(scene.lastRenderTime, scratchTime);
expect(lastRenderTime).toBeDefined();
expect(scene._renderRequested).toBe(false);

scene.requestRenderMode = true;
scene.maximumRenderTimeChange = undefined;

var ellipsoid = Ellipsoid.UNIT_SPHERE;
var globe = new Globe(ellipsoid);
scene.globe = globe;
globe.terrainProviderChanged.raiseEvent();

scene.renderForSpecs();

expect(scene._renderRequested).toBe(true);

scene.renderForSpecs();
expect(scene.lastRenderTime).not.toEqual(lastRenderTime);

scene.destroyForSpecs();
});


it('scene morphing causes a new frame to be rendered in requestRenderMode', function() {
var scene = createScene();
scene.renderForSpecs();
Expand Down
1 change: 1 addition & 0 deletions Specs/createGlobe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define([
_surface : {},
tileLoadedEvent : new Event(),
imageryLayersUpdatedEvent : new Event(),
terrainProviderChanged : new Event(),
destroy : function() {}
};

Expand Down

0 comments on commit 57061f0

Please sign in to comment.