I am developing an immersive visionOS app based on RealityKit and SwiftUI.
This app has ModelEntities
that have a PerspectiveCamera
entity as child.
I want to display the camera view in a 2D window in visionOS.
I am creating the camera, and add it to the entity with
let cameraEntity = PerspectiveCamera()
cameraEntity.camera.far = 10000
cameraEntity.camera.fieldOfViewInDegrees = 60
cameraEntity.camera.near = 0.01
entity.addChild(cameraEntity)
There are some post on SO, like this one, that apparently show such camera views as part of an arView
. However my app is not AR. The immersive view is programmatically generated.
My question is:
How can I show the camera view in a SwiftUI 2D window?