Open Amritacharya opened 3 years ago
I'm trying doing it but without sucess... Do you have some update about that?
You could implement it with Swift. You need to download the model file and then add it to the scene.
import ModelIO
import SceneKit
func download() {
let modelLocalURL = FileManager.default.temporaryDirectory.appendingPathComponent("model.obj")
let modelRemoteURL = "..."
guard let url = URL(string: modelRemoteURL) else { return }
URLSession.shared.downloadTask(with: url) { (tempFileUrl, response, error) in
if let tempFileUrl = tempFileUrl {
do {
let data = try Data(contentsOf: tempFileUrl)
try data.write(to: modelLocalURL)
loadModel(modelLocalURL)
} catch {
print("Error")
}
}
}.resume()
}
func loadModel(_ localURL: URL) {
let asset = MDLAsset(url: localURL)
asset.loadTextures()
var object: MDLObject? = asset.object(at: 0)
guard let mdlObject = object else { return }
// Wrap the ModelIO object in a SceneKit object
let node = SCNNode(mdlObject: mdlObject)
scene.rootNode.addChildNode(node)
}
Hello, I want to keep the 3D models in my own private server and want to view them in ARSceneView. Suppose the model is located at https://example.com/example.obj. How can I view this in my app? Thanks