I have a custom usdz file (not create through code, but let's say a real chair!). I save this in a Entity
.
Once I have it this is my code:
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)")
}
}
The problem here is that `"Argument type 'Entity' does not conform to expected type 'HasCollision'". So I cant add any gesture.
But I can't find any usefull resource to achieve my final goal. Is there any advice?
The problem is that you are trying to give the ModelEntity an ability it does not posses (It does not have a collision handler).
You need to create an Entity yourself, that will conform to HasCollision.
I would try something like this: