在 RealityKit 中,我有一个图像锚。当检测到图像锚时,我想显示一个对象并播放它具有的动画。我在 Reality Composer 中创建了一个动画。这是一个简单的“Ease Out”动画,内置了 Reality Composer。
目前,我的代码如下所示:
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = CustomARView(frame: .zero)
// generate image anchor
let anchor = AnchorEntity(.image(group: "AR Resources", name: "imageAnchor"))
// load 3D model from Experience.rcproject file
let box = try! Experience.loadBox()
// add 3D model to anchor
anchor.addChild(box)
// add anchor to scene
arView.scene.addAnchor(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}