Question to Gestures

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)
     
  }
}

Usual checks:

  • is the name exactly the same (including uppercase) ?
  • where is the TestSpiralr file ? In the app Bundle ?

Hi Claude31,

thanks for your answer.

The files have different names. Therefore, as you can see, I have created two lines in the code under // LOAD MODEL, where one line (the one with the usdz-file) is commented out. You can use any usdz or reality file for testing, just change the names accordingly. With the usdz-file it works, with the .reality-file it does not. You can see the structure on the picture in the attachment.

Can you go into your project file (the blue one at the top of the tree), go to Build Phases, and open the Copy Bundle Resources section? Post a picture of what you see.

Hi, thanks for your reply.

I think, I have to define the gestures completely different when using .reality file or .rcproject file because the structure of the file might be different. If I publish a usdz file on the web it is possible to rotate, scale and move the object without coding. The possibility to rotate, scale and move the object seems to be already integrated in the usdz file. But it is possibly not integrated in .rcproject or .reality-file? Therefore the same code does not work for .reality and .rcproject files. To make the object rotate, scale and move in .reality and .rcproject I have to write new/different code in Xcode/swift. But I do not know how.

This is the Screenshot you ask for:

Question to Gestures
 
 
Q