【发布时间】:2021-01-18 19:01:44
【问题描述】:
我有一个自定义的 usdz 文件(不是通过代码创建的,但假设是一把真正的椅子!)。我将其保存在 Entity 中。
一旦我有了它,这就是我的代码:
func updateUIView(_ uiView: ARView, context: Context) {
if let modelEntity = model.modelEntity {
print("\(model.modelName)")
let anchorEntity = AnchorEntity(plane: .horizontal)
anchorEntity.addChild(modelEntity.clone(recursive: true))
uiView.scene.addAnchor(anchorEntity)
// modelEntity.generateCollisionShapes(recursive: true)
// If we have multiple object, recursive true help to generate collision for all of them
uiView.installGestures(.rotation, for: modelEntity as! Entity & HasCollision)
uiView.debugOptions = .showPhysics
} else {
print("Unable to load modelEntity for \(model.modelName)")
}
}
这里的问题是`“参数类型'Entity'不符合预期的类型'HasCollision'”。所以我不能添加任何手势。
但我找不到任何有用的资源来实现我的最终目标。有什么建议吗?
【问题讨论】:
标签: swift swiftui augmented-reality arkit realitykit