Created
June 1, 2020 08:41
-
-
Save factoryhr/c95fcd4bf999d7feeb50fbe85737a8e9 to your computer and use it in GitHub Desktop.
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 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