-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moved Viewer functionality to CesiumWidget class #12202
base: main
Are you sure you want to change the base?
Conversation
Thank you for the pull request, @jfayot! ✅ We can confirm we have a CLA on file for you. |
@jjspace Could you please take a pass on this PR and see if this is a direction we'd like to go API-wise? Please be mindful of any breaking changes, and deprecate or preserve functionality where we can. |
@jjspace any update on this one? 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jfayot, this is looking good. sorry for the delay, github doesn't make it very easy to review diffs for things that move between files... I had a few initial comments
I kept duplicate tests in ViewerSpec, may be some can be removed as they are implemented in CesiumWidgetSpec now?
Generally we don't write specs that test "dependencies" of an object. I would say any tests that are for viewer functions that are now just passed through to widget functions should be removed.
this.screenSpaceEventHandler.removeInputAction( | ||
ScreenSpaceEventType.LEFT_CLICK | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is still needed for the pickAndSelectObject
that's added?
this._screenSpaceEventHandler.setInputAction( | ||
pickAndTrackObject, | ||
ScreenSpaceEventType.LEFT_DOUBLE_CLICK | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this click handler should be moved back to the Viewer
. Moving the functionality to track an entity into the CesiumWidget
is good so you can do CesiumWidget.trackedEntity = ...
but setting up the click handler interaction is a Viewer
oriented feature. Basically I would expect the handler in Viewer
to be able to do this._cesiumWidget.trackedEntity = pickEntity()
(with the extra checks it previously had).
cesiumWidget.screenSpaceEventHandler.setInputAction( | ||
pickAndTrackObject, | ||
ScreenSpaceEventType.LEFT_DOUBLE_CLICK | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given my other comment this should be brought back.
// Unsubscribe from data sources | ||
const dataSources = this.dataSources; | ||
const dataSourceLength = dataSources.length; | ||
for (i = 0; i < dataSourceLength; i++) { | ||
for (let i = 0; i < dataSourceLength; i++) { | ||
this._dataSourceRemoved(dataSources, dataSources.get(i)); | ||
} | ||
this._dataSourceRemoved(undefined, this._dataSourceDisplay.defaultDataSource); | ||
this._dataSourceRemoved(undefined, this.dataSourceDisplay.defaultDataSource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic now lives in CesiumWidget.destroy()
too, is it still needed here?
}, | ||
|
||
/** | ||
* Gets or sets the data source to track with the viewer's clock. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets or sets the data source to track with the viewer's clock. | |
* Gets or sets the data source to track with the widget's clock. |
I'll comment on a couple other instances of this but please do a pass yourself to make sure code copied over refers to a widget not a viewer in this file
* @param {ContextOptions} [options.contextOptions] Context and WebGL creation properties passed to {@link Scene}. | ||
* @param {Element|string} [options.creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added | ||
* to the bottom of the widget itself. | ||
* @param {Element|string} [options.creditViewport] The DOM element or ID that will contain the credit pop up created by the {@link CreditDisplay}. If not specified, it will appear over the widget itself. | ||
* @param {DataSourceCollection} [options.dataSources=new DataSourceCollection()] The collection of data sources visualized by the widget. If this parameter is provided, | ||
* the instance is assumed to be owned by the caller and will not be destroyed when the viewer is destroyed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the instance is assumed to be owned by the caller and will not be destroyed when the viewer is destroyed. | |
* the instance is assumed to be owned by the caller and will not be destroyed when the widget is destroyed. |
function clearZoom(viewer) { | ||
viewer._zoomPromise = undefined; | ||
viewer._zoomTarget = undefined; | ||
viewer._zoomOptions = undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and a handful of functions below that were moved over the argument names should be swapped out so they don't refer to a viewer
anymore
function clearZoom(viewer) { | |
viewer._zoomPromise = undefined; | |
viewer._zoomTarget = undefined; | |
viewer._zoomOptions = undefined; | |
} | |
function clearZoom(widget) { | |
widget._zoomPromise = undefined; | |
widget._zoomTarget = undefined; | |
widget._zoomOptions = undefined; | |
} |
Description
This is a proposal to move Viewer functionalities not related to widgets to CesiumWidget class as proposed in #11967.
Issue number and link
#11967
Testing plan
I kept duplicate tests in ViewerSpec, may be some can be removed as they are implemented in CesiumWidgetSpec now?
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change