Skip to content

Commit

Permalink
Merge pull request #11934 from CesiumGS/fix-polyline-not-rendered-in-…
Browse files Browse the repository at this point in the history
…request-render-mode

Trigger a rendering when a data source becomes ready
  • Loading branch information
ggetz committed Apr 29, 2024
2 parents ac6fdda + 32240f7 commit 9663d7e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
##### Fixes :wrench:

- Fixed a bug that Label position height may not be correctly updated when its HeightReference is relative. [#11929](https://github.com/CesiumGS/cesium/pull/11929)
- Fixed a bug where a data source was not automatically rendered after is was added in request render mode. [#11934](https://github.com/CesiumGS/cesium/pull/11934)

### 1.116 - 2024-04-01

Expand Down
5 changes: 5 additions & 0 deletions packages/engine/Source/DataSources/DataSourceDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ DataSourceDisplay.prototype.update = function (time) {
result = visualizers[x].update(time) && result;
}

// Request a rendering of the scene when the data source
// becomes 'ready' for the first time
if (!this._ready && result) {
this._scene.requestRender();
}
this._ready = result;

return result;
Expand Down
39 changes: 39 additions & 0 deletions packages/engine/Specs/DataSources/DataSourceDisplaySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,45 @@ describe(
});
});

it("triggers a rendering when the data source becomes ready", function () {
scene.requestRenderMode = true;
scene.maximumRenderTimeChange = undefined;

// When the scene is constructed, then a listener that will be added via
// RequestScheduler.requestCompletedEvent.addEventListener
// that requests a single render (by putting a call to scene.requestRender()
// into the scene._frameState.afterRender list). The requestCompletedEvent
// is triggered when the request for the terrain heights completes that
// is initiated via GroundPolylinePrimitive.initializeTerrainHeights()
// in beforeAll of this suite.
// Consume this render request here
scene.renderForSpecs();

const source = new MockDataSource();
display = new DataSourceDisplay({
scene: scene,
dataSourceCollection: dataSourceCollection,
visualizersCallback: visualizersCallback,
});
expect(display.ready).toBe(false);

return dataSourceCollection.add(source).then(function () {
// When the source becomes ready, a render should
// be requested
display.update(Iso8601.MINIMUM_VALUE);
expect(display.ready).toBe(true);
expect(scene._renderRequested).toBe(true);

scene.renderForSpecs();

// The source should remain ready during subsequent updates,
// and no further renders should be requested
display.update(Iso8601.MINIMUM_VALUE);
expect(display.ready).toBe(true);
expect(scene._renderRequested).toBe(false);
});
});

it("constructor throws if scene undefined", function () {
expect(function () {
return new DataSourceDisplay({
Expand Down

0 comments on commit 9663d7e

Please sign in to comment.