首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有SCNGeometry在SCNReferenceNode?

没有SCNGeometry在SCNReferenceNode?
EN

Stack Overflow用户
提问于 2018-04-14 08:31:44
回答 1查看 707关注 0票数 0

我正在从一个web服务器下载一个collada文件,并且希望以编程的方式映射纹理,但是有SCNGeometry是零。有人能提个建议吗?下面是示例代码。

代码语言:javascript
复制
    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!)
        })
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-14 09:58:00

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

代码语言:javascript
复制
node?.childNodes.first?.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "example.png")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49829460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档