Skip to content

Instantly share code, notes, and snippets.

@giln
Created March 4, 2019 14:44
Show Gist options
  • Save giln/e1174f1d50605eeabb56787b2ad35d62 to your computer and use it in GitHub Desktop.
Save giln/e1174f1d50605eeabb56787b2ad35d62 to your computer and use it in GitHub Desktop.
ARSCNViewDelegate
// MARK: - ARSCNViewDelegate
func renderer(_: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
guard let _ = anchor as? ARPlaneAnchor else { return nil }
// We return a special type of SCNNode for ARPlaneAnchors
return PlaneNode()
}
func renderer(_: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor,
let planeNode = node as? PlaneNode else {
return
}
planeNode.update(from: planeAnchor)
}
func renderer(_: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor,
let planeNode = node as? PlaneNode else {
return
}
planeNode.update(from: planeAnchor)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment