Skip to content

Commit 82e53fc

Browse files
committed
Merge remote-tracking branch 'origin/main' into markdownlint-changes
2 parents 3898d90 + bace4a7 commit 82e53fc

File tree

5 files changed

+39
-25
lines changed

5 files changed

+39
-25
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44

55
### @cesium/engine
66

7+
#### Breaking Changes :mega:
8+
9+
- Changed behavior of `DataSourceDisplay.ready` to always stay `true` once it is initially set to `true`. [#12429](https://github.com/CesiumGS/cesium/pull/12429)
10+
711
#### Fixes :wrench:
812

913
- Fixed error when resetting `Cesium3DTileset.modelMatrix` to its initial value. [#12409](https://github.com/CesiumGS/cesium/pull/12409)
1014
- Fixed the parameter types of the `ClippingPolygon.equals` function, and fixed cases where parameters to `equals` functions had erroneously not been marked as 'optional'. [#12394](https://github.com/CesiumGS/cesium/pull/12394)
1115
- Fixed type of `ImageryLayer.fromProviderAsync`, to correctly show that the param `options` is optional. [#12400](https://github.com/CesiumGS/cesium/pull/12400)
1216
- Fixed Draco decoding for vertex colors that are normalized `UNSIGNED_BYTE` or `UNSIGNED_SHORT`. [#12417](https://github.com/CesiumGS/cesium/pull/12417)
17+
- Fixed type error when setting `Viewer.selectedEntity` [#12303](https://github.com/CesiumGS/cesium/issues/12303)
1318

1419
## 1.125 - 2025-01-02
1520

packages/engine/Source/DataSources/BoundingSphereState.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @enum {number}
44
* @private
55
*/
6-
const BoundingSphereState = {
6+
const BoundingSphereState = Object.freeze({
77
/**
88
* The BoundingSphere has been computed.
99
* @type BoundingSphereState
@@ -22,5 +22,5 @@ const BoundingSphereState = {
2222
* @constant
2323
*/
2424
FAILED: 2,
25-
};
26-
export default Object.freeze(BoundingSphereState);
25+
});
26+
export default BoundingSphereState;

packages/engine/Source/DataSources/DataSourceDisplay.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ DataSourceDisplay.prototype.update = function (time) {
330330
if (!this._ready && result) {
331331
this._scene.requestRender();
332332
}
333-
this._ready = result;
333+
334+
// once the DataSourceDisplay is ready it should stay ready to prevent
335+
// entities from breaking updates when they become "un-ready"
336+
this._ready = this._ready || result;
334337

335338
return result;
336339
};
@@ -386,7 +389,7 @@ DataSourceDisplay.prototype.getBoundingSphere = function (
386389
Check.defined("result", result);
387390
//>>includeEnd('debug');
388391

389-
if (!this._ready && !allowPartial) {
392+
if (!this._ready) {
390393
return BoundingSphereState.PENDING;
391394
}
392395

packages/engine/Source/Widget/CesiumWidget.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,6 @@ CesiumWidget.prototype._updateCanAnimate = function (isUpdated) {
11341134
this._clock.canAnimate = isUpdated;
11351135
};
11361136

1137-
const boundingSphereScratch = new BoundingSphere();
1138-
11391137
/**
11401138
* @private
11411139
*/
@@ -1148,15 +1146,15 @@ CesiumWidget.prototype._onTick = function (clock) {
11481146
}
11491147

11501148
const entityView = this._entityView;
1151-
if (defined(entityView)) {
1149+
if (defined(entityView) && defined(entityView.boundingSphere)) {
11521150
const trackedEntity = this._trackedEntity;
11531151
const trackedState = this._dataSourceDisplay.getBoundingSphere(
11541152
trackedEntity,
1155-
true,
1156-
boundingSphereScratch,
1153+
false,
1154+
entityView.boundingSphere,
11571155
);
11581156
if (trackedState === BoundingSphereState.DONE) {
1159-
entityView.update(time, boundingSphereScratch);
1157+
entityView.update(time, entityView.boundingSphere);
11601158
}
11611159
}
11621160
};
@@ -1414,6 +1412,8 @@ CesiumWidget.prototype._postRender = function () {
14141412
updateTrackedEntity(this);
14151413
};
14161414

1415+
const zoomTargetBoundingSphereScratch = new BoundingSphere();
1416+
14171417
function updateZoomTarget(widget) {
14181418
const target = widget._zoomTarget;
14191419
if (!defined(target) || widget.scene.mode === SceneMode.MORPHING) {
@@ -1511,13 +1511,15 @@ function updateZoomTarget(widget) {
15111511
const state = widget._dataSourceDisplay.getBoundingSphere(
15121512
entities[i],
15131513
false,
1514-
boundingSphereScratch,
1514+
zoomTargetBoundingSphereScratch,
15151515
);
15161516

15171517
if (state === BoundingSphereState.PENDING) {
15181518
return;
15191519
} else if (state !== BoundingSphereState.FAILED) {
1520-
boundingSpheres.push(BoundingSphere.clone(boundingSphereScratch));
1520+
boundingSpheres.push(
1521+
BoundingSphere.clone(zoomTargetBoundingSphereScratch),
1522+
);
15211523
}
15221524
}
15231525

@@ -1552,6 +1554,8 @@ function updateZoomTarget(widget) {
15521554
}
15531555
}
15541556

1557+
const trackedEntityBoundingSphereScratch = new BoundingSphere();
1558+
15551559
function updateTrackedEntity(widget) {
15561560
if (!widget._needTrackedEntityUpdate) {
15571561
return;
@@ -1577,7 +1581,7 @@ function updateTrackedEntity(widget) {
15771581
const state = widget._dataSourceDisplay.getBoundingSphere(
15781582
trackedEntity,
15791583
false,
1580-
boundingSphereScratch,
1584+
trackedEntityBoundingSphereScratch,
15811585
);
15821586
if (state === BoundingSphereState.PENDING) {
15831587
return;
@@ -1599,7 +1603,9 @@ function updateTrackedEntity(widget) {
15991603
}
16001604

16011605
const bs =
1602-
state !== BoundingSphereState.FAILED ? boundingSphereScratch : undefined;
1606+
state !== BoundingSphereState.FAILED
1607+
? trackedEntityBoundingSphereScratch
1608+
: undefined;
16031609
widget._entityView = new EntityView(trackedEntity, scene, scene.ellipsoid);
16041610
widget._entityView.update(currentTime, bs);
16051611
widget._needTrackedEntityUpdate = false;

packages/engine/Specs/DataSources/DataSourceDisplaySpec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ describe(
363363
});
364364
});
365365

366-
it("ready is true when datasources are ready", function () {
366+
it("ready is true once datasources are ready and stays true", async function () {
367367
const source1 = new MockDataSource();
368368
const source2 = new MockDataSource();
369369

@@ -372,19 +372,19 @@ describe(
372372
dataSourceCollection: dataSourceCollection,
373373
visualizersCallback: visualizersCallback,
374374
});
375-
expect(display.ready).toBe(false);
375+
expect(display.ready).withContext("before adding sources").toBe(false);
376376

377-
return Promise.all([
377+
await Promise.all([
378378
dataSourceCollection.add(source1),
379379
dataSourceCollection.add(source2),
380-
]).then(function () {
381-
display.update(Iso8601.MINIMUM_VALUE);
382-
expect(display.ready).toBe(true);
380+
]);
383381

384-
spyOn(MockVisualizer.prototype, "update").and.returnValue(false);
385-
display.update(Iso8601.MINIMUM_VALUE);
386-
expect(display.ready).toBe(false);
387-
});
382+
display.update(Iso8601.MINIMUM_VALUE);
383+
expect(display.ready).withContext("after adding sources").toBe(true);
384+
385+
spyOn(MockVisualizer.prototype, "update").and.returnValue(false);
386+
display.update(Iso8601.MINIMUM_VALUE);
387+
expect(display.ready).withContext("after updating again").toBe(true);
388388
});
389389

390390
it("triggers a rendering when the data source becomes ready", function () {

0 commit comments

Comments
 (0)