My code uses arkit. All I want to do is when I change the text of the label. The change is reflected in the arkit text. Currently its not. Whatever the arkit label stays and default and never changes no matter what is on the label on the view controller.
import UIKit;import ARKit
class ViewController: UIViewController {
@IBOutlet var arkitView:ARSCNView!
@IBOutlet var outputImageView:UIImageView!
@IBOutlet var ffox: UILabel!
@IBOutlet var enterText: UITextField!
var textGeometry: SCNText!
//4. Create Our ARWorld Tracking Configuration
let configuration = ARWorldTrackingConfiguration()
//5. Create Our Session
let augmentedRealitySession = ARSession()
override func viewDidAppear(_ animated: Bool) {
arkitView.session.run(configuration)
//1. Create The Text
textGeometry = SCNText(string: ffox.text!, extrusionDepth: 1)
//2. Set It From The UILabel
textGeometry.string = ffox.text!
//3. Create A Material For The Text
let material = SCNMaterial()
material.diffuse.contents = UIColor.green
textGeometry.materials = [material]
//4. Create A Holder Node To Hold The Text
let node = SCNNode()
node.position = SCNVector3(x: 0, y: 0.02, z: -0.01)
node.scale = SCNVector3(x: 0.01, y: 0.01, z: 0.01)
node.geometry = textGeometry
arkitView.scene.rootNode.addChildNode(node)
arkitView.automaticallyUpdatesLighting = true
DispatchQueue.main.async {
self.textGeometry.string = self.ffox.text!
}
}
@IBAction func takeScreenshotAction() {
if let d = enterText.text
{
ffox.text = d
}}}