Search code examples
swiftaugmented-realityarkitrealitykitreality-composer

RealityComposer – Glitch with "Hide all on Scene Start"


I have a Reality Composer file with several scenes, all of which starts empty and then some models appear one by one every second. Even though the animation works perfectly in Quicklook and Reality Composer, it does a strange glitch when I try to integrate it in my app with Xcode. When the very first scene is launched or when we go to another scene, they don't start empty.. For a tiny split second, we see all the models of that scene being displayed, only to disappear immediately.

Then, we see them appearing slowly as they were supposed to. That tiny flash of models at the beginning of each scene is ruining everything. I tried using a .reality file and a .rcproject file, same problem. In fact, when we preview the animation of the Reality file inside Xcode, it does the same glitch. I tried using different Hide and Show functions, no change.. I tried different triggers such as notifications, scene start, on tap, no change.

I checked quite some tutorials and still couldn't find anything wrong in what I'm doing. I almost feel like there is a glitch in the current integration of Reality Composer. I would really appreciate some ideas on the subject...


Solution

  • Try this to prevent a glimpse...

    import UIKit
    import RealityKit
    
    class ViewController: UIViewController {
            
        @IBOutlet var arView: ARView!
        var box: ModelEntity!
        
        override func viewDidLoad() {
            super.viewDidLoad()
            
            let scene = try! Experience.loadScene()
            self.box = scene.cube!.children[0] as? ModelEntity
            self.box.isEnabled = false
            arView.scene.anchors.append(scene)
            
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                self.box.isEnabled = true
            }
        }
    }
    

    In such a scenario glitching occurs only for sphere. Box object works fine.

    enter image description here