How to get CAMetalDrawable with SceneKit API?

This question is related to my previous thread at: https://forums.developer.apple.com/thread/62727


I was looking for ways update SCNGeometry's source and elements fast, but it seems there is no easy way to this.

To get around this, I am looking into using Metal API for rendering tracing path.

With SCNSceneRendererDelegate method, I was able to access most of the things needed for rendering, except CAMetalDrawable.

Every resources I could find required CAMetalDrawable to render which is nowhere to find.

Could anyone direct me where to look regarding this?


A sample project that renders with Metal API in SceneKit context would vastly help.


Thanks.

Accepted Reply

Answering my owns question here.


I was able to get CAMetalDrawable from SCNView with:


((instance of SCNView).layer as? CAMetalLayer).nextDrawable()

Replies

Answering my owns question here.


I was able to get CAMetalDrawable from SCNView with:


((instance of SCNView).layer as? CAMetalLayer).nextDrawable()

((Very) good use of brackets)!

Thanks for this Q and A !!!