Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created June 6, 2018 16:26
Show Gist options
  • Save azamsharp/fc5e3bf3f337a84d360ebd1fdb47261f to your computer and use it in GitHub Desktop.
Save azamsharp/fc5e3bf3f337a84d360ebd1fdb47261f to your computer and use it in GitHub Desktop.
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if anchor is ARImageAnchor {
let phoneScene = SCNScene(named: "Phone_01.scn")!
let phoneNode = phoneScene.rootNode.childNode(withName: "parentNode", recursively: true)!
// rotate the phone node
let rotationAction = SCNAction.rotateBy(x: 0, y: 0.5, z: 0, duration: 1)
let inifiniteAction = SCNAction.repeatForever(rotationAction)
phoneNode.runAction(inifiniteAction)
phoneNode.position = SCNVector3(anchor.transform.columns.3.x,anchor.transform.columns.3.y + 0.1,anchor.transform.columns.3.z)
node.addChildNode(phoneNode)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment