Closed kamami closed 2 years ago
@kamami have the same issue since version 0.6.3 when the return of the addNode function was changed.
This problem only occurs when you are trying to add a node to an anchor.
I think they simply forgot to add the return of true when the node is added to an anchor. I checked the plugin code (Android) in AndoridArView.kt (addNode function)
modelBuilder.makeNodeFromGltf(viewContext, transformationSystem, objectManagerChannel, enablePans, enableRotation, dict_node["name"] as String, key, dict_node["transformation"] as ArrayList<Double>)
.thenAccept{node ->
val anchorName: String? = dict_anchor?.get("name") as? String
val anchorType: Int? = dict_anchor?.get("type") as? Int
if (anchorName != null && anchorType != null) {
// Node is added to an anchor //
val anchorNode = arSceneView.scene.findByName(anchorName) as AnchorNode?
if (anchorNode != null) {
anchorNode.addChild(node)
// here should also be 'completableFutureSuccess.complete(true)'
} else {
completableFutureSuccess.complete(false)
}
} else {
//Node is added to the world without an anchor//
arSceneView.scene.addChild(node)
completableFutureSuccess.complete(true) // change from 0.6.3
}
completableFutureSuccess.complete(false)
}
.exceptionally { throwable ->
// Pass error to session manager (this has to be done on the main thread if this activity)
val mainHandler = Handler(viewContext.mainLooper)
val runnable = Runnable {sessionManagerChannel.invokeMethod("onError", listOf("Unable to load renderable" + dict_node["uri"] as String)) }
mainHandler.post(runnable)
completableFutureSuccess.completeExceptionally(throwable)
null // return null because java expects void return (in java, void has no instance, whereas in Kotlin, this closure returns a Unit which has one instance)
}
I tried it for andorid by locally adding completableFutureSuccess.complete(true)
where I mentioned and it worked.
Can't check it for iOS but by looking at the code there is the same 'issue' in IosARView.swift.
I opened a Pull-Request for merging these changes.
fix is merged. The issue can be closed.
I am making use of the example of this repository, but always get the error "Adding Node to Anchor failed":
The object appears after a couple seconds, but
didAddNodeToAnchor
always returns false...