mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Add option to render metal view continuously

Open Cal-um opened this issue 4 years ago • 4 comments

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.

Cal-um avatar Jul 01 '21 12:07 Cal-um

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?

Screenshot 2021-08-22 at 19 20 07

vincentborcard avatar Aug 23 '21 07:08 vincentborcard

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 avatar Dec 23 '21 21:12 macdrevx

@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?

Cal-um avatar Jan 27 '22 08:01 Cal-um

Yes, you'd need to invoke it any time something happens in your model that requires a new drawing pass.

macdrevx avatar Jan 31 '22 17:01 macdrevx