Thanks @eskimo,
That makes a lot of sense. I was looking at an example where they import a file hosted in amazon web services (somehow I am not able attach the link) but as you probably guessed based on your question, the data is confidential. I could get around using a private dropbox link, but that would involve to somehow signing in with dropbox as part of the process.
I have done this with other languages but never in swift. Not sure if there is even a package for that?
Post
Replies
Boosts
Views
Activity
Thanks @eskimo,
Yes I can definitely switch to tab separated values.
What would be the best way to do that? My main question is how to make sure users always have the most updated data available after I refresh the file. From my understanding, if I just upload the tsv or txt file to xcode, users will have to download the app again every time I refresh the data (?)
Thanks,
@brandonk212
Thanks for the quick reply. I tried the code with the new fixes and it works perfectly. Really appreciate your help, being able to work with just one swiftUI file is going to save me a lot of headaches down the road. Very helpful.
Thanks for the reply. This seems exactly like what I am trying to achieve. I made the changes to the code as you suggested, however it seems that I am having issues with imageName. I am getting "Use if undeclared type 'imageName'". Is there anything I am missing. Below is my code as it looks now:
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
guard let imageAnchor = anchor as? ARImageAnchor else {return nil}
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width,
height: imageAnchor.referenceImage.physicalSize.height)
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi / 2
if let imageName = imageAnchor.referenceImage.name {
imageController(for: planeNode, imageName: imageName)
}
let node = SCNNode()
node.addChildNode(planeNode)
return node
}
func imageController(for node: SCNNode, imageName: imageName) {
let imageView = UIHostingController(rootView: imageView(name: imageName))
DispatchQueue.main.async {
imageView.willMove(toParent: self)
self.addChild(imageView)
imageView.view.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
self.view.addSubview(imageView.view)
self.showImageView(hostingVC: imageView, on: node)
}
}
func showImageView(hostingVC: UIHostingController<imageView>, on node: SCNNode) {
let material = SCNMaterial()
hostingVC.view.isOpaque = false
material.diffuse.contents = hostingVC.view
node.geometry?.materials = [material]
hostingVC.view.backgroundColor = UIColor.clear
}
}