mapbox-maps-ios
mapbox-maps-ios copied to clipboard
Add option to render metal view continuously
New Feature
Add option to render metal view continuously in the MapView class. The MTLView needs to be configured with
metalView.isPaused = false metalView.enableSetNeedsDisplay = false
as per the docs https://developer.apple.com/documentation/metalkit/mtkview
Timed updates: The view redraws its contents based on an internal timer. In this case, which is the default behavior, both isPaused and enableSetNeedsDisplay are set to false. Use this mode for games and other animated content that’s regularly updated.
Currently these are set to true.
Why
For metal SceneKit integration this is required to let the nodes animate. I need this is my current use case.
I modified metalView.isPaused = false metalView.enableSetNeedsDisplay = false in MapView.swift and it allows to continuously render metal view. Thx Cal-um. I also would like to change that through an option.
In my case, to continuously update the position of a 3D node on a path retrieved from a lineString (turf). I modified the SceneKitExample.swift to do that.
But modifying metalView.isPaused = false metalView.enableSetNeedsDisplay = false produce some strange elevation with the Hillshade. Any idea why it happens?
https://github.com/mapbox/mapbox-maps-ios/pull/964 exposed a new API that allows client code to request that the map redraw. You may be able to use that to solve some of the same problems that would be addressed by continual metal view rendering.
@macdrevx Is this API intended to be used for animations? Would it be used called continuously with a display link when needing to animate a node?
Yes, you'd need to invoke it any time something happens in your model that requires a new drawing pass.