import SwiftUI import RealityKit import ARKit
struct ARViewContainer: UIViewRepresentable { @Binding var distance: Float?
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let configuration = ARWorldTrackingConfiguration()
arView.session.run(configuration)
arView.addGestureRecognizer(UITapGestureRecognizer(target: context.coordinator, action: #selector(context.coordinator.handleTap(_:))))
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, ARSessionDelegate {
var parent: ARViewContainer
init(_ parent: ARViewContainer) {
self.parent = parent
super.init()
parent.parentSession.delegate = self
}