Access, hide and modify scene content programmatically after load time

76 views Asked by At

I am in the need to access, hide and modify scene content programmatically.

I do know that the content of a schene can be load via Model3D or RealityView (What is the difference between Model3D and RealityView in visionOS?)

I do know that I can modify the content at load time.

What I do not know is how to access the content on a later time, once it is loaded.

With scenekit or realitykit I can do that easily, how can I do that in visionOS?

1

There are 1 answers

0
Gerry Gao On

On VisionOS with RealityKit, you could hold a reference to the scene content

@State private var myContent: Entity?

Later when you load your content in RealityView:

RealityView { content in
  if let scene = try await Entity(...) {
    self.myContent = scene
    // More setup...
  }
}

With that you can access and modify any content via the myContent object.