Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Created June 20, 2018 09:14
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 simform-solutions/5054d9039bb0666dc4d91b7f63a3a627 to your computer and use it in GitHub Desktop.
Save simform-solutions/5054d9039bb0666dc4d91b7f63a3a627 to your computer and use it in GitHub Desktop.
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = UIColor(white: 1, alpha: 0.8)
let material = SCNMaterial()
material.diffuse.contents = viewObj
plane.materials = [material]
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi / 2
node.addChildNode(planeNode)
} else {
if isFirstTime == true{
isFirstTime = false
} else {
return node
}
let plane = SCNPlane(width: 5, height: 5)
plane.firstMaterial?.diffuse.contents = UIColor(white: 1, alpha: 1)
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = .pi
let shipScene = SCNScene(named: "art.scnassets/Sphere.scn")!
let shipNode = shipScene.rootNode.childNodes.first!
shipNode.position = SCNVector3Zero
shipNode.position.z = 0.15
planeNode.addChildNode(shipNode)
node.addChildNode(planeNode)
}
return node
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment