-
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
Add ability complete flight #8788
Conversation
Thanks for the pull request @SambaLim!
Reviewers, don't forget to make sure that:
|
Thanks @SambaLim there is definitely room for improvement in the camera API for stuff like this. I took a quick look at your change and I think the main feedback I have is your code will trigger the "flight cancelled" callback and not the "flight completed" callback (both are passed as parameters to Long term, I would love to make async camera operations return an object with options like this instead of globbing everything onto the Camera itself, but that can be a bigger refactoring for a future PR. |
I think positively about the same change as I mentioned earlier. The following Sandcastle Code can run fixed var viewer = new Cesium.Viewer("cesiumContainer");
var destination = Cesium.Cartesian3.fromDegrees(126.990525, 37.493530, 3000);
function testComplete() {
console.log('It Complete!');
}
function testCancel() {
console.log('It Cancel!');
}
viewer.camera.flyTo({
destination: destination,
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-60),
roll: Cesium.Math.toRadians(0),
},
duration: 5,
complete: testComplete,
cancel: testCancel
});
setTimeout(function() {
viewer.camera.completeFlight();
}, 3000); |
Source/Scene/Camera.js
Outdated
*/ | ||
Camera.prototype.completeFlight = function () { | ||
if (defined(this._currentFlight)) { | ||
this.cancelFlight(); |
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.
There's still an issue here where calling cancelFlight
will cause the current flights cancelled
callback to be called. Instead of calling cancelFlight, just add this._currentFlight = undefined;
at the end of this if
block.
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.
Sorry, I was wrong, what I meant was call this._currentFlight.cancelTween();
directly here.
Source/Scene/Camera.js
Outdated
if (defined(this._currentFlight)) { | ||
this.cancelFlight(); | ||
|
||
newOptions.duration = 0; |
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.
Do we need to set the duration
here? It doesn't look like setView
takes a duration so wouldn't it be ignored either way?
Source/Scene/Camera.js
Outdated
newOptions.duration = 0; | ||
this.setView(newOptions); | ||
|
||
if (defined(newOptions.complete)) { |
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.
To be safe, I would use this._currentFlight.complete()
instead. Then also set this._currentFlight
to undefined, since the flight is done.
Sorry for not getting back to you sooner @SambaLim, I just had to carve out some time to look more into this. I think those are the only comments I had. Thanks again for the pull request! |
Thanks for your delicate reply. |
Thanks @SambaLim, I tested this out and something isn't quite right. At the end of http://localhost:8080/Apps/Sandcastle/index.html?src=Camera.html, add Sandcastle.addToolbarButton('Complete Flight', ()=>{
scene.camera.completeFlight();
}); Then run the example and select |
Thanks to reply @mramato . I appreciate your kindness. I fix |
bump @mramato |
Thanks @SambaLim, sorry for not getting back to you sooner. I added a test and tweaked the doc. I'll merge as soon as CI passes and this will go out with tomorrow's release. |
Thanks @mramato ! |
For #8441
I add ability
completeFlight
It immediately finish a flight in progress and just jump to the end.
The following Sandcastle Code can run
completeFlight