简体   繁体   中英

Could not open file obj SceneKit

I have the problem "Could not open obj file". I'm a beginner in iOS development.

func loadObj() {
    let url = URL(string: "http://ec2-34-212-108-22.us-west-2.compute.amazonaws.com/model/2018_02_28_22_48_43_ae16dacf5b0efe6985768ab1810f60fe_2018_02_28_22_48_43.obj")
    let idleScene = try! SCNScene(url:url!)
    let node = SCNNode()
    for child in idleScene.rootNode.childNodes {
        node.addChildNode(child)
    }

Your issue is that you open the file before the download process is finished. To solve it, you can use async to finish the download process then opening the file.

You can see my answer here: ios - Could not open OBJ file when convert MDLAsset to MDLMesh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM