Last active
December 8, 2019 15:28
-
-
Save shintaro79/9416f75df8aceb81086e344108607f59 to your computer and use it in GitHub Desktop.
ブログ用に書いたやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { | |
guard anchor is ARFaceAnchor else { return nil } | |
// contentNode = SCNReferenceNode(named: "robotHead") | |
contentNode = SCNReferenceNode(named: "male1") | |
// originalJawY = jawNode.position.y | |
meshNode = contentNode?.childNode(withName: "Plane", recursively: true) | |
return contentNode | |
} | |
/// - Tag: BlendShapeAnimation | |
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) { | |
guard let faceAnchor = anchor as? ARFaceAnchor | |
else { return } | |
let blendShapes = faceAnchor.blendShapes | |
guard let eyeBlinkLeft = blendShapes[.eyeBlinkLeft] as? CGFloat, | |
let eyeLookDownLeft = blendShapes[.eyeLookDownLeft] as? CGFloat, | |
let eyeLookInLeft = blendShapes[.eyeLookInLeft] as? CGFloat, | |
let eyeLookOutLeft = blendShapes[.eyeLookOutLeft] as? CGFloat, | |
let eyeLookUpLeft = blendShapes[.eyeLookUpLeft] as? CGFloat, | |
let eyeSquintLeft = blendShapes[.eyeSquintLeft] as? CGFloat, | |
let eyeWideLeft = blendShapes[.eyeWideLeft] as? CGFloat, | |
let eyeBlinkRight = blendShapes[.eyeBlinkRight] as? CGFloat, | |
let eyeLookDownRight = blendShapes[.eyeLookDownRight] as? CGFloat, | |
let eyeLookInRight = blendShapes[.eyeLookInRight] as? CGFloat, | |
let eyeLookOutRight = blendShapes[.eyeLookOutRight] as? CGFloat, | |
let eyeLookUpRight = blendShapes[.eyeLookUpRight] as? CGFloat, | |
let eyeSquintRight = blendShapes[.eyeSquintRight] as? CGFloat, | |
let eyeWideRight = blendShapes[.eyeWideRight] as? CGFloat, | |
// 中略 | |
else { return } | |
// eyeLeftNode.scale.z = 1 - eyeBlinkLeft | |
// eyeRightNode.scale.z = 1 - eyeBlinkRight | |
// jawNode.position.y = originalJawY - jawHeight * jawOpen | |
meshNode?.morpher?.setWeight(eyeBlinkLeft, forTargetAt: 0) | |
meshNode?.morpher?.setWeight(eyeLookDownLeft, forTargetAt: 1) | |
meshNode?.morpher?.setWeight(eyeLookInLeft, forTargetAt: 2) | |
meshNode?.morpher?.setWeight(eyeLookOutLeft, forTargetAt: 3) | |
meshNode?.morpher?.setWeight(eyeLookUpLeft, forTargetAt: 4) | |
meshNode?.morpher?.setWeight(eyeSquintLeft, forTargetAt: 5) | |
meshNode?.morpher?.setWeight(eyeWideLeft, forTargetAt: 6) | |
meshNode?.morpher?.setWeight(eyeBlinkRight, forTargetAt: 7) | |
meshNode?.morpher?.setWeight(eyeLookDownRight, forTargetAt: 8) | |
meshNode?.morpher?.setWeight(eyeLookInRight, forTargetAt: 9) | |
meshNode?.morpher?.setWeight(eyeLookOutRight, forTargetAt: 10) | |
meshNode?.morpher?.setWeight(eyeLookUpRight, forTargetAt: 11) | |
meshNode?.morpher?.setWeight(eyeSquintRight, forTargetAt: 12) | |
meshNode?.morpher?.setWeight(eyeWideRight, forTargetAt: 13) | |
// 中略 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment