Created
December 3, 2019 19:44
-
-
Save digitallysavvy/648214dbf407fd5376b7eec66279f83c to your computer and use it in GitHub Desktop.
Snippet for drawing points in AR within the ARSupportBroadcastViewController
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 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