Disclosure: When you purchase a service or a product through our links, we sometimes earn a commission. Read More..

FREE Email Marketing Course

renderer did Add node for anchor function not being called/executed

October 22, 2019 By admin

anchor function not being called/executed

I was making an program which detects a plane and puts a plane within it. However, it appears as if the function isn’t being called. Here’s the code:

Func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, such as anchor: ARAnchor) 

// Checking if the planeAnchor exists

    shield let planeAnchor = anchor as?  ARPlaneAnchor else  return   

// Declaring certain variables for future usage let width = CGFloat(planeAnchor.extent.x)  

    allow elevation = CGFloat(planeAnchor.extent.z)  

//The airplane (geometry) for the node

    let airplane = SCNPlane(width: widthheight: height)  

// The planeNode for the airplane anchor

    let planeNode = SCNNode(geometry: airplane )  

//Putting the airplane node

    planeNode.geometry?.firstMaterial? .diffuse. Contents = UIColor.init(red: orange, 0: 0, azure: 1, alpha0.4)  

    planeNode.geometry?.firstMaterial? .isDoubleSided = true

// Some variables for future usage permit x = CGFloat(planeAnchor.center.x)  

    let y = CGFloat(planeAnchor.center.y)  

    let z = CGFloat(planeAnchor.center.z)  

// The plane node's ranking planeNode.position = SCNVector3(x,y,z)  

// This can be done so the plane node is horizontal

    planeNode.eulerAngles.x = -.pi / 2

/ / / Adding the planeNode to the rootNode??


// Informing the user that a plane anchor has been found

    mainLabel.text ="Found a plane anchor!"


viewDidLoad function

override public func viewDidLoad() 

configuration.planeDetection = .horizontal  


    sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints, ARSCNDebugOptions.showWorldOrigin]  


    sceneView.delegate = self  


What’s wrong? The mainLabel’s text never changes…

By the way, the viewDidLoad function is public since my class is a public course.

Please help. .

I also do this warning in the function beginning:

Instance method'renderer(_:didAdd:for:-RRB-' nearly matches optional demand'renderer(_:didAdd:for:-RRB-' of protocol'ARSCNViewDelegate'  

I’m trying all this in Swift Playground Book and this code is in the resources folder.

نتيجة بحث الصور عن ‪viewDidLoad‬‏