2
votes

I am trying to add a .rcproject to my SCNView. I am working with SwitftUI an totally lost. I have no idea how to add it.

Currently I am able to detect my objects in the room with ARKit. But I also want to add my Scene from RealityKit at this anchor point.

Is there a way to do so?

func renderer(_ renderer: SCNSceneRenderer, 
             didAdd node: SCNNode, 
              for anchor: ARAnchor) {
        
    if let objectAnchor = anchor as? ARObjectAnchor {
        let name = objectAnchor.referenceObject.name!
        print("You found a \(name) object")
        let titleNode = createTitleNode(name)
        node.addChildNode(titleNode)
            
        let example_scene = try! RealityExample.loadScene()
        arView.scene.anchors.append(example_scene) 
        // not possible, because this is not a SCNScene   
    }
}

Thanks a lot.

1

1 Answers

1
votes

You can't read in Reality Composer project (.rcproject) into ARSCNView's scene (.scn). That's because SceneKit isn't able to handle RealityKit's objects and hierarchy. In SceneKit there are nodes (SCNNode class) connected to scene's root node (however, if you're using SceneKit with ARKit, nodes must be also tethered with ARAnchors), but in RealityKit there are entities (ModelEntity class) connected to scene through AnchorEntities. These two frameworks are totally different.

The only file format RealityKit and SceneKit can share is Pixar's .usdz.