Hi, it's me again. I try to understand gestures but perhaps i have a knot in my brain.
I have completed a tutorial in which I had to load an usdz-file into Xcode and then add gestures to it. It worked fine. But if I replace the usdz-file with a .reality-file or .rcproject-file I created in RealityComposer it fails with the message: Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: RealityKit.Entity.LoadError.resourceNotFound("TestSpiralr") (TestSpiralr is the .reality-file) how do I get the script running. Thanks
import UIKit
import RealityKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewDidLoad() {
super.viewDidLoad()
// LOAD MODEL
// let entity = try! ModelEntity.loadModel(named: "cup_saucer_set"/*usdz-file*/)
let entity = try! ModelEntity.loadModel(named: "TestSpiralr"/*reality-file*/)
// ENABLE GESTURES
entity.generateCollisionShapes(recursive: true)
arView.installGestures([.translation, .rotation, .scale], for: entity)
// CREATE ANCHOR
let anchor: AnchorEntity = AnchorEntity(plane: .horizontal, classification: .any)
// PLACE ANCHOR IN THE SCENE
arView.scene.addAnchor(anchor)
// ADD ENTITY TO ANCHOR
anchor.addChild(entity)
}
}