Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
  2.  
  3. guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
  4. DispatchQueue.main.async {
  5.  
  6. let planeNode = self.createARPlaneNode(planeAnchor: planeAnchor,
  7. color: UIColor.yellow.withAlphaComponent(0.5))
  8. node.addChildNode(planeNode)
  9. }
  10. }
  11.  
  12. /*------------------------------------------------------------*/
  13.  
  14. func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
  15. DispatchQueue.main.async {
  16. if let planeAnchor = anchor as? ARPlaneAnchor, !self.isPortalPlaced {
  17. #if DEBUG
  18. let debugPlaneNode = createPlaneNode(
  19. center: planeAnchor.center,
  20. extent: planeAnchor.extent)
  21. node.addChildNode(debugPlaneNode)
  22. self.debugPlanes.append(debugPlaneNode)
  23. #endif
  24. self.messageLabel?.alpha = 1.0
  25. self.messageLabel?.text = "Tap on the detected horizontal plane to place the portal"
  26. }
  27. else if !self.isPortalPlaced {
  28.  
  29. self.portalNode = self.makePortal()
  30. if let portal = self.portalNode {
  31. node.addChildNode(portal)
  32. self.isPortalPlaced = true
  33.  
  34. self.removeDebugPlanes()
  35. self.sceneView?.debugOptions = []
  36.  
  37. DispatchQueue.main.async {
  38. self.messageLabel?.text = ""
  39. self.messageLabel?.alpha = 0
  40. }
  41. }
  42.  
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement