我试图在swiftUI中使用AR,但不支持配置我的设备是iPhone 7plus
我试图用swiftUI放置AR对象,但不支持配置显示,因此我的设备是iPhone 7plus ''' 如果是ARWorldTrackingConfiguration.SupportsGenereConstruction(.mesh){ config.sceneReconstruction=.mesh我试图在swiftUI中使用AR,但不支持配置我的设备是iPhone 7plus,swiftui,augmented-reality,usdz,Swiftui,Augmented Reality,Usdz,我试图用swiftUI放置AR对象,但不支持配置显示,因此我的设备是iPhone 7plus ''' 如果是ARWorldTrackingConfiguration.SupportsGenereConstruction(.mesh){ config.sceneReconstruction=.mesh } else { print(UIDevice.modelName) print("config not supported")
} else {
print(UIDevice.modelName)
print("config not supported")
}
这个if不起作用,它不在“else”语句中
'''
'''
struct ARViewContainer: UIViewRepresentable {
@Binding var selectedModalNameforPlaceable:String?
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let config = ARWorldTrackingConfiguration()
config.planeDetection = [.horizontal,.vertical]
config.environmentTexturing = .automatic
'my code go to else '
if ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh){
config.sceneReconstruction = .mesh
} else {
print(UIDevice.modelName)
print("config not supported")
}
arView.session.run(config)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {
if let selectedMoadal = self.selectedModalNameforPlaceable {
let fileName = selectedMoadal + ".usdz"
print(fileName)
let modalEntity = try! ModelEntity.loadModel(named: fileName)
let anchorEntity = AnchorEntity(plane: .any)
anchorEntity.addChild(modalEntity)
uiView.scene.addAnchor(anchorEntity)
// print("selecte \(selectedMoadal)")
DispatchQueue.main.async {
self.selectedModalNameforPlaceable=nil
}
}
}
}