Created
June 20, 2018 09:14
-
-
Save simform-solutions/5054d9039bb0666dc4d91b7f63a3a627 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, 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