Skip to content

Commit

Permalink
Merge pull request #12230 from Levi-Montgomery/fix-flicker
Browse files Browse the repository at this point in the history
Fix allowPartial parameter handling in getBoundingSphere to prevent blocking by other visualizers in update function
  • Loading branch information
ggetz authored Oct 15, 2024
2 parents 8edde12 + 84d0928 commit 0e9a425
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

- Added `ScreenSpaceCameraController.maximumTiltAngle` to limit how much the camera can tilt. [#12169](https://github.com/CesiumGS/cesium/pull/12169)

##### Fixes :wrench:

- Fix flickering issue caused by bounding sphere retrieval being blocked by the bounding sphere of another entity. [#12230](https://github.com/CesiumGS/cesium/pull/12230)

### 1.122 - 2024-10-01

#### @cesium/engine
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/DataSources/DataSourceDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ DataSourceDisplay.prototype.getBoundingSphere = function (
Check.defined("result", result);
//>>includeEnd('debug');

if (!this._ready) {
if (!this._ready && !allowPartial) {
return BoundingSphereState.PENDING;
}

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

it("should not return PENDING when this._ready is false and allowPartial is true", function () {
const visualizer1 = new MockVisualizer();
visualizer1.getBoundingSphereResult = new BoundingSphere(
new Cartesian3(1, 2, 3),
456,
);
visualizer1.getBoundingSphereState = BoundingSphereState.PENDING;

const visualizer2 = new MockVisualizer();
visualizer2.getBoundingSphereResult = new BoundingSphere(
new Cartesian3(7, 8, 9),
1011,
);
visualizer2.getBoundingSphereState = BoundingSphereState.DONE;

display = new DataSourceDisplay({
scene: scene,
dataSourceCollection: dataSourceCollection,
visualizersCallback: function () {
return [visualizer1, visualizer2];
},
});

const entity = new Entity();
const dataSource = new MockDataSource();
dataSource.entities.add(entity);
return display.dataSources.add(dataSource).then(function () {
display.update(Iso8601.MINIMUM_VALUE);

const result = new BoundingSphere();
const state = display.getBoundingSphere(entity, true, result);

expect(state).toBe(BoundingSphereState.DONE);
});
});

it("Computes partial bounding sphere.", function () {
const visualizer1 = new MockVisualizer();
visualizer1.getBoundingSphereResult = new BoundingSphere(
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/Source/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ Viewer.prototype._onTick = function (clock) {
const trackedEntity = this._trackedEntity;
const trackedState = this._dataSourceDisplay.getBoundingSphere(
trackedEntity,
false,
true,
boundingSphereScratch,
);
if (trackedState === BoundingSphereState.DONE) {
Expand Down

0 comments on commit 0e9a425

Please sign in to comment.