Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created October 16, 2018 15:00
Show Gist options
  • Select an option

  • Save SunXiaoShan/13bab646bb5396ffed14a7364cd56a90 to your computer and use it in GitHub Desktop.

Select an option

Save SunXiaoShan/13bab646bb5396ffed14a7364cd56a90 to your computer and use it in GitHub Desktop.
func updateFeatures(for node: SCNNode, using anchor: ARFaceAnchor) {
for (feature, indices) in zip(features, featureIndices) {
let child = node.childNode(withName: feature, recursively: false) as? EmojiNode
let vertices = indices.map { anchor.geometry.vertices[$0] }
child?.updatePosition(for: vertices)
switch feature {
case "leftEye":
let scaleX = child?.scale.x ?? 1.0
let eyeBlinkValue = anchor.blendShapes[.eyeBlinkLeft]?.floatValue ?? 0.0
child?.scale = SCNVector3(scaleX, 1.0 - eyeBlinkValue, 1.0)
let eyeLookDL = anchor.blendShapes[.eyeLookDownLeft]?.floatValue ?? 0.0
if (eyeLookDL > 0.4) {
let messageVC = UIAlertController(title: "eye look down left", message: "Account Created successfully" , preferredStyle: .actionSheet)
present(messageVC, animated: true) {
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: { (_) in
messageVC.dismiss(animated: true, completion: nil)})}
}
default:
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment