Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Created December 3, 2019 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/648214dbf407fd5376b7eec66279f83c to your computer and use it in GitHub Desktop.
Save digitallysavvy/648214dbf407fd5376b7eec66279f83c to your computer and use it in GitHub Desktop.
Snippet for drawing points in AR within the ARSupportBroadcastViewController
func session(_ session: ARSession, didUpdate frame: ARFrame) {
// if we have points - draw one point per frame
if self.remotePoints.count > 0 {
let remotePoint: CGPoint = self.remotePoints.removeFirst() // pop the first node every frame
DispatchQueue.main.async {
guard let touchRootNode = self.touchRoots.last else { return }
let sphereNode : SCNNode = SCNNode(geometry: SCNSphere(radius: 0.015))
sphereNode.position = SCNVector3(-1*Float(remotePoint.x/1000), -1*Float(remotePoint.y/1000), 0)
sphereNode.geometry?.firstMaterial?.diffuse.contents = self.lineColor
touchRootNode.addChildNode(sphereNode) // add point to the active root
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment