Well, I figured it out from the Happy Beam demo code here: Happy Beam Docs
Problem: the Bundle var wasn’t found in scope.
Solution:
Make sure that your Reality Composer Pro Package has been as a Framework in he General Project Settings
Import (your package name)
In the Sources directory that Reality Composer Pro created, there is a Swift file that contains var you’re looking for usually (your project name + Bundle; i.e. “projectnameBundle”)
Load by creating an entity; scene = Entity(named: “Scene”, in: projectnameBundle)
Add the entity to your RealityView; content.add(scene)
Note: those will place the scene at your cameras location. So, be sure to move the camera away from the starting point to verify, but it’d be best to add a horizontal anchor and add the entity to the anchor, then the anchor to the RealityView to be less confusing Visually.
import RealityKit
import projectName
struct ContentView : View {
var body: some View {
RealityView { content in
// Create horizontal plane anchor
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
// Load Scene from Reality Composer Pro Package
do {
let scene = try await Entity(named: "Scene", in: projectnameBundle)
// Add model to anchor
anchor.addChild(scene)
// Add anchor to RealityView
content.add(anchor)
} 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 scene: \(error)")
}
// View Settings
content.camera = .spatialTracking
}
.edgesIgnoringSafeArea(.all)
}
}
Topic:
Graphics & Games
SubTopic:
RealityKit