I wrote a simple ARKit app that has a hardcoded "virtual" hat into the Experience.rcproject. The hat is a .usdz file.
I want to add the functionality for the users of the app to import their own .usdz hats, in that they are not pre-hardcoded in the app. There would be a button "Upload your hat", user would click and import the .usdz file, and the hat would end up being on the user's head.
From the code perspective, the Experience model is strongly typed, so not sure how that could work:
func updateUIView(_ uiView: ARView, context: Context) {
let arConfiguration = ARFaceTrackingConfiguration()
uiView.session.run(arConfiguration,
options:[.resetTracking, .removeExistingAnchors])
let arAnchor = try! Experience.loadHat() // I want this to happen dynamically depending on the imported file from the UI
uiView.scene.anchors.append(arAnchor)
}
Is adding a .usdz file dynamically to Experience somehow possible?