SwiftUIでMetalを使う
#SwiftUI
UIViewRepresentableでUIViewをSwiftUIのViewとしてwrapできる
https://developer.apple.com/documentation/swiftui/uiviewrepresentable
MetalViewの実装例
https://medium.com/@giikwebdeveloper/metal-view-for-swiftui-93f5f78ec36a
Renderer (MTKViewDelegateの実装)に状態を渡す場合
MetalView自体に状態を持たせてupdateUIViewの中でcontext経由で渡す
MetalViewのctorに親のViewModelを渡し、親のViewModelにweakで参照を持たせる
親View -> 親ViewModel -> Renderer という経由で操作できる(e.g. シェーダーのコンパイル)
Coordinatorについて
https://yanamura.hatenablog.com/entry/2022/03/02/101925
structであるUIViewRepresentableの代わりに状態を保持するために使われる