I try to implement plane detection in my AR experience.
I have a subclass of ARSCNView
with an ARSCNViewDelegate
extension.
My cameraDidChangeTrackingState
delegate method is called. However, I've never ONCE see my renderer(_:didAdd node:, for anchor:)
method being called. Any idea?
class ARView: ARSCNView {
override init(frame: CGRect, options: [String : Any]? = nil) {
super.init(frame: frame, options: options)
let sessionConfig = ARWorldTrackingConfiguration()
sessionConfig.planeDetection = [.horizontal]
self.session.run(sessionConfig)
self.delegate = self
}
}
extension ARView: ARSCNViewDelegate{
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
//add childNodes to the node here....
//but, this method doesn't get called
}
}
EDIT: I can find ARPlaneAnchors session(_ session: ARSession, didAdd anchors: [ARAnchor])
but I am not sure if I should use this one, because in most (also Apples) examples they add objects to the node of the anchor like shown in my code above. Or do I have to trigger that didAdd node:, for anchor
method myself?