Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
- guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
- DispatchQueue.main.async {
- let planeNode = self.createARPlaneNode(planeAnchor: planeAnchor,
- color: UIColor.yellow.withAlphaComponent(0.5))
- node.addChildNode(planeNode)
- }
- }
- /*------------------------------------------------------------*/
- func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
- DispatchQueue.main.async {
- if let planeAnchor = anchor as? ARPlaneAnchor, !self.isPortalPlaced {
- #if DEBUG
- let debugPlaneNode = createPlaneNode(
- center: planeAnchor.center,
- extent: planeAnchor.extent)
- node.addChildNode(debugPlaneNode)
- self.debugPlanes.append(debugPlaneNode)
- #endif
- self.messageLabel?.alpha = 1.0
- self.messageLabel?.text = "Tap on the detected horizontal plane to place the portal"
- }
- else if !self.isPortalPlaced {
- self.portalNode = self.makePortal()
- if let portal = self.portalNode {
- node.addChildNode(portal)
- self.isPortalPlaced = true
- self.removeDebugPlanes()
- self.sceneView?.debugOptions = []
- DispatchQueue.main.async {
- self.messageLabel?.text = ""
- self.messageLabel?.alpha = 0
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement