HomeiOS DevelopmentMethods to entry a Actuality Composer Professional scene in a UIViewRepresentable ARView?

Methods to entry a Actuality Composer Professional scene in a UIViewRepresentable ARView?


I’m creating an Augmented Actuality iOS (Not VisionOS) app utilizing scenes created in Actuality Composer Professional.

I would like my code to ship a notification to a RCP scene that performs a timeline. The RCP interface has the choice to arrange a behaviour for this goal:

Methods to entry a Actuality Composer Professional scene in a UIViewRepresentable ARView?

and each this SO publish Ship Notification from SwiftUI Xcode 16 to set off Actuality Composer Professional Timeline Motion Animation and this Discussion board thread https://developer.apple.com/boards/thread/756978 present the code I want for sending a notification is:

NotificationCenter.default.publish(
  title: NSNotification.Title("RealityKit.NotificationTrigger"),
  object: nil,
  userInfo: [
    "RealityKit.NotificationTrigger.Scene": scene,
    "RealityKit.NotificationTrigger.Identifier": "HideCharacter"
  ]
)

however the ‘scene’ var must level to the related RCP scene, which is loaded inside a UIViewRepresentable ARView (as a result of I want to make use of ARKit) and I am unable to work out easy methods to accurately entry it. The examples within the hyperlinks above are for working with RealityKit, VisionOS or simply do not present sufficient context.

Code for loading the scene is as follows. How can I get the notification code above, located out of the scope of the ARView, to entry this scene?

struct ARViewContainer: UIViewRepresentable {
    
    typealias UIViewType = ARView
    
    func makeUIView(context: Context) -> ARView {
        
        // Create an ARView
        let arView = ARView(body: .zero)
        
        // Configure it
        let arConfiguration = ARWorldTrackingConfiguration()
        arConfiguration.planeDetection = [.horizontal]
        arConfiguration.environmentTexturing = .computerized
        arConfiguration.frameSemantics.insert(.personSegmentationWithDepth)
        arView.setting.sceneUnderstanding.choices.insert(.occlusion)
        arView.session.run(arConfiguration)
        
        // Load in Actuality Composer Professional scene
        let scene = attempt! Entity.load(named:"myScene)", in: realityKitContentBundle)
        
        // Create a horizontal aircraft anchor
        let anchor = AnchorEntity(.aircraft(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
        
        // Append the scene to the anchor
        anchor.youngsters.append(scene)
        
        // Append the anchor to the ARView
        arView.scene.anchors.append(anchor)
        
        return arView
    }
    
    func updateUIView(_ uiView: ARView, context: Context) {
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments