Only the renderer nodeFor anchor isn't called in Swift Playgrounds

Hi everybody!


So basically the Delegation method of ARSCNViewDelegate :


// THIS METHOD AREN'T CALLED
    func renderer(_ renderer: SCNSceneRenderer,nodeFor anchor : ARAnchor) -> SCNNode? {
        guard let faceAnchor = anchor as? ARFaceAnchor,
            let device = MTLCreateSystemDefaultDevice() else {
                return nil
        }
        let faceGeometry = ARSCNFaceGeometry(device: device)
        let node = SCNNode(geometry: faceGeometry)
        node.geometry?.firstMaterial?.fillMode = .lines
        return node
    }


It isn't called on Swift Playgrounds. I'm using an iPad Pro 11 (with Truedepth frontal-camera). I tried to run the same code on Xcode, and I got it! But on Swift Playgrounds I did not succeed.


I put this in viewDidLoad, viewWillAppear and viewWillDisappear:


     override func viewDidLoad() {
        super.viewDidLoad()
        guard ARFaceTrackingConfiguration.isSupported else {
            fatalError("Face tracking is not supported on this device")
        }
        sceneView.delegate = self
        self.view = sceneView
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        let configuration = ARFaceTrackingConfiguration()
        configuration.isLightEstimationEnabled = true
        sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        sceneView.session.pause()
    }

I need to call this function "func renderer(_ renderer: SCNSceneRenderer,nodeFor anchor : ARAnchor) -> SCNNode?", but the method doesn't work in the delegation.

Could anyone help me?

Replies

See this forum post for some clarification on the issue: https://forums.developer.apple.com/thread/114609