Skip to content

Commit f01671e

Browse files
committed
DataSourceDisplay stays ready once loaded
1 parent eed5ddb commit f01671e

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
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`.
10+
711
##### Fixes :wrench:
812

913
- Fixed error when resetting `Cesium3DTileset.modelMatrix` to its initial value. [#12409](https://github.com/CesiumGS/cesium/pull/12409)

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: 15 additions & 9 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
*/
@@ -1152,11 +1150,11 @@ CesiumWidget.prototype._onTick = function (clock) {
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 trackedEntityBoundingSphereScratch2 = 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+
trackedEntityBoundingSphereScratch2,
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+
? trackedEntityBoundingSphereScratch2
1608+
: undefined;
16031609
widget._entityView = new EntityView(trackedEntity, scene, scene.ellipsoid);
16041610
widget._entityView.update(currentTime, bs);
16051611
widget._needTrackedEntityUpdate = false;

0 commit comments

Comments
 (0)