I'm able to use nonAR (virtual reality) mode of the RealityKit with following initialization:
arView.cameraMode = .nonAR
let config = ARWorldTrackingConfiguration()
config.planeDetection = .horizontal
arView.session.run(config, options: [])
... but obviously ARWorldTrackingConfiguration is not a good idea in nonAR. How should I initialize it properly? I see nothing if I only set the cameraMode (without additional configuration).
In the SwiftUI example they use `.zero` for the frame, might be best to just use the same as it will take it to full screen either way.
For the box, in order to avoid any issues, just create and add a box manually instead, also the SwiftUI Preview will basically use the simulator, and the initialiser I mentioned is actually not available for the simulator, you'll need to put in a targetEnvironment check:
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
#if targetEnvironment(simulator)
let arView = ARView(frame: .zero)
#else
let arView = ARView(frame: .zero, cameraMode: .nonAR, automaticallyConfigureSession: false)
#endif
let newAnchor = AnchorEntity(world: [0, 0, -1])
let newBox = ModelEntity(mesh: .generateBox(size: 0.3))
newAnchor.addChild(newBox)
arView.scene.anchors.append(newAnchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
The simulator automatically uses cameraMode .nonAR, as it has no other choice and cannot be changed to `.ar`.