SCNReferenceNode 中没有可用的 SCNGeometry?

No SCNGeometry Available in SCNReferenceNode?

我正在从网络服务器下载一个 collada 文件并想以编程方式映射纹理,但 SCNGeometry 为零。任何人都可以提出建议吗?下面是示例代码。

    let url = URL(string: "https://s3.amazonaws.com/path/to/dae.dae")!
    let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

    Alamofire.download(
        url,
        method: .get,
        parameters: nil,
        encoding: JSONEncoding.default,
        headers: nil,
        to: destination).downloadProgress(closure: { (progress) in
            print(progress)
        }).response(completionHandler: { (DefaultDownloadResponse) in
            let path = DefaultDownloadResponse.destinationURL
            let node = SCNReferenceNode(url: path!)
            node?.load()
            print(node)
            print(node?.geometry)
            self.sceneView.scene.rootNode.addChildNode(node!)
        })

我找到了答案。 SCNReferenceNode 包含一个节点数组,因此为了分配纹理,您需要对其进行索引。

node?.childNodes.first?.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "example.png")