Skip to content

Commit

Permalink
fix: fixes following comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jfayot committed Oct 7, 2024
1 parent 35a1067 commit eed3697
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
10 changes: 4 additions & 6 deletions packages/engine/Source/Widget/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,8 @@ function CesiumWidget(container, options) {

const eventHelper = new EventHelper();
this._dataSourceChangedListeners = {};
this._automaticallyTrackDataSourceClocks = defaultValue(
options.automaticallyTrackDataSourceClocks,
true
);
this._automaticallyTrackDataSourceClocks =
options.automaticallyTrackDataSourceClocks ?? true;

this._dataSourceCollection = dataSourceCollection;
this._destroyDataSourceCollection = destroyDataSourceCollection;
Expand Down Expand Up @@ -1365,7 +1363,7 @@ function zoomToOrFly(that, zoomTarget, options, isFlight) {
}

//If zoomTarget is an EntityCollection, this will retrieve the array
zoomTarget = defaultValue(zoomTarget.values, zoomTarget);
zoomTarget = zoomTarget.values ?? zoomTarget;

//If zoomTarget is a DataSource, this will retrieve the array.
if (defined(zoomTarget.entities)) {
Expand Down Expand Up @@ -1415,7 +1413,7 @@ function updateZoomTarget(widget) {

const scene = widget.scene;
const camera = scene.camera;
const zoomOptions = defaultValue(widget._zoomOptions, {});
const zoomOptions = widget._zoomOptions ?? {};
let options;
function zoomToBoundingSphere(boundingSphere) {
// If offset was originally undefined then give it base value instead of empty object
Expand Down
6 changes: 3 additions & 3 deletions packages/engine/Specs/Widget/CesiumWidgetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,16 @@ describe(

expect(widget.clock.canAnimate).toBe(true);

widget.render();
widget.clock.tick();
expect(widget.clock.canAnimate).toBe(true);

updateResult = false;
widget.render();
widget.clock.tick();
expect(widget.clock.canAnimate).toBe(false);

widget.clock.canAnimate = true;
widget.allowDataSourcesToSuspendAnimation = false;
widget.render();
widget.clock.tick();
expect(widget.clock.canAnimate).toBe(true);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/widgets/Source/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function pickEntity(viewer, e) {

const scratchStopTime = new JulianDate();

function trackDataSourceClock(timeline, dataSource) {
function linkTimelineToDataSourceClock(timeline, dataSource) {
if (defined(dataSource)) {
const dataSourceClock = dataSource.clock;
if (defined(dataSourceClock) && defined(timeline)) {
Expand Down Expand Up @@ -1489,7 +1489,7 @@ Object.defineProperties(Viewer.prototype, {
set: function (value) {
if (this._cesiumWidget.clockTrackedDataSource !== value) {
this._cesiumWidget.clockTrackedDataSource = value;
trackDataSourceClock(this._timeline, value);
linkTimelineToDataSourceClock(this._timeline, value);
}
},
},
Expand Down Expand Up @@ -1909,7 +1909,7 @@ Viewer.prototype._clearObjects = function () {
*/
Viewer.prototype._onDataSourceChanged = function (dataSource) {
if (this.clockTrackedDataSource === dataSource) {
trackDataSourceClock(this.timeline, dataSource);
linkTimelineToDataSourceClock(this.timeline, dataSource);
}
};

Expand Down
25 changes: 25 additions & 0 deletions packages/widgets/Specs/Viewer/ViewerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,31 @@ describe(
viewer.homeButton.viewModel.command();
expect(viewer.trackedEntity).toBeUndefined();
});

// TO BE REMOVED BEFORE MERGE
// fit("suspends animation by dataSources if allowed", function () {
// viewer = createViewer(container);

// let updateResult = true;
// spyOn(viewer.dataSourceDisplay, "update").and.callFake(function () {
// viewer.dataSourceDisplay._ready = updateResult;
// return updateResult;
// });

// expect(viewer.clockViewModel.canAnimate).toBe(true);

// viewer.clock.tick();
// expect(viewer.clockViewModel.canAnimate).toBe(true);

// updateResult = false;
// viewer.clock.tick();
// expect(viewer.clockViewModel.canAnimate).toBe(false);

// viewer.clockViewModel.canAnimate = true;
// viewer.allowDataSourcesToSuspendAnimation = false;
// viewer.clock.tick();
// expect(viewer.clockViewModel.canAnimate).toBe(true);
// });
},
"WebGL"
);

0 comments on commit eed3697

Please sign in to comment.