1

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...

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
mete kutlu
  • 13
  • 2

2 Answers2

0

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

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • 1
    Thank you very much @AndyJazz!! The solution is working perfectly. Just needed to figure out how to properly target custom entities inside the RC file. Figured it out thanks to your other posts such as this one: https://medium.com/macoclock/realitykit-911-how-to-enable-both-vertical-and-horizontal-plane-detection-20718d409275 – mete kutlu Mar 14 '22 at 12:23
0

@AndyJazz Thanks. This solution works for me. Alternately to the line :

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.box.isEnabled = true

I suggest (while in Reality Composer) Create a Behavior with: Trigger Scene Start Action Show

The appearance of the entity can then also be tweaked with a Motion Type, Ease Type and Style as well as chained to additional sequences.