Using a scene from Reality Composer Pro in an IOS app?

I am trying to establish a workflow with using Reality Composer Pro to make scenes - I am grey boxing a scene using primitives at the moment.

I have set up a cube with a texture material and a simple animation to spin.

I am confused as to what I should be loading. I have created what I think is a scene asset in the package for the Reality Composer Project.

Here is a code snippet:

struct ContentView: View {
    var body: some View {
        RealityView { content in
            do {
                let scene = try await ModelEntity(named: "HOF")
                content.add(scene)
            } catch {
                print("Error loading scene: \(error.localizedDescription)")
            }
        }
    }
}

Here is the project layout in Reality Composer Pro:

Answered by Miro in 791266022

I went took a look at the Hello World sample & I see I made 2 mistakes:

  • use Entity(named:
  • and use the appropriate path:
struct ContentView: View {
    var body: some View {
        RealityView { content in
            do {
                let scene = try await Entity(named: "Scenes/HOF", in: HeadsOnFire.headsOnFireBundle)

                content.add(scene)

            } catch is CancellationError {
                // The entity initializer can throw this error if an enclosing
                // RealityView disappears before the model loads. Exit gracefully.
                return

            } catch let error {
                // Other errors indicate unrecoverable problems.
                print("Failed to load cube: \(error)")
            }
        }
    }
}
Accepted Answer

I went took a look at the Hello World sample & I see I made 2 mistakes:

  • use Entity(named:
  • and use the appropriate path:
struct ContentView: View {
    var body: some View {
        RealityView { content in
            do {
                let scene = try await Entity(named: "Scenes/HOF", in: HeadsOnFire.headsOnFireBundle)

                content.add(scene)

            } catch is CancellationError {
                // The entity initializer can throw this error if an enclosing
                // RealityView disappears before the model loads. Exit gracefully.
                return

            } catch let error {
                // Other errors indicate unrecoverable problems.
                print("Failed to load cube: \(error)")
            }
        }
    }
}
Using a scene from Reality Composer Pro in an IOS app?
 
 
Q