2 Replies
      Latest reply on Mar 19, 2019 10:40 AM by gchiste
      gustavo.gleite1 Level 1 Level 1 (10 points)

        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 Playground I did not succeed.

         

        I put this in viewDidLoad, viewWillAppear and viewWillDisappear:

         

             overridefunc 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, but the method doesn't work.