While loading multiple scenes (from reality composer) into arView, the scenes is not anchored in the same space.In this example, scene1 is loaded when the app starts. After the button is pressed, the scene2 is added into the scene. In both the scenes, the models are placed at the origin and are expected to overlap with scene2 is added into the view. However, the position of scene1 and scene2 is different when they are added into the arView.import UIKit
import RealityKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
@IBOutlet weak var button: UIButton!
var scene1: Experience.Scene1!
var scene2: Experience.Scene2!
override func viewDidLoad() {
super.viewDidLoad()
// Load the "Box" scene from the "Experience" Reality File
scene1 = try! Experience.loadScene1()
scene2 = try! Experience.loadScene2()
// Add the box anchor to the scene
arView.scene.addAnchor(scene1)
}
@IBAction func buttonPressed(_ sender: Any) {
arView.scene.addAnchor(scene2)
}
}Note: This issues does not happen when both the scenes are added simultaneously.How to make sure that both the scenes are anchored at the same ARAnchor?
Post
Replies
Boosts
Views
Activity
What is the difference between arView.session.add(anchor) and arView.scene.addAnchor(anchor) in RealityKit?
I have many optional variables which are subclasses of the same class:var variable1: Experience.subclass1!
var variable2: Experience.subclass2!
var variable3: Experience.subclass3!
...I want to use a common variable which can copy the value from any of these optional variables for easy code writing. Example:var commonVariable = variable1
...
commonVariable = variable2 // change the value inside another functionAny ideas on how to enable this functionality? This will greatly simplify my code.