是否可以通过编程方式下载 .scn 文件并 运行 它?

Is it possible to programmatically download a .scn file and run it?

基本上我想知道是否可以在网络上托管一个 .scn 文件,下载它,将其呈现为 SCNNode 并将其放入 sceneView

如果是这样,我需要调用哪些框架和函数来执行此操作

去年我在一个项目中做了类似的事情objective-C。我有一个包含 SCN 文件和其他资源的 zip 文件。我使用 AFNetworkng 下载 zip 文件,然后使用 SSZipArchive 将其解压缩到应用程序的文档文件夹中。

在 JSON 文件中,我有要显示的节点的形状 ID。

我构建了 SCN 文件资源的路径。为了简洁起见,我删除了一些代码。

SCNSceneSource *sceneSource = [SCNSceneSource sceneSourceWithURL:documentsDirectoryURL options:nil]; 

newShapeNode = [sceneSource entryWithIdentifier:shapeID withClass:[SCNNode class]];

[parentNode addChildNode:newShapeNode];

这里是下载方法-已编辑。

- (void) fetchRelease:(Album *) album usingProgressIndicator:(UIProgressView *) progressView completionHandler:(void(^)(NSError *error))completionHandler {
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
    [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"XXXXXXXX" password:@"XXXXXXX"];

    NSURL *URL = [NSURL URLWithString:album.url];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];

    NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
        return [self.documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
    } completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
        if (error != nil) {
            completionHandler(error);
        } else {
#ifdef DEBUG
            NSLog(@"File downloaded to: %@", filePath);
#endif
            NSError *error;
            [SSZipArchive unzipFileAtPath:filePath.path toDestination:self.documentsDirectoryURL.path overwrite:YES password:nil error:&error];
            if (error != nil) {
                completionHandler(error);
            } else {
                [self updateAlbumRelease:album];  // update the data model
                completionHandler(nil);
            }
        }
    }];

    if (progressView != nil) {
        [progressView setProgressWithDownloadProgressOfTask:downloadTask animated:YES];
    }
    [downloadTask resume];
}

这是编辑后的 ​​pod 文件:

platform :ios, '9.1'

target 'SOMEAPPNAME' do
pod 'SVProgressHUD'
pod 'SSZipArchive'
pod 'AFNetworking', '~> 3.0'
end