【问题标题】:Unable to view geometry in ARKit Scene after loading in from .scn file从 .scn 文件加载后无法在 ARKit 场景中查看几何图形
【发布时间】:2019-08-09 15:54:28
【问题描述】:

我有一个swatch.scn 文件,我正在尝试将它的几何图形添加到我的scene。我必须抓住swatch.childNodes.first 来获得正确的几何图形,然后添加它,但我的scene 中没有显示任何内容。很想知道如何解决这个问题。谢谢!

extension SCNNode {

    convenience init(named name: String) {
        self.init()
        guard let scene = SCNScene(named: name) else { return }

        for childNode in scene.rootNode.childNodes {
            addChildNode(childNode)
        }
    }

}


// in viewDidLoad

// Create a new scene
let scene = SCNScene(named: "art.scnassets/ship.scn")!

let swatch = SCNNode(named: "art.scnassets/swatch.scn")
let n = swatch.childNodes.first!
let geo = n.geometry!
print(n.geometry!) // <SCNGeometry: 0x281cb3b60 'bigger_swatch'>
n.position = SCNVector3(0, 0, -1)
n.scale = SCNVector3(3, 3, 3)
scene.rootNode.addChildNode(n)

【问题讨论】:

    标签: ios swift arkit


    【解决方案1】:

    试试这个

    let swatch = SCNNode(named: "art.scnassets/swatch.scn")
    swatch.position = SCNVector3(0, 0, -1)
    swatch.scale = SCNVector3(3, 3, 3)
    scene.rootNode.addChildNode(swatch)
    
    // Note: your swatch-node holds the entire geometries from your file.
    // You can do something like this:
    print(swatch.childnodes.count)
    

    【讨论】:

      猜你喜欢
      • 2017-05-11
      • 2020-07-06
      • 2018-07-01
      • 2018-07-04
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 2017-12-02
      相关资源
      最近更新 更多