- 建立臉部追蹤
- 建立臉部模型
- 更新臉部表情
// Create a session configuration
let configuration = ARFaceTrackingConfiguration()
// Run the view's session
sceneView.session.run(configuration)
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
if anchor is ARFaceAnchor {
let faceMesh = ARSCNFaceGeometry(device: sceneView.device!)
faceMesh?.firstMaterial?.lightingModel = .physicallyBased
let node = SCNNode(geometry: faceMesh)
return node
} else {
return nil
}
}
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
if let faceAnchor = anchor as? ARFaceAnchor, let faceGeometry = node.geometry as? ARSCNFaceGeometry {
faceGeometry.update(from: faceAnchor.geometry)
}
}
沒有留言:
張貼留言