我正在从一个web服务器下载一个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!)
})发布于 2018-04-14 09:58:00
我找到了答案。SCNReferenceNode包含一个节点数组,因此为了分配纹理,需要对其进行索引。
node?.childNodes.first?.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "example.png")https://stackoverflow.com/questions/49829460
复制相似问题