As query states, am making an attempt to load a file referred to as TestScene.usda, created in Actuality Composer Professional, utilizing the ModelEntity.load technique, into an ARView inside an iOS (not VisionOS!) undertaking, so it may be hooked up to a horizontal anchor. Documentation for a way to do that appears skinny on the bottom.
I’ve my RCP undertaking imported as a Swift package deal utilizing the next construction, and the package deal has been added to the goal as a Library:
Code as follows.
import SwiftUI
import RealityKit
import ARKit
import RealityKitContent
struct ContentView : View {
var physique: some View {
ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
typealias UIViewType = ARView
func makeUIView(context: Context) -> ARView {
let arView = ARView(body: .zero)
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = [.horizontal]
arView.session.run(arConfiguration)
let mannequin = attempt! ModelEntity.loadModel(named: "TestScene.usda", in: realityKitContentBundle)
let anchor = AnchorEntity(.airplane(.horizontal, classification: .any, minimumBounds: SIMD2(0.2, 0.2)))
anchor.youngsters.append(mannequin)
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
#Preview {
ContentView()
}
Operating the app returns an error, saying it may’t discover TestScene.usda. Undecided if I’m utilizing the fitting technique for this activity, the tactic will not work with Swift packages, I am simply naming issues incorrectly, or one thing else. Any assist appreciated!