При загрузке нескольких сцен (из композитора реальности) в arView сцены не привязаны к одному и тому же пространству.
В этом примере scene1 загружается при запуске приложения. После нажатия кнопки в сцену добавляется сцена 2. В обеих сценах модели помещаются в начало координат и, как ожидается, будут перекрываться, а в вид добавляется сцена 2. Однако положение scene1 и scene2 отличается, когда они добавляются в 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)
}
}
Примечание. Этой проблемы не возникает, если обе сцены добавляются одновременно.
Как убедиться, что обе сцены привязаны к одному и тому же ARAnchor?
arView.scene.anchors.append(scene2)
? - person iicaptain   schedule 06.06.2020