Skip to content

Instantly share code, notes, and snippets.

@factoryhr
Created June 1, 2020 08:41
Show Gist options
  • Save factoryhr/c95fcd4bf999d7feeb50fbe85737a8e9 to your computer and use it in GitHub Desktop.
Save factoryhr/c95fcd4bf999d7feeb50fbe85737a8e9 to your computer and use it in GitHub Desktop.
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
//Check that anchor is plane anchor that represents planar surfaces
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
//Create node using anchor position
let boxNode = createNode(with: planeAnchor)
//Add boxNode as a child node to newly found node
node.addChildNode(boxNode)
}
func createNode(with anchor: ARPlaneAnchor) -> SCNNode{
let boxGeometry = SCNBox(width: 0.2, height: 0.2, length: 0.2, chamferRadius: 0)
let node = SCNNode(geometry: boxGeometry)
node.positon = SCNVector3(anchor.center.x, anchor.center.y, anchor.center.z)
return node
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment