At any rate I implemented a workaround by passing the SCNNode by:
func addNode(annotationLocation: ARCL.LocationAnnotationNode) {
if let sceneNode=sceneLocationView.sceneNode {
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: annotationLocation, sceneNode: sceneNode)
} else {
let completion: ((SCNNode)->Void)={(sceneNode) in
DispatchQueue.main.async {
print("sceneNode" + (sceneNode.description))
self.sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: annotationLocation, sceneNode:sceneNode)
self.sceneLocationView.focusItems(in: annotationLocation.frame)
}
}
let nodeComposition = NamedSceneNode(sceneNodeCompletion: completion)
nodeComposition.progress()
print("count \(nodeComposition.counter)")
if var viewController=UIApplication.topViewController() as? ViewControllerProtocol{
if !viewController.nodeShowingCompletions.contains(nodeComposition){
viewController.nodeShowingCompletions.insert(
nodeComposition
)
}
}
}
}
By processing the completions when a SCNNode is ready in:
func sceneLocationViewDidUpdateLocationAndScaleOfLocationNode(sceneLocationView: SceneLocationView, locationNode: LocationNode) {
guard let sceneNode=sceneLocationView.sceneNode else {
return
}
//print("updated element"+locationNode.description + "sceneNode: " + (sceneLocationView.sceneNode?.description ?? "nil"))
if let nodeCompletion = self.nodeShowingCompletions.first{
nodeCompletion.sceneNodeCompletion(sceneNode)
self.nodeShowingCompletions.remove(nodeCompletion)
}
}
Of course until Apple clarifies how to have the node to not nil in other classes respect to the first one.
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: