Adding SCNBillboardConstraint makes node dissapear

After what I read in the documentation and on the Internet, I SCNBillboardConstraintwill rotate the node to always look in pointOfView node - in the case of a ARKitcustom camera.

The thing is, when I add a SCNBillboardConstraintnode to the child, it disappears. Nodes are just a few SCNTextsadded as a subordinate to a more complex model. The hierarchy looks something like this: RootNode -> Text node (two of them).

Right after adding the root of the node to the root of the node scene, I add this restriction as follows:

updateQueue.async {
    self.sceneView.scene.rootNode.addChildNode(virtualObject)
    self.sceneView.addOrUpdateAnchor(for: virtualObject)
    self.addBillboardContraintsToText(object: virtualObject)
}

func addBillboardContraintsToText(object: VirtualObject) {
    guard let storeNode = object.childNodes.first else {
           return
   }

   for node in storeNode.childNodes {
        if let geometry = node.geometry, geometry.isKind(of: SCNText.self) {
            let billboard = SCNBillboardConstraint()
            node.constraints = [billboard]
        }
    }
}

Text nodes have the correct position corresponding to their root node, so there is no problem with this. When I add SCNLookAtConstraint, but it works fine.

node.pivot = SCNMatrix4Rotate(node.pivot, Float.pi, 0, 1, 0)
let lookAt = SCNLookAtConstraint(target: sceneView.pointOfView)
lookAt.isGimbalLockEnabled = true
node.constraints = [lookAt]

, SCNBillboardConstraint ? - ?

+5

All Articles