问题描述
我可以跟踪一个对象并在它上面放置一个文本,它工作得非常好。 我使用这个函数来创建我的 SCNNode:
func renderer(_ renderer: SCNSceneRenderer,nodeFor anchor: aranchor) -> SCNNode? {
let node = SCNNode()
if let _ = anchor as? ARImageAnchor {
let virtualNode = VirtualObjectNode(text: "ho ho ho")
node.addChildNode(virtualNode)
textNode = node
let scene = SCNScene()
scene.rootNode.addChildNode(node)
sceneView.scene = scene
}
return node
}
现在我想将文本保留在它出现的第一个位置并停止跟踪对象... 但我无法做到这一点。 我创建了这个全局变量:
var textNode: SCNNode?
如您所见,我在创建文本后填充它,并在“didAdd 节点”函数中使用此代码将其添加到新场景中:
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
guard let planeGeoemtry = ARSCNPlaneGeometry(device: sceneView.device!) else { fatalError() }
planeAnchor.addplaneNode(on: node,geometry: planeGeoemtry,contents: UIColor.yellow.withAlphaComponent(0.1))
dispatchQueue.main.async(execute: {
node.addChildNode(self.textNode!)
})
但它根本不起作用!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)