Skip to content
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

Make it possible to cancel camera flights #2027

Closed
mramato opened this issue Aug 5, 2014 · 11 comments
Closed

Make it possible to cancel camera flights #2027

mramato opened this issue Aug 5, 2014 · 11 comments

Comments

@mramato
Copy link
Contributor

mramato commented Aug 5, 2014

From the mailing list: https://groups.google.com/d/msg/cesium-dev/hZJUrD8Owxo/WkHCoYgAkj4J

Camera.flyTo adds a tween to the scene but there doesn't seem to be a way for the dev to cancel it (maybe I'm missing something). The list of tweens is private and the flyTo function doesn't return anything.

@mramato mramato changed the title Make it easy to cancel camera flights Make it possible to cancel camera flights Aug 5, 2014
@pjcozzi pjcozzi mentioned this issue Aug 5, 2014
19 tasks
@digitaldavenyc
Copy link

Until this feature is implemented, do you know of a way to cancel any interaction with cesium until the flyTo is complete?

@marat-rkh
Copy link

Hi!
I would like to implement this feature. The simple solution I see is to return some form of camera flight manager from Camera.flyTo function. The manager will wrap the tween, created at the end of Camera.flyTo function, and contain the method cancelFlight, that will internally call cancelTween on the wrapped tween.
In fact, I have already implemented this functionality in my branch.
Is the solution sutable for a pull request (at least the idea itself)?

@hpinkos
Copy link
Contributor

hpinkos commented Jul 15, 2016

Thanks @octomarat!

I'm not sure if this is the best solution, but what I would do is change this line in Camera.flyTo
to return scene.tweens.add(CameraFlightPath.createTween(scene, newOptions));

That way, you should be able to cancel the flight like this:

var flightTween = camera.flyTo(options};
flightTween.cancelTween()

Does anyone else have input?

@marat-rkh
Copy link

Hi @hpinkos
I think the idea to return object of type Tween directly may be a little bit confusing, because it is a part of internal implementation. Users of Camera.flyTo don't know about tween and, what is more important, don't need to know about it. So I guess it is better to return an object of some abstract type, more related to the domain.
Also if the implementation of Camera.flyTo is changed in the future (to something, that is not using Tween mechanism), it is easier to maintain code compatibility, because we can construct CameraFlightManager in another way, keeping the interface the same.

@hpinkos
Copy link
Contributor

hpinkos commented Jul 15, 2016

Hmm, that's a good point. I guess the user won't probably won't care about the other tween attributes because those are all behind-the-scene details. And there aren't any other functions on tween.

What other purpose would having a CameraFlightManager serve? Do you think it would make sense to just return the cancelTween function?

@marat-rkh
Copy link

marat-rkh commented Jul 16, 2016

I also need the ability to pause camera flights, so the function pauseFlight could be added to the CameraFlightManager. But for now, as far as I understand, it is not clear how to implement pause functionality using the original Tween.js and it's cesium wrapper.
So yes, CameraFlightManager is a bit over abstracted. I don't know is it a good programming style in JS world to return a function alone. Maybe it is better to return something like:

return {
    cancelFlight : function() {
        tween.cancelTween();
    }
};

and give a description of the returned object interface somewhere? Not sure it is ok, but it looks like something in the middle between adding a whole new type (CameraFlightManager) and returning the function alone.
Another solution I see is to give a CameraFlightManager more specific name, for example rename it to OngoingCameraFlight. It is not that general as Manager, making it seen as having less responsibilities.

@marat-rkh
Copy link

Maybe someone else has an idea or comments on this topic?

mramato added a commit that referenced this issue Aug 25, 2016
1. Added `Camera.cancelFlight` to cancel the existing camera flight if it
exists.
2. Fix overlapping camera flights by always cancelling the previous flight
when a new one is created.

Fixes #2027
tfili pushed a commit that referenced this issue Aug 29, 2016
1. Added `Camera.cancelFlight` to cancel the existing camera flight if it
exists.
2. Fix overlapping camera flights by always cancelling the previous flight
when a new one is created.

Fixes #2027
@Geoneer
Copy link

Geoneer commented Dec 14, 2016

https://groups.google.com/forum/#!msg/cesium-dev/hZJUrD8Owxo/WkHCoYgAkj4J

Willem van der Gugten did create a workaround. It works nice as a pause in the flight. It's not a cancel of the flight.

@Maarondesigns
Copy link

Is this implemented? I see in Camera documentation Cesium.Camera.FlightCancelledCallback() however no method to actually cancel a flight, and user interaction on the globe does not stop the flight.

@hpinkos
Copy link
Contributor

hpinkos commented Jul 9, 2020

@Maarondesigns yes, see Camera.cancelFlight

@Maarondesigns
Copy link

@Maarondesigns yes, see Camera.cancelFlight

Ah, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants