Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Reimplement camera transitions with Core Animation #8176

Closed
1ec5 opened this issue Feb 22, 2017 · 7 comments
Closed

Reimplement camera transitions with Core Animation #8176

1ec5 opened this issue Feb 22, 2017 · 7 comments
Labels
archived Archived because of inactivity iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general needs discussion refactor

Comments

@1ec5
Copy link
Contributor

1ec5 commented Feb 22, 2017

The iOS and macOS SDKs should use indirect property animation in Core Animation to drive camera transitions in response to gestures and calls to methods like -setCamera:animated: and -flyToCamera:…. We should move off mbgl::AnimationOptions and use the mbgl::Transform methods only for incremental transform changes on each frame of the animation.

A key benefit is that the Android SDK will be able to implement concurrent animations (#3625) without us having to design an API around tweening, spring solving, or the like. There are already mature APIs for these effects in UIKit Dynamics.

#8175 is the equivalent issue on Android. Perhaps there’s also prior art in the Qt SDK, where we’ve always relied on Qt animation APIs instead of mbgl’s.

/cc @incanus @bsudekum @frederoni @boundsj

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general refactor labels Feb 22, 2017
@1ec5
Copy link
Contributor Author

1ec5 commented Feb 22, 2017

The only nontrivial animation type mbgl supports is flight animation. We could factor out a utility that calculates the trajectory given a few inputs that we can use on both iOS/macOS and Android.

@brunoabinader
Copy link
Member

@1ec5 are you thinking towards a core utility API for this? This way even e.g. Qt could take advantage of.

@1ec5
Copy link
Contributor Author

1ec5 commented Mar 6, 2017

Yes, I was envisioning a core utility API, perhaps a standalone API like Projection, that calculates flight trajectories. That would make it easily usable by the iOS, macOS, and Qt SDKs. Unfortunately, it occurs to me that it probably wouldn’t be usable by the Android SDK. That code would have to run on every frame of the animation, and my understanding is that we want to minimize the amount of JNI-crossing that occurs during animation. Fortunately, the algorithm behind flight animation is well documented, so the Android SDK would rely on a port of that code to Java.

@1ec5
Copy link
Contributor Author

1ec5 commented Aug 25, 2017

See “Property-Based Animations” for some APIs that would be used with this feature, especially UIViewPropertyAnimator and UISpringTimingParameters (for spring-solving animations).

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 1, 2017

#9808 (comment) has a basic demo of UIView animations on MGLMapView. That issue is a bit more tightly scoped that this issue, with more caveats, but it offers a concrete look at how the more general feature would look.

/cc @d-prukop

@jfirebaugh
Copy link
Contributor

A disadvantage of SDK-driven animations that incrementally update the mbgl core camera is that the core tile loading algorithm then lacks knowledge about the overall animation that would allow it to optimize decisions about what tiles to load or not load, as suggested in issues such as mapbox/mapbox-gl-js#2470 and mapbox/mapbox-gl-js#5482.

@stale
Copy link

stale bot commented Jan 13, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general needs discussion refactor
Projects
None yet
Development

No branches or pull requests

4 participants